hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3)
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt", "r", stdin),freopen("out.txt", "w", stdout)
const int INF = 0x3f3f3f3f;
const int maxn = 1e7 + ; ll n, m, k, p, q, MOD, r;
ll a[maxn];
ll b[maxn]; int main()
{
Faster;
int T;
cin >> T;
while(T--){
cin >> n >> m >> k >> p >> q >> r >> MOD;
for(int i = ;i <= n;i++){
if(i <= k){
cin >> a[i];
}
else{
a[i] = (p*a[i-] + q*i + r)%MOD;
}
}
ll cnt, ans;
cnt = ans = ;
for(int h = , t = , i = n;i >= ;i--){
while(h <= t && a[b[t]] <= a[i]) t--;
b[++t] = i;
if(i+m- <= n){
while(b[h] >= i+m) h++;
ans += i^a[b[h]];
cnt += i^(t-h+);
}
}
cout << ans << " " << cnt << endl;
}
return ;
}
hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3)的更多相关文章
- HDU 6319 Problem A. Ascending Rating(单调队列)
要求一个区间内的最大值和每次数过去最大值更新的次数,然后求每次的这个值异或 i 的总和. 这个序列一共有n个数,前k个直接给出来,从k+1到n个数用公式计算出来. 因为要最大值,所以就要用到单调队列, ...
- hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3 A)
链接: http://acm.hdu.edu.cn/showproblem.php?pid=6319 思路: 单调队列倒着维护,队列里面剩下的值的数量就是这一段区间的count值,如样例第一个区间:3 ...
- HDU 6319.Problem A. Ascending Rating-经典滑窗问题求最大值以及COUNT-单调队列 (2018 Multi-University Training Contest 3 1001)
2018 Multi-University Training Contest 3 6319.Problem A. Ascending Rating 题意就是给你长度为k的数列,如果数列长度k<n ...
- HDU 2018 Multi-University Training Contest 3 Problem A. Ascending Rating 【单调队列优化】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6319 Problem A. Ascending Rating Time Limit: 10000/500 ...
- ( 2018 Multi-University Training Contest 2)
2018 Multi-University Training Contest 2) HDU 6311 Cover HDU 6312 Game HDU 6313 Hack It HDU 6314 Mat ...
- HDU 3861 The King’s Problem 最小路径覆盖(强连通分量缩点+二分图最大匹配)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3861 最小路径覆盖的一篇博客:https://blog.csdn.net/qq_39627843/ar ...
- HDU 4897 Little Devil I(树链剖分)(2014 Multi-University Training Contest 4)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4897 Problem Description There is an old country and ...
- HDU 2037 今年暑假不AC ( 起始与终止时间 【贪心】)
今年暑假不AC Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- 【HDU 5833】Zhu and 772002(异或方程组高斯消元)
300个最大质因数小于2000的数,选若干个它们的乘积为完全平方数有多少种方案. 合法方案的每个数的质因数的个数的奇偶值异或起来为0. 比如12=2^2*3,对应的奇偶值为01(2的个数是偶数为0,3 ...
随机推荐
- [Usaco2005 Dec]Cleaning Shifts 清理牛棚
题目描述 Farmer John's cows, pampered since birth, have reached new heights of fastidiousness. They now ...
- performSelector: 与 dispatch_time 异同
iOS中timer相关的延时调用,常见的有NSObject中的performSelector:withObject:afterDelay:这个方法在调用的时候会设置当前runloop中timer,还有 ...
- 在react里面使用jquery插件
在react里面使用jquery插件 背景: 虽然现在react,vue等框架开启了前端开发的新篇章, 但对于一些比较复杂的页面,比如想在项目里面生成 组织架构图,人员汇报关系等还是需要用到之前的 j ...
- netstat 参数
Netstat用于显示与IP.TCP.UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况. NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] ...
- ffmpeg 编码h264 profile如何设置为baseline的问题
http://blog.csdn.net/kisaa133/article/details/7792008 使用最新版ffmpeg-0.11 libx264-125,使用默认编码时,用Eyecard发 ...
- HTML预览 正则替换
1. [代码][PHP]代码 <?php if(!defined('BASEPATH')) exit('No direct script access allowed'); /** ...
- php排序方法之快速排序
$arr = array(3,55,45,2,67,76,6.7,-65,85,4); function quickSort($arr){ if (count($arr) <= 1){ retu ...
- AC自动机-题目集合
AC自动机-题目集合 模板 如果你想要学习AC自动机,推荐一些学习资料. 学习可以看这篇博客 http://blog.csdn.net/niushuai666/article/details/7002 ...
- 【CQ18高一暑假前挑战赛3】标程
[A:LCM] #include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll a,b, ...
- hadoop应用场景
大数据量存储:分布式存储 日志处理: Hadoop擅长这个 海量计算: 并行计算 ETL:数据抽取到oracle.mysql.DB2.mongdb及主流数据库 使用HBase做数据分析: 用扩展性应对 ...