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张骨牌连接的方案?思路:裸的欧拉回路,注 ...
随机推荐
- [转载]C# HashTable 遍历与排序
private void Form1_Load(object sender, EventArgs e) { Hashtable ht = new Hashtable(); ht.Add("j ...
- ExtJS 获取浏览器宽度
JS中代码: Ext.onReady(function() { var width=window.screen.availWidth; var height=window.screen.availHe ...
- 解决win8 plsql无法登录
今天安装完oracle客户端,然后打开 plsql 之后,就一个提示框,提示没有登录,后来解决方法如下: 在plsql的图标上点右键,以管理员身份运行,即可! 如果不想一直点右键执行,就图标上点右键- ...
- Handlebars 介绍
最新项目用到了Ember.js前端框架,第一次使用这样的框架,准备国庆节花2天时间,研究一下它的用法. Ember框架的模板引擎用到了handlebars, 先看国外的一篇介绍文章:An Introd ...
- var a=[]; 和 var a=new Array(); 的区别,为什么前者效率高
因为 JSON格式的语法是引擎直接解释的.而new Array 则需要调用Array的构造器.还有就是1.当你需要将一个数字转化为字符串时可以这样定义:var s=""+1; 这样 ...
- [jobdu]二维数组中的查找
http://ac.jobdu.com/problem.php?pid=1384 基本思路很简单,从最右上角找起. 九度的OJ做得还是不太行啊.必须要int main()才行,这道题时间卡得太紧,用c ...
- Delphi实现多个图像相互覆盖时无内容处点击穿透
http://www.52delphi.com/list.asp?ID=1405 CM_HITTEST是Delphi自定义的控件消息
- WebBrowser控件的高级定制+mshtml
--> blog:WebBrowser控件的高级定制---以下为三篇重要的参考文献, 第一篇可以禁用了js弹窗和声音 第二篇的引用文献禁用了IE弹窗,但是原文的说明很好 第3篇 ...
- ActionBar官方教程(2)选主题让应用支或不支持ActionBar及支持ActionBar的应用如何隐藏和显示
Adding the Action Bar As mentioned above, this guide focuses on how to use the ActionBar APIs in the ...
- EditPlus 配置 Java & C/CPP 开发环境
0.1安装EditPlus 0.2安装Java 0.3安装MinGW 0.4配置Java和MinGW环境变量 1.配置Java开发环境 1.1 Tool-->Preferences 1.2 Ja ...