zoukankan      html  css  js  c++  java
  • hdu 5874

    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.InputMultiple 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)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.OutputFor 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

    很简单的一道题,当所有人构成二分图的时候,需要的颜色最多。
    附ac代码:
     1 #include <cstdio>
     2 #include <iostream>
     3 #include <cmath>
     4 #include <cstring>
     5 #include <algorithm>
     6 #define ll long long
     7 const int maxn = 1000+10;
     8 using namespace std;
     9 
    10 int main() {
    11     
    12     ll n,m;
    13     while(~scanf("%lld %lld",&n,&m))
    14     {
    15         if(((n+1)/2)*(n/2)<=m)
    16             printf("T
    ");
    17         else
    18             printf("F
    ");
    19     }
    20     
    21     return 0;
    22 }
    View Code
  • 相关阅读:
    cocoaPods 最新系统上的安装和基本使用图文笔记
    iOS cell左滑出现多个功能按钮(IOS8以后支持)
    JPA error org.hibernate.AnnotationException: No identifier specified for entity
    spring-boot Jpa配置
    Java中各种集合(字符串类)的线程安全性!!!
    kafka浅谈
    Redis 指令
    JVM监控及堆栈内存
    redis与mysql性能对比、redis缓存穿透、缓存雪崩
    分布式锁机制
  • 原文地址:https://www.cnblogs.com/zmin/p/7995071.html
Copyright © 2011-2022 走看看