TOJ 3974: Region n条直线m个圆最多将圆分为几个区域
3974: Region
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
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