Bzoj 3398: [Usaco2009 feb]bullcow Bull and Cow (DP)

Source: Internet
Author: User

Water problem ... Forget to take the mold there is no 1 a ....

---------------------------------------------------------------------------

#include <bits/stdc++.h>

using namespace std;const int MOD = 5000011;const int MAXN = 100009;int DP[MAXN], n, K;int main () {cin >> n >> K;for (int i = 0; I <= k; i++)Dp[i] = i + 1;for (int i = k + 1; I <= n; i++)Dp[i] = (Dp[i-1] + dp[i-k-1])% MOD;cout << dp[n] << "\ n";return 0;}

---------------------------------------------------------------------------

3398: [Usaco2009 feb]bullcow Bull and Cow time limit: 1 Sec Memory Limit: MB
Submit: Solved: 54
[Submit] [Status] [Discuss] DescriptionJohn 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 inputone line, enter two integers n and K.OutputAn integer that represents the number of methods queued. Sample Input4 2
Sample Output6
Sample Description
6 methods are: Doe DOE DOE Doe, Hart Doe Doe DOE, DOE DOE Doe, DOE Doe Hart Doe, DOE Doe Doe Hart, Hart Doe Doe HartHINT

Source

Silver

Bzoj 3398: [Usaco2009 feb]bullcow Bull and Cow (DP)

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.