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

Test#5
Posted by bars_rb 15 Sep 2010 17:54
What's in this test?
Results for 0 is 10
For 1..9 is 1..9, it's OK.
For 128 is 2222222

Here is alg
    int n;
    int e=0;
    int q=0;
    cin>>n;
    if(n==1){cout<<1;cin>>n;return 0;}
    if(n==0){cout<<10;cin>>n;return 0;}

    while (n>1)
    {
        e=0;
        if(q==-1)break;
        for(int i=2;i<=9;i++)
        {

            if((n/i)*i==n)
            {
                q=q*10+i;
                n=n/i;
                break;
            }
            else
            {if(i==9)e=1;}
        }
        if (e==1)
        q=-1;
    }
cout<<q;
cin>>q;
    return 0;

Thanks.
Re: Test#5
Posted by TheDreamCatcher 25 Oct 2010 22:22
On input 45 correct answer is 59!
In your case answer is 335
Re: Test#5
Posted by Mikael Arakelyan(ERIICTA) 23 Nov 2010 20:33
I didn't give the whole code..
I hate this f*cking excercise.. it is second day I am trying to solve ...
now please help me
here is the input and output, please be careful to notice something
........
what is wrong here???
first number is my input and the second is output...
heeeelp
mikael@ubuntu:~/Desktop$ ./xx
1
1
mikael@ubuntu:~/Desktop$ ./xx
0
10
mikael@ubuntu:~/Desktop$ ./xx
2
2
mikael@ubuntu:~/Desktop$ ./xx
3
3
mikael@ubuntu:~/Desktop$ ./xx
4
22
mikael@ubuntu:~/Desktop$ ./xx
5
5
mikael@ubuntu:~/Desktop$ ./xx
6
23
mikael@ubuntu:~/Desktop$ ./xx
8
24
mikael@ubuntu:~/Desktop$ ./xx
9
33
mikael@ubuntu:~/Desktop$ ./xx
10
25
mikael@ubuntu:~/Desktop$ ./xx
20
45
mikael@ubuntu:~/Desktop$ ./xx
25
55
mikael@ubuntu:~/Desktop$ ./xx
30
56
mikael@ubuntu:~/Desktop$ ./xx
45
59
mikael@ubuntu:~/Desktop$ ./xx
60
256
mikael@ubuntu:~/Desktop$ ./xx
105
357
mikael@ubuntu:~/Desktop$ ./xx
108
269
mikael@ubuntu:~/Desktop$

Re: Test#5
Posted by Vlad Tarniceru 28 Dec 2010 16:58
for 128 isn't 2222222 , is 882

for(int i=2;i<=9;i++)

corect is:
for(int i=9;i>=2;i--)  becouse 222 is the same product like 8, 33 like 9
Re: Test#5
Posted by Gio Pataraia 6 Jan 2011 14:26
no for 128 minimal is 288 and not 222222
bars_rb wrote 15 September 2010 17:54
What's in this test?
Results for 0 is 10
For 1..9 is 1..9, it's OK.
For 128 is 2222222

Here is alg
    int n;
    int e=0;
    int q=0;
    cin>>n;
    if(n==1){cout<<1;cin>>n;return 0;}
    if(n==0){cout<<10;cin>>n;return 0;}

    while (n>1)
    {
        e=0;
        if(q==-1)break;
        for(int i=2;i<=9;i++)
        {

            if((n/i)*i==n)
            {
                q=q*10+i;
                n=n/i;
                break;
            }
            else
            {if(i==9)e=1;}
        }
        if (e==1)
        q=-1;
    }
cout<<q;
cin>>q;
    return 0;

Thanks.
Re: Test#5
Posted by King Taylor Ag 15 Jan 2011 18:39
input 4
output 4
4<22
!!
Re: Test#5
Posted by [PNTU]Sergiy D 14 May 2011 19:57
sory, but why for 60 is 256? i think it's 160
Re: Test#5
Posted by Volodymyr K 18 May 2011 20:37
1*6*0 =0;
0 != 60

Edited by author 18.05.2011 20:37
Re: Test#5
Posted by ScaV 26 Aug 2011 03:02


Edited by author 26.08.2011 03:02