QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582147#7927. Fortune TellingqwerasdfCompile Error//C++201.9kb2024-09-22 15:29:312024-09-22 15:29:31

Judging History

你现在查看的是最新测评结果

  • [2024-09-22 15:29:31]
  • 评测
  • [2024-09-22 15:29:31]
  • 提交

answer

#include <atcoder/math>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder; //https://github.com/atcoder/ac-library

#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define bit(n, k) ((n >> k) & 1)
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> pii;

int get1(int n, int r){
    // 0,...,n-1
    int remove=(n-1)/6;
    if((n-1)%6>=r)remove++;
    return n-remove;
}

int get2(int k,int r){
    // 0,...,k
    int remove=k/6;
    if(k%6>=r)remove++;
    return k-remove;
}

void test_case(int tt){
    int n; cin>>n;
    map<pii,ll> dp;
    
    const int mod=998244353;
    ll six=inv_mod(6,998244353);
    //rep(i,2,7)cout<<inv_mod(i,998244353)<<'\n';
    //cout<<six<<'\n';
    dp[{1,0}]=1;
    function<ll(int,int)> solve=[&](int N, int k)->ll {
        if(N==0 || k>=N)return ll(0);
        if(dp.count({N,k})>0)return dp[{N,k}];
        ll &ret=dp[{N,k}];
        ret=0;
        if(N<6){
            //rep(i,0,n)cout<<N<<' '<<k<<' '<<i<<' '<<get(N,i)<<' '<<get(k,i)<<'\n';
            rep(i,0,N){
                if(k%6!=i%6){
                    ret=(ret+solve(get1(N,i),get2(k,i)))%mod;
                }
            }
            ret=(ret*inv_mod(N,998244353))%mod;
            //cout<<N<<' '<<k<<' '<<ret<<'\n';
            return ret;
        }
        // rep(i,0,6){
        //     if(k%6!=i%6){
        //         cout<<N<<' '<<k<<' '<<i<<' '<<get1(N,i)<<' '<<get2(k,i)<<'\n';
        //     }
        // }
        rep(i,0,6){
            if(k%6!=i%6){
                ret=(ret+(solve(get1(N,i),get2(k,i))*six%mod))%mod;
            }
        }
        //cout<<N<<' '<<k<<' '<<ret<<'\n';
        return ret;
    };
    rep(i,0,n)cout<<solve(n,i)<<'\n';
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    //cin>>t;
    rep(i, 1, t + 1)
    {
        test_case(i);
    }
    return 0;
}

詳細信息

answer.code:1:10: fatal error: atcoder/math: No such file or directory
    1 | #include <atcoder/math>
      |          ^~~~~~~~~~~~~~
compilation terminated.