题意:

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);
}

 

相关文章:

  • 2021-06-24
  • 2021-09-18
  • 2021-11-15
  • 2021-07-06
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2021-09-08
  • 2021-10-16
  • 2021-10-07
  • 2021-10-17
  • 2022-03-02
相关资源
相似解决方案