题意  数字串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. java kafka 生产者消费者demo

    一.修改kafka   server.porperties的ip是你本机的ip listeners=PLAINTEXT://192.168.111.130:9092 二.生产者的例子 import o ...

  2. 简单的document操作

    1.新增商品:新建文档,建立索引PUT /index/type/id{ "json数据"}例如:PUT /ecommerce/product/1{ "name" ...

  3. python 遇到的问题及解答

    1.使用pip安装python 模块 打开cmd 输入pip install *,如pip install numpy    等待安装(如下) C:\WINDOWS\System32>pip i ...

  4. 微信小程序首支视频广告片发布

    自2017年1月9日上线以来,微信小程序瞬间引爆网络,又迅速归于平静.对这个“无需安装.触手可及.用完即走.无需卸载”的小程序,微信从一开始就对它寄予了无限期望.在公布一系列规则更改后,微信小程序终于 ...

  5. Java基础知识(抽象类和接口)

    一.抽象类 在了解抽象类之前,先来了解一下抽象方法.抽象方法是一种特殊的方法:它只有声明,而没有具体的实现.抽象方法的声明格式为: 1 abstract void fun(); 抽象方法必须用abst ...

  6. 报错解决——DateTimeField *** received a naive datetime (***) while time zone support is active

    这是一个跟时区有关的问题,报错中说到datetime字段得到一个naive datetime,而不是支持time zone的active datetime由于Django的设置中米哦人USE_TZ设置 ...

  7. Ubuntu如何修改默认python版本为python3

    修改默认python版本 Ubuntu系统内置python2.7版本,默认运行python就是运行python2.7.现在很多人都是用python3作为开发语言,我们需要修改python的默认版本为p ...

  8. 002-linux使用SecureCRT

    一.ssh 登录linux系统 1.确定网络连通性:ping www.jd.com 2.rpm -qa | grep ssh 可以看到系统中ssh安装包 查找当前系统是否已经安装 注:如果没有安装SS ...

  9. php-fpm sock 进程池优化

    更改tcp为sock ;listen = 127.0.0.1:9000 listen = /dev/shm/php-cgi.sock pm = static \\静态进程池 pm.max_childr ...

  10. git push 报错:you are not allowed to upload merges

    git rebase Cannot rebase: You have unstaged changes. git stash # 每次 push 前 git pull --rebase git pus ...