Problem 1607 Greedy division from http://acm.fzu.edu.cn/problem.php?pid=1607
来源:互联网 发布:查士丁尼瘟疫 知乎 编辑:程序博客网 时间:2024/05/01 19:41
Problem Description
Oaiei has inherited a large sum of wealth recently; this treasure has n pieces of golden coins. Unfortunately, oaiei can not own this wealth alone, and he must divide this wealth into m parts (m>1). He can only get one of the m parts and the m parts have equal coins. Oaiei is not happy for only getting one part of the wealth. He would like to know there are how many ways he can divide the wealth into m parts and he wants as many golden coins as possible. This is your question, can you help him?
Input
There are multiply tests, and that will be 500000. For each test, the first line is a positive integer N(2 <= N <= 1000000), N indicates the total number of golden coins in the wealth.
Output
For each test, you should output two integer X and Y, X is the number of ways he can divide the wealth into m parts where m is large than one, Y is the number of golden coins that he can get from the wealth.
Sample Input
Sample Output
Hint
There are huge tests, so you should refine your algorithm.
Source
FOJ月赛-2008年5月- #include<cstdio>
- #include<iostream>
- #include<algorithm>
- #include<cmath>
- #include<memory.h>
- using namespace std;
- int prime[1000005];
- int minp[1000005];
- int n, m, ans, k, choices;
- int main(){
- //freopen("in.txt", "r", stdin);
- /*int d = sqrt(1000005);
- memset(prime, 0, sizeof(prime));
- for(int i=2;i<=d;++i){
- if(!prime[i]){
- prime[i] = 1;
- minp[i] = i;
- for(int j=i*2;j<=1000000;j+=i){
- if(!prime[j]){
- prime[j] = 2;
- minp[j] = i;
- }
- }
- }
- }*/
- memset(prime,0,sizeof(prime));
- int ddd=sqrt(1000000.0)+1;
- for(int i=2;i<=1000000;i++)
- {
- if(prime[i])continue;
- minp[i]=i;
- if(i>ddd)continue;
- for(int j=i*2;j<=1000000;j+=i)
- if(prime[j]==0)
- prime[j]=1,minp[j]=i;
- }
- while(scanf("%d", &n)!=EOF){
- m = n;
- ans = 1;
- while(n>1){
- k = minp[n];
- choices = 1;
- while(n%k==0){
- choices++;
- n /= k;
- }
- ans *= choices;
- }
- printf("%d %d\n", ans-1, m/minp[m]);
- }
- //fclose(stdin);
- }
- Problem 1607 Greedy division from http://acm.fzu.edu.cn/problem.php?pid=1607
- Problem 1057 ab from http://acm.fzu.edu.cn/problem.php?pid=1057
- Problem 1453 Bignum Arithmetic from http://acm.fzu.edu.cn/problem.php?pid=1453
- Problem 1410 变位词 from http://acm.fzu.edu.cn/problem.php?pid=1410
- Problem 1207 半数集问题 from http://acm.fzu.edu.cn/problem.php?pid=1207
- Problem 1582 众数问题 from http://acm.fzu.edu.cn/problem.php?pid=1582
- Problem 1478 环形整数串 from http://acm.fzu.edu.cn/problem.php?pid=1478
- Problem 1046 Tempter of the Bone, from http://acm.fzu.edu.cn/problem.php?pid=1046
- Problem 1202 信与信封问题 from http://acm.fzu.edu.cn/problem.php?pid=1202
- fzu 1402 中国剩余定理 http://acm.fzu.edu.cn/problem.php?pid=1402
- http://acm.fzu.edu.cn/problem.php?pid=1698 最大乘积
- http://acm.fzu.edu.cn/problem.php?pid=2113 数位DP
- 单调队列入门 foj 1894 http://acm.fzu.edu.cn/problem.php?pid=1894
- http://acm.uestc.edu.cn/problem.php?pid=1784&&
- http://acm.fzu.edu.cn/problem.php?pid=1564 C(n,k)和素数P的问题
- http://acm.uestc.edu.cn/problem.php?pid=1480&cid=164
- A + B Problem II &&http://acm.hdu.edu.cn/showproblem.php?pid=1002
- http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=301 (矩阵的用法)
- http://ac.jobdu.com/problem.php?pid=1013
- http://ac.jobdu.com/problem.php?pid=1012
- http://ac.jobdu.com/problem.php?pid=1011
- http://ac.jobdu.com/problem.php?pid=1010
- 餐饮经营思考(一)——利润&成本
- Problem 1607 Greedy division from http://acm.fzu.edu.cn/problem.php?pid=1607
- Problem 1582 众数问题 from http://acm.fzu.edu.cn/problem.php?pid=1582
- Problem 1478 环形整数串 from http://acm.fzu.edu.cn/problem.php?pid=1478
- Visual CertExam Suite v3 0 1 Cracked-BLiZZARD
- ZOJ Problem Set - 3661 Palindromic Substring
- JPEG图片存储格式及原理
- JS + CSS 超漂亮切换效果
- MyBatis传参方式和批量操作总结
- 光标控制器