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 ...
随机推荐
- bootstrap中可用的图标集
- Size Balanced Tree(SBT) 模板
首先是从二叉搜索树开始,一棵二叉搜索树的定义是: 1.这是一棵二叉树: 2.令x为二叉树中某个结点上表示的值,那么其左子树上所有结点的值都要不大于x,其右子树上所有结点的值都要不小于x. 由二叉搜索树 ...
- xml 解析 python
1 综述 有很多种解析方法. (1) DOM 缺点是:1 不能解析格式不正确或者不规则xml 2据说只能解析utf-8格式,非utf-8需要转码 与SAX比较,DOM典型的缺点是比较慢,消耗更 ...
- Object.defineproperty实现数据和视图的联动 ------是不是就是 Angular 模型和视图的同步的实现方式???
参考:http://www.cnblogs.com/oceanxing/p/3938443.html https://developer.mozilla.org/zh-CN/docs/Web/Java ...
- /system改成可写
读写: mount -o remount,rw /dev/block/mtdblock0 /system 只读mount -o remount,ro /dev/block/mtdblock0 /sys ...
- fuel健康检查Heat失败的原因
service openstack-heat-engine restart chkconfig --level 2345 openstack-heat-engine on
- Git 常用命令汇总
#安装git yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel yum install -y g ...
- ffmpeg ffplay ffprobe资料整理
1. 官网地址:https://ffmpeg.org/ 官网文档地址:https://ffmpeg.org/documentation.html 官网下载地址:https://ffmpeg.org/d ...
- Linux的iptables常用配置范例(2)
iptables -F #清除所有规则 iptables -X #清除所有自定义规则 iptables -Z #各项计数归零 iptables -P INPUT DROP #将input链 ...
- [转] 用Maven搭建多模块企业级项目
转自:http://www.cnblogs.com/quanyongan/archive/2013/05/28/3103243.html 首先,前面几次学习已经学会了安装maven,如何创建maven ...