hdu 5874 Friends and Enemies【题意不明系列+二分图】
2016-09-11 11:20
399 查看
Friends and Enemies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 214 Accepted Submission(s): 121
Problem Description
On an isolated island, lived some dwarves. A king (not a dwarf) ruled the island and the seas nearby, there are abundant cobblestones of varying colors on the island. Every two dwarves on the island are either friends or enemies. One day, the king demanded
that each dwarf on the island (not including the king himself, of course) wear a stone necklace according to the following rules:
For any two dwarves, if they are friends, at least one of the stones from each of their necklaces are of the same color; and if they are enemies, any two stones from each of their necklaces should be of different colors. Note that a necklace can be empty.
Now, given the population and the number of colors of stones on the island, you are going to judge if it's possible for each dwarf to prepare himself a necklace.
Input
Multiple test cases, process till end of the input.
For each test case, the one and only line contains 2 positive integers M,N (M,N<231) representing
the total number of dwarves (not including the king) and the number of colors of stones on the island.
Output
For each test case, The one and only line of output should contain a character indicating if it is possible to finish the king's assignment. Output ``T" (without quotes) if possible, ``F" (without quotes) otherwise.
Sample Input
20 100
Sample Output
T
Source
2016 ACM/ICPC Asia Regional Dalian Online
题目大意:
说一个岛上有m个人,n种石头,两个人见面要么是朋友要么是敌人,是朋友的要求是两个矮人的身上的项链上至少有一个石头的颜色相同,是敌人的要求就是两个矮人的身上没有石头颜色相同。问给出m,n的值,能否满足使得两个人见面要么是敌人要么是朋友的条件。
思路:
1、到今天的我读完这个题还是觉得只要n>=1就输出T就行了。其实题意隐晦成这个样子:就是让你将m个人分成两个部落,使得部落和部落之间都是朋友,部落和部落之间是敌人。
2、那么最坏的条件就是将m个人分成两个部落,每个部落m/2个人。那么满足两两之间见面都有关系,那么需要m/2*m/2条边,也就是需要m/2*m/2种石头。
按照上述判断一下即可。
Ac代码:
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
long long int n,m;
while(~scanf("%I64d%I64d",&m,&n))
{
if(m*m/4>n)printf("F\n");
else printf("T\n");
}
}
相关文章推荐
- HDU 5874 Friends and Enemies (二分图 读不懂题系列)
- hdu 5874 Friends and Enemies -ICPC网络赛大连-二分图
- HDU 5874 Friends and Enemies(二分图思想)——2016 ACM/ICPC Asia Regional Dalian Online
- hdu 5874 Friends and Enemies【二分图,构造】
- hdu 5874 Friends and Enemies
- HDU 5874 Friends and Enemies【思维】
- Friends and Enemies HDU - 5874
- HDU 5874 Friends and Enemies(构造)
- HDU 5874-Friends and Enemies(n个结点的无三元环的图的最大边数)
- HDU 5874 Friends and Enemies
- HDU 5874 Friends and Enemies
- 2016 ICPC 大连网络赛 HDU 5874 Friends and Enemies
- HDU-5874-Friends and Enemies
- HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)
- hdu 5874 Friends and Enemies
- HDU 5874 Friends and Enemies
- hdu 5874 Friends and Enemies(思维)
- HDU 5874 Friends and Enemies 大连网络赛
- HDU-5874-Friends and Enemies-构造+找规律
- 【2016-大连赛区网络赛-G】(Friends and Enemies,hdu 5874)