Submission #2420

#TimeUsernameProblemLanguageResultExecution timeMemory
2420pl0892029생일수 I (GA4_birthday1)C++98
14 / 100
591 ms8696 KiB
#include <cstdio>

const int mx = 1000001;

int path[mx];
int stack[mx];

int main() {
    for(int i=0;i<mx;i++) path[i]=-1;
    
    path[3]=3;
    path[5]=5;
    path[8]=8;
    
    for(int i=3;i+3<mx;i++) {
        if( path[i] == -1 ) continue;
        if( i+3 < mx && path[i+3] == -1 ) path[i+3]=3;
        if( i+5 < mx && path[i+5] == -1 ) path[i+5]=5;
        if( i+8 < mx && path[i+8] == -1 ) path[i+8]=8;
    }
    
    int T;
    scanf("%d",&T);
    while(T--) {
        int n;
        scanf("%d",&n);
        
        if( path[n] == -1 ) puts("-1");
        else {
             int index = n, top = 0;
             while(index>0) {
                 stack[top++] = path[index];
                 index -= path[index];
             }
             while(top-->0) printf("%d",stack[top]);
             puts("");
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...