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 ...
随机推荐
- 洛谷P3121 审查(黄金)Censoring(Gold) [USACO15FEB] AC自动机
正解:AC自动机 解题报告: 传送门! 啊我好呆啊其实就挺模板题的,,,只是要一个栈搞一下,,,然后我就不会了,,,是看了题解才get的,,,QAQ 然后写下解法趴QwQ 首先看到多串匹配不难想到AC ...
- POJ2431 Expedition 贪心
正解:模拟费用流 解题报告: 先放个传送门鸭,题目大意可以点Descriptions的第二个切换成中文翻译 然后为了方便表述,这里强行改一下题意(问题是一样的只是表述不一样辣,,, 就是说现在在高速公 ...
- 只读事务@Transactional(readOnly = true)
定义 从设置的时间点(时间点beta)开始到事务结束的过程中,该事务将看不见其他事务所提交的数据,即查询中不会出现别人在beta之后提交的数据. 应用场合 对于一个函数,如果执行的只是 ...
- LED客显的类
using System; using System.IO.Ports; namespace Common { public class LedHelper { ; private static st ...
- 【SQL】from a,b。表a 和b之间是什么关系?
1.select a.id from a,b……——>这里a和b用逗号隔开,a,b之间默认是inner join的关系.
- RN NetInfo使用
代码: class NetInfoView extends Component { getNetInfo() { //如果是andorid的程序,需要在xml添加获取网络请求权限 NetInfo.fe ...
- python中base64编码与解码
在python3中用base64进行编码和解码的时候特别注意: 题目要求: 准备一张.jpg图片,比如:mm.jpg,读取图片数据并通过b85encode加密之后写入到新文件mm.txt文件中,然后读 ...
- vue中less的使用
1.安装:npm install less less-loader --save 2.修改webpack.config.js文件,配置loader加载依赖,让其支持外部的less,在原来的代码上添加 ...
- 微信小程序 - 表单验证插件WxValidate使用
插件下载地址及官方文档:https://github.com/skyvow/wx-extend 具体的WxValidate.js文件的位置在wx-extend/src/assets/plugins/w ...
- [LeetCode] 1. Two Sum_Easy
Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...