結果
| 問題 | 
                            No.1383 Numbers of Product
                             | 
                    
| コンテスト | |
| ユーザー | 
                             milanis48663220
                         | 
                    
| 提出日時 | 2021-07-01 22:52:13 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,358 bytes | 
| コンパイル時間 | 1,483 ms | 
| コンパイル使用メモリ | 123,512 KB | 
| 最終ジャッジ日時 | 2025-01-22 15:28:04 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 45 WA * 6 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
const ll INF = 2e18;
ll calc(ll a, ll b, ll k){
    ll ans = a;
    for(ll i = 1; i <= b; i++){
        ll x = a+k*i;
        if(ans >= INF/x) return INF;
        ans *= x;
    }
    // cout << "calc(" << a << "," << b << "," << k << ") = " << ans << endl;
    return ans;
}
ll f(ll x, ll k){
    ll l = 0, r = 1e9;
    while(r-l > 1){
        ll c = (l+r)/2;
        if(c*(c+k) > x) r = c;
        else l = c;
    }
    return l;
}
int naive(ll n, ll k, ll m){
    map<ll, int> cnt;
    for(int b = 1; ; b++){
        if(calc(1, b, k) > n) break;
        for(int a = 1; ; a++){
            ll x = calc(a, b, k);
            if(x > n) break;
            if(cnt.count(x) == 0) cnt[x] = 1;
            else cnt[x]++;
        }
    }
    int ans = 0;
    for(auto [_, c]: cnt){
        if(c == m) ans++;
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll n, k, m; cin >> n >> k >> m;
    map<ll, int> cnt;
    for(int b = 2; ; b++){
        if(calc(1, b, k) > n) break;
        for(int a = 1; ; a++){
            ll x = calc(a, b, k);
            if(x > n) break;
            if(cnt.count(x) == 0) cnt[x] = 1;
            else cnt[x]++;
        }
    }
    vector<ll> v;
    for(auto &[x, c]: cnt) {
        ll y = f(x, k);
        if(calc(y, 1, k) == x){
            v.push_back(x);
            c++;
        }
    }
    int ans = 0;
    for(auto [_, c]: cnt){
        if(c == m) ans++;
    }
    if(m == 1){
        ll y = f(n, k);
        ans += y;
        for(auto [x, c]: cnt){
            ll y = f(x, k);
            if(calc(y, 1, k)  == x) ans--;
        }
    }
    cout << ans << endl;
    // cout << naive(n, k, m) << endl;
}
            
            
            
        
            
milanis48663220