标签:style blog http color os io div line
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=46
用类似于快速幂的方法做,注意1的时候是0;
#include <iostream> using namespace std; int main() { int ase; int num; int res; cin>>num; while(num--) { res = 0; cin>>ase; if(ase==1) { cout<<0<<endl; continue; } while(ase!=1) { if(ase%2==1) res+=2; else res++; ase = ase/2; } cout<<res<<endl; } return 0; }
标签:style blog http color os io div line
原文地址:http://www.cnblogs.com/ltwy/p/3902402.html