C++

Source: Internet
Author: User
Problem description Very sorry, originally excitedly engaged in a practice game, due to my lack of preparation, there are a lot of data errors, now here for a simple topic:

A few days ago on the internet to find ACM data, see a high School Olympiad question, is disjoint curve segment division plane problem, I have sent to the forum, and LXJ has got a conclusion, here is not

More than that, here's a similar and simpler question:

If there are n points on the plane, and each point has at least 2 curved segments connected to it, that is, each curve is closed, and we stipulate that:
1) All curved segments do not intersect;
2) But there can be more than one curve segment between any two points.

If we know that these line segments divide the plane into m parts, can you tell how many curved segments there are?
Input data containing n and m,n=0,m=0 represent the end of the input, not processing.
All input data is within a 32-bit integer range. The number of segments corresponding to the output outputs. Sample Input
3 20 0
Sample Output
3
#include <iostream>using namespace Std;int main () {    long long n,m;    while (cin>>n>>m) {        if (n==0 && m==0) break            ;        cout<<n+m-2<<endl;    }    return 0;}


Learning experience: This problem is typical of mathematical thinking, but also can. Continue to refuel!!!

C++

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.