POJ 1029
来源:互联网 发布:淘宝助理尺码表制作 编辑:程序博客网 时间:2024/05/04 01:12
思路:
1 只要在等式两边的则一定是正的。 2 假coin出现的次数一定和“>”,“<”出现的次数一样多。
代码:
#include<iostream>#include<string>#include<fstream>#include<cstring>using namespace std;struct coins{int id;bool trueCoin;};int main(){int n,k;coins coinsArray[1001],temp;int max[501],min[501],record[501];// ifstream infile("test.txt");// if(!infile)// {// cout<<"Error"<<endl;// }while(cin>>n>>k){int i,count;for(i=1;i<=n;i++){coinsArray[i].id=i;coinsArray[i].trueCoin=false;} memset(max,0,sizeof(max));memset(min,0,sizeof(min));count=0;while(k>0){int z;cin>>z;for(i=0;i<2*z;i++)cin>>record[i];string inputString;cin>>inputString;if(inputString=="="){for(i=0;i<2*z;i++)coinsArray[record[i]].trueCoin=true;}else if(inputString==">"){for(i=0;i<z;i++)max[record[i]]++;for(i=z;i<2*z;i++)min[record[i]]++;count++;}else{for(i=0;i<z;i++)min[record[i]]++;for(i=z;i<2*z;i++)max[record[i]]++;count++;}k--;}for(i=1;i<=n;i++){if(max[i]!=count&&min[i]!=count)coinsArray[i].trueCoin=true;}int tag=0;for(i=1;i<=n;i++){if(coinsArray[i].trueCoin==false){tag++;temp.id=coinsArray[i].id;}}if(tag==0||tag>1)cout<<"0"<<endl;else if(tag==1)cout<<temp.id<<endl;}return 0;}
- poj 1029
- POJ 1029
- POJ 1029
- poj-1029
- Poj 1029
- poj-1029
- poj 1029
- poj 1029
- poj 1013 && poj 1029【寻找硬币】
- poj 1029 False Coin
- POJ 1029 False coin
- poj 1029 False coin
- poj 1029 False coin
- poj 1029 False coin
- POJ-1029-False coin
- POJ 1029 False coin
- False coin - POJ 1029
- POJ 1029 False coin
- WEB程序员需要掌握的十大MySQL优化技巧
- C#冒泡排序
- android Fragment demo学习
- 根据两点间的经纬度计算距离
- 成都理工大学计算机与网络科技协会CSDN高校俱乐部成立仪式成功举行
- POJ 1029
- yii快速入门教程16
- windows server 2008修改远程桌面连接数
- 车载安卓,想说爱你不容易
- yii快速入门教程6
- C++编程惯用法----代译者序、序、第0章 简介
- SNIFF原理解析
- yii快速入门教程7
- openwrt编译基本教程