|
|
back to boardWA #3 Here is my program. Throws an error number 3. Tested for n = 10 ^ 9 and n = 0. I can not understand. #include <iostream> #include <conio.h> using namespace std; main() { long long int a=0,b=0,c=0,n=0,m[10001],d=0; cin >> n; if (n==0) goto qwerty; for (a=9;a>=1;a--) while (n % a == 0) { if ((a==1) && (b>1)) break; n/=a; b++; m[b]=a; } if (n==1) { for (a=1;a<=b;a++) for (c=1;c<b;c++) if (m[c]>m[c+1]) { m[c]+=m[c+1]; m[c+1]=m[c]-m[c+1]; m[c]-=m[c+1];} d=1; n=0; for (a=b;a>=1;a--) { m[a]*=d; d*=10; n+=m[a]; } cout << n; } else cout << -1; qwerty: if (n==0) cout << -1; getch(); } Edited by author 09.11.2013 21:58 Re: WA #3 Have a look at the case n=1 |
|
|