
613 - Numbers That Count
Moderator: Board moderators
613 - Numbers That Count
Any tricky input in this problem?? I got WA
so many times...

-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
I'm also getting WA several times ... I don't know what I'm doing wrong in this code (below). Could anyone tell me ? Or suggest some special cases which I missed ?
Best regards
DM
Best regards
DM
Code: Select all
spoiler - Acc with minor changes. I made a little bug when I was outputting results :-)
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
613 Wrong Answer :-(
Hi,
I got WA multiple times and looked at my running time and it's very faster than the first in the rankings, so I guess, I've misunderstood this problem.
Could you please check the following testcases for me:
my result is:
is there any tricky input / special case? is only number on a line?
Thanks,
Tobi
I got WA multiple times and looked at my running time and it's very faster than the first in the rankings, so I guess, I've misunderstood this problem.
Could you please check the following testcases for me:
Code: Select all
777777777
97
1719
12345678901234567890123456789012345678901234567890123456789012345678901234567890
1
0
8999
11111111111111111111111111111111111111111111111111111111111111111111111111111111
801
-1
my result is:
Code: Select all
777777777 can not be classified after 15 iterations
97 enters an inventory loop of length 2
1719 enters an inventory loop of length 2
12345678901234567890123456789012345678901234567890123456789012345678901234567890 is self-inventorying after 4 steps
1 is self-inventorying after 12 steps
0 is self-inventorying after 10 steps
8999 can not be classified after 15 iterations
11111111111111111111111111111111111111111111111111111111111111111111111111111111 can not be classified after 15 iterations
801 enters an inventory loop of length 2
Thanks,
Tobi
-
- New poster
- Posts: 30
- Joined: Sat Nov 30, 2002 1:04 pm
Last edited by tat tvam asi on Mon Oct 18, 2004 7:04 pm, edited 1 time in total.
thanks for your quick reply. I have the same output for your testcases.
But is the judge's test input format as yours? I didn't found in the problem assignment that there are multiple testcases the number of testcases in the first line and multiple occurrences of -1 in the testcases.
In other words: Do I have to take the first number of the test case as the first integer or as the number of testcases following?
But is the judge's test input format as yours? I didn't found in the problem assignment that there are multiple testcases the number of testcases in the first line and multiple occurrences of -1 in the testcases.
In other words: Do I have to take the first number of the test case as the first integer or as the number of testcases following?
-
- New poster
- Posts: 30
- Joined: Sat Nov 30, 2002 1:04 pm
-
- New poster
- Posts: 2
- Joined: Fri Jun 30, 2006 4:22 pm
613 - WA???
Is there any test case my code can't handle?
A little help plz.
Here's my code :
C:
#include<stdio.h>
#include<string.h>
int i,len,num[15],step;
char s[20][82];
void main(){
while(scanf("%s",&s[1])){
if(!strcmp(s[1],"-1")) break;
len=strlen(s[1]);
for(step=2;step<=16;step++){
memset(num,0,20);
for(i=0;i<len;i++) num[s[step-1]-48]++;
for(i=0,len=0;i<10;i++){
if(num){
if(num>9){
s[step][len++]=num/10+48;
s[step][len++]=num%10+48;
}
else s[step][len++]=num+48;
s[step][len++]=i+48;
}
}
s[step][len]=0;
for(i=step-1;i;i--){
if(!strcmp(s,s[step])){
if(step-i==1){
printf("%s is self-inventorying",s[1]);
if(step==2) printf("\n");
else printf(" after %i steps\n",step-2);
}
else printf("%s enters an inventory loop of length %i\n",s[1],step-i);
break;
}
}
if(i) break;
}
if(step==17) printf("%s can not be classified after 15 iterations\n",s[1]);
}
}
/* end of code */
thanx
A little help plz.
Here's my code :
C:
#include<stdio.h>
#include<string.h>
int i,len,num[15],step;
char s[20][82];
void main(){
while(scanf("%s",&s[1])){
if(!strcmp(s[1],"-1")) break;
len=strlen(s[1]);
for(step=2;step<=16;step++){
memset(num,0,20);
for(i=0;i<len;i++) num[s[step-1]-48]++;
for(i=0,len=0;i<10;i++){
if(num){
if(num>9){
s[step][len++]=num/10+48;
s[step][len++]=num%10+48;
}
else s[step][len++]=num+48;
s[step][len++]=i+48;
}
}
s[step][len]=0;
for(i=step-1;i;i--){
if(!strcmp(s,s[step])){
if(step-i==1){
printf("%s is self-inventorying",s[1]);
if(step==2) printf("\n");
else printf(" after %i steps\n",step-2);
}
else printf("%s enters an inventory loop of length %i\n",s[1],step-i);
break;
}
}
if(i) break;
}
if(step==17) printf("%s can not be classified after 15 iterations\n",s[1]);
}
}
/* end of code */
thanx