zoukankan      html  css  js  c++  java
  • bzoj 1962 硬币游戏 (猜数问题)

    【bzoj1962】模型王子

    Description

    Input

    输入数据共一行,两个整数N,K,用一个空格隔开,具体意义如题目中所述。

    Output

    输出数据共一行,为最少所需要的时间S。

    Sample Input

    5 3

    Sample Output

    5

    HINT

    对于全部的数据,1 < = K < = 100,1 < = N < = 10^5

    题解:

      https://wenku.baidu.com/view/62c94bf7ba0d4a7302763a23.html

     1 #include<cstring>
     2 #include<cmath>
     3 #include<algorithm>
     4 #include<iostream>
     5 #include<cstdio>
     6 
     7 
     8 using namespace std;
     9 inline int read()
    10 {
    11     int x=0,f=1;char ch=getchar();
    12     while(ch>'9'||ch<'0'){if (ch=='-') f=-1;ch=getchar();}
    13     while(ch<='9'&&ch>='0'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    14     return x*f;
    15 }
    16 
    17 int n,k;
    18 int f[100007][107];
    19 
    20 int main()
    21 {
    22     n=read(),k=read();
    23     for (int i=2;;i++)
    24     {
    25         f[i][1]=i/2;
    26         for (int j=2;j<=k;j++)
    27             f[i][j]=max(f[i-1][j]+f[i-2][j-2],f[i-2][j]+f[i-1][j-1])+1;
    28         if (f[i][k]>=n)
    29         {
    30             printf("%d
    ",i);
    31             return 0;
    32         }    
    33     }
    34 }
  • 相关阅读:
    两个不同于LR和jmeter的性能测试工具
    一个基于集成jenkins的测试平台
    sparkR原理
    Python 出现需要使用fPIC重新编译的问题
    eclipse中使用jython
    R中逻辑运算
    R语言的一些笔记
    Distributed R
    R语言和大数据
    Mysql command line
  • 原文地址:https://www.cnblogs.com/fengzhiyuan/p/8034920.html
Copyright © 2011-2022 走看看