hdu 5747 Aaronson
T : 1
n m: 10 2
题解:20 * 0 + 21* 1 + 22* 2 = 10
输出:3 <-- 0+1+2=3
AC 代码:
#include<stdio.h> #include<algorithm> using namespace std; int main(void) { int T,n,m; int val=0; while(scanf("%d",&T)!=EOF) { while(T--) { scanf("%d%d",&n,&m); m=min(m,31); val=n/(1<<m); while(n!=1||n!=2) { n%=(1<<m); m=m-1; val+=n/(1<<m); if(n==0)break; } printf("%d\n",val); } } return 0; }