ytyuhuan @ 2020-12-25 22:44:00
之前看了看讨论版大佬的做法,就自己写了一个非常弱的代码,结果开了O2一交,傻眼了:就10分!
关了O2再交
还是10分
蒟蒻求助各位大佬
#include <cstdio>
using namespace std;
int a, b, c, n, t;
int main()
{
scanf("%d", &n);
if (n == 0 || n == 1 || n == 2 || n == 5)
{
printf("0 0 0\n");
return 0;
}
if (n < 6 && n != 4 && n != 3)
{
printf("-1\n");
return 0;
}
t = n / 14;
n = n % 14;
if (n < 6 && n != 4 && n != 3 && n != 0)
{
t--;
n = n + 14;
if (n == 0)
{
printf("%d %d %d\n", t, t, t);
return 0;
}
}
switch (n)
{
case 3:
printf("%d %d %d\n", t, t, t + 1);
case 4:
printf("%d %d %d\n", t, t + 1, t);
case 6:
printf("%d %d %d\n", t, t, t + 2);
case 7:
printf("%d %d %d\n", t, t + 1, t + 1);
case 8:
printf("%d %d %d\n", t, t + 2, t);
case 9:
printf("%d %d %d\n", t, t, t + 3);
case 10:
printf("%d %d %d\n", t, t + 1, t + 2);
case 11:
printf("%d %d %d\n", t, t + 2, t + 1);
case 12:
printf("%d %d %d\n", t, t, t + 4);
case 13:
printf("%d %d %d\n", t, t + 1, t + 3);
case 15:
printf("%d %d %d\n", t, t, t + 5);
case 16:
printf("%d %d %d\n", t, t + 1, t + 4);
case 19:
printf("%d %d %d\n", t, t + 1, t + 5);
}
return 0;
}
by lcyxds @ 2021-04-18 07:36:05
@Miyang001 样例都不测试的吗。。。
你这代码就没找着啥对的地方真的
by lcyxds @ 2021-04-18 07:38:08
@Miyang001 改动最小的 AC 代码了。。。
#include <cstdio>
using namespace std;
int a, b, c, n, t;
int main()
{
scanf("%d", &n);
if (n == 0 )
{
printf("0 0 0\n");
return 0;
}
if (n < 6 && n != 4 && n != 3)
{
printf("-1\n");
return 0;
}
t = n / 14;
n = n % 14;
if (n < 6 && n != 4 && n != 3 && n != 0)
{
t--;
n = n + 14;
}
if (n == 0)
{
printf("%d %d %d\n", t, t, t);
return 0;
}
switch (n)
{
case 3:
printf("%d %d %d\n", t, t, t + 1);break;
case 4:
printf("%d %d %d\n", t, t + 1, t);break;
case 6:
printf("%d %d %d\n", t, t, t + 2);break;
case 7:
printf("%d %d %d\n", t, t + 1, t + 1);break;
case 8:
printf("%d %d %d\n", t, t + 2, t);break;
case 9:
printf("%d %d %d\n", t, t, t + 3);break;
case 10:
printf("%d %d %d\n", t, t + 1, t + 2);break;
case 11:
printf("%d %d %d\n", t, t + 2, t + 1);break;
case 12:
printf("%d %d %d\n", t, t, t + 4);break;
case 13:
printf("%d %d %d\n", t, t + 1, t + 3);break;
case 15:
printf("%d %d %d\n", t, t, t + 5);break;
case 16:
printf("%d %d %d\n", t, t + 1, t + 4);break;
case 19:
printf("%d %d %d\n", t, t + 1, t + 5);
}
return 0;
}
by ytyuhuan @ 2021-04-18 08:57:22
@lcyxds 感谢orz