zoukankan      html  css  js  c++  java
  • sgu107. 987654321 problem 简单打表 难度:0

    107. 987654321 problem

    time limit per test: 0.25 sec. 
    memory limit per test: 4096 KB

     

    For given number N you must output amount of N-digit numbers, such, that last digits of their square is equal to 987654321.

     

    Input

    Input contains integer number N (1<=N<=106)

     

    Output

    Write answer to the output.

     

    Sample Input

    8
    

    Sample Output

    0
    思路:打表找规律
    WA 原因:打表速度太慢,我以为打完了,9之间只有4个
    应用时:思路3min 打表30min
    #include <cstdio>
    using namespace std;
    int n;
    int main(){
        while(scanf("%d",&n)==1){
            if(n<9)puts("0");
            else if(n==9)puts("8");
            else{
                printf("72");
                for(int i=10;i<n;i++){
                    putchar('0');
                }
                putchar('\n');
            }
        }
        return 0;
    }
    

      

  • 相关阅读:
    如何复用网页
    sap
    学习方法
    spring + ehcache 实例
    200个 jquery插件
    vs 示例代码浏览器 搜索
    struts jquery 整合
    eclipse clean 后clease 为空
    mvc相关
    css 框架
  • 原文地址:https://www.cnblogs.com/xuesu/p/4001282.html
Copyright © 2011-2022 走看看