题意  数字串a[0---n-1], 通过不断的重复组成了 b[0,---l-1]l<10^18,

让你计算出 长度小于等于k的最长非递减子序列,满足,取得第 i 个取得是 L1 第i+1个取得是L2  ------ L1/n +1 = L2, 通过这个我们先对原数组进行排序,排完后使用vector去计算dp[i][j]

及时 第i个数放在第j位的方案总数, 然后我们依次枚举放1 个 2 个3个。。。k, 贡献分别是  l/n,l/n-1....1,这样再枚举那最后的余下的那一些。

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string.h>
using namespace std;
const int maxn=;
typedef long long LL;
const LL mod=;
int A[maxn],B[maxn],C[maxn],D[maxn],E[maxn];
vector<LL>G[maxn];
void init(int n,int k)
{
for(int i=; i<=n; i++)
{
G[i].clear();
for(int j=; j<=k; j++)G[i].push_back();
}
}
int main()
{
int n,k;LL l;
while(scanf("%d%I64d%d",&n,&l,&k)==)
{
init(n,k);
for(int i=;i<n; i++)
{
scanf("%d",&A[i]);
B[i]=A[i];
}
sort(B,B+n);
int ge=;
C[]=;
for(int i=; i<n;i++)
{
if(B[i]==B[ge-])C[ge-]++;
else{
B[ge++]=B[i]; C[ge-]=;
}
}
LL num=l/n;
LL ans=l%mod;
LL uu=min(k*1LL,num+);
int lest=l%n,numoflest=;
sort(A,A+lest);
if(lest>){
E[]=; for(int i=; i<lest; i++)
{
if(A[i]==A[numoflest-])E[numoflest-]++;
else{
A[numoflest++]=A[i]; E[numoflest-]=;
}
}
}
for(int i=; i<ge; i++)G[i][]=C[i];
for(int i=; i<=k; i++)
{
long long d=,S=;
int loc=;
for(int j=; j<ge; j++)
{
d+=G[j][i-];
d=d%mod;
G[j][i]=(d*C[j])%mod;
S=(S+G[j][i])%mod;
while(loc<lest&&A[loc]<B[j])loc++;
if(loc<lest && A[loc] == B[j])
{
if(i<=uu)
ans=(ans+(d*E[loc])%mod )%mod;
}
}
if( num - i + > )
{
long long gg=( S * ( ( num - i + )%mod ) )%mod;
ans=(ans+gg)%mod;
}
}
printf("%I64d\n",ans);
}
return ;
}

D. Duff in Beach的更多相关文章

  1. Codeforces Round #326 (Div. 2) D. Duff in Beach dp

    D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/probl ...

  2. codeforces 587B B. Duff in Beach(dp)

    题目链接: B. Duff in Beach time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  3. 2015南阳CCPC A - Secrete Master Plan 水题

    D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Master Mind KongMing gave ...

  4. cf Round 587

    A.Duff and Weight Lifting(思维) 显然题目中只有一种情况可以合并 2^a+2^a=2^(a+1).我们把给出的mi排序一下,模拟合并操作即可. # include <c ...

  5. 2015南阳CCPC A - Secrete Master Plan A.

    D. Duff in Beach Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a ...

  6. 2021record

    2021-10-14 P2577 [ZJOI2004]午餐 2021-10-13 CF815C Karen and Supermarket(小小紫题,可笑可笑) P6748 『MdOI R3』Fall ...

  7. Codeforces Round #326 (Div. 2) B. Pasha and Phone C. Duff and Weight Lifting

    B. Pasha and PhonePasha has recently bought a new phone jPager and started adding his friends' phone ...

  8. 【转】Duff's Device

    在看strcpy.memcpy等的实现发现用了内存对齐,每一个word拷贝一次的办法大大提高了实现效率,参加该blog(http://totoxian.iteye.com/blog/1220273). ...

  9. Codeoforces 558 B. Duff in Love

    //   B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

随机推荐

  1. python_flask 注册,登陆,退出思路 ---纯个人观点

    1注册逻辑首先查询数据库用户名 并判断用户是否存在,如不存在就插入数据 并返回响应给前端2前端模板获取注册信息 判断 用户名不能为空及密码不能为空,和密码不一致 拼接注册url 组成get获取对象 响 ...

  2. 如何在Win10上永久禁用Windows Defender Antivirus

    1.使用Windows键+ R键盘快捷键打开运行命令. 2.键入regedit,然后单击确定以打开注册表. 3.浏览以下路径: HKEY_LOCAL_MACHINE/SOFTWARE/Policies ...

  3. 拦截器的作用之session认证登录和资源拦截

    背景: 在项目中我使用了自定义的Filter 这时候过滤了很多路径,当然对静态资源我是直接放过去的,但是,还是出现了静态资源没办法访问到springboot默认的文件夹中得文件.另外,经常需要判断当前 ...

  4. 终于解决“Git Windows客户端保存用户名与密码”的问题(转载)

    add by zhj:不建议用这种方法,建议用SSH,参见 TortoiseGit密钥的配置 http://www.cnblogs.com/ajianbeyourself/p/3817364.html ...

  5. Nginx安装、配置虚拟主机、反向代理、负载均衡

    1.   nginx安装 下载nginx: 官方网站: http://nginx.org/ 使用的版本是1.8.0版本. Nginx提供的源码. 1.1. 要求的安装环境 1.需要安装gcc的环境.y ...

  6. Innodb buffer 相关参数

    buffer相关参数: show GLOBAL VARIABLES LIKE 'innodb_buffer_pool_instances'; show GLOBAL VARIABLES LIKE 'i ...

  7. vue-router利用url传递参数

    app.vue <template> <div id="app"> <router-link to="/">home< ...

  8. sql server外网复制+非默认端口

    注意查看服务器名称,这出来的是什么,就必须要在别名上写什么,如果不一样,请参照 :修改计算机名 SELECT @@SERVERNAME as InstalledName, SERVERPROPERTY ...

  9. 20180328 Redis和MSMQ

    以前接触的页面记录多为session或者传递的方式短暂记忆.今天接触了一个Redis作为缓存的想法,在之前我也是用过Redis ,但是只是作为异步任务系统记录是否执行成功使用,目前看来用Redis也可 ...

  10. 【LDA】周志华

    一.书籍