TOJ 3974: Region n条直线m个圆最多将圆分为几个区域

3974: Region 分享至QQ空间

Time Limit(Common/Java):1000MS/3000MS     Memory Limit:65536KByte
Total Submit: 33            Accepted:8

Description

 

In geometry, lines and circles are both very charming shapes, with a lot of interesting properties. We know a line divides the plane into two regions, so does a circle. But how many regions N lines and M circles can divide at most?

 

Input

 

The first line contains a single integer T, indicating the number of test cases.

Each test case begins with two integers N (0 <= N <= 1000) and M (0 <= M <= 1000), indicating the number of lines and circles respectively.

 

Output

 

For each case, output one integer, indicating the maximum regions.
 

 

Sample Input

 

4
1 1
1 2
2 1
2 2

Sample Output

 

4
8
8
14

Source

e鸣杯程序设计竞赛 2010

n条直线m个圆最多将圆分为几个区域

n条直线最多能将平面分为n*(n+1)/2+1个区域

m个圆最后能将平面分为为m*(m-1)+2个区域

我选择用直线去切圆,会多一个2*m*n个区域,那个常数项有待证明

无脑交错了,hhhh

因为满足不了0条直线啊

 

#include <stdio.h>
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n,m;
        scanf("%d%d",&n,&m);
        printf("%d\n",2*m*n+n*(n+1)/2+m*(m-1)+1+(n==0&&m));
    }
    return 0;
}

 

 

 

posted @ 2017-08-25 13:51  暴力都不会的蒟蒻  阅读(519)  评论(0编辑  收藏  举报