codeforces587B Duff in Beach
来源:互联网 发布:淘宝运营工资6000高吗 编辑:程序博客网 时间:2024/05/23 01:57
题意就是两个数组A,B其中B[i] = A[i%n],B有l个元素,A有n个元素。
从B中选取x个元素,相邻元素在B中的下标满足Ij/n + 1 == I[j+1]/n。
可以用dp[i][j]表示第i个数选的是j,那么dp[i][j] = ∑dp[i-1][t] && t <= j。
数字比较大,得先离散化一下,且要用滚动数组。。。。
/*****************************************Author :Crazy_AC(JamesQi)Time :2016File Name :*****************************************/// #pragma comment(linker, "/STACK:1024000000,1024000000")#include <iostream>#include <algorithm>#include <iomanip>#include <sstream>#include <string>#include <stack>#include <queue>#include <deque>#include <vector>#include <map>#include <set>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <climits>using namespace std;#define MEM(x,y) memset(x, y,sizeof x)#define pk push_backtypedef long long LL;typedef unsigned long long ULL;typedef pair<int,int> ii;typedef pair<ii,int> iii;const double eps = 1e-10;const int inf = 1 << 30;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;LL dp[2][1000010];LL a[1000010],b[1000010];int n, k;LL l;int main(){ // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); cin >> n >> l >> k; for (int i = 1;i <= n;++i) { // cin >> a[i]; scanf("%I64d",&a[i]); b[i] = a[i]; } sort(b + 1,b + 1 + n); int cnt = unique(b + 1,b + 1 + n) - b; for (int i = 1;i <= n;++i) { a[i] = lower_bound(b + 1,b + cnt, a[i]) - b; // cout << a[i] << ' '; } // cout << endl; int now = 1, la = 0; dp[now][0] = 1; LL ans = 0; LL seg = l / n; for (int i = 1;i <= k && i <= seg + 1;++i) { swap(la, now); for (int j = 0;j <= cnt;++j) dp[now][j] = 0; for (int j = 1;j <= cnt;++j) dp[la][j] = (dp[la][j-1] + dp[la][j]) % MOD; for (int j = 1;j <= n;++j) dp[now][a[j]] = (dp[now][a[j]] + dp[la][a[j]]) % MOD; for (int j = 1;j <= cnt;++j) ans = (ans + (seg - i + 1)%MOD * dp[now][j]%MOD) % MOD; for (int j = 1;j <= l - seg*n;++j) ans = (ans + dp[la][a[j]]) % MOD; } cout << ans << endl; return 0;}
0 0
- codeforces587B Duff in Beach
- Codeforces 587B Duff in Beach
- codeforces #326 D. Duff in Beach (dp)
- codeforces 587 B. Duff in Beach
- codeforces 587B Duff in Beach (dp)
- codeforces#326-D - Duff in Beach- dp+分块
- Codeforces Round #326 (Div. 1) B Duff in Beach
- Codeforces 588D Duff in Beach 【离散化 + dp】
- Codeforces Round #326 (Div. 2) D. Duff in Beach
- Codeforces Round #326 (Div. 1)-B. Duff in Beach
- Codeforces Round #326 (Div. 2) D. Duff in Beach(LIS)
- 【Codeforces Round 326 (Div 2)D】【DP】Duff in Beach 数列重复取数最多k次使得单调不下降
- B. Duff in Love
- B. Duff in Love
- Duff in Love
- CF587C Duff in the Army
- codeforces587C Duff in the Army
- codeforces#326-B-Duff in Love-暴力
- 写出高效清晰Layout布局文件的一些技巧--------自定义CoordinatorLayout:实现淘宝和QQ ToolBar透明渐变效果-------自定义Coordi快速返回效果
- vs2008突然不能使用查找功能了
- 学习Discuz! X3.2记录:使用superslide幻灯特效,配置方法
- 第八章 多态
- TortoiseSVN客户端重新设置用户名和密码
- codeforces587B Duff in Beach
- 韩顺平 javascript教学视频_学习笔记25_bom介绍_dom对象层次图_dom对象(window对象1)
- wpf设计器显示图片,运行却不显示图片
- Java线程池(1)
- AFMWorking 网络监听
- HDU 1257最少拦截系统(贪心)
- swift-函数02-函数返回值
- Python练习-- condition
- fsl audio 架构介绍