bzoj:3398: [Usaco2009 feb]bullcow Bull and Cow

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.