import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int num = scanner.nextInt(); for(int i=0;i<num;i++) { String x = scanner.next(); long[] temp = new long[x.length()]; if(x.length()==1) { System.out.println(1); continue; } if(x.length()==2) { System.out.println(2); continue; } temp[0] = 1; temp[1] = 2; for(int j=2;j<x.length();j++) { temp[j] = temp[j-1] + temp[j-2]; } System.out.println(temp[x.length()-1]); } scanner.close(); } } |
Double click to view unformatted code.