题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1192
大水题,把m分成二的幂次方和。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int main(){ 6 int m; 7 scanf("%d",&m); 8 int sum=1,ans=0; 9 while(1){ 10 ans++; 11 sum<<=1; 12 if(m<sum){ 13 printf("%d\n",ans); 14 return 0; 15 } 16 } 17 }
时间: 2024-10-12 18:57:12