思路:
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 }
原文:https://www.cnblogs.com/AntonLiu/p/12246718.html