Submission #16365

# Submission time Handle Problem Language Result Execution time Memory
16365 2015-08-21T15:35:12 Z eaststar 생일수 I (GA4_birthday1) C++14
100 / 100
867 ms 13316 KB
#include <bits/stdc++.h>
int D[1000010]={1},p[1000010];
void ans(int x){
    if(!x)return;
    ans(p[x]);
    printf("%d",x-p[x]);
}
int main(){
    int i,n,t;
    for(i=3;i<=1e6;++i){
        if(D[i-3])D[i]=D[i-3]+1,p[i]=i-3;
        if(i>4&&D[i-5]&&(!D[i]||D[i]>D[i-5]))D[i]=D[i-5]+1,p[i]=i-5;
        if(i>7&&D[i-8]&&(!D[i]||D[i]>D[i-8]))D[i]=D[i-8]+1,p[i]=i-8;
    }
    scanf("%d",&t);
    for(;t--;){
        scanf("%d",&n);
        if(D[n])ans(n),puts("");
        else puts("-1");
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9532 KB Output is correct
2 Correct 4 ms 9532 KB Output is correct
3 Correct 11 ms 9532 KB Output is correct
4 Correct 8 ms 9532 KB Output is correct
5 Correct 6 ms 9532 KB Output is correct
6 Correct 4 ms 9532 KB Output is correct
7 Correct 12 ms 9532 KB Output is correct
8 Correct 12 ms 9532 KB Output is correct
9 Correct 7 ms 9532 KB Output is correct
10 Correct 12 ms 9532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 803 ms 13288 KB Output is correct
2 Correct 735 ms 13312 KB Output is correct
3 Correct 867 ms 13264 KB Output is correct
4 Correct 789 ms 13292 KB Output is correct
5 Correct 768 ms 13212 KB Output is correct
6 Correct 825 ms 13236 KB Output is correct
7 Correct 711 ms 13248 KB Output is correct
8 Correct 770 ms 13308 KB Output is correct
9 Correct 797 ms 13260 KB Output is correct
10 Correct 730 ms 13288 KB Output is correct
11 Correct 773 ms 13280 KB Output is correct
12 Correct 760 ms 13304 KB Output is correct
13 Correct 780 ms 13312 KB Output is correct
14 Correct 771 ms 13240 KB Output is correct
15 Correct 729 ms 13284 KB Output is correct
16 Correct 740 ms 13224 KB Output is correct
17 Correct 839 ms 13312 KB Output is correct
18 Correct 723 ms 13316 KB Output is correct
19 Correct 780 ms 13300 KB Output is correct
20 Correct 696 ms 13240 KB Output is correct
21 Correct 794 ms 13312 KB Output is correct
22 Correct 804 ms 13312 KB Output is correct
23 Correct 811 ms 13272 KB Output is correct
24 Correct 830 ms 13308 KB Output is correct
25 Correct 799 ms 13280 KB Output is correct