[BZOJ1192][HNOI2006]鬼谷子的錢袋(數學相關)

題目描述

傳送門

題目大意:問最少用多少個不同的數,能組合出來1~m中所有的數。

題解

顯然是所有<=m的2的冪次

代碼

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int n,p;
int main()
{
    scanf("%d",&n);
    for (p=0;(1<<p)<n;++p);
    printf("%d\n",p);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章