Submission #25619059


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/modint>
#include <atcoder/convolution>
using namespace std;
using mint=atcoder::modint998244353;
using atcoder::convolution;

mint fac(int n){
    static vector<mint> cache{1};
    while(cache.size()<=n)
        cache.push_back(cache.back()*cache.size());
    return cache[n];
}

mint ifac(int n){
    static vector<mint> cache{1};
    while(cache.size()<=n)
        cache.push_back(cache.back()/cache.size());
    return cache[n];
}

mint perm(int n,int m){
    if(n<m)return 0;
    return fac(n)*ifac(n-m);
}

int main(){
    int n,m;
    cin>>n>>m;
    int q=n/m,r=n%m;
    vector<mint> g(n+1);
    for(int k=1;k<=n;k++){
        g[k]=perm(k,q).pow(m-r)*perm(k,q+1).pow(r);
        g[k]*=ifac(k);
    }
    vector<mint> h(n+1);
    for(int i=0;i<=n;i++){
        h[i]=ifac(i);
        if(i%2)h[i]=-h[i];
    }
    vector<mint> f=convolution(g, h);
    for(int i=1;i<=n;i++)
        cout<<f[i].val()<<'\n';
}

Submission Info

Submission Time
Task G - Groups
User cai_lw
Language C++ (GCC 9.2.1)
Score 600
Code Size 996 Byte
Status AC
Exec Time 9 ms
Memory 3900 KiB

Compile Error

./Main.cpp: In function ‘mint fac(int)’:
./Main.cpp:10:23: warning: comparison of integer expressions of different signedness: ‘std::vector<atcoder::static_modint<998244353> >::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
   10 |     while(cache.size()<=n)
      |           ~~~~~~~~~~~~^~~
./Main.cpp: In function ‘mint ifac(int)’:
./Main.cpp:17:23: warning: comparison of integer expressions of different signedness: ‘std::vector<atcoder::static_modint<998244353> >::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
   17 |     while(cache.size()<=n)
      |           ~~~~~~~~~~~~^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 27
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 9 ms 3604 KiB
random_02.txt AC 3 ms 3604 KiB
random_03.txt AC 6 ms 3672 KiB
random_04.txt AC 8 ms 3744 KiB
random_05.txt AC 6 ms 3732 KiB
random_06.txt AC 8 ms 3724 KiB
random_07.txt AC 4 ms 3716 KiB
random_08.txt AC 5 ms 3696 KiB
random_09.txt AC 9 ms 3824 KiB
random_10.txt AC 2 ms 3736 KiB
random_11.txt AC 2 ms 3552 KiB
random_12.txt AC 7 ms 3748 KiB
random_13.txt AC 2 ms 3664 KiB
random_14.txt AC 2 ms 3632 KiB
random_15.txt AC 2 ms 3668 KiB
random_16.txt AC 4 ms 3688 KiB
random_17.txt AC 3 ms 3772 KiB
random_18.txt AC 4 ms 3692 KiB
random_19.txt AC 5 ms 3832 KiB
random_20.txt AC 8 ms 3844 KiB
random_21.txt AC 8 ms 3900 KiB
random_22.txt AC 5 ms 3708 KiB
random_23.txt AC 7 ms 3700 KiB
random_24.txt AC 6 ms 3816 KiB
sample_01.txt AC 1 ms 3584 KiB
sample_02.txt AC 2 ms 3632 KiB
sample_03.txt AC 2 ms 3528 KiB