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
Posted by Nebojsa 27 Apr 2008 19:18
where i make mistake

#include <iostream.h>

int main(){
int n,q;
cin>>n;
if (n==0)
{q=10;
         cout<<q;
         goto tu;}
if(n<100);
{
          for(int x=1;x<10;x++)
{
          for(int y=1;y<10;y++)
{
          q=x*y;
          if(q==n)
          {cout<<x<<y;
          goto tu;
          }}}}

          if((n>=100) && (n<1000))
          {
                     for(int x=1;x<10;x++)
                     {for(int y=1;y<10;y++)
                     {for(int o=1;o<10;o++)
                    { q=x*y*o;
          if(q==n)
          {cout<<x<<y<<o;
          goto tu;
          }}}}}
          if((n>=1000) && (n<10000))
          {for(int x=1;x<10;x++)
                     {for(int y=1;y<10;y++)
                     {for(int o=1;o<10;o++)
                     {for(int a=1;a<10;a++)
                     {
                        q=x*y*o*a;
          if(q==n)
          {cout<<x<<y<<o<<a;
          goto tu;
          }}}}}}
          if((n>=10000) && (n<100000))
          {for(int x=1;x<10;x++)
                     {for(int y=1;y<10;y++)
                     {for(int o=1;o<10;o++)
                     {for(int a=1;a<10;a++)
                     {for(int b=1;b<0;b++)
                     {
                        q=x*y*o*a*b;
          if(q==n)
          {cout<<x<<y<<o<<a<<b;
          goto tu;
          }}}}}}}
          if((n>=100000) && (n<1000000))
          {for(int x=1;x<10;x++)
                     {for(int y=1;y<10;y++)
                     {for(int o=1;o<10;o++)
                     {for(int a=1;a<10;a++)
                     {for(int b=1;b<0;b++)
                     {for(int c=1;c<10;c++)
                     {
                        q=x*y*o*a*b*c;
          if(q==n)
          {cout<<x<<y<<o<<a<<b<<c;
          goto tu;
          }}}}}}}}
               if((n>=1000000) && (n<10000000))
          {for(int x=1;x<10;x++)
                     {for(int y=1;y<10;y++)
                     {for(int o=1;o<10;o++)
                     {for(int a=1;a<10;a++)
                     {for(int b=1;b<0;b++)
                     {for(int c=1;c<10;c++)
                     {for(int d=1;d<10;d++)
                     {
                        q=x*y*o*a*b*c*d;
          if(q==n)
          {cout<<x<<y<<o<<a<<b<<c<<d;
          goto tu;
          }}}}}}}}}
                         if((n>=10000000) && (n<100000000))
          {for(int x=1;x<10;x++)
                     {for(int y=1;y<10;y++)
                     {for(int o=1;o<10;o++)
                     {for(int a=1;a<10;a++)
                     {for(int b=1;b<0;b++)
                     {for(int c=1;c<10;c++)
                     {for(int d=1;d<10;d++)
                     {for(int e=1;e<10;e++)
                     {
                        q=x*y*o*a*b*c*d*e;
          if(q==n)
          {cout<<x<<y<<o<<a<<b<<c<<d<<e;
          goto tu;
          }}}}}}}}}}
          cout<<-1;
          tu: ;
          system("pause");
          return 0;
          }
Re: Wrong answer
Posted by Madhav 13 Jun 2008 19:31
Your program goes wrong for this test case
1000000000.The output is 555555555888
Your Output is -1.