제출 #2517

#제출 시각아이디문제언어결과실행 시간메모리
2517kipa00생일수 I (GA4_birthday1)C++98
14 / 100
62 ms884 KiB
#include <cstdio>
using namespace std;

int T, N;
int threes, fives, eights;

int t[8] = {0, 3, 0, 1, 4, 0, 2, 0};
int f[8] = {0, 0, 2, 0, 0, 1, 0, 3};
int e[8] = {0, 1, 1, 0, 1, 0, 0, 1};
int small[8] = {-1, -1, -1, 3, -1, 5, 33, -1};

void makeinput(char c, int count) {
    while (count--) {
        printf("%c", c);
    }
}

int main() {
    scanf("%d", &T);
    while (T--) {
        threes = fives = eights = 0;
        scanf("%d", &N);
        if (N < 8) {
            printf("%d\n", small[N]);
            continue;
        }
        eights = N / 8;
        N %= 8;
        threes += t[N]; fives += f[N]; eights -= e[N];
        makeinput('3', threes);
        makeinput('5', fives);
        makeinput('8', eights);
        printf("\n");
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...