SGU107——987654321 problem
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的更多相关文章
- sgu107. 987654321 problem 简单打表 难度:0
107. 987654321 problem time limit per test: 0.25 sec. memory limit per test: 4096 KB For given numbe ...
- 找规律 SGU 107 987654321 problem
题目地址:http://acm.sgu.ru/problem.php?contest=0&problem=107 /* 题意:n位数的平方的后面几位为987654321的个数 尼玛,我看描述这 ...
- 数论 - SGU 107 987654321 problem
987654321 problem Problem's Link Mean: 略 analyse: 这道题目是道简单题. 不过的确要好好想一下: 通过简单的搜索可以知道,在N<9时答案一定为0, ...
- (水题)987654321 problem -- SGU 107
链接: http://vj.acmclub.cn/contest/view.action?cid=168#problem/G 时限:250MS 内存:4096KB 64位IO格式:%I ...
- SGU 107 987654321 problem【找规律】
题目链接: http://acm.sgu.ru/problem.php?contest=0&problem=107 题意: 平方后几位为987654321的n位数有多少个 分析: 虽然说是水题 ...
- sgu 107 987654321 problem
其实挺水的,因为两个数平方,只有固定的后面几位数会影响到最后结果的后面几位数.也就是说,如果想在平方之后尾数为987654321,那么就有固定的几个尾数在平方后会是这个数,打个表,发现 10^8 内 ...
- 987654321 problem - SGU 107(找规律)
题目大意:求n位数的平方的后几位结果是987654321的个数是多少. 分析:刚看到这道题的时候怀疑过有没有这样的数,于是暴力跑了一下,发现还真有,9位的数有8个,如下: i=111111111, i ...
- SGU 107
107. 987654321 problem time limit per test: 0.25 sec. memory limit per test: 4096 KB For given numbe ...
- SGU 乱搞日志
SGU 100 A+B :太神不会 SGU 101 Domino: 题目大意:有N张骨牌,两张骨牌有两面有0到6的数字,能相连当且仅当前后数字相同,问能否有将N张骨牌连接的方案?思路:裸的欧拉回路,注 ...
随机推荐
- 找工作ing
找工作已经一个月多了,这一个月跑来跑去,挺累的,倒也不是身体有多累,关键是心累!作为一名控制工程专业的研究生,想找一份软件开发类的工作,没想到这么难!在起初的时候,觉得自己C++和JAVA都会,找哪个 ...
- 解决在构造函数中使用Session,Session为null的问题
问题描述: public abstract class PageBase : System.Web.UI.Page 在PageBase中如何使用Session??? 我直接用 Session[&quo ...
- 安装Ubuntu 14.04后要做的5件事情
转自安装Ubuntu 14.04后要做的5件事情 Ubuntu目前是世界上最流行的Linux操作系统,它提供了桌面版本和服务器版本,其他流行的Linux发行版本如Linux Mint也是基于Ubunt ...
- linux 访问windows共享
1. windows端建立一个用户user用于共享访问 2. 共享一个目录,设置user可以访问,并在windows系统中确认可以访问 3. linux端创建一个用于挂载共享目录的目录 mkdi ...
- [jobdu]把数组排成最小的数
这道题见过,就是把相加的结果作为比较来排序就行了.注意的是comp函数里面要用const引用.而且c++里的字符串直接操作(读入和相加)也很方便. #include <iostream> ...
- ANDROID_MARS学习笔记_S02_009_Animation_Interpolator
public class MainActivity extends Activity { private Button button = null; private ImageView imageVi ...
- Android笔记5-与USB HID 设备通信(一)
1.了解 支持USB 主机(host)或者从机(accessary )模式最终是取决于设备的硬件,而与平台版本无关.我们可以通过usesfeature这个方法来查询自己的设备是否支持USB主从. ...
- Delphi 中的DLL 封装和调用对象技术(刘艺,有截图)
Delphi 中的DLL 封装和调用对象技术本文刊登2003 年10 月份出版的Dr.Dobb's 软件研发第3 期刘 艺摘 要DLL 是一种应用最为广泛的动态链接技术但是由于在DLL 中封装和调用对 ...
- MySQL性能调优与架构设计-架构篇
架构篇(1) 读书笔记 1.Scale(扩展):从数据库来看,就是让数据库能够提供更强的服务能力 ScaleOut: 是通过增加处理节点的方式来提高整体处理能力 ScaleUp: 是通过增加当前处理节 ...
- Ember.js demo5
<!DOCTYPE html> <html> <head> <meta name="description" content=" ...