Submission #7762

#TimeUsernameProblemLanguageResultExecution timeMemory
7762tncks0121생일수 I (GA4_birthday1)C++98
100 / 100
184 ms1088 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <deque> #include <utility> #include <bitset> using namespace std; typedef long long ll; const int INF = 987654321; const ll LINF = (ll)1e15; int TC; int N; int main (){ int x, y, z; scanf("%d", &TC); while(TC--) { scanf("%d", &N); int rx, ry, rz, rv = N+1; for(z = N/8; z >= 0; z--) { for(x = 0; x <= 5; x++) { int m = N - 3*x - 8*z; if(m % 5 == 0 && m >= 0) { y = m / 5; if(x+y+z < rv) { rv=x+y+z; rx = x; ry = y; rz = z; } } } } if(rv > N) { puts("-1"); }else { while(rx--) putchar('3'); while(ry--) putchar('5'); while(rz--) putchar('8'); puts(""); } } 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...