# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
2326 |
2013-07-21T02:42:22 Z |
zyslee |
생일수 I (GA4_birthday1) |
C++ |
|
1000 ms |
884 KB |
#include<stdio.h>
int main()
{
int n, i, t, j, a, b, c, k, l;
scanf("%d", &n);
for(i=1;i<=n;i++){
scanf("%d", &t);
a = b = c = 0;
for(j=t/8;j>=0;j--){
for(k=(t-(j*8))/5;k>=0;k--){
if((t-(j*8)-(k*5))%3==0){
if(j+k+((t-(j*8)-(k*5))/3)<a+b+c || (a==0 && b==0 && c==0)){
a = j;
b = k;
c = (t-(j*8)-(k*5))/3;
}
else if(j+k+((t-(j*8)-(k*5))/3)==a+b+c){
if(a<j){
a = j;
b = k;
c = (t-(j*8)-(k*5))/3;
}
else if(a==j){
if(b<k){
a = j;
b = k;
c = (t-(j*8)-(k*5))/3;
}
}
}
}
}
}
if(a==0 && b==0 && c==0) printf("-1\n");
else{
for(j=1;j<=c;j++) printf("3");
for(j=1;j<=b;j++) printf("5");
for(j=1;j<=a;j++) printf("8");
printf("\n");
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
884 KB |
Output is correct |
2 |
Correct |
1 ms |
884 KB |
Output is correct |
3 |
Correct |
1 ms |
884 KB |
Output is correct |
4 |
Correct |
0 ms |
884 KB |
Output is correct |
5 |
Correct |
1 ms |
884 KB |
Output is correct |
6 |
Correct |
1 ms |
884 KB |
Output is correct |
7 |
Correct |
1 ms |
884 KB |
Output is correct |
8 |
Correct |
0 ms |
884 KB |
Output is correct |
9 |
Correct |
1 ms |
884 KB |
Output is correct |
10 |
Correct |
0 ms |
884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
0 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |