|
|
back to boardWrong answer at test 8 #include <iostream> #include <cstring> #include <stdlib.h> using namespace std; int main() { long long m=0; long long n; char num[50]; std::cin.getline(num, 50); string number(num); for (int i = 0; i<number.length(); i++) { if (number[i]==' ') { number.erase(i,1); } } n = atoi(number.c_str()); if(n==1) { cout << "1"; } else { if(n<10) { cout << "1" << n << "\n"; } else { for(int i=9;i>1;i--) { if(n%i==0) { n=n/i; m=m*10+i; i++; } } if(n!=1) { cout << "-1" << "\n"; } else { char buf[50]; sprintf(buf, "%Ld", m); string s(buf); for (int j = s.length()-1; j>=0; j--) { cout << s[j]; } } } } } This is solution. What wrong with test 8? For number 1 000 000 000 result is 555555555888 Re: Wrong answer at test 8 Try these tests: 0 -> 10 12 -> 26 112 -> 278 Re: Wrong answer at test 8 all this tests ok Re: Wrong answer at test 8 But you have already got AC in this problem. Why do you care about it now? :) |
|
|