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. 用c++写一个 “hello,world” 的 FastCGI程序

    原文:http://chriswu.me/blog/writing-hello-world-in-fcgi-with-c-plus-plus/ 上面的连接地址给出的是作者的原文地址. 另外一个作者稍微 ...

  2. Raspberry Pi 上使用WN725N连接WIFI

    系统版本 lee@Lee-RPi ~ $ uname -ar Linux Lee-RPi + # PREEMPT Thu Dec :: GMT armv6l GNU/Linux 这个版本的系统,已经集 ...

  3. ZjDroid工具介绍及脱壳详细示例

    前提条件: 1.Root手机一部 2.需要通过Xposed installer(http://dl.xposed.info/latest.apk)安装Xposed Framework; 一.ZjDro ...

  4. Bootstrap环境及屏幕适配-(一)

    一.环境搭建 1.目录结构 需要引用的文件有, jquery.js.bootstrap.min.js 和 bootstrap.min.css 文件,下面看下在线的文档Hello Word <!D ...

  5. Polipo

    polipo代理服务器简介 HTTP代理polipo的配置与使用:http://wuwei5460.blog.51cto.com/2893867/1407369/

  6. 利用 gperftools 对nginx mysql 内存管理 性能优化

    利用 gperftools 对nginx 与 mysql  进行 内存管理  性能优化 降低负载. Gperftools 是由谷歌开发.官方对gperftools 的介绍为: These tools ...

  7. soot的安安装与使用

    soot 工具是一个可以分析多种源代码的工具,可以进行插桩,最新版本可对android apk文件,进行相应的分析以往可以直接在eclipse里面在线安装. soot(A framework for  ...

  8. Activiti----hellowWorld(使用H2数据库)

    1.项目结构 2.pom <dependencies> <dependency> <groupId>junit</groupId> <artifa ...

  9. JS、html打开超链接的几种形式

    1.直接使用input在原有的标签页中直接打开一个页面,将原有标签页覆盖 在按钮中直接打开一个连接,这里不需要用到js的代码,根据HTML中的onclick属性 <input type=&quo ...

  10. runtime - associated(关联)

    category和associative作为objective-c的扩展机制的两个特性,category用来扩展类的方法,associative可以用来扩展类的属性.使用associative需要导入 ...