zoukankan      html  css  js  c++  java
  • HDU 5874 Friends and Enemies

    Friends and Enemies

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


    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
     
     
     
     
     
     
    #include <cstdio>
    #define ll long long
    
    int main()
    {
        ll n, m;
        while(~scanf("%I64d%I64d", &n, &m)){
            printf((n/2)*(n-n/2) <= m ? "T
    " : "F
    ");
        }
        return 0;
    }
    

      

  • 相关阅读:
    Prometheus监控学习笔记之Prometheus监控简介
    GO语言学习笔记之Linux环境下安装GO语言
    Jetson tx1 安装ROS
    ssh Jetson tk1
    Jetson tk1 安装 Intel 7260 无线网卡驱动
    ubuntu 14.04 软件中心闪退解决方案
    Jetson tk1 刷机后要做的几件事
    Jetson tk1 安装 usbtoserials 驱动(重新刷机)
    usbserials
    ubuntu 14.04 安装 eclipse
  • 原文地址:https://www.cnblogs.com/inmoonlight/p/5866230.html
Copyright © 2011-2022 走看看