Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)(set容器里count函数以及加强for循环)
2016-10-02 22:58
232 查看
题目链接:http://codeforces.com/contest/722/problem/D 1 #include <bits/stdc++.h> #include <iostream> #include <queue> #include <stdio.h> #include <string.h> #include <algorithm> #include <string> #include <math.h> #include <set> #include <map> #define mod 1000000007 #define MAXN 100+10 #define INF 1000000000 #define eps 10e-6 #define ll long long using namespace std; bool cmp(int a, int b) { return a > b; } //****************************************************************************** int main(void) { //std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n; set<int>st; cin >> n; for(int i=0; i<n; i++) { int x; cin >> x; st.insert(x); } while(1) { int x=*st.rbegin(), i; for(i=x; i&&st.count(i); i/=2); //***st.count(x)查找st里i出现的次数 if(!i) { break; } st.erase(x); st.insert(i); } for(int it : st) //***类似java里面的加强for循环 { printf("%d ", it); } printf("\n"); return 0; }
相关文章推荐
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C 并查集
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array(并查集)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) [D] Destroying Array
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A B C D 水 模拟 并查集 优先队列
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- C. Destroying Array (并查集)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D. Generating Sets 贪心
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D. Generating Sets 贪心
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D. Generating Sets __ dfs+优先队列+贪心
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- B. Verse Pattern(水题)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) B. Verse Pattern 水题
- Codeforces Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) 部分题解
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)C. Destroying Array(想法题/并查集)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) E
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)F. Cyclic Cipher
- codeforces(Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) )(C,D)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A. Broken Clock 水题
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C. Destroying Array 带权并查集
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined)