#P7089. [NWRRC2013] Kids in a Friendly Class
[NWRRC2013] Kids in a Friendly Class
题目描述
Kevin resembles his class in primary school. There were girls and boys in his class. Some of them were friends, some were not. But if one person considered another person a friend, the opposite was also true.
Interestingly, every girl had exactly a friends among girls and exactly friends among boys, whereas every boy had exactly friends among girls and exactly friends among boys.
Kevin does not remember the size of his class. Help him reconstruct the class with minimal possible number of kids, such that the above conditions are satisfied.
输入格式
The only line contains four integers , and .
输出格式
Output an example of a class of minimal possible size satisfying the above conditions.
The first line should contains two positive integers: -- the number of girls, and -- the number of boys.
Let's assign numbers through to the girls and through to the boys.
Each of the next lines should contain a pair of distinct integers describing a pair of friends by their numbers. Each pair of friends should appear exactly once in this list.
题目大意
题目描述
凯文的班级里有女生也有男生。他们中有些人是朋友,有些人不是。但是,如果A认为B是他的朋友,那么B也认为A是他的朋友。
有趣的是,每个女生都有 a 个女性朋友和 b 个男性朋友,而每个男生都有 c 个女性朋友和 d 个男性朋友。
凯文不记得自己班级的人数。请算出班级的人数,使得班级人数尽可能少,同时又能满足上面的条件。
输入格式
只有一行,包括4个整数 a , b , c,d (1≤a,b,c,d≤50) .
输出格式
输出一个班级人数,使得其数量尽可能小又满足上述条件。
第一行应该包括两个正整数 m —— 女生人数 n —— 男生人数。
用编号1 到 m 表示女生,编号 m+1 到m+n 表示男生。
接下来的每一行,都应该包含一对不同的整数,来表示一对朋友,而且每对朋友只出现一次。
1 2 1 2
2 4
1 2
1 3
1 5
2 4
2 6
3 4
3 5
4 6
5 6
提示
Time limit: 2 s, Memory limit: 256 MB.