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. javascript中部分不能使用call apply调用来重写的构造函数

      This tests if TypeError is thrown or not when we call a constructor as a normal function.       On ...

  2. JavaScript 找出数组中重复的元素

    实现检测数组重复元素的功能,需要注意一点的是,多个(2个或2个以上)重复元素,我们只需要挑出一个来就可以了. <!DOCTYPE html> <html> <head&g ...

  3. 九张图让你的PPT立刻高大上

  4. Cassandra查询语言CQL的基本使用

    在window环境下运行CQL语言要先安装python环境,在linux下不需要,cassandra内置了python. 1.查看python版本:python --version2.运行pythod ...

  5. 图像色彩空间YUV和RGB的差别

    http://blog.csdn.net/scg881008/article/details/7168637 假如是200万像素的sensor,是不是RGB一个pixel是2M,YUV是1M? 首先, ...

  6. UAC新解(有非正常手段可以绕过)

    360第一次注册是需要弹,可是以后就不弹了开机自启动不弹框,开机自启动不弹框 服务是system权限再说一句,一般程序也不需要过UAC系统启动项白名单.UAC有一个白名单机制.还有UAC也可以通过wu ...

  7. 释放SQL Server占用的内存

    由于Sql Server对于系统内存的管理策略是有多少占多少,除非系统内存不够用了(大约到剩余内存为4M左右),Sql Server才会释放一点点内存.所以很多时候,我们会发现运行Sql Server ...

  8. SLF4J user manual

    http://www.slf4j.org/manual.html The Simple Logging Facade for Java (SLF4J) serves as a simple facad ...

  9. C# 4.0 新特性之并行运算(Parallel)

    介绍C# 4.0 的新特性之并行运算 Parallel.For - for 循环的并行运算 Parallel.ForEach - foreach 循环的并行运算 Parallel.Invoke - 并 ...

  10. BZOJ_1026_[SCOI2009]_windy数_(数位dp)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1026 windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为wi ...