题目链接: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. Vue.js插槽slot和作用域插槽slot-scope学习小结

    一般来说,在Vue项目中使用父子组建时,都是把通用的HTML结构提取出来写成一个子组件,需要动态展示的数据用过prop属性传递,不过有时候我们可能想给子组件传递一个HTML代码,这个时候用prop不太 ...

  2. 转 UTL_FILE Throws ORA-29284 Or ORA-29283 When Attempting To READ File

    APPLIES TO: PL/SQL - Version 9.2.0.8 and laterInformation in this document applies to any platform.* ...

  3. Percona Mysql备份

    介绍 Percona是唯一一款开源.免费的mysql热备份工具,实现了对InnoDB数据库的非阻塞式的备份.有如下优势:1.完整.快速.可靠的备份2.备份期间不打断事务执行(innodb引擎)3.备份 ...

  4. How to install local .deb packages

    如何安装本地的.deb包 usually I do dpkg -i <deb file>, it'll fail saying it needs dependencies. After t ...

  5. TOJ 4289 Unrequited Love

    Description There are n single boys and m single girls. Each of them may love none, one or several o ...

  6. CTPN_论文阅读总结

    论文全名:Detecting Text in Natural Image with Connectionist Text Proposal Network 1.摘要 (1)本文提出新型网络CTPN,用 ...

  7. 详解 UWP (通用 Windows 平台) 中的两种 HttpClient API

    UWP (通用 Windows 平台) 应用开发者在构建通过 HTTP 与 Web 服务或服务器断点交互的应用时,有多种 API 可以选择.要在一个托管 UWP 应用中实现 HTTP 客户端角色,最常 ...

  8. JS数组遍历方法

    常用数组遍历方法: 1.原始for循环 var a = [1,2,3]; for(var i=0;i<a.length;i++){ console.log(a[i]); //结果依次为1,2,3 ...

  9. 解决python3缺少zlib的问题

    解决python3缺少zlib的问题 Table of Contents 1. 安装zlib 2. 重新编译安装python 3. 补充说明 在使用python3运行spark时,报缺少zlib的错误 ...

  10. Cannot execute request on any known server

    1.com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: c ...