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;
}

 

 

 

转载于:https://www.cnblogs.com/BobHuang/p/7427697.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值