“蓝桥杯”练习系统 - 入门训练 - 序列求和

思路:

1 ≤ n ≤ 1,000,000,000,需要用long long存.

 1 #include <iostream>
 2 using namespace std;
 3 typedef long long ll;
 4 
 5 int main()
 6 {
 7     ios::sync_with_stdio(false);
 8     cin.tie(0);
 9 
10     ll n;
11     cin >> n;
12     cout << n * (n + 1) / 2 << endl;
13 
14     return 0;
15 }

 

posted @ 2020-01-31 21:02  域Anton  阅读(135)  评论(0)    收藏  举报