結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー Nzt3Nzt3
提出日時 2022-11-27 21:17:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 195,852 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 02:57:39
合計ジャッジ時間 2,437 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,948 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
void ch(long long &a,long long b){
  a=(a+b)%mod;
}

long long fac[3001];
long long inv[3001];
long long invf[3001];

long long modcomb(int a,int n){
  return fac[a]*invf[n]%mod*invf[a-n]%mod;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  fac[0]=inv[0]=invf[0]=1;
  fac[1]=inv[1]=invf[1]=1;
  for(int i=2;i<3001;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
    invf[i]=invf[i-1]*inv[i]%mod;
  }
  long long p25[3001];
  p25[0]=1;
  for(int i=1;i<3001;i++){
    p25[i]=p25[i-1]*25%mod;
  }
  long long ans=0;
  for(int i=0;i<=N;i++){
    ch(ans,(i/3)*p25[N-i]%mod*modcomb(N,i));
  }
  cout<<ans<<'\n';
}
0