uvaUVa 10392 - Factoring Large Numbers
简单,读题加AC用了很短的时间,我自己单独把题目意思揣摩出来的,呵呵
View Code
#include<stdio.h> #include<math.h> int main() { long long f[50000], n, i, k, m; k = 0; for(n = 2;k < 50000;n++) { for(i = 2;i < sqrt(n)+1; i++) { if(n%i == 0) break; } if(i > sqrt(n)) f[k++] = n; } while(scanf("%lld",&n) && (n > 0)) { i = 0; while(n) { while(n%f[i] == 0) { printf(" %lld\n",f[i]); n /= f[i]; } i++; if(n < f[i] || i > 49999)break; } if(n>1) printf(" %lld\n",n); printf("\n"); } return 0; }