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

简单数学,题目说,一个数字n、找n*n结果末尾是987654321的数。

先傻瓜式搜索,发现8位以下没有符合要求的;9位有4个,10位以上根据数学排列知识就搞定了。

最近在搞SGU,先从简单题目入手,碰到什么算法就搞什么算法。

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
// for(int i=0;i<99999999;i++)
// if(i*i==987654321)
// printf("%d\n",i);
// for(long long i=sqrt(987654321.0);i<=999999999;++i)
// if( i*i%1000000000 == 987654321 )
// printf("%d\n",i);
//}
// 111111111
// 119357639
// 380642361
// 388888889
// 611111111
// 619357639
// 880642361
// 888888889 int n;
while (scanf("%d",&n)!=EOF)
{
if (n<=8)
printf("0\n");
else if (n==9)
printf("8\n");
else
{
printf("72");
for (int i=0;i<n-10;++i)
printf("0");
printf("\n");
}
} }

SGU107——987654321 problem的更多相关文章

  1. sgu107. 987654321 problem 简单打表 难度:0

    107. 987654321 problem time limit per test: 0.25 sec. memory limit per test: 4096 KB For given numbe ...

  2. 找规律 SGU 107 987654321 problem

    题目地址:http://acm.sgu.ru/problem.php?contest=0&problem=107 /* 题意:n位数的平方的后面几位为987654321的个数 尼玛,我看描述这 ...

  3. 数论 - SGU 107 987654321 problem

    987654321 problem Problem's Link Mean: 略 analyse: 这道题目是道简单题. 不过的确要好好想一下: 通过简单的搜索可以知道,在N<9时答案一定为0, ...

  4. (水题)987654321 problem -- SGU 107

    链接: http://vj.acmclub.cn/contest/view.action?cid=168#problem/G 时限:250MS     内存:4096KB     64位IO格式:%I ...

  5. SGU 107 987654321 problem【找规律】

    题目链接: http://acm.sgu.ru/problem.php?contest=0&problem=107 题意: 平方后几位为987654321的n位数有多少个 分析: 虽然说是水题 ...

  6. sgu 107 987654321 problem

    其实挺水的,因为两个数平方,只有固定的后面几位数会影响到最后结果的后面几位数.也就是说,如果想在平方之后尾数为987654321,那么就有固定的几个尾数在平方后会是这个数,打个表,发现 10^8 内 ...

  7. 987654321 problem - SGU 107(找规律)

    题目大意:求n位数的平方的后几位结果是987654321的个数是多少. 分析:刚看到这道题的时候怀疑过有没有这样的数,于是暴力跑了一下,发现还真有,9位的数有8个,如下: i=111111111, i ...

  8. SGU 107

    107. 987654321 problem time limit per test: 0.25 sec. memory limit per test: 4096 KB For given numbe ...

  9. SGU 乱搞日志

    SGU 100 A+B :太神不会 SGU 101 Domino: 题目大意:有N张骨牌,两张骨牌有两面有0到6的数字,能相连当且仅当前后数字相同,问能否有将N张骨牌连接的方案?思路:裸的欧拉回路,注 ...

随机推荐

  1. 解决win8.1右键菜单出现在左边

    这个问题估计很少有人遇到,当在桌面上单击鼠标右键时,如果正常情况下,应该是在鼠标光标的右侧弹出来,除非右边的空间不够了,才在左侧弹出.但遇到故障,就是不论在桌面的哪里点右键,菜单都在左侧弹出,虽然不影 ...

  2. Python解决codeforces ---- 1

    第一题 1A A. Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input stan ...

  3. 转自 void- man 差分约束系统详解

    一直不知道差分约束是什么类型题目,最近在写最短路问题就顺带看了下,原来就是给出一些形如x-y<=b不等式的约束,问你是否满足有解的问题 好神奇的是这类问题竟然可以转换成图论里的最短路径问题,下面 ...

  4. 对SharePoint 2007数据库中一些数据表的使用

    转:http://blog.csdn.net/ma_jiang/article/details/6553392 在工作中接触了一些SharePoint的数据库中的一些表.在此做个总结. 一位高手告诉我 ...

  5. SharePoint对象模型性能考量

    转:http://blog.csdn.net/ma_jiang/article/details/6553373 部分常见用例场景都是关于显示和编辑SharePoint列表的--可惜,这也是我们看到很多 ...

  6. wpa_supplicant 与iwpriv工具配置WIFI的命令

    =====================================================hostapd 配置命令=================================== ...

  7. HDU 3427

    DP: According to the meaning of problems,if we check n to m, assume x and y are both solvable,then w ...

  8. [转]ASP.NET MVC 入门11、使用AJAX

    在ASP.NET MVC beta发布之前,M$就宣布支持开源的JS框架jQuery,然后ASP.NET MVC beta发布后,你建立一个ASP.NET MVC beta的项目后,你可以在项目的sc ...

  9. SR4000(二)

    返回相位(用于测距离,一个全相位代表5m)  D=3*10^8/2f(60M)=5m full-phase(0xffff) 返回LED反射光的振幅和背景光均值 无效数据: B太大 幅度(也是16bit ...

  10. 类加载器classCloader

    ref: http://blog.csdn.net/studyvcmfc/article/details/7720322 得复习一下深入java虚拟机 1.类加载器干啥的? 把 class文件加载到虚 ...