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('
');}
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);
	return 0;
}
「我不敢下苦功琢磨自己,怕终于知道自己并非珠玉;然而心中既存着一丝希冀,便又不肯甘心与瓦砾为伍。」
原文地址:https://www.cnblogs.com/Apocrypha/p/9432181.html