Friends and Enemies
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.
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.
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.
20 100
T
这道题翻译了我很久,真的很气,题目要求是满足所有的情况,无非就是判断石头的颜色种类到底够不都,只需要考虑最多需要的石头颜色的种类即可,也就是人数分半相乘,这是个极限,小于这个数的都可以满足;
代码如下:
#include <stdio.h> int main() { int N , M; while(~scanf("%d%d",&N,&M)) { int n = N/2 , m = N - n; if(n * m <= M) printf("T\n"); else printf("F\n"); } return 0; }