hdu 1405 The Last Practice(数论:欧拉函数的变形)
2014-07-10 23:27
387 查看
一遇到求素数就用欧拉函数或者其变形,简直爽死了
不过生成素数表应该更快,但是不喜欢那个代码
这道题的输出简直是大坑
不仅样例之间要有换行
每个样例中的输出数字后面都要有个空格,凭着刷题的直觉我只在数字中间保留空格
结果就presentation erroe
坑死了
0ms AC代码如下:
不过生成素数表应该更快,但是不喜欢那个代码
这道题的输出简直是大坑
不仅样例之间要有换行
每个样例中的输出数字后面都要有个空格,凭着刷题的直觉我只在数字中间保留空格
结果就presentation erroe
坑死了
0ms AC代码如下:
#include <math.h> #include <stdio.h> #define MAXN 100 struct Num { int i, j; }a[MAXN]; int cas = 1; int euler_phi(int n) { int m = sqrt(n+0.5); int i, c=0, cnt; for(i=2; i<=m; ++i) { if(n%i == 0) { a[c].i = i; n /= i; cnt = 1; while(n%i == 0) { n /= i; cnt++; } a[c++].j = cnt; } } if(n > 1) { a[c].i = n; a[c++].j = 1; } return c; } int main(void) { int c, n, i; while(scanf("%d", &n), n>=0) { c = euler_phi(n); if(cas > 1) printf("\n"); printf("Case %d.\n", cas++); for(i=0; i<c; ++i) { printf("%d %d ", a[i].i, a[i].j); } printf("\n"); } return 0; }
相关文章推荐
- hdu1405 The Last Practice
- hdu 1405 The Last Practice (数学)
- HDU 1405 The Last Practice(暴力枚举)
- HDU 1405 The Last Practice
- hdu 1405 The Last Practice 输出格式需注意
- hdu-oj 1405 The Last Practice
- HDU 1405 The Last Practice
- HDU 1405 The Last Practice - 解题心得
- The Last Practice hdu 1405
- 【HDU】1405 The Last Practice(分解质因数)
- HDU 1405 坑爹的The Last Practice
- HDU 1405 The Last Practice
- HDU 1405 The Last Practice
- HDU 1405 The Last Practice
- hdu_1405 The Last Practice
- hdu 1405 The Last Practice (数学)
- HDU 1405 The Last Practice(求质因子及其个数 )
- HDU 1405 The Last Practice(数学题,变态的格式)
- 数学—杭电1405 The Last Practice
- HDOJ 1405 The Last Practice [恶心题]