首页 > 其他 > 详细

bzoj 1962 硬币游戏 (猜数问题)

时间:2017-12-14 03:09:15      阅读:258      评论:0      收藏:0      [点我收藏+]

【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\n",i);
31             return 0;
32         }    
33     }
34 }

 

bzoj 1962 硬币游戏 (猜数问题)

原文:http://www.cnblogs.com/fengzhiyuan/p/8034920.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!