codechef Chef and Rainbow Array - 2

Problem Description

Chef loves arrays. But he really loves a specific kind of them - Rainbow Arrays.
The array is a Rainbow Array if it has such a structure:
The first a1 elements equal to 1.
The next a2 elements equal to 2.
The next a3 elements equal to 3.
The next a4 elements equal to 4.
The next a5 elements equal to 5.
The next a6 elements equal to 6.
The next a7 elements equal to 7.
The next a6 elements equal to 6.
The next a5 elements equal to 5.
The next a4 elements equal to 4.
The next a3 elements equal to 3.
The next a2 elements equal to 2.
The next a1 elements equal to 1.
ai is a positive integer, the variables with the same index (a1 in the first statement and a1 in the last one, for example) are equal.
There are no any other elements in array.
For example, {1,1,2,2,2,3,4,5,5,6,7,7,7,6,5,5,4,3,2,2,2,1,1} is a Rainbow Array.
The array {1,2,3,4,5,6,7,6,6,5,4,3,2,1} is not a Rainbow Array, because the sizes of the blocks with the element 6 are different.
Please help Chef to count the number of different Rainbow Arrays that contain exactly N elements.

Input

The first line contains a single integer N.

Output

Output the number of different Rainbow Arrays with N elements, modulo 10^9+7.
Constraints
1 ≤ N ≤ 106

Example


Input #1:
10
Output #1:
0

Input #2:
13
Output #2:
1

Input #3:
14
Output #3:
1

Input #4:
15
Output #4:
7

题解

开始打不开中文题面,又看不懂题面,就看了看别人的代码,结果发现根本看不懂。

之后打开了中文题面……好像只是无脑的DP吧。

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#define ll long long
#define mod 1000000007
using namespace std;
int n;
ll f[1000002][8];
int main()
{
	scanf("%d",&n);
	n=(n+1)>>1;
	int i,j;
	f[0][0]=1;
	for(i=1;i<=n;i++)
	for(j=1;j<=min(i,7);j++)
	   {f[i][j]=(f[i][j]+f[i-1][j-1])%mod;
	    f[i][j]=(f[i][j]+f[i-1][j])%mod;
	   }
	printf("%lld\n",f[n][7]);
	return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
源码编译安装 Chef Solo 分为以下几个步骤: 1. 安装 Ruby 和 RubyGems:Chef Solo 是基于 Ruby 编写的,所以需要先安装 Ruby 和 RubyGems。您可以使用操作系统的包管理器安装,或者从官方网站下载源代码编译安装。安装完成后,请验证 Ruby 和 RubyGems 是否安装成功。 2. 安装 Chef 和依赖组件:Chef Solo 是 Chef 的一个独立组件,需要先安装 Chef 和依赖组件。您可以使用 RubyGems 安装,命令如下: ``` gem install chef ``` 安装完成后,请验证 Chef 是否安装成功。 3. 下载 Chef Solo 源代码:您可以从官方网站下载最新版本的 Chef Solo 源代码,或者使用以下命令从 GitHub 上下载: ``` git clone https://github.com/chef/chef.git ``` 4. 编译和安装 Chef Solo:使用以下命令编译和安装 Chef Solo: ``` cd chef/chef-solo gem build chef-solo.gemspec gem install chef-solo-<version>.gem ``` 其中,`<version>` 是 Chef Solo 的版本号,您需要将其替换为实际的版本号。安装完成后,请验证 Chef Solo 是否安装成功。 5. 配置 Chef Solo:将您的 Chef Solo 配置文件(通常是 solo.rb 和 json 文件)放置在合适的目录下,并确保您的配置文件正确。可以使用 `chef-solo -c <config_file>` 命令来验证配置文件是否正确。 6. 使用 Chef Solo:使用 `chef-solo -c <config_file>` 命令来启动 Chef Solo,并运行您的 Chef 配方(cookbooks)。 希望这个步骤对您有所帮助,如果您有其他问题,请随时问我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值