結果

問題 No.1809 Divide NCK
ユーザー reg7777
提出日時 2022-01-14 21:53:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 709 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 169,336 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-20 09:46:48
合計ジャッジ時間 2,329 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD1 1000000007
#define MOD2 998244353
#define MOD MOD1
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N,K,M;
    cin>>N>>K>>M;
    int n=64;
    vector<int>a(n);
    int d=M;
    for(int i=1;i<n;i++){
        int nd=N/d;
        int nkd=(N-K)/d;
        int kd=K/d;
        a[i]=nd-nkd-kd;
        if(1.*d>1.*N/M)break;
        d*=M;
    }
    int ans=0;
    for(int i=0;i<n;i++)ans+=a[i];
    cout<<ans<<endl;

    return 0;
}
0