码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-07-31 00:39:00      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:std   hdu   set   asc   ble   long   +=   signed   false   

 1 #include <stdio.h>
 2 #include <iostream>
 3 #include <cstdlib>
 4 #include <cmath>
 5 #include <string>
 6 #include <cstring>
 7 #include <algorithm>
 8 #include <stack>
 9 #include <queue>
10 #include <set>
11 #include <map>
12 #include <vector>
13 using namespace std;
14 typedef long long ll;
15 typedef unsigned long long ull;
16 
17 #define Faster ios::sync_with_stdio(false),cin.tie(0)
18 #define Read freopen("in.txt", "r", stdin),freopen("out.txt", "w", stdout)
19 const int INF = 0x3f3f3f3f;
20 const int maxn = 1e7 + 5;
21 
22 ll n, m, k, p, q, MOD, r;
23 ll a[maxn];
24 ll b[maxn];
25 
26 int main() 
27 {
28     Faster;
29     int T;
30     cin >> T;
31     while(T--){
32         cin >> n >> m >> k >> p >> q >> r >> MOD;
33         for(int i = 1;i <= n;i++){
34             if(i <= k){
35                 cin >> a[i];
36             }
37             else{
38                 a[i] = (p*a[i-1] + q*i + r)%MOD;
39             }
40         }
41         ll cnt, ans;
42         cnt = ans = 0;
43         for(int h = 1, t = 0, i = n;i >= 1;i--){
44             while(h <= t && a[b[t]] <= a[i]) t--;
45             b[++t] = i;
46             if(i+m-1 <= n){
47                 while(b[h] >= i+m) h++;
48                 ans += i^a[b[h]];
49                 cnt += i^(t-h+1);
50             }
51         }
52         cout << ans << " " << cnt << endl;
53     }
54     return 0;
55 }

 

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

标签:std   hdu   set   asc   ble   long   +=   signed   false   

原文地址:https://www.cnblogs.com/jaydenouyang/p/9393454.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!