2016 ACM/ICPC Asia Regional Dalian Online Friends and Enemies
2016-09-10 20:51
609 查看
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5874
Friends and Enemies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 88 Accepted Submission(s): 50
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
Sample Input
20 100
Sample Output
T
Source
2016 ACM/ICPC Asia Regional Dalian Online
下面是AC代码:
Friends and Enemies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 88 Accepted Submission(s): 50
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
下面是AC代码:
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<stack> #include<queue> #include<set> using namespace std; int main() { long long int m,n; while(~scanf("%I64d%I64d",&m,&n)) { if(n>=(m*m)/4) { printf("T\n"); } else { printf("F\n"); } } return 0; }
相关文章推荐
- HDU 5874 Friends and Enemies(二分图思想)——2016 ACM/ICPC Asia Regional Dalian Online
- HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)
- HDU 5874 2016 ACM/ICPC Asia Regional Dalian Online 1007 Friends and Enemies
- HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)
- HDU 5874 2016 ACM/ICPC Asia Regional Dalian Online 1007 Friends and Enemies
- 2016 ACM/ICPC Dalian Online-1007 Friends and Enemies
- 2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873
- 2016 ACM/ICPC Asia Regional Dalian Online 1010 Weak Pair dfs序+分块
- 2016 ACM/ICPC Asia Regional Dalian Online
- [Contests]2016 ACM/ICPC Asia Regional Dalian Online(1006/7/8/9)
- 补图+BFS( 邻接链表 )——HDU 5876 ( 2016 ACM/ICPC Asia Regional Dalian Online 1009 )
- 2016 ACM/ICPC Asia Regional Dalian Online 1008 Function 二分+RMQ
- 2016 ACM/ICPC Asia Regional Dalian Online 1007
- HDU 5876 Sparse Graph(bfs求解补图中的单源最短路)——2016 ACM/ICPC Asia Regional Dalian Online
- 2016 ACM/ICPC Asia Regional Dalian Online 1006 football game 1007 hdu 5873 hdu 5874
- 2016 ACM/ICPC Asia Regional Dalian Online Football Games
- HDU 5876 Sparse Graph 【补图最短路 BFS】(2016 ACM/ICPC Asia Regional Dalian Online)
- HDU 5875 Function(二分区间+RMQ)——2016 ACM/ICPC Asia Regional Dalian Online
- hdu 5900 QSC and Master 区间dp(2016 ACM/ICPC Asia Regional Shenyang Online)
- HDU 5875 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)