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 1165. Subnumber

Wrong Anser: BUT I checked with the test data on this site....correct....
Posted by Teh Ming Han 18 Oct 2002 23:50
Wrong Anser: BUT I checked with the test data on this
site....correct....

take a look at my code please.
thanks. is there any test case that does not work??

// USU Problem 1165
// Subnumber
// Done by Teh Ming Han

#include <string.h>
#include <iostream.h>
#include <stdlib.h>

int main(){
    int i,a,pos,mat=-1,ori=-1,n=0;
    char dat[201]={'\0'};
    cin.getline(dat,200,'\n');

    pos=0;
    int length = strlen(dat);
    for (i=1;true;i++){
        char ne[8]={'\0'};
        itoa(i,ne,10);
        for (a=0;a<strlen(ne);a++){
            n++;
            if (ne[a]==dat[pos]){
                if (pos==0) ori = n;
                pos++;
            }else pos=0;
            if (pos==length){
                mat = ori;
                break;
            }
        }
        if (mat!=-1) break;
    }
    cout<<mat;
    return 0;
}
Re: Wrong Anser: BUT I checked with the test data on this site....correct....
Posted by daizi sheng(from USTC) 22 Oct 2002 20:08
> Wrong Anser: BUT I checked with the test data on this
> site....correct....
>
> take a look at my code please.
> thanks. is there any test case that does not work??
>

here!
9100
your output is 2889
99100
your output is 188
91001
your output is 38939


> // USU Problem 1165
> // Subnumber
> // Done by Teh Ming Han
>
> #include <string.h>
> #include <iostream.h>
> #include <stdlib.h>
>
> int main(){
>     int i,a,pos,mat=-1,ori=-1,n=0;
>     char dat[201]={'\0'};
>     cin.getline(dat,200,'\n');
>
>     pos=0;
>     int length = strlen(dat);
>     for (i=1;true;i++){
>         char ne[8]={'\0'};
>         itoa(i,ne,10);
>         for (a=0;a<strlen(ne);a++){
>             n++;
>             if (ne[a]==dat[pos]){
>                 if (pos==0) ori = n;
>                 pos++;
>             }else pos=0;
>             if (pos==length){
>                 mat = ori;
>                 break;
>             }
>         }
>         if (mat!=-1) break;
>     }
>     cout<<mat;
>     return 0;
> }