ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1014. Product of Digits

Wrong answer at test 8
Posted by Alexandr 22 Dec 2010 20:53
#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
Posted by bsu.mmf.team 23 Dec 2010 01:17
Try these tests:
0 -> 10
12 -> 26
112 -> 278
Re: Wrong answer at test 8
Posted by Alexandr 23 Dec 2010 12:05
all this tests ok
Re: Wrong answer at test 8
Posted by bsu.mmf.team 23 Dec 2010 16:46
But you have already got AC in this problem. Why do you care about it now? :)