题意  数字串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. NodeJS笔记(一)-免安装设置

    之前在官网下载的nodejs win64版本4.* 最近发现nodejs都已经更新到了7.X 稳定版都升级到了6.X ,nodejs升级的真是神速了,想要升级下, 使用官方给的方法更新失败(使用的是n ...

  2. panda核心数据结构

    Series Series是一维带标签的数组,数组里可以放任意的数据(整数.浮点数.字符串.python Object)等等 创建函数: (1)s = pd.Series(data,index=ind ...

  3. pyqt5_eric6_Qt desinger

    麦子学院视频教程day1 1.创建pushbutton 绑定信号和槽 Ui_mainWindow.py 1 from PyQt5 import QtCore, QtGui, QtWidgets cla ...

  4. 集齐所有机制的按键控制LED驱动

    内核版本:linux2.6.22.6 硬件平台:JZ2440 驱动源码 final_key.c : #include <linux/module.h> #include <linux ...

  5. 【JMeter】【性能测试】分布式远程服务器

    jmeter分布式简单步骤说明: 1:添加远程服务器IP到配置文件 在JMETER_HOME / bin / jmeter.properties中,找到名为“ remote_hosts ” 的属性,并 ...

  6. tail命令 输出文件后n行,默认查看文件的后10行

    默认查看文件的后10行 -n 3 数字   也可以忽略-n 直接加数字 tail 3 查看文件后3行 [root@localhost ~]# tail /etc/passwd // 默认查看文件的后十 ...

  7. Laravel上传产品图片Uploading img

    这节我们讲Laravel产品图片上传,有很多方式可以实现,这里我们用intervention/image插件来进行.首先安装intervention/image插件,在命令行输入 composer r ...

  8. Codefoces 432C Prime Swaps(数论+贪心)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u011328934/article/details/26094917 题目连接:Codefoces ...

  9. what's the 头寸

    头寸,是一种市场约定,承诺买卖外汇合约的最初部位,买进外汇合约者是多头,处于盼涨部位:卖出外汇合约为空头,处于盼跌部位.头寸可指投资者拥有或借用的资金数量. “头寸”一词来源于近代中国,银行里用于日常 ...

  10. JsonDataObjects 简单实用

    下载地址https://github.com/ahausladen/JsonDataObjects Simple example var Obj: TJsonObject; begin Obj := ...