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. PAT 天梯赛 L1-009 N个数求和

    模拟题 题目链接 题解 每次将两个分数进行相加,到最后再将结果化成带分数.主要考察的最大公约数与最小公倍数. 代码如下: #include<cstdio> #include<cstd ...

  2. CSS的三种手段让元素脱离标准本文档流——浮动、绝对定位、固定定位

    1.浮动 浮动是CSS中用到的最多的一个选项,他有三个性质.关于浮动我们要强调一点,永远不是一个东西单独浮动,浮动都是一起浮动,要浮动,大家都浮动. 1.1 浮动元素脱离标准文档流 1.1.1 大概描 ...

  3. 浅谈Linux集群

      集群听起来好像就是一个很高端很的技术,其实不是的,那么集群其实就是一堆计算机的集合,给用户提供同一个服务的一组计算机,就称之为集群,对于用户而言好像就是一台计算机提供的服务,集群主要分为三大类, ...

  4. MOS管常识

    http://anlx27.iteye.com/blog/1583089 学过模拟电路,但都忘得差不多了.重新学习MOS管相关知识,大多数是整理得来并非原创.如有错误还请多多指点! 先上一张图 一. ...

  5. [Asp.Net Core轻量级Aop解决方案]AspectCore Project 介绍

    AspectCore Project 介绍 什么是AspectCore Project ? AspectCore Project 是适用于Asp.Net Core 平台的轻量级 Aop(Aspect- ...

  6. Cordova3+sencha touch2.x 环境搭建

    1.安装 nodejs 2.安装 cordova: npm install -g cordova 3.创建一个工程: cordova create MyApp com.example.MyApp My ...

  7. Servlet中文乱码处理

                                                       }                             }                   ...

  8. Bash中的变量

    Bash中的变量1.用户定义的变量变量的定义  用户定义的变量有字母数字及下划线组成,并且变量名的第一个字符不能为数字.            与其它UNIX名字一样,变量名是大小写敏感的. 对于变量 ...

  9. 10天学会phpWeChat——第九天:数据库增、删、改、查(CRUD)操作

    数据库的操作(CRUD)是一个现代化计算机软件的核心,尤其针对web应用软件.虽然在前面的几讲里,我们针对数据库操作大致有了一些了解,但今天我们需要再次强化下. 除了新瓶装老酒,我们今天还引入一个新的 ...

  10. STM32中的位带(bit-band)操作(转)

    源:STM32中的位带(bit-band)操作 支持了位带操作后,可以使用普通的加载/存储指令来对单一的比特进行读写.在 CM3 中,有两个区中实现了位带.其中一个是 SRAM 区的最低 1MB 范围 ...