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++