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 1072. Routing

WA 5. Maybe i read incorrect data?
Posted by Lifanov 31 Mar 2005 18:22
unsigned int convert(char *a){
    unsigned int S=0,t;
    int j=0;
    for(int i=0;i<3;i++){
        S*=256;
        t=0;
        while(a[j]!='.'){
            t+=a[j]-'0';
            t*=10;
            j++;
        }
        S+=t;
    }
    j=0;
    t=0;
    for(;j<strlen(a);j++){
        t*=10;
        t+=a[j]-'0';

    }
    S*=256;
    S+=t;
    return S;
}
void read(int n){ // n -index PC
    int k,i;
    char ip[100],mask[100];
    scanf("%d",&k);
    Count[n]=k;
    for(i=0;i<k;i++){
        scanf("%s %s",ip,mask);
        IP[n][i]=convert(ip);
        Mask[n][i]=convert(mask);
    //    printf("%s %s %u %u\n",ip,mask,IP[n][i],Mask[n][i]);
    }
}
I change Analysis string to sscanf("%d.%d....); and get AC.
Posted by Lifanov 2 Apr 2005 17:54