HDU 5747 BestCoder Round #84 Aaronson (模拟)
来源:互联网 发布:淘宝客服接待流程 编辑:程序博客网 时间:2024/04/30 22:09
Aaronson
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 346 Accepted Submission(s): 210
Problem Description
Recently, Peter saw the equationx0+2x1+4x2+...+2mxm=n . He wants to find a solution (x0,x1,x2,...,xm) in such a manner that ∑i=0mxi is minimum and every xi (0≤i≤m ) is non-negative.
Input
There are multiple test cases. The first line of input contains an integerT (1≤T≤105) , indicating the number of test cases. For each test case:
The first contains two integersn and m (0≤n,m≤109) .
The first contains two integers
Output
For each test case, output the minimum value of∑i=0mxi .
Sample Input
101 23 25 210 210 310 413 520 411 1112 3
Sample Output
1223223232
Source
BestCoder Round #84
Recommend
wange2014 | We have carefully selected several similar problems for you: 5751 5750 5749 5748 5746
题解:模拟一下就好了。。。
AC代码:
//#include<bits/stdc++.h>#include<iostream>#include<stdio.h>#include<cstring>#include<algorithm>using namespace std;int main(){int t;scanf("%d",&t);while(t--){int n,m;scanf("%d%d",&n,&m);int ans=0;int d =1 <<(min(m,30)); while(n) { ans+=n/d; n-=n/d*d; d/=2;}printf("%d\n",ans);} return 0;}
1 0
- HDU 5747 BestCoder Round #84 Aaronson (模拟)
- hdu 5747 Aaronson (BestCoder Round #84 1001)
- BestCoder Round #84 1001 hdu 5747 模拟
- 【HDOJ】【BestCoder Round #84】1001 Aaronson
- BestCoder Round #841001Aaronson
- hdu 5747 Aaronson(贪心)
- HDU 5747 Aaronson(贪心)
- HDU OJ 5747(Aaronson)
- HDU 5777 BestCoder Round #85 domino (多米诺骨牌模拟)
- Bestcoder-Aaronson
- 【HDU5747 BestCoder Round 84A】【贪心 细节】Aaronson m范围最少数量2的幂凑成n
- HDU 5747 Aaronson (lower_bound函数)
- 【HDU】5747 - Aaronson(位运算 & 贪心)
- HDU 5747 Aaronson 贪心
- hdu 5747 Aaronson【贪心】
- HDU 5747 Aaronson
- hdu 5747Aaronson(暴力)
- HDU 5747 Aaronson
- Win7 Git bash 出现Permission denied (publickey)错误
- Android应用程序获取system权限
- sizeof
- 【Android】子Fragment获取父Fragment
- 显示软键盘时,键盘没有自动弹出
- HDU 5747 BestCoder Round #84 Aaronson (模拟)
- java提高篇之关键字final
- Mini Project #8 - RiceRocks (Asteroids)
- 欢迎使用CSDN-markdown编辑器
- Android开发代号和对应API等级
- Git回退服务器版本及receive.denyDeleteCurrent配置
- 2016 北邮暑期训练3-C题(CodeForces 699BOne Bomb)白痴题
- 精简系统的几个网站
- 欢迎使用CSDN-markdown编辑器