UVa 10474: Where is the Marble
2017-01-08 14:55
344 查看
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> using namespace std; int main() { int N, Q; int case_num = 1; while(cin >> N >> Q) { if (N == 0 && Q == 0) return 0; if(N <= 0 || N > 10000 || Q <= 0 || Q > 10000) return 1; int *marbel = new int[N + 1]; int *query = new int[Q]; for(int i = 1; i <= N; i++) { cin >> marbel[i]; if(marbel[i] < 0 || marbel[i] > 10000) return 1; } for(int j = 0; j < Q; j++) { cin >> query[j]; if(query[j] < 0 || query[j] > 10000) return 1; } sort(marbel + 1, marbel + N + 1); cout << "CASE# " << case_num << ":" << endl; for(int k = 0; k < Q; k++) { int p = lower_bound(marbel + 1, marbel + 1 + N, query[k]) - marbel; if(marbel[p] == query[k]) cout << query[k] << " found at " << p << endl; else cout << query[k] << " not found" << endl; } case_num++; delete(marbel); delete(query); if(case_num >= 65) return 0; } return 0; }
相关文章推荐
- UVa 10474 Where is the Marble? (二分查找&equal_range()的使用)
- 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?
- uva 10474 Where is the Marble?
- uva-10474 - Where is the Marble?
- UVa10474 Where is the Marble?
- UVA10474 - 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? 计数排序
- UVa 10474 - Where is the Marble?