CodeForces 722D Generating Sets 贪心+Set
来源:互联网 发布:怎么样做淘宝服装模特 编辑:程序博客网 时间:2024/06/05 11:40
从当前集合中选取最大的元素进行/2的操作,每次操作后如果集合中没有这个元素了就放下,继续找最大的.
如果一个元素被除到了0说明这个元素不能再减小了,则这个元素应该就是最后集合中最大的元素.
#include<bits/stdc++.h>using namespace std;set<int> S;set<int>::iterator it;int N,temp;int main(){ cin.sync_with_stdio(false); cin>>N; for (int i=1;i<=N;i++) { cin>>temp; S.insert(temp); } while (true) { it=S.end(); it--; int p=*it; while (S.find(p)!=S.end()&&p) p>>=1; if (p==0) break; S.erase(it); S.insert(p); } for (it=S.begin();it!=S.end();it++) cout<<*it<<' '; return 0;}
0 0
- CodeForces 722D Generating Sets 贪心+Set
- codeforces 722D Generating Sets (二叉树 + 贪心)
- Codeforces 722D Generating Sets【优先队列+贪心】
- codeforces 722D. Generating Sets
- Codeforces(722D)-Generating Sets
- 【Codefoces 722 D Generating Sets】+ 贪心 + map
- 【53.57%】【codeforces 722D】Generating Sets
- 【Intel Code Challenge Elimination Round (Div1 + Div2, combined) D】【贪心 暴力 SET】Generating Sets n个不同的x变
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- D. Generating Sets(贪心)
- Intel Code Challenge Elimination Round 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) D. Generating Sets 贪心
- Codeforces722D-Generating Sets(set + 二分答案)
- codeforces 520d Cubes 贪心+set
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D. Generating Sets __ dfs+优先队列+贪心
- Generating Sets
- 【codeofrces 722D】【贪心 STL维护】D. Generating Sets 【X集合的数 可以有两种方式变换Y 现在给你一个集合Y 求X 且这个X的里最大的数尽可能小】
- Codeforces 486D. Valid Sets
- CodeForces 733D Kostya the Sculptor 思维题
- 百度分享插件使用经验
- [深度学习论文笔记][Semantic Segmentation] Fully Convolutional Networks for Semantic Segmentation
- HDU-1045-二分图
- 交换机背板带宽、交换容量、包转发率和线速转发的含义
- CodeForces 722D Generating Sets 贪心+Set
- chm文档:无法打开提、示无法显示
- java学习日记_69:System类
- bzoj 3751: [NOIP2014]解方程 (数论)
- CSU 1162 Balls in the Boxes 快速幂 水
- 批量操作
- CodeForces 723D Lakes in Berland DFS
- 如何对 Android 应用进行性能分析
- 1-100