CodeForces 414B Mashmokh and ACM

news/2024/7/5 19:30:13

 

->题目链接

 

  定义一个数组dp,dp[ i ][ j ]表示以数值 i 结尾的、长度为 j 的good序列。

  容易知道dp[ i ][1](1≤i≤n) 为1。

  每求得一个 i,j 对应的dp[ i ][ j ],就把这个值加在

dp[ p*i ][ j+1 ],dp[ p*i ][ j+2 ],…,dp[ p*i ][ k ](p>1 且 p*i ≤ n)

上,最后,答案为sum(dp[ q ][k]),1≤q≤n。

 

 

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <map>
 4 #include <vector>
 5 #include <functional>
 6 #include <string>
 7 #include <cstring>
 8 #include <queue>
 9 #include <stack>
10 #include <set>
11 #include <cmath>
12 #include <cstdio>
13 using namespace std;
14 #define IOS ios_base::sync_with_stdio(false)
15 #define TIE std::cin.tie(0)
16 #define MAX2(a,b) (a>b?a:b)
17 #define MAX3(a,b,c)  (a>b?(a>c?a:c):(b>c?b:c))
18 typedef long long LL;
19 typedef unsigned long long ULL;
20 const int INF=0x3f3f3f3f;
21 const double PI=4.0*atan(1.0);
22 const int MOD=1000000007;
23 int n,k,dp[2005][2005],ans;
24 
25 int main()
26 {
27     //while(~scanf("%d%d",&n,&k))
28         scanf("%d%d",&n,&k);
29         ans=0;
30         for(int i=1;i<=n;i++){
31             dp[i][1]=1;
32             for(int j=i;j<=n;j+=i){
33                 for(int p=2;p<=k;p++){
34                     dp[j][p]+=dp[i][p-1];
35                     if(dp[j][p]>MOD) dp[j][p]-=MOD;
36                 }
37             }
38         }
39         for(int i=1;i<=n;i++){
40             ans+=dp[i][k];
41             if(ans>MOD) ans-=MOD;
42         }
43         printf("%d\n",ans);
44     //}
45 }
View Code

 

转载于:https://www.cnblogs.com/cumulonimbus/p/5741196.html


http://www.niftyadmin.cn/n/1942736.html

相关文章

Masonry整理

Masonry整理Masonry是以AutoLayout为基础的轻量级布局框架更加简化了整个约束系统Masonry三方下载本文参考&#xff1a; 地址1 地址2 地址3 地址4*Masonry有哪些属性property (nonatomic, strong, readonly) MASConstraint left;property (nonatomic, strong, read…

HBase 查找版本

直接使用hbase shell命令进入shell时间会告诉版本&#xff1a;进shell后。关键在version命令。能够查看版本&#xff1a;# hbase shell HBase Shell; enter help<RETURN> for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell…

戴尔r410服务器raid装系统,Dell R410 Raid磁盘阵列驱动

软件简介 Soft Introductiondell r410服务器的磁盘阵列在windows系统下的驱动程序&#xff0c;能够直接加载。支持32-64位Windows Server 2008操作系统支持下面硬件ID&#xff1a;PCI\VEN_1028&DEV_0016&subsys_1F241028PCI\VEN_8086&DEV_3A25&subsys_020F1028…

水质评价---2综合水质标识指数法

综合水质标识指数评价法分单因子水质标识指数和综合水质标识指数两步进行。 单因子水质标识指数P由一位整数、小数点后2位或3位有效数字组成,表示为Px1.x2x3。x1代表第i项水质指标的水质类别;x2代表监测数据在x1类水质变化区间中所处的位置,根据公式按四舍五入的原则计算确定;x…

组播服务器性能要求,组播源服务器配置

组播源服务器配置 内容精选换一换在使用负载均衡服务时&#xff0c;确保至少有一台后端服务器在正常运行&#xff0c;可以接收负载均衡转发的客户端请求。如果请求的需求流量上升&#xff0c;用户需要向负载均衡器添加更多后端服务器处理需求。移除负载均衡器绑定的后端服务器&…

包包各部位名称图解_樱桃树栽培技术|樱桃树与修剪相关的各部位名称

樱桃树体由地下和地上两部分组成&#xff0c;地下部分统称为根系&#xff0c;地上部分统称为树冠。树冠中各种骨干枝和结果枝组在空间上分布排列的情况称为树体结构。1、主干从地面处的根茎以上到着生第一主枝处的部位称为主干&#xff0c;也称树干。这一段的长度称为干高。2、…

Android 比较两个时间段是否有交集或重复

先看一个例图&#xff1a; 在金山《电池管家》应用中就有一个类似上图这样的功能—— 开启多个定时任务。 当开启另一个定时任务的时候&#xff0c;如果即将开启的这个定时任务的时间段与已经开启了的定时任务的时间段有交集的话&#xff0c;它就会提示&#xff1a;重叠的任务不…

自动升级程序

http://www.cnblogs.com/stoneniqiu/p/3806558.html http://www.cnblogs.com/KnightsWarrior/archive/2010/10/20/1856255.html http://autoupdater.codeplex.com/