Background
Special for beginners, ^_^
Description
同一平面内有n (n≤500) 条直线,已知其中p (p≥2) 条直线相交于同一点,则这 n 条直线最多能将平面分割成多少个不同的区域?
Format
Input
两个整数n (n≤500) 和 p (2≤p≤n)。
Output
一个正整数,代表最多分割成的区域数目。
Samples
輸入資料 1
12 5
輸出資料 1
73
Limitation
1s, 1024KiB for each test case.
代码
#include<iostream>
using namespace std;
int main()
{
int n,p,a = 0;
cin>>n>>p;
a = 2 * p;
for(int i = p + 1; i <= n; i++)
{
a += i;
}
cout<<a;
}
谢谢观看。