codeforces 414B B. Mashmokh and ACM(dp)
题目链接:
1 second
256 megabytes
standard input
standard output
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.
A sequence of l integers b1, b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally for all i (1 ≤ i ≤ l - 1).
Given n and k find the number of good sequences of length k. As the answer can be rather large print it modulo 1000000007(10^9 + 7).
The first line of input contains two space-separated integers n, k (1 ≤ n, k ≤ 2000).
Output a single integer — the number of good sequences of length k modulo 1000000007 (10^9 + 7).
- 3 2
- 5
- 6 4
- 39
- 2 1
- 2
In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].
题意:
给出这么多数[1,n],问能形成长为l的数列满足b[i]|b[i+1]的方案数;
思路:
dp[i][j]表示长为i,以j结尾的方案数,
dp[i+1][j]=∑dp[i][k],k为j的因数;
AC代码:
- #include <bits/stdc++.h>
- using namespace std;
- #define Riep(n) for(int i=1;i<=n;i++)
- #define Riop(n) for(int i=0;i<n;i++)
- #define Rjep(n) for(int j=1;j<=n;j++)
- #define Rjop(n) for(int j=0;j<n;j++)
- #define mst(ss,b) memset(ss,b,sizeof(ss));
- typedef long long LL;
- const LL mod=1e9+;
- const double PI=acos(-1.0);
- const int inf=0x3f3f3f3f;
- const int N=2e5+;
- LL dp[][];
- int main()
- {
- int n,k;
- scanf("%d%d",&n,&k);
- for(int i=;i<=n;i++)
- {
- dp[][i]=;
- }
- for(int i=;i<=k;i++)
- {
- Rjep(n)
- {
- for(int x=;x*j<=;x++)
- {
- dp[i+][x*j]+=dp[i][j];
- dp[i+][x*j]%=mod;
- }
- }
- }
- LL ans=;
- for(int i=;i<=n;i++)
- {
- ans+=dp[k][i];
- ans%=mod;
- }
- cout<<ans<<"\n";
- return ;
- }
codeforces 414B B. Mashmokh and ACM(dp)的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- Codeforces Round #240 (Div. 1) B. Mashmokh and ACM DP
B. Mashmokh and ACM ...
- B. Mashmokh and ACM(dp)
http://codeforces.com/problemset/problem/414/B B. Mashmokh and ACM time limit per test 1 second memo ...
- [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)
[Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...
- [CodeForces - 1225E]Rock Is Push 【dp】【前缀和】
[CodeForces - 1225E]Rock Is Push [dp][前缀和] 标签:题解 codeforces题解 dp 前缀和 题目描述 Time limit 2000 ms Memory ...
- [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT)
[Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT) 题面 给出一个\(n\)个点\(m\)条边的有向图(可能有环),走每条边需要支付一个价格\(c_i ...
- Codeforces 414B Mashmokh and ACM
http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...
- codeforces D.Mashmokh and ACM
题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长 ...
- CodeForces 415D Mashmokh and ACM
$dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{} {dp[i - 1][k]}$ ...
随机推荐
- 一个关于 jquery 和 php 的 jsonp 例子(与后台PHP成功通信)
<script> $(document).ready(function(){ $.ajax({ url:'http://localhost/test/jsonp.php', dataTyp ...
- T1191 数轴染色 codevs
http://codevs.cn/problem/1191/ 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Descr ...
- jquery的固定定位效果
今天做了个固定定位的效果.比如对导航需要进行固定定位效果: 当没有滚动到导航下面,导航正常显示. 当滚动到导航下面,导航就固定到顶部. 这个效果使用了jquery的方法实现,具体思路为: 1)首先获取 ...
- Access restriction: The method 'CharacterEncoder.encode(byte[])' is not API...
问题描述:Access restriction: The method 'CharacterEncoder.encode(byte[])' is not API... 解决方法:这种错误是eclips ...
- Java修饰符关键字的顺序
Java语言规范建议按以下顺序列出修饰符: 1. Annotations 2. public 3. protected 4. private 5. abstract 6. static 7. fina ...
- MFC中的双缓冲技术(解决绘图闪烁问题)
转自 MFC绘图不闪烁——双缓冲技术[转] 在VC/MFC用CDC绘图时,频繁的刷新,屏幕会出现闪烁的现象,CPU时间占用率相当高,绘图效率极低,很容易出现程序崩溃. 所谓双缓冲技术,下面是百度百科的 ...
- 【swagger】1.swagger提供开发者文档--简单集成到spring boot中【spring mvc】【spring boot】
swagger提供开发者文档 ======================================================== 作用:想使用swagger的同学,一定是想用它来做前后台 ...
- Go -- 漫谈IM通信架构
前前后后做的IM和推送系统已经有好几个了,一直都想好好总结下,因此就有了这篇文章.在我刚学编程的那会儿,觉得网络通信是一个很牛逼和门槛很高的一门技术,但是随着开源技术的发展和互联网知识的共享,现在要写 ...
- 天下文章一大抄 mysql远程连接
使用GRANT命令创建远程连接mysql授权用户特定用户mysql -u root -ppassword 注意:p后面没有空格直接密码.mysql>grant all privileges ...
- 【转】Code Your Own PHP MVC Framework in 1 Hour
原文: https://www.codeproject.com/Articles/1080626/Code-Your-Own-PHP-MVC-Framework-in-Hour --------- ...