- 輸入
- There are multiple test cases.
The input consists of a single integer N that is not greater than 10000 by it's absolute value. - 輸出
- Write a single integer number that is the sum of all integer numbers lying between 1 and N inclusive.
- 樣例輸入
-
3
- 樣例輸出
-
6
#include<iostream> #include<string.h> #include<stdio.h> #include<ctype.h> #include<algorithm> #include<stack> #include<queue> #include<set> #include<math.h> #include<vector> #include<deque> #include<list> using namespace std; int main() { int n; //int sum=0; while(scanf("%d",&n)!=EOF) { printf("%d\n", (abs(n - 1) + 1) * (1 + n) / 2); } return 0; }
sum of all integer numbers(坑題,水題)
描述
Your task is to find the sum of all integer numbers lying between 1 and N inclusive.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.