This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |