Where is the Marble? UVA
来源:互联网 发布:仓鼠用品淘宝 编辑:程序博客网 时间:2024/06/02 03:32
lower_bound(a.begin(),a.end(),x)-a.begin()
函数返回的是迭代器,减去首指针即为下标
取的是列表中大于等于x的第一个
//@auther zhou//@Number 201408070203//@start time://@finish time:/*@此处注意:*//* 测试数据*/#include<iostream>#include<cstring>#include<vector>#include<cmath>#include<algorithm>using namespace std;int main(){int num,ques;cin>>num>>ques;int count=1;while(!cin.eof()){if((!num)&(!ques)){return 0;}cout<<"CASE# "<<count++<<":"<<endl;vector<int> marble;int temp;for(int i=0;i<num;i++){cin>>temp;marble.push_back(temp);}sort(marble.begin(),marble.end());//for(int i=0;i<num;i++)//cout<<marble[i]<<" ";for(int j=0;j<ques;j++){cin>>temp;int p=lower_bound(marble.begin(),marble.end(),temp)-marble.begin();if(marble[p]==temp){cout<<temp<<" found at "<<p+1<<endl;}else{cout<<temp<<" not found"<<endl;}}cin>>num>>ques;}return 0;}
阅读全文
0 0
- UVa Where is the Marble?
- Where is the Marble? UVA
- Where is the Marble? UVA
- Where is the Marble? UVA
- UVa 10474 Where is the Marble?
- Uva 10474 Where is the Marble?
- uva 10474 Where is the Marble?
- UVA 10474 Where is the Marble?
- UVA 10474 - Where is the Marble
- uva-10474 - Where is the Marble?
- UVA-10470- Where is the Marble?
- uva 10474 - Where is the Marble?
- UVA 10474 - Where is the Marble?
- UVa 10474 - Where is the Marble?
- UVa 10474 - Where is the Marble
- UVa 10474 - Where is the Marble?
- UVA 10474 Where is the Marble?
- UVA 10474 - Where is the Marble
- 七巧板问题及 fatal error LNK1168: cannot open Debug/5.exe for writing报错
- android布局文件的命名规则
- codeforces 78C. Beaver Game
- css3动态前半部分
- 从AtCoder RC 077D: 11 中学习逆元的线性求法
- Where is the Marble? UVA
- Java关键字——final详谈
- kmp(基本操作)
- php echo 和 print的区别
- 教教你如何下载去掉水印的美拍视频
- session的使用方法及实例
- POJ3159---Candies(最短路:spfa+栈or队列)(邻接表)
- 06 在mysql使用full join
- Java 观察者模式