boj1232
http://acm.scs.bupt.cn/onlinejudge/showproblem.php?problem_id=1232
很简单的一道题,不过一直wa,之后才发现原来0应该用10表示!!!郁闷!!!
#include<stdio.h> #include<stdlib.h> int main() { int n,m,i,j,sum[100],total;
scanf("%d",&n); m = n; if (n == 0) printf("10\n"); else if (n == 1) printf("1\n"); else { total = 0; for (i = 9;i > 1;i--) { while(m % i == 0) { sum[total] = i; total++; m /= i; } } if (m != 1) printf("-1\n"); else { for (i = total-1;i >=0;i--) printf("%d",sum[i]); printf("\n"); } } // system("Pause"); return 0; }