HDU.2516 取石子游戏 (博弈论 斐波那契博弈) 题意分析 简单的斐波那契博弈 博弈论快速入门 代码总览 #include <bits/stdc++.h> #define nmax 51 using namespace std; int main() { int fib[nmax]; fib[1] = fib[2] = 1; for(int i = 3;i<nmax;++i){ fib[i] = fib[i-1] + fib[i-2]; } int n; while(scanf(&…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2018 母牛的故事 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 104893    Accepted Submission(s): 51449 Problem Description 有一头母牛,它每年年初生一头小母牛.每头小母牛从第四个年…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2018 思路分析: 问题分析:这道题的递推关系非常类似斐波那契数列,由题意不难得到以下函数递推式: 对于上述的递推函数,最简单的做法是编写一个递归的函数来实现.实际上,本题的递推函数是可以用一个递推过程的函数来实现的,即不需要用递归函数来实现.用递推函数效率(计算的时间更少,使用的空间更小)会更高.不过,递归函数也是常用的,这里是用递归函数实现计算过程. 代码如下: #include <iostrea…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Problem Description Mr. Frog has n sticks, whose lengths are 1,2, 3⋯n respectively. Wallice is a bad man, so he does not want Mr. Frog to form a triangle with three of the sticks here. He decides t…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1715 大菲波数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22523    Accepted Submission(s): 8096 Problem Description Fibonacci数列,定义如下:f(1)=f(2)=1f(…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2044 题目分析:其实仔细读题就会发现其中的规律, 其中:这是一个典型的斐波那契数列. 代码如下: #include <iostream> using namespace std; int t, a, b; long long num[50]; long long dp(int n) { num[1] = 1; num[2] = 2; if (n > 2) for (int i = 3; i…
取石子游戏 Time Limit: 2000/1000 MS(Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2101 Accepted Submission(s): 1205 Problem Description 1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍.取完者胜.先取者负输出"Secondwin".先取者…
题目 //每次for循环的时候总是会忘记最后一段,真是白痴.... //连续的he的个数 种数 //0 1 //1 1 //2 2 //3 3 //4 5 //5 8 //…… …… //斐波纳契数列 //不连续的就用相乘(组合数)好了 #include<iostream> #include<algorithm> #include<string> #include <stdio.h> #include <string.h> #include &l…
KK's Steel 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/J Description Our lovely KK has a difficult mathematical problem:he has a meters steel,he will cut it into steels as many as possible,and he doesn't want any two of them be the sam…
题意:1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍. 取完者胜,先取者负输出"Second win",先取者胜输出"First win". 思路:很明显这是一个斐波那契博弈,当且仅当 n 为斐波那契数时先手必败 代码: #include <iostream> using namespace std; int main() { int n; ]; f[]=; f[]=; ;i<;i…