UuMo @ 2024-10-09 08:55:44
#include <stdio.h>
#include <malloc.h>
int main()
{
int N;
scanf("%d",&N);
int* Light = (int*)malloc(sizeof(int)*N);
for (int i = 0;i<N;i++)
{Light[i] = 0; //数组中的序号对应灯的编号,元素是2的倍数表示开,不是2的倍数表示关
}
for (int i = 1;i<=N;i++)
{
int n = 0;
n = N/i; //计算出有多少个灯的状态需要改变
for (int j = 1;j<=n;j++)
{
Light[j*i-1]++;
// printf("%d",Light[j*i-1]);
}
// printf("\n");
}
for(int i =0;i<N;i++)
{
if (Light[i]%2!=0)
printf("%d ",i+1);
}
return 1;
} ```
by _chicken_ @ 2024-10-09 08:57:55
@UuMo 返回值必须为0而不是1
by UuMo @ 2024-10-09 09:02:10
@chicken 喔哦,ac了,非常感谢,但是这个返回的为什么一定要是0啊
by _chicken_ @ 2024-10-09 09:10:08
@UuMo 评测机会根据main函数返回值来判断程序是否正常结束
by UuMo @ 2024-10-09 09:29:54
@_chicken_哦哦,原来是这样,懂了,谢谢你