描述
输入There will be T (T <= 100) cases, each case will input a n. 输出For each group of input integers you should output how many ways GuoJie can walk in one line, and with one line of output for each line in input. 样例输入
样例输出
The first lady of our lab is GuoJie, GuoJie likes walking very much.
Today GuoJie walks from the original point (0, 0), everytime he(may be she?) can go up or left or right a step.
But she can't go back the point where she have visited.
For example, if he goes up a step, she will be at (1, 0) and she never comes back the point.
Now, if she can walk n(n <= 100000) steps, can you find how many ways she can walk? the result mod 1e9 + 7.
1 2
7#include <iostream> #include<stdio.h> using namespace std; long long num[1000006]; void gon() { long long a=1; long long b=0; num[0]=1; for(int i=1;i<1000000;i++) { a=a+b; b=num[i-1]-a; num[i]=3*a+2*b; while(num[i]>=1000000007) num[i]-=1000000007; } num[0]=0; return ; } int main() { int t,n; gon(); scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",num[n]); } return 0; }