zoukankan      html  css  js  c++  java
  • 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
    ",2*m*n+n*(n+1)/2+m*(m-1)+1+(n==0&&m));
        }
        return 0;
    }

     

     

  • 相关阅读:
    jenkins+jmeter结合使用
    Bean的前身今世&处理器&Aware
    Spring的profile属性
    XML的验证模式
    org.springframework.beans包
    packge-info.java
    字节码解释执行引擎
    invokedynamic指令
    多态方法调用的解析和分派
    运行时栈帧结构
  • 原文地址:https://www.cnblogs.com/BobHuang/p/7427697.html
Copyright © 2011-2022 走看看