# 2017CCPC杭州题解(持续更新)

2017CCPC 杭州

比赛

Problem A. Super-palindrome

在这里插入图片描述

#include <bits/stdc++.h>

using namespace std;
int vis[30];
int vis1[30];

int main() {
    int T;
    cin >> T;
    while (T--) {
        memset(vis, 0, sizeof(vis));
        memset(vis1, 0, sizeof(vis1));
        string str;
        cin >> str;
        for (int i = 0; i < str.length(); i++) {
            if (i & 1) {
                vis1[str[i] - 'a']++;
            } else {
                vis[str[i] - 'a']++;
            }
        }
        sort(vis, vis + 26);
        sort(vis1, vis1 + 26);
        cout << str.length() - vis[25] - vis1[25] << endl;
    }
}

Problem B. Master of Phi

待补,我去问问我队友。
我不是很会推这个东西。

Problem C. Hakase and Nano

我出的博弈题!
变形的Nim。
就是每次可选择其中1堆石子取≥1颗石头。
然后一个人作弊,连续操作两次。
给你石子情况和先手安排。

发现必败态是1 1 1的情况,如果轮到H(作弊的人)拿(d==1),就必输,当然轮N也一样是必败态,推广到3的倍数堆都只有1颗石子的石子堆都是必败态。

H先手,除非初始情况就是必败态。
其他情况都是H胜利。

N先手,除非能把H变为必败态,不然还是H胜利。

再打一次居然WA了一次…
在这里插入图片描述
少了一次

#include <bits/stdc++.h>

using namespace std;


int main() {
    int T;
    cin >> T;
    while (T--) {
        int n, x;
        cin >> n;
        int d;
        cin >> d;
        int cnt1 = 0;
        for (int i = 0; i < n; i++) {
            cin >> x;
            if (x == 1)cnt1++;
        }
        if (d == 1) {
            //H
            if (n % 3 == 0 && cnt1 == n)
                cout << "No" << endl;
            else cout << "Yes" << endl;
        } else {
            //N
            if (n % 3 == 0 && cnt1 == n - 1)
                cout << "No" << endl;
            else if (n % 3 == 1 && cnt1 == n - 1)
                cout << "No" << endl;
            else if (n % 3 == 1 && cnt1 == n)
                cout << "No" << endl;
            else
                cout << "Yes" << endl;
        }
    }
}

Problem D. Master of Random

式子题,我再推一次看看。
题解明天写,绷不住了。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
ll qpow(ll a, int b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
ll inv[100010];
int main()
{
    int t;
    for (int i = 1; i <= 100000; i++)
        inv[i] = qpow(i, mod - 2);
    scanf("%d", &t);
    while (t--)
    {
        int n;
        scanf("%d", &n);
        ll pre = 0;
        ll ans = 0;
        for (int i = 1; i <= n; i++)
        {
            ll x;
            scanf("%lld", &x);
            ll now = pre * inv[i - 1] % mod + 1;
            ans = (ans + now * x % mod * inv[n] % mod) % mod;
            pre = (pre+now)%mod;
        }
        printf("%lld\n", ans);
    }
}
/*
2
2
1 1
3 
1 2 3
*/

Problem J. Master of GCD

待补

Problem K. Master of Sequence

待补

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值