Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
1 100
1 5050
感觉就是一等差数列,d=1
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
ll n;
while(~scanf("%I64d",&n))
{
printf("%I64d\n\n",(1+n)*n/2);
}
return 0;
}