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>
int T, N, num3, num5, num8, rest;
void input(void)
{
scanf("%d",&N);
num3=num5=num8=rest=0;
}
void output(void)
{
int i;
for(i=1 ; i<=num3 ; i++)
printf("3");
for(i=1 ; i<=num5 ; i++)
printf("5");
for(i=1 ; i<=num8 ; i++)
printf("8");
printf("\n");
}
void process(void)
{
num3=N/3;
rest=N%3;
while(rest>0 && num3>0)
{
num3--;
rest+=3;
num5+=rest/5;
rest%=5;
}
if(rest)
printf("-1\n");
else
{
if(num3<num5)
{
num8=num3;
num5-=num3;
num3=0;
num8+=num5/8*5;
num5%=8;
}
else
{
num8=num5;
num3-=num5;
num5=0;
num8+=num3/8*3;
num3%=8;
num5+=num3/5*3;
num3%=5;
}
output();
}
}
int main(void)
{
int i;
scanf("%d",&T);
for(i=1 ; i<=T ; i++)
{
input();
process();
}
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... |