【CF】【Amr and Chemistry】
来源:互联网 发布:如何做采购数据分析 编辑:程序博客网 时间:2024/05/24 15:40
#include <iostream>#include <cstring>#include <cmath>#include <queue>#include <stack>#include <list>#include <map>#include <set>#include <string>#include <cstdlib>#include <cstdio>#include <algorithm>using namespace std;int n;const int maxn = 100010;int arr[maxn];int vis[maxn];int cnt[maxn];int stp[maxn];int main(){int num;freopen("1.txt","r",stdin);while(scanf("%d",&n) != EOF){queue<pair<int,int> > q;memset(arr,0,sizeof(arr));memset(vis,0,sizeof(vis));memset(cnt,0,sizeof(cnt));memset(stp,0,sizeof(stp));for(int i=1;i<=n;i++){scanf("%d",&num);q.push(make_pair(num,0));while(!q.empty()){int x = q.front().first;int y = q.front().second;q.pop();if(x > 100003) continue;if(vis[x] == i) continue;vis[x] = i;cnt[x] ++;stp[x] += y;q.push(make_pair(x*2,y+1));q.push(make_pair(x / 2,y + 1));}}int minstp = 0x3f3f3f3f;for(int i=0;i<100010;i++){if(cnt[i] == n && stp[i] < minstp){minstp = stp[i];}}printf("%d\n",minstp);}}
0 0
- 【CF】【Amr and Chemistry】
- CF 558C Amr and Chemistry
- cf#312-C - Amr and Chemistry-枚举
- CF 558C(Amr and Chemistry-构造法)
- CF 558 C. Amr and Chemistry 暴力+二进制
- CF #312.div2 -Amr and Chemistry-暴力+位运算
- cf 558C C. Amr and Chemistry (51nod 1483)
- codeforcesC. Amr and Chemistry
- codeforces558C Amr and Chemistry
- 558C Amr and Chemistry
- C-CodeForces558C- Amr and Chemistry
- codeforces 558 C Amr and Chemistry
- Amr and Chemistry time limit per test
- Codeforces 558C Amr and Chemistry 规律
- Codeforces 558C Amr and Chemistry
- Codeforces 558C Amr and Chemistry 暴力 - -
- codeforces 558C Amr and Chemistry
- Codeforces Amr and Chemistry(数学+乱搞)
- Android - Launcher Icon Size
- javaWeb——图片验证
- mysql时间查询
- 黑马程序员-IOS基础之浅谈C语言指针
- android 视图getParent,getChildAt
- 【CF】【Amr and Chemistry】
- c#调用TeamViewer或AnyDesk实现远程控制
- IPSec VPN(一)
- IPSec VPN(二)
- android MediaRecorder 与 AudioRecord 差异
- spring 标签
- 策略模式 - 行为模式
- C++学习 C/C++之回调函数
- 第二天——命名规则和循环语句