A667.数字和 题解
2026-08-14 16:56:06
发布于:浙江
1阅读
0回复
0点赞
等差数列求和:(首项+末项)*项数/2
见:
1 2 3 4 5 6 ... 99 100
+ + + + + + + +
100 99 98 97 95 94 ... 2 1
101 101 101 101 101 101 ... 101 101
\/
n个101
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
cout<<(1+n)*n/2;
return 0;
}
这里空空如也








有帮助,赞一个