結果

問題 No.1383 Numbers of Product
ユーザー chocoruskchocorusk
提出日時 2021-02-07 21:25:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,672 bytes
コンパイル時間 1,376 ms
コンパイル使用メモリ 136,028 KB
実行使用メモリ 68,300 KB
最終ジャッジ日時 2023-09-17 20:30:15
合計ジャッジ時間 19,609 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 382 ms
43,124 KB
testcase_08 AC 372 ms
42,568 KB
testcase_09 AC 470 ms
52,044 KB
testcase_10 AC 628 ms
67,536 KB
testcase_11 AC 615 ms
66,536 KB
testcase_12 AC 621 ms
67,344 KB
testcase_13 AC 597 ms
64,940 KB
testcase_14 AC 500 ms
55,256 KB
testcase_15 AC 402 ms
45,436 KB
testcase_16 AC 620 ms
66,836 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 8 ms
4,456 KB
testcase_29 AC 482 ms
53,168 KB
testcase_30 AC 633 ms
68,152 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 WA -
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 570 ms
62,820 KB
testcase_36 AC 544 ms
59,884 KB
testcase_37 AC 636 ms
68,224 KB
testcase_38 AC 653 ms
68,224 KB
testcase_39 AC 634 ms
68,172 KB
testcase_40 AC 632 ms
68,292 KB
testcase_41 AC 633 ms
68,164 KB
testcase_42 AC 648 ms
68,176 KB
testcase_43 AC 632 ms
68,284 KB
testcase_44 AC 633 ms
68,172 KB
testcase_45 AC 639 ms
68,300 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 609 ms
66,632 KB
testcase_48 AC 617 ms
67,228 KB
testcase_49 AC 628 ms
68,292 KB
testcase_50 AC 621 ms
67,996 KB
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
                p=min(p, (lll)(n+1));
            }
            mp[p]^=(1<<i);
            if(p==n+1){
                myon=a;
                break;
            }
        }
        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