poj 1013(uva 608) Counterfeit Dollar
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std; #define FOR(i,s,t) for (int i = s; i < t; ++i)
#define MEM(s,v) memset(s, v, sizeof(s)) #define EPS 1e-8
#define _N 15
#define _M 105
#define PI acos(-1.0) int even[], light[], heavy[];
char l[_N], r[_N], b[_N]; void set_union(int *a, char *b)
{
FOR (i, , strlen(b)) { a[b[i] - 'A'] += ; }
} int main()
{
int n; scanf("%d", &n); while (n--) {
MEM (even, ); MEM (light, ); MEM (heavy, );
FOR (i, , ) {
scanf("%s%s%s", l, r, b);
if (b[] == 'e') {
set_union(even, l);
set_union(even, r);
} else if (b[] == 'u') {
set_union(heavy, l);
set_union(light, r);
} else {
set_union(light, l);
set_union(heavy, r);
}
}
int _l[], _h[];
FOR (i, , ) {
_l[i] = light[i] * (!even[i] && light[i]);
_h[i] = heavy[i] * (!even[i] && heavy[i]);
}
int max_c = , max_n = , _t = ;
FOR (i, , ) if (_l[i] > max_n) {
max_c = i; max_n = _l[i]; _t = -;
}
FOR (i, , ) if (_h[i] > max_n) {
max_c = i; max_n = _h[i]; _t = ;
}
printf("%c is the counterfeit coin and it is %s.\n", max_c + 'A', _t == - ? "light" : "heavy");
}
return ;
}
poj 1013(uva 608) Counterfeit Dollar的更多相关文章
- Poj 1013 Counterfeit Dollar / OpenJudge 1013(2692) 假币问题
1.链接地址: http://poj.org/problem?id=1013 http://bailian.openjudge.cn/practice/2692 http://bailian.open ...
- POJ 1013 Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36206 Accepted: 11 ...
- POJ 1013:Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42028 Accepted: 13 ...
- Counterfeit Dollar 分类: POJ 2015-06-12 15:28 19人阅读 评论(0) 收藏
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41559 Accepted: 13 ...
- POJ1013 Counterfeit Dollar
题目来源:http://poj.org/problem?id=1013 题目大意:有12枚硬币,其中有一枚假币.所有钱币的外表都一样,所有真币的重量都一样,假币的重量与真币不同,但我们不知道假币的重量 ...
- Counterfeit Dollar -----判断12枚钱币中的一个假币
Counterfeit Dollar Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u ...
- poj1013.Counterfeit Dollar(枚举)
Counterfeit Dollar Time Limit: 1 Sec Memory Limit: 64 MB Submit: 415 Solved: 237 Description Sally ...
- POJ 1013 小水题 暴力模拟
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35774 Accepted: 11 ...
- POJ 3525/UVA 1396 Most Distant Point from the Sea(二分+半平面交)
Description The main land of Japan called Honshu is an island surrounded by the sea. In such an isla ...
随机推荐
- PAT (Advanced Level) 1063. Set Similarity (25)
读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...
- 配置 php-fpm 监听的socket
一般现在我们配置的PHP的web环境,如LNMP(linux+Nginx+Mysql+PHP), 这里linux可能是centos, ubuntu..., 数据库可能是mysql, postgresq ...
- wget获取https资源
使用wget获取 https资源,缺省命令下是要使用证书,如果还未安装证书,可以选择忽略. 例如没有github.com的证书,执行如下命令 mkdir -p model cd model wget ...
- swift之向ftp服务器传文件
在 mac 上如何使用 xcode, swift 语言开发一个向 ftp 服务器上传文件的工具? 使用的是第三方库 Rebekka,下载地址为:https://github.com/Constanti ...
- ACM录 之 常识和错误。
接下来说说一些ACM里面的常识和错误...(可能会比较乱) —— 首先ACM里面的代码都是要提交上去,然后让计算机自动判题的,所以...千万不要把 system("pause"); ...
- FM收音机 RDS的强大功能
FM收音机 RDS的强大功能 分类: MTK2011-04-26 16:06 14889人阅读 评论(6) 收藏 举报 交通公告体育音乐娱乐教育 前言 随着发展,会有越来越多的电台具有RDS广播功能, ...
- HDU 2498 Digits
水题.题目这样定义的,另f(x)为x有几位,x[i]=f(x[i-1]); 求最小的i使得x[i]==x[i-1] #include<cstdio> #include<cstring ...
- 第三方app抽奖发送微信红包
1.控制器方法: private string SendRedPackge(string OpenId, int Amount, string LuckyCode) { Models.PayWeiXi ...
- Xcode8 去除系统日志输出
Edit Scheme-> Run -> Arguments, 在Environment Variables里边添加 OS_ACTIVITY_MODE = disable
- SVN参考命令
SVN 命令参考(svn command reference) 用法: svn <subcommand> [options] [args]Subversion 命令行客户端,版本 1.6. ...