zoukankan      html  css  js  c++  java
  • bzoj 1192 鬼谷子的钱袋

    题目大意:

    用尽可能少的不同的自然数(两两不相同),这些自然数的和为m

    且这些数能表示出m及m以下的所有数,求这些自然数的个数

    思路:

    根据小学数学很容易就能看出

    这是一道小学数学题 只要排出二进制就好了

    所以我们要找到2^k次方使它大于m

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 #include<cstdlib>
     5 #include<cstring>
     6 #include<algorithm>
     7 #include<vector>
     8 #include<queue>
     9 #define inf 2139062143
    10 #define ll long long
    11 #define MAXN 10010000
    12 #define MOD
    13 using namespace std;
    14 inline int read()
    15 {
    16     int x=0,f=1;char ch=getchar();
    17     while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
    18     while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
    19     return x*f;
    20 }
    21 int main()
    22 {
    23     int n,k=2;
    24     n=read();
    25     for(int i=1;i;i++) 
    26         {if(k>n) {printf("%d",i);return 0;}k*=2;}
    27 }
    View Code
  • 相关阅读:
    C++链式队列基本操作
    C++链栈基本操作
    C++顺序栈基本操作
    C++链表基本操作
    C/C++/JAVA
    C++操作链表
    How Many Maos Does the Guanxi Worth
    Heavy Transportation
    Frogger
    Til the Cows Come Home(Dijkstra)
  • 原文地址:https://www.cnblogs.com/yyc-jack-0920/p/7921071.html
Copyright © 2011-2022 走看看