結果
| 問題 |
No.2381 Gift Exchange Party
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-15 01:25:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 2,000 ms |
| コード長 | 348 bytes |
| コンパイル時間 | 3,987 ms |
| コンパイル使用メモリ | 252,712 KB |
| 最終ジャッジ日時 | 2025-02-15 14:55:58 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d%d",&n,&p);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using mint=atcoder::modint998244353;
using namespace std;
int main(){
int n,p;
scanf("%d%d",&n,&p);
vector<mint> fac(n+1);
fac[0]=1;
for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i;
mint ans=fac[n];
for(int i=0;i<=n/p;i++){
ans-=fac[n]/mint(p).pow(i)/fac[i]/fac[n-p*i];
}
printf("%d\n",ans.val());
}