|
|
back to boardHelp! Hello. I don't know what is wrong with my solution, maybe someone can help me. here is my code #include <stdio.h> int maxdivisor(unsigned long long n) { for(int i=9;i>1;i--) if(n%i==0) return i; return 1; } int main() { unsigned long long n; scanf("%Ld",&n); if(n==0) { printf("10"); return 0; } if(n<10) { printf("%Ld",n); return 0; } int dig[100]; int k=0; int d; int flag=0; while(n>1) { d=maxdivisor(n); if(d==1) { flag=1; n=1; } else { dig[k]=d; k++; n=n/d; } } if(flag==1) printf("-1."); else for(int i=k-1;i>=0;i--) printf("%d",dig[i]); return 0; } Thanks in advance Re: Help! Error here printf("-1."); you must write printf("-1"); Re: Help! Posted by Abraham 22 May 2007 01:53 Altough I corrected it, it is still giving me wrong answer in test 1. |
|
|