7 solutions
-
0
C++
这题要注意int的范围可能不够🤔
#include <iostream> using namespace std; int main() { long long n = 0; long long sum = 0; cin >> n; for(int i = 1; i <= n; i++) sum += i; cout << sum << endl; return 0; }
python
while True: try: n = input() sum = 0 for i in range(n+1): sum += i print(sum) except: break
- 1
Information
- ID
- 34
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 8
- Tags
- # Submissions
- 2839
- Accepted
- 413
- Uploaded By