NEFUOJ 424偶数求和
作者:互联网
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n, m,sum,a0,isprime;
while (scanf("%d%d", &n, &m) != EOF)
{
a0 = 2,sum = 0;
isprime = 0;
for (int i = 1; i <= n; i++)
{
sum += a0;
a0 = a0 + 2;
if (i % m == 0)
{
if (isprime == 1)printf(" ");
printf("%d", sum / m); // 每m个一组
sum = 0; //输出一次 sum清空
isprime = 1;
}
}
if (n % m == 0)printf("\n"); //n是m的整数倍结束
else printf(" %d\n", sum / (n % m)); //剩余的再输出一下
}
return 0;
}
标签:main,int,sum,偶数,a0,NEFUOJ,isprime,include,424 来源: https://blog.csdn.net/weixin_62486861/article/details/121718837