結果

問題 No.1383 Numbers of Product
ユーザー ChanyuhChanyuh
提出日時 2021-02-16 14:36:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,572 bytes
コンパイル時間 1,476 ms
コンパイル使用メモリ 131,640 KB
実行使用メモリ 68,332 KB
最終ジャッジ日時 2023-10-11 02:51:39
合計ジャッジ時間 16,937 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 313 ms
43,092 KB
testcase_08 WA -
testcase_09 AC 387 ms
51,964 KB
testcase_10 AC 528 ms
67,552 KB
testcase_11 AC 510 ms
66,564 KB
testcase_12 AC 520 ms
67,376 KB
testcase_13 WA -
testcase_14 AC 414 ms
55,340 KB
testcase_15 AC 332 ms
45,480 KB
testcase_16 AC 513 ms
66,868 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,348 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,352 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,356 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 6 ms
4,488 KB
testcase_29 AC 396 ms
53,320 KB
testcase_30 AC 523 ms
68,296 KB
testcase_31 AC 2 ms
4,356 KB
testcase_32 AC 97 ms
16,740 KB
testcase_33 AC 2 ms
4,352 KB
testcase_34 AC 1 ms
4,356 KB
testcase_35 AC 480 ms
62,564 KB
testcase_36 AC 448 ms
60,016 KB
testcase_37 AC 521 ms
68,320 KB
testcase_38 AC 525 ms
68,208 KB
testcase_39 AC 527 ms
68,332 KB
testcase_40 AC 525 ms
68,204 KB
testcase_41 AC 525 ms
68,200 KB
testcase_42 AC 518 ms
68,208 KB
testcase_43 AC 533 ms
68,200 KB
testcase_44 AC 521 ms
68,200 KB
testcase_45 AC 519 ms
68,244 KB
testcase_46 AC 1 ms
4,348 KB
testcase_47 AC 497 ms
66,672 KB
testcase_48 AC 505 ms
67,240 KB
testcase_49 AC 515 ms
67,996 KB
testcase_50 AC 513 ms
67,820 KB
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<array>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

ll N,M,K;
map<ll,int> ma;

ll Kth_root(ll x,int k){
    if(x==1) return 1;
    if(k>64) return 1;
    ll l=0,r=numeric_limits<ll>::max();
    while(r-l>1){
        ll mid=(l+r)/(ll)2;
        ll d=mid;
        bool larger=false;
        rep(i,k-1){
            if(d>x/mid+(ll)1){
                larger=true;
                break;
            }
            d*=mid;
        }
        if(d>x) larger=true;
        if(larger) r=mid;
        else l=mid;
    }
    return l;
}

void solve(){
    cin >> N >> K >> M;
    Rep(i,2,21){
        ll A=1;
        while(true){
            ll Z=1;
            bool flag=false;
            rep(j,i+1){
                Z*=A+j*K;
                if(Z>N) {
                    flag=true;
                    break;
                }
            }
            if(flag) break;
            ma[Z]++;
            A++;
        }
    }
    ll ans=0;
    if(M==1){
        ll l=0,r=mod;
        while(r-l>1){
            ll mid=(l+r)/2;
            if(mid*(mid+K)>N) r=mid;
            else l=mid;
        }
        ans+=l;
    }
    for(auto p:ma){
        bool f=false;
        ll l=0,r=mod;
        while(r-l>1){
            ll mid=(l+r)/2;
            if(mid*(mid+K)>p.first) r=mid;
            else l=mid;
        }
        //cout << p.first << " " << p.second << " " << l << " " << l*(l+K) << endl;
        if(l*(l+K)==p.first) f=true;
        if(f+p.second==M) ans++;
        if(M==1 && f) if(p.second>=1) ans--;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}
0