CF414B Mashmokh and ACM
思路:
dp。
实现:
1.O(n5/2)
#include <iostream>
#include <cstdio>
using namespace std; const int MOD = 1e9 + ; int n, k, dp[][]; int solve()
{
for (int i = ; i <= n; i++) dp[][i] = ;
for (int i = ; i < k; i++)
{
for (int j = ; j <= n; j++)
{
for (int p = ; p * p <= j; p++)
{
if (j % p == )
{
dp[i][j] = (dp[i][j] + dp[i - ][p]) % MOD;
if (p * p != j) dp[i][j] = (dp[i][j] + dp[i - ][j / p]) % MOD;
}
}
}
}
int sum = ;
for (int i = ; i <= n; i++) sum = (sum + dp[k - ][i]) % MOD;
return sum;
} int main()
{
cin >> n >> k;
cout << solve() << endl;
return ;
}
2.O(n2log(n))
#include <iostream>
#include <cstdio>
using namespace std; const int MOD = 1e9 + ; int n, k, dp[][]; int solve()
{
for (int i = ; i <= n; i++) dp[][i] = ;
for (int i = ; i < k; i++)
{
for (int j = ; j <= n; j++)
{
for (int p = j; p <= n; p += j)
{
dp[i][p] = (dp[i][p] + dp[i - ][j]) % MOD;
}
}
}
int sum = ;
for (int i = ; i <= n; i++) sum = (sum + dp[k - ][i]) % MOD;
return sum;
} int main()
{
cin >> n >> k;
cout << solve() << endl;
return ;
}
CF414B Mashmokh and ACM的更多相关文章
- 【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 414B B. Mashmokh and ACM(dp)
题目链接: B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input sta ...
- 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 D.Mashmokh and ACM
题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长 ...
- Codeforces 414B Mashmokh and ACM
http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表 ...
- CodeForces 415D Mashmokh and ACM
$dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{} {dp[i - 1][k]}$ ...
- Mashmokh and ACM CodeForces - 414D (贪心)
大意: 给定n结点树, 有k桶水, p块钱, 初始可以任选不超过k个点(不能选根结点), 在每个点放一桶水, 然后开始游戏. 游戏每一轮开始时, 可以任选若干个节点关闭, 花费为关闭结点储存水的数量和 ...
- CF 414B Mashmokh and ACM 动态规划
题意: 给你两个数n和k.求满足以下条件的数列有多少个. 这个数列的长度是k: b[1], b[2], ……, b[k]. 并且 b[1] <= b[2] <= …… <= b[k] ...
随机推荐
- Leetcode 114.二叉树展开为链表
二叉树展开为链表 给定一个二叉树,原地将它展开为链表. 例如,给定二叉树 将其展开为: class Solution{ public: void flatten(TreeNode* root){ if ...
- HDU 1212 大整数的取模运算
因为这里是MOD最大为100000 所以我将字符串看作5个一组,并记录后面跟了多少个100000 每次取5个数根据其数据进行取模更新 注意过程中 100000*100000会超int #include ...
- 20181010关于pt-kill自动杀死运行超长的进程
转自: http://blog.chinaunix.net/uid-16844903-id-4442030.htmlhttp://blog.chinaunix.net/uid-31396856-id- ...
- yum 源本地化 (two)
之前写过一个yum源本地化的文章. 后来发现那个方法有些缺陷, yum install --downloadonly --downloaddir=/tmp/atomicdownload memcach ...
- [JavaEE] Implement a test for REST endpoint
1. We have the BookEndpoint.java: package com.pluralsight.bookstore.rest; import com.pluralsight.boo ...
- [Vue-rx] Switch to a Function which Creates Observables with Vue.js and Rxjs
Wrapping the creation of an Observable inside of a Function allows you delay the creation of the Obs ...
- 设置默认訪问项目的client的浏览器版本号(IE版本号)
在项目开发部署中.发现浏览器不兼容现象,在不处理兼容性情况下让用户更好体验(IE浏览器) 我们来设置client默认訪问项目的浏览器版本号 例如以下所看到的的是不同IE版本号下的效果截图比較: IE5 ...
- effective C++ 读书笔记 条款14 以对象管理资源
如果我们使用一个投资行为的程序库: #include "stdafx.h" #include <iostream> #include <memory> us ...
- es bulk 批量删除
bulk [root@hadoop2 ~]# cat bulk.del.es.json {"delete":{"_index":"direct_vot ...
- Delphi中ARC内存管理的方向
随着即将发布的10.3版本,RAD Studio R&D和PM团队正在制作Delphi在内存管理方面的新方向. 几年前,当Embarcadero开始为Windows以外的平台构建新的Delph ...