結果
| 問題 |
No.1809 Divide NCK
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2022-01-27 02:28:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 532 bytes |
| コンパイル時間 | 2,314 ms |
| コンパイル使用メモリ | 191,072 KB |
| 最終ジャッジ日時 | 2025-01-27 15:30:51 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 22 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k,m;
cin>>n>>k>>m;
ll ans=0;
ll t=m;
while(n/t>=1){
ans+=n/t;
if(t>n/m) break;
t*=m;
}
t=m;
while(k/t>=1){
ans-=k/t;
if(t>k/m) break;
t*=m;
}
t=m;
while((n-k)/t>=1){
ans-=(n-k)/t;
if(t>(n-k)/m) break;
t*=m;
}
cout<<ans<<endl;
return 0;
}
umezo