結果

問題 No.1809 Divide NCK
ユーザー umezo
提出日時 2022-01-27 02:32:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 9,575 ms
コンパイル使用メモリ 454,356 KB
最終ジャッジ日時 2025-01-27 15:31:21
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  Bint n,k,m;
  cin>>n>>k>>m;
  
  Bint ans=0;
  Bint t=m;
  while(n/t>=1){
    ans+=n/t;
    t*=m;
  }
  t=m;
  while(k/t>=1){
    ans-=k/t;
    t*=m;
  }
  t=m;
  while((n-k)/t>=1){
    ans-=(n-k)/t;
    t*=m;
  }
  cout<<ans<<endl;
  
  return 0;
}
0