結果
問題 |
No.1809 Divide NCK
|
ユーザー |
|
提出日時 | 2024-09-07 11:43:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 877 bytes |
コンパイル時間 | 1,213 ms |
コンパイル使用メモリ | 112,348 KB |
最終ジャッジ日時 | 2025-02-24 05:07:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 22 |
ソースコード
#include<iostream> #include<string> #include<queue> #include<vector> #include<cassert> #include<random> #include<set> #include<map> #include<cassert> #include<unordered_map> #include<bitset> #include<numeric> #include<algorithm> using namespace std; typedef long long ll; const int inf=1<<30; const ll INF=1LL<<62; typedef pair<int,ll> P; typedef pair<int,P> PP; const ll MOD=998244353; const int dy[]={0,1,0,-1}; const int dx[]={1,0,-1,0}; int main(){ ll N,K,M; cin>>N>>K>>M; auto divide=[&](ll n,ll k){ //n!は kで何回割れるか? ll res=0; while(n>0){ res+=n/k; n/=k; } return res; }; ll ans=0; ans+=divide(N,M);//N!はMで何回割れるか? ans-=divide(K,M);//K!はMで何回割れるか? ans-=divide(N-K,M);//(N-K)!はMで何回割れるか? cout<<ans<<endl; }