結果

問題 No.2742 Car Flow
ユーザー butsurizukibutsurizuki
提出日時 2024-04-21 03:38:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,889 bytes
コンパイル時間 3,271 ms
コンパイル使用メモリ 273,636 KB
実行使用メモリ 20,096 KB
最終ジャッジ日時 2024-04-21 03:38:15
合計ジャッジ時間 6,199 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
19,712 KB
testcase_01 AC 32 ms
19,840 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 35 ms
19,968 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 27 ms
19,840 KB
testcase_13 AC 26 ms
19,840 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 31 ms
19,968 KB
testcase_18 AC 22 ms
19,712 KB
testcase_19 WA -
testcase_20 AC 24 ms
19,712 KB
testcase_21 WA -
testcase_22 AC 30 ms
19,968 KB
testcase_23 AC 32 ms
19,840 KB
testcase_24 AC 26 ms
19,840 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 25 ms
19,840 KB
testcase_28 WA -
testcase_29 AC 22 ms
19,712 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 33 ms
19,968 KB
testcase_33 AC 31 ms
19,968 KB
testcase_34 AC 25 ms
19,840 KB
testcase_35 AC 23 ms
19,968 KB
testcase_36 WA -
testcase_37 AC 25 ms
19,712 KB
testcase_38 AC 28 ms
19,840 KB
testcase_39 WA -
testcase_40 AC 21 ms
19,968 KB
testcase_41 AC 21 ms
19,840 KB
testcase_42 AC 21 ms
19,840 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 21 ms
19,840 KB
testcase_46 WA -
testcase_47 AC 22 ms
19,968 KB
testcase_48 AC 21 ms
19,712 KB
testcase_49 AC 21 ms
19,968 KB
testcase_50 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// Counting Template
#include<bits/stdc++.h>

using namespace std;

#define mod 998244353
#define FACSIZE 1048576

long long power(long long a,long long b){
  long long x=1,y=a;
  while(b>0){
    if(b&1ll){
      x=(x*y)%mod;
    }
    y=(y*y)%mod;
    b>>=1;
  }
  return x%mod;
}

long long modular_inverse(long long n){
  return power(n,mod-2);
}

long long factorial[FACSIZE];
long long invfact[FACSIZE];

void cfact(){
  long long i;
  factorial[0]=1;
  factorial[1]=1;
  for(i=2;i<FACSIZE;i++){
    factorial[i]=factorial[i-1]*i;
    factorial[i]%=mod;
  }
  invfact[FACSIZE-1]=modular_inverse(factorial[FACSIZE-1]);
  for(i=FACSIZE-2;i>=0;i--){
    invfact[i]=invfact[i+1]*(i+1);
    invfact[i]%=mod;
  }
}

long long calcnCr(long long n,long long k){
  if(k<0 || n<k){return 0;}
  return (factorial[n]*((invfact[k]*invfact[n-k])%mod))%mod;
}

long long solve(){
  long long n;
  cin >> n;
  long long p=0,q=0;
  for(long long i=0;i<n;i++){
    long long a;
    cin >> a;
    p+=a;
    q++;
  }
  return (p*modular_inverse(q))%mod;
}

int main(){
  cfact();
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t=1;
  // cin >> t;
  while(t>0){
    t--;
    cout << solve()%mod << "\n";
  }
  return 0;
}

// #include<bits/stdc++.h>
//
// using namespace std;
//
// vector<int> f(vector<int> &a){
//   int n=a.size();
//   vector<int> res;
//   for(int i=0;i<n;i++){
//     if(a[(i+n-1)%n]==1 && a[i]==0){
//       res.push_back(1);
//       continue;
//     }
//     else if(a[i]==1 && a[(i+1)%n]==1){
//       res.push_back(1);
//       continue;
//     }
//     else{
//       res.push_back(0);
//     }
//   }
//   return res;
// }
//
// int main(){
//   ios::sync_with_stdio(false);
//   cin.tie(nullptr);
//   vector<int> a={1,1,0};
//   for(int tr=0;tr<10;tr++){
//     for(auto &nx : a){cout << nx << " ";}
//     cout << "\n";
//     a=f(a);
//   }
//   return 0;
// }
0