Hust oj 2121 你猜猜(水题)
来源:互联网 发布:朝鲜奢侈生活知乎 编辑:程序博客网 时间:2024/04/30 19:49
你猜猜Time Limit: 1000 MSMemory Limit: 32768 KTotal Submit: 270(70 users)Total Accepted: 91(62 users)Rating: Special Judge: NoDescription
too high
3
too low
4
too high
2
right on
5
too low
7
too high
6
right on
Sample Output
ACM集训队不培训的闲暇时间里,Woods就会和他的GrilFriend(GF)玩一些小游戏(咳咳…不要邪恶)。GF为了考验Woods和她的默契程度,玩了个“你猜猜”的游戏,规则如下:
GF在心里想一个数,然后Woods开始猜,对于Woods每次猜的数,GF可以有三种回答:too high,too low,right on。分别表示太高了,太低了,猜对了。Woods非常了解GF,每次都很快猜对。但是GF非常好强,有的时候就是不想让Woods猜对,于是她可能会故意错误的回答。请你判断一下,GF到底有没有故意回答错误?(参见第一组样例。Woods说10,GF说太高了。Woods说3,GF说太低了。Woods说4,GF说太高了。Woods说2,GF说对了。但显然2不是正确答案。因为Woods说3的时候就已经太低了。)
多组测试数据。每组数据包含许多组猜测。每组猜测包括两行,第一行为一个数字代表Woods猜的数,第二行为GF的一个回答,只包含too high,too low,right on三种。每组数据以right on结束。
Output每组数据输出一行。如果GF没有故意回答错误,输出"GF may be honest."如果GF有故意错误回答,输出"GF is dishonest."(引号不输出)。Sample Input10
too high
3
too low
4
too high
2
right on
5
too low
7
too high
6
right on
Sample Output
GF is dishonest.GF may be honest.
读第一遍的时候没反应过来,还以为是什么难题,后来才明白,用两个数组分别存low和high,再用right和他们分别比较,如果比low小或者比high大都是错的,要注意等于也算错的,因为这个WA了一发
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;const int maxn = 105;int high[maxn];int low[maxn];char a[maxn];int main(){ int n; int cnt1 = 0,cnt2 = 0; int flag = 0; while(~scanf("%d",&n)) { getchar(); gets(a); if(strcmp(a,"too high") == 0) { high[cnt1++] = n; } if(strcmp(a,"too low") == 0) { low[cnt2++] = n; } if(strcmp(a,"right on") == 0) { for(int i=0;i<cnt1;i++) { if(n >= high[i]) { flag = 1; break; } } for(int i=0;i<cnt2;i++) { if(n <= low[i] || flag == 1) { flag = 1; break; } } if(flag == 1) printf("GF is dishonest.\n"); else printf("GF may be honest.\n"); cnt1 = 0; cnt2 = 0; flag = 0; } } return 0;}
0 0
- Hust oj 2121 你猜猜(水题)
- Hust oj 1369 Buy Computers(水题)
- Hust oj 2235 毒(水题)
- Hust oj 2125 钱多多(水题)
- Hust oj 1693 Difficult work(水题)
- Hust oj 2000 极差(水题)
- Hust oj 1720 Fibonacci Numbers(水题)
- Hust oj 1629 统计图(水题)
- Hust oj 1431 摞盘子(水题)
- Hust oj 1046 Balls Collision(水题)
- 你猜猜
- 你猜猜
- Hust oj 2084(大数)
- Hust oj 1394 XianGe的游戏I(水题)
- Hust oj 1197 Cuts the cake(水题)
- Hust oj 1384 Leyni, LOLI and Toasts(水题)
- Hust oj 2116 Maximum continuous product(水题)
- Hust oj 1673 2013新的旅程(水题)
- Java操作Excel文件以及将xls/xlsx转为csv文件
- Spark Streaming源码解读之Job动态生成和深度思考
- 最新android APP框架介绍
- Octave 线性代数 行列式 2
- 04.手把手教你 .Net EasyUI DataGrid(弹框式添加数据)
- Hust oj 2121 你猜猜(水题)
- RxJava Creating Observables(创建操作符)
- 344. Reverse String
- 可展开的列表组件 ExpandableListview
- Java动态代理
- 如何在ubantu下设置中文输入法
- 如何从socket到tomcat
- 如何在CSS中自定义鼠标样式?
- 使用编译时注解方式实现View注入(Android Studio)