Yuki gets a binary string “01”. Every day, the digits in the string will increase themself by 1, which means that “0” becomes “1” and “1” becomes “10”. For example, the second day Yuki owns “110”, and the third day he owns “10101”. After n days, he gets a very long string, and he wants to know how many 0 and 1 are in the string.
输入描述:
The first line contains one integer T (1 ≤ T ≤ 50), the number of test cases.
For each test case, there is only one line containing an integer n (1 ≤ n ≤ 50), which represents the day.
输出描述:
For each case, your program will output two integers, representing the number of 0 and the number of 1 in the string after n days.
示例1
输入
3
1
2
4
输出
1 1
1 2
3 5
思维题,先有一个0,一个1;一天之后,变为一个0,两个1;两天之后,变为两个0;三个1;
1的数量 0的数量
1 1
2 1
3 2
5 3
8 5
. .
. .
. .
可以看出,1和0的数量等于前两项之和;
代码如下:

#include<bits/stdc++.h>

using namespace std;

int main()
{
    long long T,n; 
    cin>>T;
    while(T--)
    {
        cin>>n;
        long long a[55];
        a[0]=1;
        a[1]=1;
        a[2]=2;
        for(int i=3;i<=n;i++)
        {
            a[i]=a[i-1]+a[i-2];
        }
        cout<<a[n-1]<<' '<<a[n]<<endl;
    }
    return 0;
 }