Friends and Enemies

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 171    Accepted Submission(s): 100

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

 
最后竟成了找规律。。
1 0
2 1
3 2
4 4
5 6
6 9
7 12
8 16
9 20
10 25
11 30
12 36
13 42
......
 //2016.9.10
#include <iostream>
#include <cstdio> using namespace std; long long fun(int m)
{
long long ans;
ans = (m/)*(m/);
if(m%)ans += (m/);
return ans;
} int main()
{
long long n, m, res;
while(scanf("%lld%lld", &m, &n)!=EOF)
{
res = fun(m);
if(n>=res)
printf("T\n");
else printf("F\n");
} return ;
}

HDU5874的更多相关文章

  1. HDU5874:Friends and Enemies

    题目链接: Friends and Enemies 分析: 是一道想法题,我们假设x个人互相敌对,然后有y个人与这x个人都是朋友,而这y个人互相敌对. 则有 x+y=m x*y<=n 举个例子: ...

随机推荐

  1. HDU 3255 Farming

    矩形面积并变形,一层一层的算体积 #include<cstdio> #include<cstring> #include<cmath> #include<ma ...

  2. USACO Section 1.1 Greedy Gift Givers 解题报告

    题目 问题描述 有若干个朋友,朋友之间可以选择互相赠送一些有价值的礼物.一个人可以选择将一部分钱分给若干个朋友,例如某人送给其他两个人钱,总共赠送3元,两个人平均分,原本应该是每人1.5元,但是只能取 ...

  3. 转发:Xcode插件

    古人云“工欲善其事必先利其器”,打造一个强大的开发环境,是立即提升自身战斗力的绝佳途径!以下是搜集的一些有力的XCode插件.   1.全能搜索家CodePilot 2.0 你要找的是文件?是文件夹? ...

  4. myEclipse 8.5下SVN环境的搭建

    myEclipse 8.5下SVN环境的搭建 在应用myEclips 8.5做项目时,svn会成为团队项目的一个非常好的工具,苦苦在网上寻求了一下午,终于整合好了这个环境,在这里简单介绍下,希望能为刚 ...

  5. CentOS7 开源跳板机(堡垒机) Jumpserver

    开源跳板机(堡垒机)Jumpserver 环境 CentOS 7   x64       关闭 selinux  firewalld jumpserver: 172.24.0.14 testserve ...

  6. 单片机裸机下写一个自己的shell调试器

    该文章是针对于串口通讯过程中快速定义命令而写的,算是我自己的一个通用化的平台,专门用来进行串口调试用,莫要取笑 要处理串口数据首先是要对单片机的串口中断进行处理,我的方法是正确的命令必须要在命令的结尾 ...

  7. Spring自学教程-声明式事务处理(六)

    Spring事务处理分两种: 一.编程式事务:在程序中控制事务开始,执行和提交: 1.1 使用TransactionTemplate, 使用回调函数执行事务,不需要显示开始事务,不需要显示提交事务,但 ...

  8. 分治算法(Divide-and-Conquer)和Google的云计算

    1.云计算:涉及到存储.计算.资源的调度和权限的管理等   2.分治算法的原理:           讲一个复杂的问题,分成若干个简单的子问题进行解决,然后对子问题的记过进行合并,得到原有问题的解   ...

  9. Oracle物化视图的用法与总结

    物化视图(material view)是什么? 物化视图是包括一个查询结果的数据库对象,它是远程数据的的本地副本,或者用来生成基于数据表求和的汇总表. 物化视图存储基于远程表的数据,也可以称为快照(类 ...

  10. linux之scp

    传输文件夹 scp -r -P 目标端口号 文件夹名 目标用户名@目标服务器地址:目标存放地址 传输文件夹 scp -P 目标端口号 文件名 目标用户名@目标服务器地址:目标存放地址