题解报告(CDUT暑期集训——第三场)

题解报告(CDUT暑期集训——第三场)


A - Problem A. Ascending Rating

HDU - 6319

  • 思路:单调队列板子题?(但是弱的一批的我还是不会用(有空补上 用的滑动窗口算法 按着题解的从后往前做(ps:菜是原罪

  • AC代码


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

const int N = 10000010;

int t;
ll n, m, k, p, q, r, mod;
ll a[N], b[N], c[N];

void calc(){
    ll l = 0, r = 0, tot = 0, t_ = n, tmp = 0;
    ll cnt = 0, ans = 0;
    b[0] = 0;
    c[0] = 0;
    for (int i = n; i >= 1; i -- ){
        tot ++;
        if (i == n){
            c[r] = i;
            b[r ++] = a[i];
            if (m == 1){
                tmp ++;
                ans = b[l] ^ (t_ - m + 1);
                cnt = (r - l) ^ (t_ - m + 1);
                t_ --;
            }
            continue;
        }
        if (tot > m){
            tot --;
            while (r > l && c[l] >= n - tmp + 1) l ++;
        }
        if (a[i] < b[r - 1] || r == l){
            c[r] = i;
            b[r ++] = a[i];
        }
        else{
            while (r > l && a[i] >= b[r - 1]) r --;
            c[r] = i;
            b[r ++] = a[i];
        }
        if (tot == m){
            ans += b[l] ^ (t_ - m + 1);
            cnt += (r - l) ^ (t_ - m + 1);
            tmp ++;
            t_ --;
        }
    }
    printf("%lld %lld\n", ans, cnt);
}

int main(){
    scanf("%d", &t);
    while (t -- ){
        scanf("%lld%lld%lld%lld%lld%lld%lld", &n, &m, &k, &p, &q, &r, &mod);
        for (int i = 1; i <= n; i ++ ){
            if (i <= k) scanf("%lld", &a[i]);
            else a[i] = ((p * a[i - 1] + q * i + r) % mod + mod) % mod;
            b[i] = 0;
            c[i] = 0;
        }
        calc();
    }
    return 0;
}

D - Problem D. Euler Function

HDU - 6322

  • 思路:打表秒出规律 没啥说的

  • AC代码


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<vector>
#include<stack>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

int t, k;

int main(){
    scanf("%d", &t);
    while (t -- ){
        scanf("%d", &k);
        if (k == 1) printf("%d\n", 5);
        else printf("%d\n", k + 5);
    }
    return 0;
}

F - Problem F. Grab The Tree

HDU - 6324

  • 思路:简单思维题+博弈(?)

  • AC代码


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<vector>
#include<stack>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

const int N = 100010;

int t, n, x, y, tmp, cnt;

int main(){
    scanf("%d", &t);
    while (t -- ){
        scanf("%d", &n);
        scanf("%d", &tmp);
        cnt = tmp;
        for (int i = 1; i < n; i ++ ){
            scanf("%d", &tmp);
            cnt ^= tmp;
        }
        for (int i = 1; i < n; i ++ )
            scanf("%d%d", &x, &y);
        if (cnt) printf("Q\n");
        else printf("D\n");
    }
    return 0;
}

L - Problem L. Visual Cube

HDU - 6330

  • 思路:水题 画图即可(水题我都wa了一发 还交成A交错了一发(菜是原罪

  • AC代码


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<vector>
#include<stack>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

const int N = 100;

int t, a, b, c;
char ans[100][100];

void draw(int a, int b, int c){
    for (int i = 0; i < 2 * b; i ++ ){
        for (int j = 2 * b - i; j < 2 * (a + b) - i + 1; j ++ ){
            if (i & 1){
                if (j & 1) ans[i][j] = '/';
            }
            else{
                if (j & 1) ans[i][j] = '-';
                else ans[i][j] = '+';
            }
        }
    }
    for (int i = 2 * b; i < 2 * (b + c) + 1; i ++ ){
        for (int j = 0; j < 2 * a + 1; j ++ ){
            if (i & 1){
                if (!(j & 1)) ans[i][j] = '|';
            }
            else{
                if (j & 1) ans[i][j] = '-';
                else ans[i][j] = '+';
            }
        }
    }
    for (int i = 2 * (a + b); i >= 2 * a + 1; i -- ){
        for (int j = 2 * (a + b) - i; j < 2 * (a + b + c) - i + 1; j ++ ){
            if (i & 1){
                if (j & 1) ans[j][i] = '/';
            }
            else{
                if (j & 1) ans[j][i] = '|';
                else ans[j][i] = '+';
            }
        }
    }
    for (int i = 0; i < 2 * (b + c) + 1; i ++){
        for (int j = 0; j < 2 * (a + b) + 1; j ++ )
            printf("%c", ans[i][j]);
        printf("\n");
    }
}

int main(){
    scanf("%d", &t);
    while (t -- ){
        memset(ans, '.', sizeof(ans));
        scanf("%d%d%d", &a, &b, &c);
        draw(a, b, c);
    }
    return 0;
}
posted @ 2019-07-21 23:13  Misuchii  阅读(147)  评论(0编辑  收藏  举报