uva 11384 正整数序列
证明过程
代码
#include <bits/stdc++.h>
#define cl(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define sc(x) scanf("%d",&x)
using namespace std;
const int maxn=1e5+50;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
typedef long long ll;
typedef pair<int,int> PII;
ll fpow(ll n,ll k,ll p=mod){ll r=1;for(;k;k>>=1){if(k&1)r = r*n%p;n=n*n%p;}return r;}
ll inv(ll n,ll p=mod) {return fpow(n,p-2,p);}
ll fact[maxn];
void init(){fact[0]=1;rep(i,1,maxn-1) fact[i]=fact[i-1]*i%mod;}
ll C(ll a, ll b){ll ans = fact[a]; ans =ans*inv(fact[b])%mod; ans=ans*inv(fact[a-b])%mod;return ans;}
ll n;
ll f(ll n)
{
if(n==1)return 1;
return f(n/2)+1;
}
int main()
{
while(cin>>n)
{
cout<<f(n)<<endl;
}
return 0;
}