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 1407. One-two, One-two

where is my mistake?
Posted by ooo 11 Dec 2008 22:39
#include  <iostream.h>
bool z(int);
void main()
{int n,i,q=1;
cin>>n;
for(i=1;i<=n;i++) q*=2;
for(i=0;i<10000;i++) if((z(i)) && (i%q==0)) {cout<<i; break;}
if(i==10000) cout<<"No solution";}
bool z(int x)
{int j=0;
while(x!=0) {if((x%10!=1) && (x%10!=2)) j++; x=x/10;}
if(j==0) return true;
else return false;}
Re: where is my mistake?
Posted by Dmitriy 3 Feb 2010 21:00
Imagine that n is 100.
q (2 ^ 100) will be overflowed.
You must have 10000 digits but not number under 10000=)