atcoderABC414复盘

· · 个人记录

昨天打了一场ABC,太久没打了(主要是比赛能力不行),C题起做没一道做出来,C22AC11TLE,D未提交,E赛后1分钟提交51AC5WA,FG未提交,实际总分0分,折算部分分(含赛后1分钟提交的E):22/(22+11)350+0+51/(51+5)475+0+0=665.9。

赛后复盘:

C题太奇葩,后来补了一个32AC1TLE的,跟正解算法一样,然而实现如果一样全TLE,用我的加速实现法32AC1TLE,不知道他怎么AC的(有知道的可以告诉我)。当然他的构造法比我快,我用的构造法是a-回文-a是构造,以0,1,2,3,4,5,6,7,8,9,00,11,22,33,44,55,66,77,88,99为基础回文,他用的是aa法和a拼接a.substr(0,a.length() - 1)来构造,a从1枚举到999999(10^6-1)。 32AC1TLE代码

#include<bits/stdc++.h>
const std::string E = "";
typedef long long ll;
int a;ll n,ans;
std::string toA(ll x){
    std::string s = E;
    if (x >= a) s = toA(x / a);
    return s + (char)(x % a + '0');
}
int main(){
    std::cin.tie(0)->sync_with_stdio(0);
    std::cin >> a >> n;
    for (int i = 1;i <= 999999;i++){
        {
            std::string s = std::to_string(i);
            std::string str = s;
            std::reverse(s.begin(),s.end());
            str += s;ll x;
            std::stringstream scin(str);scin >> x;
            if (x <= n){
                std::string str2 = toA(x);
                for (int i = 0,j = str2.length() - 1;i < j;i++,j--)
                    if (str2[i] != str2[j]) goto nxt;
                ans += x;
            }
        }
        nxt:{
            std::string s = std::to_string(i);
            std::string str = s;
            std::reverse(s.begin(),s.end());
            str += s.substr(1,s.length() - 1);ll x;
            std::stringstream scin(str);scin >> x;
            if (x <= n){
                std::string str2 = toA(x);
                for (int i = 0,j = str2.length() - 1;i < j;i++,j--)
                    if (str2[i] != str2[j]) goto nxt2;
                ans += x;nxt2:;
            }
        }
    }
    std::cout << ans << '\n';
    return 0;
}

E题至今不知道怎么WA到(有知道的可以告诉我),但是我觉得这道题有两个可以总结的,对于这种枚举abc的题目,且当ab固定时c固定的情况,可以直接记所有ab最后减不合法,比如本题就是减掉整除。ps:分块除法是蓝题,所以本题至少蓝,也让我了解了ABC的难度(C黄/绿,DE绿/蓝) 51AC5WA代码:

#include<bits/stdc++.h>
typedef long long ll;
const int N = 5e5 + 5,mod = 998244353;
int qpow(int a,int b){
    int res = 1;
    for (;b;b >>= 1){
        if (b & 1) res = 1LL * res * a % mod;
        a = 1LL * a * a % mod;
    }
    return res;
}
int main(){
    std::cin.tie(0)->sync_with_stdio(0);
    ll n;std::cin >> n;
    ll ans = n % mod * ((n - 2) % mod) % mod - (n + 1) % mod * ((n - 2) % mod) % mod * qpow(2,mod - 2) % mod + (n - 2) % mod;
    ans %= mod;
    ll tmp = 0;
    for (ll i = 1;i <= n;){
        ll k = n / i,r = n / k;
        ans = (ans - k % mod * ((r - i + 1) % mod) % mod) % mod;
        i = r + 1;
    }
    std::cout << (ans + n + 1) % mod << '\n';
    return 0;
}