Description John is going to take N (1≤n≤100000) cattle to the show at the rally, which can be bull or cow. The cows were to stand in a row. But the bull was aggressive, and John decided to have at least K (o≤k<n) cow between any two bulls in order to avoid the bull's trouble. Please calculate how many kinds of queueing methods are in common. All bulls can be seen as the same, and all cow are the same. Answer to 5000011 modulo input line, enter two integers n and k.output An integer that represents the number of methods queued. Sample Input4 2
Sample Output6
Second day in the Kinaka camp when the game wrote 233 ... I was trampled on by the gentleman. Direct Push F[i]=f[i-1]+f[i-m-1] on the line. The examination room on its own f[i][0],f[i][1] said the two bulls put in the last time the number of separate programs, and then found very good understanding.
#include <cstdio>intf[100001],n,m;intMain () {scanf ("%d%d",&n,&m); f[0]=1; for(intI=1; i<=n;i++){ if(i>m+1) f[i]=f[i-m-1]+f[i-1];Elsef[i]=f[i-1]+1; if(f[i]>=5000011) f[i]-=5000011; } printf ("%d", F[n]);}
bzoj:3398: [Usaco2009 feb]bullcow Bull and Cow