POJ1013
来源:互联网 发布:音频后期制作软件 编辑:程序博客网 时间:2024/05/18 02:36
摘要:暴搜,测试每个或重或轻
#include <iostream>
#include <string>
using namespace std;
typedef struct weighing{
string left;
string right;
string result;
}weighing;
weighing w[3];
bool check(string coin, int weight, int i )
{
if( w[i].left.find(coin) != string::npos ){
if( weight == 1){
if(w[i].result != "up"){
return false;
}
return true;
}
if( weight == -1){
if(w[i].result != "down"){
return false;
}
return true;
}
}
if( w[i].right.find(coin) != string::npos ){
if( weight == 1){
if(w[i].result != "down"){
return false;
}
return true;
}
if( weight == -1){
if(w[i].result != "up"){
return false;
}
return true;
}
}
if( w[i].result != "even" ){
return false;
}
return true;
}
int main()
{
int n;
cin >> n;
while( n > 0 ){
for(int i=0; i<3; i++){
cin >> w[i].left >> w[i].right >> w[i].result;
}
for(int i=0; i<12; i++){
char ch = ('A'+i);
char buf[10];
sprintf(buf, "%c", ch);
string coin = buf;
int j=0;
int weight = 1;
for(j=0; j<3; j++){
if( !check(coin, weight, j) ){
break;
}
}
if( j == 3 ){
cout << coin << " is the counterfeit coin and it is heavy." << endl;
break;
}
weight = -1;
for(j=0; j<3; j++){
if( !check(coin, weight, j) ){
break;
}
}
if( j == 3 ){
cout << coin << " is the counterfeit coin and it is light." << endl;
break;
}
}
n--;
}
return 0;
}
- POJ1013
- POJ1013
- POJ1013
- POJ1013
- poj1013
- poj1013
- poj1013
- poj1013
- poj1013
- poj1013
- poj1013 模拟
- poj1013 模拟
- CounterfeitCoin POJ1013
- 瞎搞poj1013
- POJ1013解题报告
- POJ1013 Counterfeit Dollar
- poj1013(称量+hash)
- poj1013--Counterfeit Dollar
- Fireworks(FW)制作圆角矩形
- CHtmlView当前浏览器打开新窗口
- Oracle内存全面分析(6)
- 自学JAVA的心得
- Oracle内存全面分析(7)
- POJ1013
- Oracle内存全面分析(8)
- servlet生命周期
- POJ1008
- Oracle内存全面分析(9)
- Thank you,my dear friends!
- WEB开发技巧集锦
- mock Request on Controller in ASP.Net MVC ?
- Oracle内存全面分析(10)