http://poj.org/problem?id=1013

 #include<stdio.h>
#include<string.h>
#include<math.h>
const int INF=<<;
int main()
{
char rw[][],lw[][],vis[][];
int ans[],t;
scanf("%d",&t);
while(t--)
{
memset(ans,,sizeof(ans));
for (int i = ; i < ; i ++)
{
scanf("%s %s %s",lw[i],rw[i],vis[i]);
}
for (int i = ; i < ; i ++)
{
if(vis[i][]=='e')
{
for (int j = ; lw[i][j]!='\0'; j ++)
{
ans[lw[i][j]-'A'] = INF;
ans[rw[i][j]-'A'] = INF;
}
}
}
for (int i = ; i < ; i ++)
{ for (int j = ; lw[i][j]!='\0'; j ++)
{
if (vis[i][]=='u')
{ if(ans[lw[i][j]-'A'] != INF)
{
ans[lw[i][j]-'A']++;
}
if(ans[rw[i][j]-'A'] != INF)
{
ans[rw[i][j]-'A']--;
}
} else if (vis[i][]=='d')
{ if(ans[lw[i][j]-'A'] != INF)
{
ans[lw[i][j]-'A']--;
}
if(ans[rw[i][j]-'A'] != INF)
{
ans[rw[i][j]-'A']++;
}
}
else
break;
}
}
int max = ,pos;
for (int i = ; i <= 'L'-'A'; i ++)
{
if (ans[i]!=INF)
{
if(fabs(ans[i]) > max)
{
max = fabs(ans[i]);
pos = i;
}
}
}
if(ans[pos] <= )
printf("%c is the counterfeit coin and it is light.\n",pos+'A');
else
printf("%c is the counterfeit coin and it is heavy.\n",pos+'A');
}
return ; }

Counterfeit Dollar的更多相关文章

  1. Counterfeit Dollar -----判断12枚钱币中的一个假币

     Counterfeit Dollar Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u ...

  2. POJ 1013 Counterfeit Dollar

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36206   Accepted: 11 ...

  3. poj1013.Counterfeit Dollar(枚举)

    Counterfeit Dollar Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 415  Solved: 237 Description Sally ...

  4. Counterfeit Dollar 分类: POJ 2015-06-12 15:28 19人阅读 评论(0) 收藏

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 41559   Accepted: 13 ...

  5. Poj 1013 Counterfeit Dollar / OpenJudge 1013(2692) 假币问题

    1.链接地址: http://poj.org/problem?id=1013 http://bailian.openjudge.cn/practice/2692 http://bailian.open ...

  6. POJ1013 Counterfeit Dollar

    题目来源:http://poj.org/problem?id=1013 题目大意:有12枚硬币,其中有一枚假币.所有钱币的外表都一样,所有真币的重量都一样,假币的重量与真币不同,但我们不知道假币的重量 ...

  7. POJ 1013:Counterfeit Dollar

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42028   Accepted: 13 ...

  8. 【poj1013】 Counterfeit Dollar

    http://poj.org/problem?id=1013 (题目链接) 题意 12个硬币中有1个是假的,给出3次称重结果,判断哪个硬币是假币,并且判断假币是比真币中还是比真币轻. Solution ...

  9. POJ 1013 Counterfeit Dollar 集合上的位运算

    Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...

  10. D - Counterfeit Dollar(第二季水)

    Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...

随机推荐

  1. C++ Error C2662 cannot convert 'this' pointer from 'const *'

    ---恢复内容开始--- 这个错误在于一点:常量对象只能调用常量成员(函数\变量),不能调用非常量成员.另一方面,非常量对象,既可以调用常量成员,又可以调用非常量成员. class A { publi ...

  2. Python学习-算术运算符,赋值运算符和复合运算符

    算术运算符 常见的算术运算符有 : +     加法运算符 print(1 + 2); // 3 print('1' + '2'); //12 不仅可以进行2个数字的相加,还可以连接2个字符串 -   ...

  3. buf.writeUInt8()函数详解

    buf.writeUInt8(value, offset[, noAssert]) value {Number} 需要被写入到 Buffer 的字节 offset {Number} 0 <= o ...

  4. PAT 1138 Postorder Traversal

    Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and in ...

  5. 自己写一个HashMap

    package cn.aresoft; /** * HashMap原理 * * @author develp * HashMap是一种以键值对存储数据的数据结构,简单的来说是这样.内部怎么实现的呢?实 ...

  6. Maven_真的需要吗?

    1.真的需要吗? Maven 是干什么用的?这是很多同学在刚开始接触 Maven 时最大的问题.之所以会提出这个问题,是因为即使不使用 Maven 我们仍然可以进行 B/S 结构项目的开发.从表述层. ...

  7. 【Codeforces 369C】 Valera and Elections

    [链接] 我是链接,点我呀:) [题意] 给你一棵树 让你选择若干个修理点. 这些修理点被选中之后,节点i到1号节点之间的所有"坏路"都会被修好 问最少需要选择多少个点才能将所有的 ...

  8. noip模拟赛 罪犯分组

    分析:看了题后没别的思路,感觉就是dp,普通dp的话状态和方程实在是不好设计,观察数据,发现N非常小,暗示了这道题要用状压dp来做. 先枚举每个集合,再用O(n^2)的暴力看这个集合内有多少个冲突,如 ...

  9. mappingLocations、mappingDirectoryLocations与mappingJarLocations 区别 (转)

    mappingLocations.mappingDirectoryLocations与mappingJarLocations 区别 由于spring对hibernate配置文件hibernate.cf ...

  10. cogs——1786. 韩信点兵

    1786. 韩信点兵 ★★★   输入文件:HanXin.in   输出文件:HanXin.out   简单对比 时间限制:1 s   内存限制:256 MB [题目描述] 韩信是中国军事思想“谋战” ...