hdu 1482
来源:互联网 发布:手机淘宝卖家中心 编辑:程序博客网 时间:2024/06/10 09:35
http://acm.hdu.edu.cn/showproblem.php?pid=1482
首先要明白,给出的数据一定能找出假币。even表明两边都是真币。真要不是even,那么两边出现的币里一定有假币,假币造成的轻重影响可用正负表示。所以用一个数组记录一定为真的货币,一个数组记录影响,由于每次两边的变化不同,所以要用两个数组存两边字母。最后绝对值最大的一定是假币。
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
char left[3][6],right[3][6],status[3][6];
int effect['L'+1];
bool zero['L'+1];
memset(zero,0,sizeof(zero));
memset(effect,0,sizeof(effect));
for(int i=0;i<3;i++)
cin>>left[i]>>right[i]>>status[i];//输入
for(int i=0;i<3;i++)
{
switch(status[i][0])
{
case 'u':
{
for(int j=0;j<4;j++)
{
effect[left[i][j]]++;
effect[right[i][j]]--;
}
break;
}
case 'd':
{
for(int j=0;j<4;j++)
{
effect[left[i][j]]--;
effect[right[i][j]]++;
}
break;
}
case 'e':
{
for(int j=0;j<4;j++)
{
zero[left[i][j]]=true;
zero[right[i][j]]=true;
}
break;
}
}
}//影响处理
int Max=-1; char temp;
for(int i='A';i<='L';i++)
{
if(zero[i]==true) continue;
if(fabs(effect[i])>Max) {
temp=i;
Max=fabs(effect[i]);
}
}
if(effect[temp]<0) printf("%c is the counterfeit coin and it is light.\n",temp);
else printf("%c is the counterfeit coin and it is heavy.\n",temp);
}
}
- hdu 1482
- hdu 1482
- hdu 1482 Counterfeit Dollar
- hdu 1482 Counterfeit Dollar
- HDU-1482-Counterfeit Dollar
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- 1041. Be Unique (20)
- Oracle 触发器的使用小结
- oracle利用触发器实现自增列
- erlang jcl远程调试 rabbitmq
- Oracle触发器(trigger):一般用法
- hdu 1482
- oracle触发器的类型及使用方法
- Win10 UWP开发系列:实现Master/Detail布局
- linux 下 C 编程 C版的try catch 捕捉段错误和异常处理
- UML 画用例图
- Java带进度多线程下载文件
- MYSQL错误查找
- 计数排序、桶排序和基数排序
- Logcat保存数量设置