hdu 5874 构造
2016-09-10 20:12
337 查看
链接:戳这里
Friends and Enemies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
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
题意:
有n个人,m种颜色的石头,任意两个人之间的关系可以是敌人也可以是朋友,但是只能是其中一种,每个人可以用选择若干石头或者不带,要求朋友的关系是两个人之间至少有一种颜色相同的石头,敌人是不能有相同颜色的石头,注意若一个人没有携带石头则与任意的人都是敌人,现在问最坏的情况,m种颜色的石头是否能满足条件(这里的满足条件是指所有n个人之间所有的关系都可以构造出来)
思路:
反正OEIS就对了
链接
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
ll n,m;
int main(){
while(scanf("%I64d%I64d",&n,&m)!=EOF){
ll x=floor(n*n/4LL);
if(m>=x) printf("T\n");
else printf("F\n");
}
return 0;
}
Friends and Enemies
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
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
题意:
有n个人,m种颜色的石头,任意两个人之间的关系可以是敌人也可以是朋友,但是只能是其中一种,每个人可以用选择若干石头或者不带,要求朋友的关系是两个人之间至少有一种颜色相同的石头,敌人是不能有相同颜色的石头,注意若一个人没有携带石头则与任意的人都是敌人,现在问最坏的情况,m种颜色的石头是否能满足条件(这里的满足条件是指所有n个人之间所有的关系都可以构造出来)
思路:
反正OEIS就对了
链接
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
ll n,m;
int main(){
while(scanf("%I64d%I64d",&n,&m)!=EOF){
ll x=floor(n*n/4LL);
if(m>=x) printf("T\n");
else printf("F\n");
}
return 0;
}
相关文章推荐
- vs2015里给c#添加轮廓折叠功能
- hdu5869——Different GCD Subarray Query(思考+树状数组)
- Appium基于安卓的元素定位方法
- HDU2544-最短路
- python爬虫之scrapy框架(一)
- IOS 之 Quartz 2D 绘图(上)
- effective stl 第18条: 避免使用vector<bool>
- hdu5873 Football Games(数学)(Landau's Theorem )
- LeetCode 4 Median of Two Sorted Arrays
- Python标准库简介
- diy自己的linux
- 每天一个linux命令(3):du命令
- HDU5874 Friends and Enemies
- hdu5869——Different GCD Subarray Query(思考+树状数组)
- 蓝桥杯 奇怪的比赛-低碳生活大奖赛(DFS水)
- 树和二叉树
- 利用协方差矩阵特征向量创建坐标系
- Hive 2.1 安装
- Java 版本6下载大全
- 2016 ACM/ICPC Asia Regional Dalian Online HDU 5877 Weak Pair treap + dfs序