HDU 5874 - Friends ans Enemis
来源:互联网 发布:经典的迷宫生成算法 编辑:程序博客网 时间:2024/06/10 08:27
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
题意:有 m 个人和 n 个石头,他们不是敌人就是朋友,每个人有一串项链,上面有若干不同颜色的石头。两人之间若是朋友则至少有一块石头是一样颜色的,若是敌人,则不能有相同颜色的石头。
可以看成是二分图,图之间是敌人,图内是朋友,则只需要边最多。
#include <cstdio>int main(){ int m, n; while (scanf("%d%d", &m, &n) != EOF) { int sym = m/2 * (m-m/2); if (n >= sym) printf("T\n"); else printf("F\n"); } return 0;}
- HDU 5874 - Friends ans Enemis
- 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
- HDU-Friends
- Friends (HDU
- hdu 4923 Room ans Moor
- ANS
- HDU 5874 Friends and Enemies【思维】
- HDU 5874 Friends and Enemies(构造)
- hdu 5874 Friends and Enemies(思维)
- HDU 5810 Balls ans Boxes(二项分布)
- hdu 3172 Virtual Friends
- hdu 3172 Virtual Friends
- hdu 3172:Virtual Friends
- hdu 3172 Virtual Friends
- 京东抢购服务高并发实践
- 一起写RPC框架(十)RPC服务提供端二--服务的编织和注册
- 动作传感器的组成及使用方法
- C++11 并发指南四(<future> 详解一 std::promise 介绍)
- HBase学习之HBase的RowKey设计原则
- HDU 5874 - Friends ans Enemis
- 浅谈Android手写画板(个性签名)示例及遇到的一些问题
- [verilog读书笔记]8.任务和函数
- Java线程总结(四):ThreadLocal实现线程范围的共享变量
- 计算几何之凸包(三) {旋转卡壳初步}
- MFC创建线程,消息通信修改
- 手机浏览器使用html5的datepicker,页面渲染完后value不显示的问题。
- 欢迎使用CSDN-markdown编辑器
- C++11 并发指南四(<future> 详解二 std::packaged_task 介绍)