hdu_2044_一只小蜜蜂...(递推专题)
2014-12-14 16:48
411 查看
<a target=_blank href="http://acm.hdu.edu.cn/showproblem.php?pid=2044">http://acm.hdu.edu.cn/showproblem.php?pid=2044</a>
/*从1到3 和 从2到3的方法不同*/ #include <iostream> using namespace std; long long a[51]; //打表 void fac() { a[1] = 1; a[2] = 2; long long a1 = 1; long long a2 = 2; for(int i = 3;i < 50;i++) { a[i] = a1 + a2; a1 = a2; a2 = a[i]; } } long long f(int x,int y) { int result = y - x; return a[result]; } int main(int argc, char *argv[]) { fac(); int s; cin >> s; while(s--) { int x,y; cin >> x >> y; if(x >= y) { cout << 0 << endl; continue; } if(x % 2 != 0) { cout << f(1,y-x+1) << endl; } else { cout << f(2,y-x+2) << endl; } } return 0; }
相关文章推荐
- hdu-2044一只小蜜蜂-递推
- 一只小蜜蜂... 【hdu-2044】【递推】
- HDU 2044 一只小蜜蜂... (递推)
- HDU 2044 一只小蜜蜂...(递推,Fibonacci)
- HDU 2044 一只小蜜蜂...(DP递推)
- HDU 2044 一只小蜜蜂... (递推)
- hdu 2044一只小蜜蜂...(斐波那契数列)递推
- HDU 2044 一只小蜜蜂... (递推)
- HDU 2044 一只小蜜蜂…【递推】
- HDU2044 一只小蜜蜂... 动态规划入门-递推
- HDU-#2044-2050 递推求解专题
- 递推专题(一)HDU2044——2050
- HDOJ(HDU).2044-2049 递推专题
- hdu 2044 一只小蜜蜂...(很简单的递推)
- hdu 2044-2050 递推求解专题练习
- hdu 2044 一只小蜜蜂... (递推)
- HDU 2044 一只小蜜蜂... 递推
- HDU - 2044 一只小蜜蜂...
- DP Problem J:一只小蜜蜂(HDU 2044)
- Hdu 2044 一只小蜜蜂 简单DP