My math can't be that hard to push.Time limit (normal/java): ms/9000 MS Run memory limit: 65536 KByte
Total Submissions: 49 Tested by: 24
Describe
No problem, how to do it ~
All right, Baidu goes together.
So this problem turned out, only for happy.
Xiao Ming likes to play chess, one day he idle to bored, black and white pieces into a long observation, found black mixed together good ugly ah.
Immediately thought, black and sunspots are not adjacent, placed into a strip, how many kinds of possible?!
Input
Multiple sets of test data (approx. 1w Group)
First line, total number of pieces N (0<n<=1000000)
Output
Only one row, to ensure that sunspots and sunspots are not adjacent, the number of pieces placed in all cases after the result of 1000000007 modulo.
Sample input
1
100
Sample output
2
470199269
Analysis: Set A[i] for the total number of pieces of I, b[i] for the total number of white ending, c[i] for the total number of black chess. Then there is a[i]=b[i]+c[i],b[i]=a[i-1],c[i]=b[i-1];
#include <cstdio>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>#include<queue>#include<cstdlib>#include<stack>#include<vector>#include<Set>#include<map>#defineLL Long Long#defineMoD 1000000007#defineINF 0x3f3f3f3f#defineN 1000010using namespacestd;intA[n],b[n],c[n];voidinit () {a[1]=2; b[1]=1; c[1]=1; for(intI=2; i<=1000000; i++) {B[i]=a[i-1];c[i]=b[i-1]; A[i]=b[i]+C[i]; A[i]%=MoD; }}intMain () {intN; Init (); while(SCANF ("%d", &n) >0) {printf ("%d", A[n]); }}
View Code
Southwest min da oj (recursive)