D. Duff in Beach
题意 数字串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的更多相关文章
- 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 ...
- 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 ...
- 2015南阳CCPC A - Secrete Master Plan 水题
D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Master Mind KongMing gave ...
- cf Round 587
A.Duff and Weight Lifting(思维) 显然题目中只有一种情况可以合并 2^a+2^a=2^(a+1).我们把给出的mi排序一下,模拟合并操作即可. # include <c ...
- 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 ...
- 2021record
2021-10-14 P2577 [ZJOI2004]午餐 2021-10-13 CF815C Karen and Supermarket(小小紫题,可笑可笑) P6748 『MdOI R3』Fall ...
- 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 ...
- 【转】Duff's Device
在看strcpy.memcpy等的实现发现用了内存对齐,每一个word拷贝一次的办法大大提高了实现效率,参加该blog(http://totoxian.iteye.com/blog/1220273). ...
- Codeoforces 558 B. Duff in Love
// B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
随机推荐
- ORACLE DB体系结构
. 实例:一组oracle后台进程.线程以及一个共享内存区. 连接:用户进程和实例之间的通信 会话:用户通过用户进程与实例建立的特定连接 参数文件:包含控制文件的位置和名称 分为pfile和spfil ...
- Java之旅_面向对象_重写和重载
参考并摘自:http://www.runoob.com/java/java-override-overload.html 重写(Override) 子类对父类(允许访问的)方法的实现过程进行重新编写, ...
- kubernetes有状态集群服务部署与管理
有状态集群服务的两个需求:一个是存储需求,另一个是集群需求.对存储需求,Kubernetes的解决方案是:Volume.Persistent Volume .对PV,除了手动创建PV池外,还可以通过S ...
- SQL优化之踩过的坑【一】
正看资料看的过瘾,突然收到报警,说服务器负载太高,好吧,登录服务器看看,我擦嘞,还能不能愉快的玩耍了?下面是当时的负载情况 看见mysql使用cpu已经到了2000,io没有等待.说明应该没有大的临时 ...
- InnoDB启用大内存页
在 Linux 操作系统上运行内存需求量较大的应用程序时,由于其采用的默认页面大小为 4KB,因而将会产生较多 TLB Miss 和缺页中断,从而大大影响应用程序的性能.当操作系统以 2MB 甚至更大 ...
- Sql server 2016 Always On 搭建Windows集群配置
.安装WSFC群集组件 1)打开服务器管理器,选择“功能”,在右边窗口中点击“添加功能”. 2)在添加功能向导中,勾选“故障转移群集”,点击“下一步”. 3)在“确认安装选择”页面中,点击“安装”,进 ...
- 快学Scala 2
控制结构和函数 1.在Scala中,几乎所有构造出来的语法结构都有值.这个特性是为了使得程序更加精简,也更易读. (1)if表达式有值 (2)块也有值——是它最后一个表达式的值 (3)Scala的fo ...
- function module 调用类对象
1: 定义一个类,编辑里面的方法 method METHOD1. write EV_P2. ev_p1 = 'test'. endmethod. 2:在其它function module 中调用
- QGL登陆wui 提示not possible
1: sap 登陆 QGL系统, 提示 2: 需要到该系统下,使用 T-CODE su01 或者 su3 对LIHANS1 用户角色进行修改. 3:su53 查询 自己操作的 历史纪录和 状 ...
- internal table operation
1: the basic operation *&---------------------------------------------------------------------* ...