bzoj-1192 [HNOI2006]鬼谷子的钱袋(水题)

题目链接:

[HNOI2006]鬼谷子的钱袋

Time Limit: 10 Sec  Memory Limit: 162 MB

Description

鬼谷子非常聪明,正因为这样,他非常繁忙,经常有各诸侯车的特派员前来向他咨询时政。有一天,他在咸阳游历的时候,朋友告诉他在咸阳最大的拍卖行(聚宝商行)将要举行一场拍卖会,其中有一件宝物引起了他极大的兴趣,那就是无字天书。但是,他的行程安排得很满,他他已经买好了去邯郸的长途马车标,不巧的是出发时间是在拍卖会快要结束的时候。于是,他决定事先做好准备,将自己的金币数好并用一个个的小钱袋装好,以便在他现有金币的支付能力下,任何数目的金币他都能用这些封闭好的小钱的组合来付账。鬼谷子也是一个非常节俭的人,他想方设法使自己在满足上述要求的前提下,所用的钱袋数最少,并且不有两个钱袋装有相同的大于1的金币数。假设他有m个金币,你能猜到他会用多少个钱袋,并且每个钱袋装多少个金币吗?

Input

包含一个整数,表示鬼谷子现有的总的金币数目m。其中,1≤m ≤1000000000。

Output

只有一个整数h,表示所用钱袋个数

Sample Input

3

Sample Output

2
 
题意:
 
思路:
 
水题,不说了;
 
AC代码:
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
    char CH; bool F=false;
    for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
    for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
    F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
    if(!p) { puts("0"); return; }
    while(p) stk[++ tp] = p%10, p/=10;
    while(tp) putchar(stk[tp--] + '0');
    putchar('\n');
}

const LL mod=1e8;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=(1<<12)+10;
const int maxn=1005;

int m;
int main()
{
    while(cin>>m)
    {
        LL w=1;
        for(int  i=1; ;i++)
        {
            if(w>m){printf("%d\n",i-1);break;}
            else w*=2;
        }
    }

        return 0;
}

 

 
posted @ 2016-06-23 11:44  LittlePointer  阅读(226)  评论(0编辑  收藏  举报