BZOJ1192 鬼谷子的钱袋

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;
}
posted @ 2018-08-06 19:42  Apocrypha  阅读(185)  评论(0编辑  收藏  举报