BZOJ 1192: [HNOI2006]鬼谷子的钱袋 [娱乐]

题意:

n个数分组,使得小于n的每个数都能表示出来,最少几组

 


就是“最优集合”的超级弱化版.....每次+=now+1

然后一个貌似科学的方法是n二进制拆分

 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int n, cnt, now;
int main() {
    n=read();
    while(now < n) cnt++, now += now + 1; 
    printf("%d", cnt);
}

 

posted @ 2017-03-20 23:27  Candy?  阅读(127)  评论(0编辑  收藏  举报