sdut 3251 Nias and Tug-of-War 模拟
2016-05-18 20:08
295 查看
Nias and Tug-of-War
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Nias is fond of tug-of-war. One day, he organized a tug-of-war game and invited a group of friends to take part in.Nias will divide them into two groups. The strategy is simple, sorting them into a row according to their height from short to tall, then let them say one and two alternately (i.e. one, two, one, two...). The people who
say one are the members of the red team while others are the members of the blue team.
We know that the team which has a larger sum of weight has advantages in the tug-of-war. Now give you the guys' heights and weights, please tell us which team has advantages.
输入
The first line of input contains an integer T, indicating the number of test cases.The first line of each test case contains an integer N (N is even and 6 ≤ N ≤ 100).
Each of the next N lines contains two real numbers X and Y, representing the height and weight of a friend respectively.
输出
One line for each test case. If the red team is more likely to win, output "red", if the blue team is more likely to win, output "blue". If both teams have the same weight, output "fair".
示例输入
1 6 170 55 165.3 52.5 180.2 60.3 173.3 62.3 175 57 162.2 50
示例输出
blue
提示
来源
示例程序
提交
状态
讨论
省赛水题
#pragma warning(disable:4786)//使命名长度不受限制 #pragma comment(linker, "/STACK:102400000,102400000")//手工开栈 #include <map> #include <set> #include <queue> #include <cmath> #include <stack> #include <cctype> #include <cstdio> #include <cstring> #include <stdlib.h> #include <iostream> #include <algorithm> #define rd(x) scanf("%d",&x) #define rd2(x,y) scanf("%d%d",&x,&y) #define rd3(x,y,z) scanf("%d%d%d,&x,&y,&z) #define rdl(x) scanf("%I64d,&x); #define rds(x) scanf("%s",x) #define rdc(x) scanf("%c",&x) #define ll long long int #define ull unsigned long long #define maxn 1005 #define mod 1000000007 #define INF 0x3f3f3f3f //int 最大值 #define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i) #define MT(x,i) memset(x,i,sizeof(x)) #define PI acos(-1.0) #define E exp(1) #define eps 1e-8 ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);} ll mul(ll a,ll b,ll p){ll sum=0;for(;b;a=(a+a)%p,b>>=1)if(b&1)sum=(sum+a)%p;return sum;} inline void Scan(int &x) { char c;while((c=getchar())<'0' || c>'9');x=c-'0'; while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0'; } using namespace std; struct N{ double x,y; void in(){cin>>x>>y;} bool operator <(const N &b)const{return this->x<b.x;} }my[maxn]; int main(){ int n,loop,cnt=1; scanf("%d",&loop); while(loop--){ scanf("%d",&n); for(int i=0;i<n;++i)my[i].in(); sort(my,my+n); double a=0,b=0; for(int i=0;i<n;i+=2){ a+=my[i].y; b+=my[i+1].y; } if(fabs(a-b)<eps)puts("fair"); else if(a>b)puts("red"); else puts("blue"); } return 0; }
相关文章推荐
- c++数据类型相互转
- java之架构基础-动态代理&cglib
- JS跨域问题以及采用JSONP方式解决跨域问题
- 并查集——HDOJ-1232-畅通工程
- shell简单使用(四)内置命令
- 修改安卓串口蓝牙app问题记录
- IOS-swift 动画01
- 回溯法,DFS的应用
- C++学习笔记(四)C++ 概述
- 字符串转换md5
- HDUOJ Max Sum Plus Plus Plus--1244
- commons-httpclient 3.x如何按照host单独配置连接数和超时参数
- Java中异常机制的意义
- 绿盟面试
- ProgressBar-进度条案例
- js对象与jquery之间的转换
- 三日NJU
- 深入Spring:自定义事务管理
- bzoj 3670(KMP)
- 用两个队列实现栈