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

Pages: Previous 1 2
Re: Test #8
Posted by Andres 3 Oct 2010 02:25
Yep... problem in java was using int instead of long.
Re: Test #8
Posted by VityaZ 5 Oct 2010 15:11
I have Q->555555555888 when N=1 000 000 000, but Test#8 say "WA". Why?
Re: Test #8
Posted by iNeedSomeMind 16 Sep 2011 13:52
tnx
Re: Test #8
Posted by jambas92 2 Oct 2011 20:46


Edited by author 02.10.2011 20:48
Re: Test #8
Posted by Firestein 18 Aug 2012 20:34
use long long int
Re: Try this~!
Posted by saba_tavdgiridze 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
Re: Test #8
Posted by Nathan_Ying 18 Jul 2013 09:19
enlarge your array size
Re: Test #8
Posted by Md. Hafizur Rahman Arfin 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".
Pages: Previous 1 2