您的位置:首页 > 其它

Friends and Enemies HDU - 5874

2017-05-14 15:08 288 查看
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)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

题意:反正我到现在还是不懂。。。大概看了题解强行解释。。他的岛上大概是分两个阵营?对每个人来说在一个阵营里的是朋友 ,不在的是敌人?

思路:反正按照我的理解。。。我一直觉得最少只要0个。。最坏是n-1个。。。。 然后按照题解来理解的话。。那就是求二分图对吧。因为只有两个阵营嘛。那我把人分成两堆,代表两个阵营,然后朋友之间连一条线。为什么是朋友之间呢。。因为朋友才可以用一块石头啊2333一条线代表一块石头嘛。那建图就建起来了,就是求一个完全二分图里面的边数。假设u,v是二分图两个点集的数量,那边数是u*v u+v是定值。。基本不等式 u=v取最大。。那如果石头大于等于这个值的话就可以了

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<map>
#include<set>
using namespace std;

//thanks to pyf ...

#define INF 0x3f3f3f3f
#define CLR(x,y) memset(x,y,sizeof(x))
#define mp(x,y) make_pair(x,y)
typedef pair<int, int> PII;
typedef long long ll;

const int N = 1e6 + 5;

int main()
{
ll m, n;
while (cin >> m >> n)
{
ll group1 = m / 2;
ll group2 = m - group1;
ll need = group1 * group2;
if (need > n)
cout << "F" << endl;
else
cout << "T" << endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: