#include<iostream>
#include<stdio.h>
#include<list>
using namespace std;
int main()
{
int t,n,i;
list<int> d;
list<int>::iterator j;
scanf("%d", &t);
for(i=1; i<=t; i++){
scanf("%d", &n);
d.clear();
while(1){
if(n==0) break;
else if((n-8)>=0 && (n-8)%3==0 || (n-5)>=0 && (n-8)%5==0 || (n-5)>=0 && (n-8)%8==0){
d.push_front(8);
n=n-8;
}
else if((n-5)>=0 && (n-5)%3==0 || (n-5)>=0 && (n-5)%5==0 || (n-5)>=0 && (n-5)%8==0){
d.push_front(5);
n=n-5;
}
else if((n-3)>=0 && (n-3)%3==0 || (n-5)>=0 && (n-3)%5==0 || (n-5)>=0 && (n-3)%8==0){
d.push_front(3);
n=n-3;
}
else {printf("-1"); break;}
}
for(j=d.begin(); j!=d.end(); ++j) printf("%d", *j);
printf("\n");
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
723 ms |
5072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |