Problem Description
I am very sorry, originally excitedly engaged in a practice game, because I am not prepared enough, 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
The input data contains N and m,n=0,m=0 to indicate the end of the input, not to be processed.
All input data is within a 32-bit integer range.
Output
The output corresponds to the number of segments.
Sample Input
3 2
0 0
Sample Output
3
Application of Euler's formula:
Euler formula:
A relationship between the number of vertices of a simple polyhedron V, the number of polygons F and the number of edges E
v+f-e=2
(This topic: Vertex + polygon number -2= number of edges)
You can deduce it yourself!
Imagine that n points are enclosed in a closed graph, which is divided into 2 polygons.
This time the line segment is the N bar.
If you need to add a polygon, the segment needs to be added one more.
So, input n points, divided into M-plane, it can be deduced that the segment is n-2+m.
Note: n+m is super int range!
import java.util.scanner; Public class main{public static void main (string[] args) {Scanner sc = new Scanner (system. In ); while (Sc.hasnext ()) {long n = sc.nextlong (); long m = Sc.nextlong (); if (N==0 &&m==0 ) {return ; } System. out . println (N+m-2 ); } }}
Hdoj 1418 Sorry (Euler formula)