提出 #34624129


ソースコード 拡げる

#include <bits/stdc++.h>
#include <atcoder/modint>
using mint = atcoder::modint998244353;
#define rep(i,a,n) for (int i=a;i<(int )n;i++)
int read(){int r;scanf("%d",&r);return r;} // read

mint a[1010];
mint f[1010][1010]; // [0~n个][选0~n个] = 乘积的和
int main(){
  int n = read();
  int k = read();
  rep(i,0,n) a[i] = read();
  f[0][0]=1;
  // dp[i+1][j] = dp[i][j] + dp[i][j-1]A_{i+1}
  rep(i,1,n+1) rep(j,0,i+1) f[i][j] = f[i-1][j] + (j?f[i-1][j-1]*a[i-1]:0);
  mint c=0;
  mint x=mint(1)/n;
  mint fac=1;
  rep(j,0,std::min(n,k)+1) {
    c+=f[n][n-j]*fac;
    fac*=x*(k-j);
  }
  printf("%d\n",c.val());
  return 0;
}

提出情報

提出日時
問題 G - Balls in Boxes
ユーザ cromarmot
言語 C++ (GCC 9.2.1)
得点 600
コード長 632 Byte
結果 AC
実行時間 16 ms
メモリ 7820 KiB

コンパイルエラー

./Main.cpp: In function ‘int read()’:
./Main.cpp:5:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    5 | int read(){int r;scanf("%d",&r);return r;} // read
      |                  ~~~~~^~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 3
AC × 35
セット名 テストケース
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, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 14 ms 7652 KiB
random_02.txt AC 10 ms 7692 KiB
random_03.txt AC 11 ms 7684 KiB
random_04.txt AC 10 ms 7796 KiB
random_05.txt AC 11 ms 7688 KiB
random_06.txt AC 14 ms 7608 KiB
random_07.txt AC 12 ms 7608 KiB
random_08.txt AC 9 ms 7684 KiB
random_09.txt AC 13 ms 7792 KiB
random_10.txt AC 9 ms 7792 KiB
random_11.txt AC 16 ms 7556 KiB
random_12.txt AC 12 ms 7608 KiB
random_13.txt AC 13 ms 7792 KiB
random_14.txt AC 10 ms 7696 KiB
random_15.txt AC 16 ms 7688 KiB
random_16.txt AC 15 ms 7792 KiB
random_17.txt AC 13 ms 7556 KiB
random_18.txt AC 7 ms 7580 KiB
random_19.txt AC 11 ms 7732 KiB
random_20.txt AC 8 ms 7688 KiB
random_21.txt AC 9 ms 7696 KiB
random_22.txt AC 9 ms 7580 KiB
random_23.txt AC 10 ms 7652 KiB
random_24.txt AC 6 ms 7736 KiB
random_25.txt AC 12 ms 7656 KiB
random_26.txt AC 8 ms 7608 KiB
random_27.txt AC 12 ms 7696 KiB
random_28.txt AC 7 ms 7820 KiB
random_29.txt AC 10 ms 7792 KiB
random_30.txt AC 9 ms 7604 KiB
random_31.txt AC 12 ms 7692 KiB
random_32.txt AC 6 ms 7736 KiB
sample_01.txt AC 7 ms 7700 KiB
sample_02.txt AC 7 ms 7684 KiB
sample_03.txt AC 8 ms 7564 KiB