hdu2024递归水题

import java.util.Scanner;

public class hdu2044 {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        //坑点 
        long[] aa = new long[51];
        aa[1] = 1;
        aa[2] = 2;
        for (int i = 3; i < aa.length; i++) {
            aa[i] = aa[i-1]+aa[i-2];            
        }
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int x = b-a;
            System.out.println(aa[x]);

        }
        sc.close();
    }
}

 

posted @ 2024-05-10 14:48  XiaohuangTX  阅读(2)  评论(0编辑  收藏  举报