#include<iostream>
using namespace std;
int main()
{
int n, m;
while (cin >> n >> m)
{
// end指能够完成“对完整m个取平均值”循环的最后一个索引(索引从1开始)
int end = n - (n % m);
for (int i = 1; i <= end; i += m)
{
// 为了输出格式正确
if (i >= 2)
cout << " ";
// 平均值 = (首项 + 末项) / 2
cout << i + (i + m - 1);
}
if (end < n)
// 平均值 = (首项 + 末项) / 2
cout << " " << (end + 1) + n << endl;
else
cout << endl;
}
}
hdu 2015 an even number of summation
Guess you like
Origin blog.csdn.net/weixin_43469047/article/details/104762589
Recommended
Ranking