$dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{}  {dp[i - 1][k]}$.答案为$\sum\limits_{k=1}^{m}  {dp[n][k]}$ #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #i…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长度为i,以j为结尾有多少.dp[i][j]+=dp[i-1][s],j%s==0; #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; int n,k; ][];…
http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表a整除b), 求长度为K,元素大小小于等于N的序列个数 思路:f[i][j] 代表在序列的第i位,当前数字为j的方案数 #include<cstdio> #include<cmath> #include<algorithm> #include<cstring>…
题目链接: B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participat…
                                             B. Mashmokh and ACM                                                                                             time limit per test 1 second                                                                …
http://codeforces.com/problemset/problem/414/B B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh d…
codeforces 414D Mashmokh and Water Tanks 题意 题解 \(a_i\):第 \(i\) 层的结点个数. \(b_i\):第 \(i\) 层初始有水的结点个数. 如果不允许关闭水塔,最后的答案就是 \(max\{a_i\}\). 现在允许关闭部分水塔,我们可以把一些连续层数的水汇聚到同一层.假设我们汇聚 \([l, r]\) 范围的水,总花费是 \(\Sigma_{i=l}^r\{b_i*(r-i)\}\). 双指针实现即可. 代码 #include<bits…
[Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每通过一关后可以选择继续下一关或者时间清0并从第一关开始,先要求通过所有关卡的时间和不能超过R才算彻底通关,问直到彻底通关位置的游戏时间的期望值为多少 分析 二分从头开始通关的用时期望mid 设\(dp[i][j]\)表示通前i关,当前时间为j的期望,倒推期望. 若超时重新开始,则\(dp[i][j]…
[CodeForces - 1225E]Rock Is Push [dp][前缀和] 标签:题解 codeforces题解 dp 前缀和 题目描述 Time limit 2000 ms Memory limit 524288 kB Source Technocup 2020 - Elimination Round 2 Tags binary search dp *2200 Site https://codeforces.com/problemset/problem/1225/E 题面 Examp…