POJ 1013
#include"string.h"
char left[3][7],right[3][7],result[3][5];
bool isHeavy(char x )
{
int i;
for(i=0;i<3;i++)
{
switch(result[i][0])
{
case 'u':if(strchr(left[i],x)==NULL)return false;break;
case 'e':if(strchr(left[i],x)!=NULL||strchr(right[i],x)!=NULL)return false;break;
case 'd':if(strchr(right[i],x)==NULL)return false;break;
}
}
return true; //
}
bool isLight(char x )
{
int i;
for(i=0;i<3;i++)
{
switch(result[i][0])
{
case 'u':if(strchr(right[i],x)==NULL)return false;break;
case 'e':if(strchr(left[i],x)!=NULL||strchr(right[i],x)!=NULL)return false;break;
case 'd':if(strchr(left[i],x)==NULL)return false;break;
}
}
return true; //
}
int main()
{
int n;
char c;
int i;
scanf("%d",&n);
while(n>0)
{
for( i=0;i<3;i++)
scanf("%s%s%s",left[i],right[i],result[i]);
for(c='A';c<='L';c++)
{
if(isLight(c))
{
printf("%c is the counterfeit coin and it is light.\n",c);
break;
}
if(isHeavy(c))
{
printf("%c is the counterfeit coin and it is heavy.\n",c);
break;
}
}
n--;
}
return 0;
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com
POJ 1013的更多相关文章
- Poj 1013 Counterfeit Dollar / OpenJudge 1013(2692) 假币问题
1.链接地址: http://poj.org/problem?id=1013 http://bailian.openjudge.cn/practice/2692 http://bailian.open ...
- 模拟,找次品硬币,Counterfeit Dollar(POJ 1013)
题目链接:http://poj.org/problem?id=1013 解题报告: 1.由于次品的重量不清楚,用time['L'+1]来记录各个字母被怀疑的次数.为负数则轻,为正数则重. 2.用zer ...
- POJ 1013 Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36206 Accepted: 11 ...
- POJ 1013 Counterfeit Dollar 集合上的位运算
Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...
- POJ 1013 小水题 暴力模拟
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35774 Accepted: 11 ...
- poj 1013(uva 608) Counterfeit Dollar
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #in ...
- POJ 1013:Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42028 Accepted: 13 ...
- 思维+模拟--POJ 1013 Counterfeit Dollar
Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver d ...
- POJ1013 称硬币
题目链接:http://poj.org/problem?id=1013 题目大意 有12枚硬币.其中有11枚真币和1枚假币.假币和真币重量不同,但不知道假币比真币轻还是重.现在,用一架天平称了这些币三 ...
随机推荐
- 2018.09.16 bzoj1086: [SCOI2005]王室联邦(贪心)
传送门 就是给树分块. 对于一个节点. 如果它的几棵子树加起来超过了下限,就把它们分成一块. 这样每次可能会剩下几个节点. 把它们都加入栈中最顶上那一块就行了. 代码: #include<bit ...
- hdu-1150(二分图+匈牙利算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 思路:题目中给出两个机器A,B:给出k个任务,每个任务可以由A的x状态或者B的y状态来完成. 完 ...
- Excel获得焦点变色
1. 点击 Sheet 2. 右键菜单 查看代码 3. 复制如下代码 Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Ran ...
- SGU 169 Numbers (找规律)
题意:中文题,直接忽略... 析:先说说我的思路,我一看这个题第一感觉就是要找规律,要是挨着算,猴年马月都跑不完,更何况时间限制是0.25s,怎么找规律呢,我算了一下前10位,分别是8,1,1,3,1 ...
- VHDL 中的数据转换函数
2013年8月5日 ieee.std_logic_arith.all SXT:是对std_logic_vector转换成std_logic_vector数据类型,并进行符号扩展. <slv_sx ...
- python-optparse模块给脚本增加参数选项
import optparse parser = optparse.OptionParser('[-] Usage %prog '+ '-H <RHOST[s]> -l [-p -F ]' ...
- (KMP灵活运用 利用Next数组 )Theme Section -- hdu -- 4763
http://acm.hdu.edu.cn/showproblem.php?pid=4763 Theme Section Time Limit: 2000/1000 MS (Java/Others) ...
- Business Cards
Problem Description Running a paper shop is not an easy job, especially with harsh customers. Today ...
- Hdu1728 逃离迷宫 2017-01-17 10:56 81人阅读 评论(0) 收藏
逃离迷宫 Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submissi ...
- HashMap底层实现原理以及HashMap与HashTable区别以及HashMap与HashSet区别
①HashMap的工作原理 HashMap基于hashing原理,我们通过put()和get()方法储存和获取对象.当我们将键值对传递给put()方法时,它调用键对象的hashCode()方法来计算h ...