# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
2592 |
2013-07-27T06:40:02 Z |
swh0329 |
생일수 I (GA4_birthday1) |
C++ |
|
100 ms |
1088 KB |
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, t, n, n5, n3, s5, n8, t3, t5, minn;
scanf("%d", &t);
while(t>0)
{
t--;
scanf("%d", &n);
if(n==1 || n==2 || n==4 || n==7) {printf("-1\n"); continue;}
if(n%8==0)
{
for(i=1;i<=n/8;i++) printf("8");
printf("\n");
continue;
}
n5=n/5;
minn=999999999;
t3=0;
t5=0;
for(i=n5;i>=0;i--)
{
s5=i*5;
if((n-s5)%3==0)
{
n3=(n-s5)/3;
n5=i;
if(abs(n5-n3)<minn)
{
t3=n3;
t5=n5;
minn=abs(n5-n3);
}
}
}
n3=t3;
n5=t5;
if(n3>n5)
{
n8=n5;
n3=n3-n5;
n5=0;
}
else
{
n8=n3;
n5=n5-n3;
n3=0;
}
for(i=1;i<=n3;i++) printf("3");
for(i=1;i<=n5;i++) printf("5");
for(i=1;i<=n8;i++) printf("8");
printf("\n");
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
1088 KB |
Output is correct |
2 |
Correct |
88 ms |
1088 KB |
Output is correct |
3 |
Correct |
100 ms |
1088 KB |
Output is correct |
4 |
Correct |
96 ms |
1088 KB |
Output is correct |
5 |
Correct |
80 ms |
1088 KB |
Output is correct |
6 |
Correct |
100 ms |
1088 KB |
Output is correct |
7 |
Correct |
76 ms |
1088 KB |
Output is correct |
8 |
Correct |
76 ms |
1088 KB |
Output is correct |
9 |
Correct |
100 ms |
1088 KB |
Output is correct |
10 |
Correct |
80 ms |
1088 KB |
Output is correct |
11 |
Correct |
76 ms |
1088 KB |
Output is correct |
12 |
Correct |
80 ms |
1088 KB |
Output is correct |
13 |
Correct |
84 ms |
1088 KB |
Output is correct |
14 |
Correct |
68 ms |
1088 KB |
Output is correct |
15 |
Correct |
60 ms |
1088 KB |
Output is correct |
16 |
Correct |
92 ms |
1088 KB |
Output is correct |
17 |
Correct |
96 ms |
1088 KB |
Output is correct |
18 |
Correct |
88 ms |
1088 KB |
Output is correct |
19 |
Correct |
88 ms |
1088 KB |
Output is correct |
20 |
Correct |
80 ms |
1088 KB |
Output is correct |
21 |
Correct |
76 ms |
1088 KB |
Output is correct |
22 |
Correct |
84 ms |
1088 KB |
Output is correct |
23 |
Correct |
88 ms |
1088 KB |
Output is correct |
24 |
Correct |
100 ms |
1088 KB |
Output is correct |
25 |
Correct |
96 ms |
1088 KB |
Output is correct |