n straight lines up plane can be divided into several parts?
Input formats:
Plural sets of inputs, each input a positive integer n (n≤1000000), n straight lines expressed.
Output formats:
Each input and output a positive integer, each output per line, up to the plane into several parts n straight lines.
Sample input:
1 2
Sample output:
2 4
1: 2
2: There is a point of intersection with the first, separated two new 2 + 2 = 4
3: Up to now the two intersections of two lines, the newly added three surfaces 2 + 3 + 2 = 7
4: with 3 intersections three lines, the newly added four faces 2 + 3 + 4 + 2 = 11
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define pr make_pair
#define maxn 100005
using namespace std;
int main(void){
int n;
while(cin >> n){
ll ans = (1+n)/2.0*n+1;
cout << ans << endl;
}
return 0;
}
Note: /2.0