题目链接:http://poj.org/problem?id=1013

解题报告:

1、由于次品的重量不清楚,用time['L'+1]来记录各个字母被怀疑的次数。为负数则轻,为正数则重。

2、用zero['L'+1]记录当天平结果是even时,硬币绝对是真,true;

#include <iostream>
#include <cmath> using namespace std; int main()
{
int t;
cin>>t;
while(t--)
{
char left[][],right[][],result[][]; int time['L'+]= {}; ///标记各个字母被怀疑的次数;
bool zero['L'+]= {false}; ///标记字母绝对是真币; for(int k=; k<; k++)
cin>>left[k]>>right[k]>>result[k]; for(int i=; i<; i++) ///3次判断
{
///检查天平状态
switch(result[i][])
{
case 'e':///天平平衡
{
for(int j=; left[i][j]!='\0'; j++)
{
zero[left[i][j]]=true; zero[right[i][j]]=true;
}
break;
}
case 'u':///天平右边轻些
{
for(int j=; left[i][j]!='\0'; j++)
{
time[left[i][j]]++; time[right[i][j]]--;
}
break;
}
case 'd':///天平右边重些
{
for(int j=; left[i][j]!='\0'; j++)
{
time[left[i][j]]--; time[right[i][j]]++;
}
break;
}
}
} int Max=-;///查找被怀疑程度最高的硬币
char alpha;
for(int j='A';j<='L';j++)
{
if(zero[j])
continue; if(Max<=abs(time[j]))
{
Max=abs(time[j]);
alpha=j;
}
}
cout<<alpha<<" is the counterfeit coin and it is ";
if(time[alpha]>)
cout<<"heavy.\n";
else cout<<"light.\n";
}
return ;
}

模拟,找次品硬币,Counterfeit Dollar(POJ 1013)的更多相关文章

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

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

  2. POJ 1013 Counterfeit Dollar

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

  3. POJ 1013:Counterfeit Dollar

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

  4. POJ 1013 小水题 暴力模拟

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

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

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

  6. POJ1013 Counterfeit Dollar

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

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

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

  8. poj1013.Counterfeit Dollar(枚举)

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

  9. 思维+模拟--POJ 1013 Counterfeit Dollar

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

随机推荐

  1. 转 Oracle]如何在Oracle中设置Event

    https://www.cnblogs.com/gaojian/p/7619960.html 为了调查Oracle 的故障,可以通过设置event ,来了解详细的状况.方法如下: ■ 如果使用 SPF ...

  2. SpringMVC HandlerMethodArgumentResolver自定义参数转换器

    来源: https://www.cnblogs.com/daxin/p/3296493.html 自定义Spring MVC3的参数映射和返回值映射 + fastjson首先说一下场景:在一些富客户端 ...

  3. (转)Nginx静态服务配置---详解root和alias指令

    Nginx静态服务配置---详解root和alias指令 原文:https://www.jianshu.com/p/4be0d5882ec5 静态文件 Nginx以其高性能著称,常用与做前端反向代理服 ...

  4. opensuse13.2国内源和设置命令

    ustc-osshttp://mirrors.ustc.edu.cn/opensuse/distribution/13.2/repo/oss/ustc-non-osshttp://mirrors.us ...

  5. TOJ 4523 Transportation

    Description Given N stations, you want to carry goods from station 1 to station N. Among these stati ...

  6. java使用POI进行 Excel文件解析

    package com.timevale.esign.vip.util; import java.io.File; import java.io.FileInputStream; import jav ...

  7. 1、Angular2 Component 组件

    angular2借鉴了.http://www.cnblogs.com/lewis617/p/5191007.html 导入了自己的思维方式 1.基本属性 2.*语法与template标签 3.组件的嵌 ...

  8. asp.net的几种页面传值方式

    1."~/x/xx.aspx?id=" + id string id=Request.Params["id"].ToString(); 2.Response.R ...

  9. 数组和矩阵(2)——Reshape the Matrix

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  10. Linux的find命令实例详解和mtime ctime atime

    这次解释一下三个Linux文件显示的三个时间,然后展示一下find命令的各个功能 在linux操作系统中,每个文件都有很多的时间参数,其中有三个比较主要,分别是ctime,atime,mtime mo ...