sdnuoj 1302

来源:互联网 发布:淘宝如何上架宝贝 编辑:程序博客网 时间:2024/06/06 00:26

1302.凸多边形

Time Limit: 1000 MS    Memory Limit: 32768 KB
Total Submission(s): 57    Accepted Submission(s): 31

Description

给定一个有N个顶点的凸多边形,内有K个点,这N+K个点不会有三点共线,可以选择两个点连一条线段,但是线段只能在内部的点相交,问最多能连出多少个三角形。

Input

第一行T(T≤100)为测试用例个数。

然后下面的T行,每行两个数N(3≤N≤10000)和K(1≤K≤10000)

Output

每个测试用例输出一行,最多连多少三角形

Sample Input

33 13 23 42

Sample Output

3585
水题不解释。
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){     int T;     int n,k;     scanf("%d",&T);     while(T--)     {          scanf("%d%d",&n,&k);          cout<<n-2+k*2<<endl;     }     return 0;}

0 0