You are not logged in. Please login at to post your questions!


Why Codechef rejected my code (Chef and digits of a number)


int main() { long long int t,num,temp,count1,count0,b; scanf("%lld",&t); while(t--) { scanf("%lld",&num); temp=0,b=0; temp=num; count1=0,count0=0; while(temp!=0) { b=temp%10; if(b==1) count1++; else if(b==0) count0++; temp/=10; } if(num==1||num==0) printf("Yes\n"); else { if((count1>1&&count0>1)||count1==0||count0==0) printf("No\n"); else if(count1==1&&count0>1) printf("Yes\n"); else if(count0==1&&count1>1) printf("Yes\n"); else if(count1==1&&count0==1) printf("Yes\n");


}return 0; }

asked 08 Nov '18, 23:48

milanshu_185's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 08 Nov '18, 23:48

question was seen: 89 times

last updated: 08 Nov '18, 23:48