답안 #7766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7766 2014-08-18T11:45:10 Z studenttest 생일수 II (GA4_birthday2) C++
45 / 100
1000 ms 3040 KB
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char a[200001], b[200001];
int x[200001], y[200001];
int main()
{
    long long int i, kx, ky, k, kk, c=0, z, ans=0;
    scanf("%s", a);
    scanf("%s", b);
    kx = strlen(a);
    ky = strlen(b);
    for(i=1;i<=kx;i++){
        if(a[kx-i]=='3') x[i] = 3;
        if(a[kx-i]=='5') x[i] = 5;
        if(a[kx-i]=='8') x[i] = 8;
    }
    for(i=1;i<=ky;i++){
        if(b[ky-i]=='3') y[i] = 3;
        if(b[ky-i]=='5') y[i] = 5;
        if(b[ky-i]=='8') y[i] = 8;
    }
    k = 0;
    if(kx>8){
        for(i=kx;i>kx-8;i--){
            k*=10;
            k+=x[i];
        }
        k%=19980305;
        for(i=kx-8;i>=1;i--){
            k*=10;
            k+=x[i];
            k%=19980305;
        }
    }
    else{
        for(i=kx;i>=1;i--){
            k*=10;
            k+=x[i];
        }
    }
    while(1){
        if(x[1]==3){
            x[1] = 5;
            kk = k+2;
        }
        else if(x[1]==5){
            x[1] = 8;
            kk = k+3;
        }
        else{
            x[1] = 3;
            for(i=2;i<=kx+1;i++){
                if(i==kx+1){
                    kx++;
                    x[i] = 3;
                    break;
                }
                if(x[i]==3){
                    x[i] = 5;
                    break;
                }
                else if(x[i]==5){
                    x[i] = 8;
                    break;
                }
                else{
                    x[i] = 3;
                }
            }
            kk = 0;
            if(kx>8){
                for(i=kx;i>kx-8;i--){
                    kk*=10;
                    kk+=x[i];
                }
                kk%=19980305;
                for(i=kx-8;i>=1;i--){
                    kk*=10;
                    kk+=x[i];
                    kk%=19980305;
                }
            }
            else{
                for(i=kx;i>=1;i--){
                    kk*=10;
                    kk+=x[i];
                }
            }
        }
        z = 0;
        for(i=1;i<=ky;i++){
            if(x[i]!=y[i]){
                z = 1;
                break;
            }
        }
        ans = (ans+(k*kk))%19980305;
        if(z==0) break;
        k = kk;
    }
    printf("%lld", ans);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3040 KB Output is correct
2 Correct 0 ms 3040 KB Output is correct
3 Correct 0 ms 3040 KB Output is correct
4 Correct 0 ms 3040 KB Output is correct
5 Correct 0 ms 3040 KB Output is correct
6 Correct 0 ms 3040 KB Output is correct
7 Correct 0 ms 3040 KB Output is correct
8 Correct 0 ms 3040 KB Output is correct
9 Correct 0 ms 3040 KB Output is correct
10 Correct 0 ms 3040 KB Output is correct
11 Correct 0 ms 3040 KB Output is correct
12 Correct 0 ms 3040 KB Output is correct
13 Correct 0 ms 3040 KB Output is correct
14 Correct 0 ms 3040 KB Output is correct
15 Correct 0 ms 3040 KB Output is correct
16 Correct 0 ms 3040 KB Output is correct
17 Correct 0 ms 3040 KB Output is correct
18 Correct 0 ms 3040 KB Output is correct
19 Correct 0 ms 3040 KB Output is correct
20 Correct 0 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3040 KB Output is correct
2 Correct 0 ms 3040 KB Output is correct
3 Correct 0 ms 3040 KB Output is correct
4 Correct 0 ms 3040 KB Output is correct
5 Correct 0 ms 3040 KB Output is correct
6 Correct 0 ms 3040 KB Output is correct
7 Correct 0 ms 3040 KB Output is correct
8 Correct 0 ms 3040 KB Output is correct
9 Correct 0 ms 3040 KB Output is correct
10 Correct 0 ms 3040 KB Output is correct
11 Correct 0 ms 3040 KB Output is correct
12 Correct 0 ms 3040 KB Output is correct
13 Correct 0 ms 3040 KB Output is correct
14 Correct 0 ms 3040 KB Output is correct
15 Correct 0 ms 3040 KB Output is correct
16 Correct 0 ms 3040 KB Output is correct
17 Correct 0 ms 3040 KB Output is correct
18 Correct 0 ms 3040 KB Output is correct
19 Correct 0 ms 3040 KB Output is correct
20 Correct 0 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3040 KB Output is correct
2 Correct 0 ms 3040 KB Output is correct
3 Correct 0 ms 3040 KB Output is correct
4 Correct 0 ms 3040 KB Output is correct
5 Correct 0 ms 3040 KB Output is correct
6 Correct 0 ms 3040 KB Output is correct
7 Correct 0 ms 3040 KB Output is correct
8 Correct 0 ms 3040 KB Output is correct
9 Correct 0 ms 3040 KB Output is correct
10 Correct 0 ms 3040 KB Output is correct
11 Correct 0 ms 3040 KB Output is correct
12 Correct 0 ms 3040 KB Output is correct
13 Correct 0 ms 3040 KB Output is correct
14 Correct 0 ms 3040 KB Output is correct
15 Correct 0 ms 3040 KB Output is correct
16 Correct 0 ms 3040 KB Output is correct
17 Correct 0 ms 3040 KB Output is correct
18 Correct 0 ms 3040 KB Output is correct
19 Correct 0 ms 3040 KB Output is correct
20 Correct 0 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 3036 KB Program timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 3036 KB Program timed out
2 Halted 0 ms 0 KB -