BZOJ1192 鬼谷子的钱袋

题目传送门

题解

比较水的题目,只要知道用1、2、4...\(2^n\)可以组成\([1,2^{n+1})\)这个区间里的任意一个数这个结论就行了。

code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
ll m,now;
int n;
/*==================Define Area================*/
int main() {
	read(m);
	now=1;n=1;
	if(m==2) return puts("2"),0;
	while((now<<=1)<m) n++;
	printf("%d\n",n);
	return 0;
}

相关文章:

  • 2021-11-22
  • 2021-11-15
  • 2021-07-06
  • 2022-12-23
  • 2021-12-08
猜你喜欢
  • 2021-11-26
  • 2021-09-30
  • 2021-07-24
  • 2021-07-06
  • 2021-09-20
  • 2021-09-18
相关资源
相似解决方案