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

Igor Gomes Test #8 [27] // Problem 1014. Product of Digits 8 Oct 2004 10:55

My code is ok all tests before #8, but I've WA on #8... Anything that I don't see?

Thanks
Airinei Adrian Re: Test #8 // Problem 1014. Product of Digits 29 Jul 2005 01:06
Can anyone help me? I have the same problem and I know the code is ok, I checked it 100 times

Edited by author 29.07.2005 01:06
Valentine Re: Test #8 [6] // Problem 1014. Product of Digits 31 Jul 2005 03:41
I also had WA on test#8(now I have AC). I don't know this test, but look:
 N = 362880
Right Q is 2578899.
You see: all numbers(digits)in Q must be sorted:
2<=5<=7<=8<=8<=9<=9 - it's condition for minimal Q, but
you must surch begining from 9
Airinei Adrian Re: Test #8 [1] // Problem 1014. Product of Digits 31 Jul 2005 21:39
in my program the digits are sorted. for your example my answer is also 2578899
Yoyo Re: Test #8 // Problem 1014. Product of Digits 2 Aug 2005 22:53
correct answer for 0 is 10.
maybe this fact help you.
reason supreme Re: Test #8 [1] // Problem 1014. Product of Digits 4 Jan 2008 16:39
my God..my alog is WRONG.
thx!
Madhav Re: Test #8 // Problem 1014. Product of Digits 13 Jun 2008 19:42
Try n=1234.Output is -1.
iNeedSomeMind Re: Test #8 // Problem 1014. Product of Digits 16 Sep 2011 13:52
tnx
jambas92 Re: Test #8 // Problem 1014. Product of Digits 2 Oct 2011 20:46


Edited by author 02.10.2011 20:48
ali ahmad Re: Test #8 [1] // Problem 1014. Product of Digits 24 Nov 2005 21:19
May be this helps. If input is 12 output should be 26 not 34 .
Torax [Lviv NU] Re: Test #8 // Problem 1014. Product of Digits 30 Nov 2005 04:40
It is something strange...
My program outputs 10, when input is 0, in your examples: 12 -> 26, not 34, but I have WA#8, why????? Program is correct, maybe tests are wrong???
Abhay Re: Test #8 [1] // Problem 1014. Product of Digits 3 Dec 2005 18:22
Yes i am having the exact same problem... considered all test cases and am getting the write answers in ascending order but test#8 is giving WA

Edited by author 03.12.2005 18:23

Edited by author 03.12.2005 18:23
Burunduk1 Re: Test #8 // Problem 1014. Product of Digits 3 Dec 2005 19:44
I think tests are OK.
If you still need some help send me your code
to sk1@hotbox.ru
Maciej Rygielski Try this~! [4] // Problem 1014. Product of Digits 3 Apr 2006 17:21
try input 1000 000 000
Torry Re: Try this~! [3] // Problem 1014. Product of Digits 5 Apr 2006 14:14
I have this problem too!!!
All test, what i see is correct;
I use unsigned long;
May be it consist false;
What I doing wrong?

Edited by author 05.04.2006 14:23
KAV Re: Try this~! [1] // Problem 1014. Product of Digits 7 Apr 2006 13:18
How about N = 13 ? ;)
Peter Petrov (Sedefcho) Re: Try this~! // Problem 1014. Product of Digits 4 Jul 2006 19:42
test

Edited by author 04.07.2006 19:44
saba_tavdgiridze Re: Try this~! // Problem 1014. Product of Digits 9 May 2013 15:09
my solution in c++ 0.031 s.
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

inline bool isprime(long a)
{
    if(a==1)return false;
    if(a==2)return true;
    if(a%2==0)return false;
    for(int i=3;i<sqrt(a);i+=2)
    {

        if(a%i==0)return false;
    }
    return true;



}


int main()
{
    string a;
    long n;
    int d=1;
    cin>>n;
    if(n==0)cout<<"10"<<endl;
    else if(n==1)cout<<"1"<<endl;
    else{
    if(isprime(n) && n>10)d=0;
    else
    {
        int gamyop=9;
        while(n!=1)
        {

            if(n%gamyop==0)
            {
                a+=(gamyop+'0');
                n/=gamyop;
                if(isprime(n) && n>10){d=0;break;}

            }
            else
            {
                gamyop--;
            }


        }



    }
    sort(a.begin(),a.end());
    if(d==1)cout<<a<<endl;
    else cout<<"-1"<<endl;
    }

    return 0;
}
Torry wrote 5 April 2006 14:14
I have this problem too!!!
All test, what i see is correct;
I use unsigned long;
May be it consist false;
What I doing wrong?

Edited by author 05.04.2006 14:23
gnocuil Re: Test #8 [8] // Problem 1014. Product of Digits 24 Feb 2007 17:02
try string,or int64
Timofey Koolin Re: Test #8 [7] // Problem 1014. Product of Digits 15 Nov 2008 03:46
gnocuil wrote 24 February 2007 17:02
try string,or int64
if I using __int64 I have overflow too. In this problem must use only string for result.
mss(It-Team) Re: Test #8 [6] // Problem 1014. Product of Digits 12 Mar 2009 00:38
I used recursive algorithm. (C++)
result and local variables in function must be __int64(long long)
In other cases you'll get an overflow
Usage of string not are obligatory

Test#8 is:

N=1 000 000 000
Q->555555555888

for examle with local or result variables of type unsigned you'll get
Q->1504774704

Sorry for my English :)
Shu Konstantin Preslavski Re: Test #8 [2] // Problem 1014. Product of Digits 22 Apr 2010 04:46
I don't know if what is exactlly the test but the answer is something like -1 or 26 ;D It works for me there after fixing that... ;)
Andres Paez Martinez Re: Test #8 // Problem 1014. Product of Digits 3 Oct 2010 02:25
Yep... problem in java was using int instead of long.
Andres Paez Martinez Re: Test #8 // Problem 1014. Product of Digits 3 Oct 2010 02:25
Yep... problem in java was using int instead of long.
VityaZ Re: Test #8 [1] // Problem 1014. Product of Digits 5 Oct 2010 15:11
I have Q->555555555888 when N=1 000 000 000, but Test#8 say "WA". Why?
Firestein Re: Test #8 // Problem 1014. Product of Digits 18 Aug 2012 20:34
use long long int
Md. Hafizur Rahman Arfin Re: Test #8 // Problem 1014. Product of Digits 17 Aug 2016 21:24
thanks mate. I was getting wrong for this reason.
Those who are  getting WA at Test #8. try to use "Unsigned long long int" insted of "int".
Nathan_Ying Re: Test #8 // Problem 1014. Product of Digits 18 Jul 2013 09:19
enlarge your array size