12527 - Different Digits

All about problems in Volume 125. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
sai123
New poster
Posts: 1
Joined: Sat Oct 26, 2013 8:42 pm

12527 - Different Digits

Post by sai123 » Sat Oct 26, 2013 8:51 pm

#include<stdio.h>

int h[10]={0};


int main()
{

int C;
scanf("%d",&C);
while(C--)
{
int n , m;
int i=0;
int notvalid=-1;
int count=0;
scanf("%d %d",&n,&m);

int k=0;
int a=0;
for(n;n<m;n++)
{
a=n;
while(a>0)
{
h[a%10]++;
if(h[a%10]>1)
{
notvalid=1;
break;
}

a=a/10;
}

if(notvalid==1)
notvalid=-1;
else
count++;

for(k=0;k<10;k++)
h[k]=0;

}

printf("%d\n",count);

}


return 0;
}




subitting this code gives wrong answer though critical cases giving correct answer
as

1 5000
1 1
99 99
1 9
10 100

gives output
2754
1
0
9
81



whats wrong ?? :cry:

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: problem 12527

Post by brianfry713 » Mon Oct 28, 2013 8:37 pm

Doesn't match the sample I/O.
Check input and AC output for thousands of problems on uDebug!

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: problem 12527

Post by uDebug » Fri May 30, 2014 2:02 pm

Replying to follow the thread.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

ssavi
New poster
Posts: 28
Joined: Thu Nov 20, 2014 9:57 pm

Re: 12527 - Different Digits

Post by ssavi » Sat Dec 06, 2014 6:28 pm

Why i am getting WA ?? Although it matches all test cases ??

Code: Select all

Yess . I got My silly mistake .. 
I know I am a Failure Guy . :(

Post Reply

Return to “Volume 125 (12500-12599)”