<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; }