結果

問題 No.1383 Numbers of Product
ユーザー chocoruskchocorusk
提出日時 2021-02-07 21:24:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,690 bytes
コンパイル時間 1,358 ms
コンパイル使用メモリ 135,744 KB
実行使用メモリ 68,356 KB
最終ジャッジ日時 2023-09-17 20:27:52
合計ジャッジ時間 12,515 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
4,376 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 406 ms
42,564 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 632 ms
64,740 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 WA -
testcase_23 RE -
testcase_24 WA -
testcase_25 RE -
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 1 ms
4,380 KB
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 579 ms
59,988 KB
testcase_37 AC 661 ms
68,356 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 663 ms
68,216 KB
testcase_42 RE -
testcase_43 AC 669 ms
68,276 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 659 ms
67,844 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;
    assert(M==1);
    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(int 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