数论 - SGU 107 987654321 problem】的更多相关文章

987654321 problem Problem's Link Mean: 略 analyse: 这道题目是道简单题. 不过的确要好好想一下: 通过简单的搜索可以知道,在N<9时答案一定为0,而N=9时有8个解.由于题目只是问“最后9位”,所以N=10的时侯第10位的取值不会对平方和的“最后9位”产生影响,而第10位上有9种取值方法,所以N=10的时侯,答案是72. 同样可以知道,当N>10的时侯,只要在72后加入(N-10)个“0”即可. Time complexity: O(n) vie…
题目地址:http://acm.sgu.ru/problem.php?contest=0&problem=107 /* 题意:n位数的平方的后面几位为987654321的个数 尼玛,我看描述这一句话都看了半天,其实只要先暴力程序测试一边就知道规律 详细解释:http://www.cnblogs.com/Rinyo/archive/2012/12/04/2802089.html */ #include <cstdio> #include <iostream> #include…
题目链接: http://acm.sgu.ru/problem.php?contest=0&problem=107 题意: 平方后几位为987654321的n位数有多少个 分析: 虽然说是水题,但是我觉得很好体现了做某些数学题的方法,就是找规律 暴力求出一些较小的数,然后其他位数的数就是在求出的数的前面填数就好了. 然后注意位数很多,所以以字符的形式输出0. 代码: #include<cstdio> int main (void) { int n; scanf("%d&quo…
其实挺水的,因为两个数平方,只有固定的后面几位数会影响到最后结果的后面几位数.也就是说,如果想在平方之后尾数为987654321,那么就有固定的几个尾数在平方后会是这个数,打个表,发现 10^8 内 没有,10^9 内只有 8 个,然后排列组合…… 上代码: #include <cstdio> #include <cstring> #include <cstdlib> #include <cstring> using namespace std; typed…
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<…
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<…
链接: http://vj.acmclub.cn/contest/view.action?cid=168#problem/G 时限:250MS     内存:4096KB     64位IO格式:%I64d & %I64u 提交 状态 练习 SGU 107 问题描述 For given number N you must output amount of N-digit numbers, such, that last digits of their square is equal to 987…
SGU 105-DIV 3 Problem's Link Mean: 定义这样一种数列:1,12,123.. 给出一个n,求这个数列中能被3整除的数的个数. analyse: 这道题可以用分析的方法解决: 对于正整数k,k+1,k+2总有 k+(k+1)+(k+2) =k+k+1+k+2 =3k+3 =3(k+1) 3(k+1)可以被3整除,而且,一个数是否能被3整除表现为它的各位数字之和能否被三整除. 这就意味着对于一个数12345678910111213...k(连写),我们可以从后面开始,…
题目大意:求n位数的平方的后几位结果是987654321的个数是多少. 分析:刚看到这道题的时候怀疑过有没有这样的数,于是暴力跑了一下,发现还真有,9位的数有8个,如下: i=111111111, i*i=12345678987654321i=119357639, i*i=14246245987654321i=380642361, i*i=144888606987654321i=388888889, i*i=151234567987654321i=611111111, i*i=373456789…
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 简单数学,题目说,…
205. Quantization Problem time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard output: standard When entering some analog data into a computer, this information must be quantized. Quantization transforms each measured value…
403. Scientific Problem Time limit per test: 0.25 second(s)Memory limit: 65536 kilobytes input: standardoutput: standard Once upon a time Professor Idioticideasinventor was travelling by train. Watching cheerless landscape outside the window, he deci…
题意:求平方后末尾9个数是987654321的数个数. 之前做此题,竟然愚蠢到用计算器 在哪里算,还加笔算,SB啊!不知道先打印一下吗! #include<iostream> #include<cstdio> using namespace std; int main() { /* for(long long i=100000;i<999999999;i++) { if(i*i%1000000000==987654321) cout<<i<<endl;…
403. Scientific Problem Time limit per test: 0.25 second(s) Memory limit: 65536 kilobytes input: standard output: standard Once upon a time Professor Idioticideasinventor was travelling by train. Watching cheerless landscape outside the window, he de…
A New Change Problem Problem Description Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1.Here you can assume that there are enough coins for both kinds.Please calculate the maximal value that you cannot pay and the total number tha…
题目描述 让你输出区间内的素数的个数 分析 预处理筛法,在随便搞一下就好了. AC代码 #include <bits/stdc++.h> using namespace std; #define ms(a,b) memset(a,b,sizeof(a)) typedef long long ll; const int maxn=1000005; int sum[maxn],vis[maxn]; inline int read(){ int X=0,w=0; char ch=0; while(!…
SGU 100 A+B :太神不会 SGU 101 Domino: 题目大意:有N张骨牌,两张骨牌有两面有0到6的数字,能相连当且仅当前后数字相同,问能否有将N张骨牌连接的方案?思路:裸的欧拉回路,注意自环,连通 //sgu101 #include<iostream> #include<cstdio> #include <math.h> #include<algorithm> #include<string.h> #include<queu…
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traffic Lights 最短路 104 Little Shop of Flowers 动态规划 105 Div 3 找规律 106 The Equation 扩展欧几里德 107 987654321 Problem 找规律 108 Self-numbers II 枚举+筛法递推 109 Magic of Dav…
acmsguru 101 - Domino 要求每两个相邻的多尼诺骨牌相对的数字相同,即做一个一笔画 #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; #define afdafafafdafaf y1; int ar[maxn], n; vector<int> ans1, ans2; int b[maxn], to[maxn], c[maxn], index[maxn]; int head…
SGU 107 题意:输入一个N,表示N位数字里面有多少个的平方数的结尾9位是987654321 收获:打表,你发现相同位数的数相乘结果的最后几位,就和那两个相乘的数最后几位相乘一样,比如3416*8516 = 29090656,它的最后两位就和16*16=256的最后两位一样 为56,那么你发现987654321位9位,而且你预处理出的那8个答案就是9位,你就看d=n-9为多少位,那么就是9*8*(d位10)相乘,一个for就行了 #include<bits/stdc++.h> using…
VJ小组:SGU---48h/题 每道做出的题目写成题解,将传送门更新在这里. SGU:101 - 200 SGU - 107 水题 解题报告 SGU - 105 找规律水题 解题报告 SGU - 104 动态规划+记录路径 解题报告 SGU - 103 最短路变形 解题报告 SGU - 102 欧拉函数 解题报告 SGU - 101 无向图多重边欧拉回路的求解 解题报告…
P2368 EXCEEDED WARNING B 题目背景 SGU 107 题目描述 求有多少个平方后末尾为987654321的n位数 输入输出格式 输入格式: 整数n 输出格式: 答案,即[b]“平方后末尾为987654321的n位数”[/b]的个数 输入输出样例 输入样例#1: 复制 8 输出样例#1: 复制 0 说明 1≤n≤1 000 000 [b][color=#767676]不要问我暴力能过几个点,我只想说呵呵.[/color][/b] 打表找规律 我们可以发现,当n小于等于8的时候…
P2368 EXCEEDED WARNING B 题目背景 SGU 107 题目描述 求有多少个平方后末尾为987654321的n位数 输入输出格式 输入格式: 整数n 输出格式: 答案,即[b]“平方后末尾为987654321的n位数”[/b]的个数 输入输出样例 输入样例#1: 复制 8 输出样例#1: 复制 0 说明 1≤n≤1 000 000 [b][color=#767676]不要问我暴力能过几个点,我只想说呵呵.[/color][/b] 思路:数学+打表(暴力)找规律 #includ…
sgu 542 Gena vs Petya sgu 543 Cafe 题意:有N组人需要被分配到某些固定了人数的桌子上,其中ai表示第i组有多少个人,安排作为需要符合如下安排:某一组的人员不能够单独在一张桌子,每张桌子坐的人数不能够超过其限制,问至少要安排多少张给定了人数限制的桌子. 分析:此题是一个贪心题,如果直接求解的话,由于桌子的数量是未知的,因此不太好分配,因此二分桌子的数量,在已知桌子的数量后运用贪心规则来求得最优解.但尽管在二分已知桌子的情况下还是不太好实现这个贪心规则.其思路是这样…
1094 - Farthest Nodes in a Tree problem=1094" style="color:rgb(79,107,114)"> problem=1094&language=english&type=pdf" style="color:rgb(79,107,114)">PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Li…
[题解]CF986E Prince's Problem(树上差分+数论性质) 题目大意: 给定你一棵树,有点权\(val_i\le 10^7\).现在有\(m\)组询问给定参数\(x,y,w\)问你对于\((x->y)\)的路径经过的点集\(P\),问你这个东西: \[ \prod_{u \in P} {\mathrm{gcd}(w,val_u)} \mod 1000000007 \] 考虑这样一种做法: 把询问差分成 \[ ans(1,x) \times ans(1,y) \times \ma…
E. Ehab's REAL Number Theory Problem 数论+图论 求最小环 题目大意: 给你一个n大小的数列,数列里的每一个元素满足以下要求: 数据范围是:\(1<=a_i<=10^6\) \(a_i\) 最多只有7个因数 题目要求在这个数列找到一个最短的子数列,子数列的所有的数相乘是一个完全平方数. 题解: 这个题对于 \(x^{3}\) 应该等价于 \(x\) ,其实就是可以除去 \(a_i\)中的所有的平方项,显而易见,这个并不影响答案. 因为 \(a_i\) 最多只…
X problem      X问题     Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)    Total Submission(s): 4358 Accepted Submission(s): 1399 Problem Description     求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod…
题意: 给出n, k,求 分析: 假设,则k mod (i+1) = k - (i+1)*p = k - i*p - p = k mod i - p 则对于某个区间,i∈[l, r],k/i的整数部分p相同,则其余数成等差数列,公差为-p 然后我想到了做莫比乌斯反演时候有个分块加速,在区间[i, n / (n / i)],n/i的整数部分相同,于是有了这份代码. #include <cstdio> #include <algorithm> using namespace std;…
题目链接: http://acm.fzu.edu.cn/problem.php?pid=2238 题目大意: 已知等差数列A(0)的首项a和公差d,求出数列A(0)前n项和,得到新数列A(1);以此类推,最终求A(m)的第i项mod1000000007 题目思路: [动态规划] 不难推出c[i][j]=c[i-1][j]+c[i][j-1] 但是i太大不能直接递推,m<=1000不能矩阵快速幂. 通过推导可以求出c[i][j]=a*C(n+m-1,n-1)+d*C(n+m-1,n-2) 求模时除…