#include <iostream> #include <fstream> using namespace std; #define MAX 46 int Fibonacci[MAX]; int main() { int N, n; int cnt = 0; Fibonacci[1] = 2;Fibonacci[2] = 3; for(int i = 3; i <= 45; ++i) Fibonacci[i] = Fibonacci[i-1] + Fibonacci[i-2]; scanf("%d", &N); while(N--) { scanf("%d", &n); printf("Scenario #%d:/n%d/n/n",++cnt, Fibonacci[n]); } return 0; } //Fibnacci数列的运用: /* 证明:when n >= 2,f[n] = f[n-1] + f[n-2] 证明: 1. if a[n] = 0 => f[n] = f[n-1]; 2. if a[n] = 1 => a[n-1] = 0 => f[n] = f[n-2]; In total: f[n] = f[n-1] + f[n-2] */