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 ...
随机推荐
- 删除SVN账号
删除里面的所有文件 C:\Users\Administrator\AppData\Roaming\Subversion\auth
- linux apache服务器
apache服务器 服务端功能是侦听和响应客户端的http请求.http协议的默认端口是80. 1996年以来,apache成为最流行的web服务器. IIS web服务器只能安装在windows上. ...
- cannot find -lbz2 解决方法
sudo yum install -y bzip2* 或者sudo apt-get install bzip2* 还是报错就找到libbz2.so.1,建立连接或者复制到 /usr/lib/libbz ...
- double转int时精度不一致问题
float和double类型的主要设计目的是为了科学计算和工程计算.它们执行二进制浮点运算,这是为了在广域数值范围上提供较为精确的快速近似计算而精心设计的.然而,它们没有提供完全精确的结果,所以不应该 ...
- 数据库之Oracle
数据库之Oracle 一. 用户的管理 1. 用户就是好比公司的某个人,而权限是这个人能在公司做什么,他的角色就是说明他的职位. 2. 用户的权限分为: 系统权限:对别的用户的管理操作. 对象权限:对 ...
- Android终端管理器删除文件夹
终端管理器删除文件夹不能用网上提供的: rm -rf 文件夹名 而要用: rm -r 文件夹名. http://blog.csdn.net/enhancing/article/details/8490 ...
- 【EOJ Monthly 2018.2 (Good bye 2017)】
23333333333333333 由于情人节要回家,所以就先只放代码了. 此题是与我胖虎过不去. [E. 出老千的 xjj] #include<cstdio> #include<c ...
- 算法实现c语言--03
实现 mystrcpy(), mystrcmp(), mystrcat(), mystrlen() ; #include<stdio.h> #include<stdlib.h> ...
- MTK USB 子系统
一.USB 子系统初始化 1. kernel/drivers/usb/core/usb.c subsys_initcall(usb_init); static int __init usb_init( ...
- 21.java方法详解
public class MethondTest07{ //入口 public static void main(String[] args){ A.m1(); //error:若方法名字的前面什么都 ...