結果

問題 No.1383 Numbers of Product
ユーザー chocoruskchocorusk
提出日時 2021-02-07 21:32:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 610 ms / 2,000 ms
コード長 1,731 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 136,092 KB
実行使用メモリ 68,224 KB
最終ジャッジ日時 2024-05-02 10:18:08
合計ジャッジ時間 18,108 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 352 ms
43,136 KB
testcase_08 AC 337 ms
42,624 KB
testcase_09 AC 424 ms
51,968 KB
testcase_10 AC 571 ms
67,584 KB
testcase_11 AC 578 ms
66,560 KB
testcase_12 AC 565 ms
67,328 KB
testcase_13 AC 564 ms
64,768 KB
testcase_14 AC 462 ms
55,424 KB
testcase_15 AC 374 ms
45,440 KB
testcase_16 AC 584 ms
66,816 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 9 ms
5,376 KB
testcase_29 AC 485 ms
53,120 KB
testcase_30 AC 599 ms
68,096 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 110 ms
16,640 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 524 ms
62,464 KB
testcase_36 AC 506 ms
60,032 KB
testcase_37 AC 578 ms
68,224 KB
testcase_38 AC 576 ms
68,224 KB
testcase_39 AC 595 ms
68,224 KB
testcase_40 AC 597 ms
68,224 KB
testcase_41 AC 596 ms
68,224 KB
testcase_42 AC 610 ms
68,224 KB
testcase_43 AC 593 ms
68,224 KB
testcase_44 AC 587 ms
68,224 KB
testcase_45 AC 588 ms
68,224 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 571 ms
66,688 KB
testcase_48 AC 567 ms
67,200 KB
testcase_49 AC 593 ms
67,968 KB
testcase_50 AC 584 ms
67,840 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    ll n, k, M; cin>>n>>k>>M;
    using lll=__int128_t;
    map<ll, int> mp;
    for(int i=2; i<=19; i++){
        int myon=0;
        for(lll a=1; ; a++){
            lll p=1;
            for(lll j=0; j<=i; j++){
                p*=(a+j*k);
                if(p>n){
                    p=n+1;
                    break;
                }
            }
            if(p==n+1){
                myon=a;
                break;
            }
            mp[p]^=(1<<i);
        }
        if(myon==1) break;
    }
    int c=0;
    for(auto &p:mp){
        ll x=p.first;
        ll l=0, r=1e9;
        while(r-l>1){
            lll m=(l+r)/2;
            if(m*(m+k)>=x) r=m;
            else l=m;
        }
        if((lll)r*(r+k)==x){
            p.second^=2;
            c++;
        }
    }
    if(M>=2){
        int ans=0;
        for(auto p:mp){
            if(popcount(p.second)==M) ans++;
        }
        cout<<ans<<endl;
        return 0;
    }
    ll l=0, r=1e9;
    while(r-l>1){
        lll m=(l+r)/2;
        if(m*(m+k)<=n) l=m;
        else r=m;
    }
    ll ans=l-c;
    for(auto p:mp){
        if(popcount(p.second)==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}
0