Friends and Enemies HDU - 5874(思维)

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

题意:一个岛上有m个人,n种石头,两个人见面要么是朋友,要么是敌人,是朋友的要求两个人

身上的项链上至少有一个石头的颜色相同,是敌人的要求两个人的身上没有石头颜色相同。问所给的m,

n的值,能否使得任意两人见面要么是朋友,要么是敌人。

思路:将m个人分成多个部落,使得部落内部都是朋友,部落之间都是敌人,那么最坏的情况就是将m个

人分成两个部落,每个部落m/2个人,那么要满足两两见面都有关系,那么需要m/2*m/2条边,也就是至少需要

m/2*m/2种石头。

#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
int main(){
	LL n,m;
	while(~scanf("%lld%lld",&m,&n)){
		LL ans=m*m/4;
		if(ans>n) printf("F\n");
		else printf("T\n");
	}
	return 0;
} 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值