#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)的更多相关文章

  1. HDU 6319 Problem A. Ascending Rating(单调队列)

    要求一个区间内的最大值和每次数过去最大值更新的次数,然后求每次的这个值异或 i 的总和. 这个序列一共有n个数,前k个直接给出来,从k+1到n个数用公式计算出来. 因为要最大值,所以就要用到单调队列, ...

  2. hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3 A)

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=6319 思路: 单调队列倒着维护,队列里面剩下的值的数量就是这一段区间的count值,如样例第一个区间:3 ...

  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 ...

  4. 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 ...

  5. ( 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 ...

  6. HDU 3861 The King’s Problem 最小路径覆盖(强连通分量缩点+二分图最大匹配)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3861 最小路径覆盖的一篇博客:https://blog.csdn.net/qq_39627843/ar ...

  7. 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 ...

  8. HDU 2037 今年暑假不AC ( 起始与终止时间 【贪心】)

    今年暑假不AC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  9. 【HDU 5833】Zhu and 772002(异或方程组高斯消元)

    300个最大质因数小于2000的数,选若干个它们的乘积为完全平方数有多少种方案. 合法方案的每个数的质因数的个数的奇偶值异或起来为0. 比如12=2^2*3,对应的奇偶值为01(2的个数是偶数为0,3 ...

随机推荐

  1. ABAP抓取异常 try ,endtry.

    DATA: O_CX TYPE REF TO CX_ROOT. TRY . MOVE LS_UPLOAD-MENGE TO LS_OUTPUT-MENGE. CATCH CX_ROOT INTO O_ ...

  2. [数据挖掘课程笔记]Naïve Bayesian Classifier

    朴素贝叶斯模型 1) X:一条未被标记的数据 2) H:一个假设,如H=X属于Ci类 根据贝叶斯公式 把X表示为(x1,x2,....xn) x1,x2,....xn表示X在各个特征上的值. 假设有c ...

  3. php常用加密函数总结

    $var = 123; /** * md5 加密(单项加密.不可逆) * param $var 需要加密的变量(int\float\string\bool\null),资源类型(resource)和复 ...

  4. Android Weekly Notes Issue #241

    Android Weekly Issue #241 January 22nd, 2017 Android Weekly Issue #241 本期内容包括: 经典导航模式Master/Detail的设 ...

  5. lvs+keepalived+nginx高性能负载均衡集群

    项目发布时候,别人还能访问呢? 双机主从热备 LVS作用 LVS是一个开源的软件,可以实现传输层四层负载均衡.LVS是Linux Virtual Server的缩写,意思是Linux虚拟服务器.目前有 ...

  6. ibatis 优点,未完版

    iBatis是Apache的一个开源项目,一个O/R Mapping(???)解决方案,iBatis最大的特点就是小巧,上手很快,如果不需要太多复杂的功能,ibatis是能满足你得要求又足够灵活的最简 ...

  7. poj图论解题报告索引

    最短路径: poj1125 - Stockbroker Grapevine(多源最短路径,floyd) poj1502 - MPI Maelstrom(单源最短路径,dijkstra,bellman- ...

  8. POJ 3764 The xor-longest( 树上异或前缀和&字典树求最大异或)

    In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edg ...

  9. bzoj 1086 [SCOI2005]王室联邦——思路

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1086 于是去看了题解. 要回溯的时候再把自己加进栈里判断.这样才能保证剩下的可以通过自己连到 ...

  10. HDU1083(最大匹配)

    Courses Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total S ...