結果

問題 No.1383 Numbers of Product
ユーザー okok
提出日時 2021-02-07 22:03:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 549 ms / 2,000 ms
コード長 2,279 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 94,020 KB
実行使用メモリ 84,480 KB
最終ジャッジ日時 2024-05-02 10:19:44
合計ジャッジ時間 15,415 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 321 ms
52,992 KB
testcase_08 AC 315 ms
52,480 KB
testcase_09 AC 395 ms
64,256 KB
testcase_10 AC 522 ms
83,712 KB
testcase_11 AC 522 ms
82,688 KB
testcase_12 AC 528 ms
83,456 KB
testcase_13 AC 504 ms
80,256 KB
testcase_14 AC 428 ms
68,224 KB
testcase_15 AC 333 ms
56,064 KB
testcase_16 AC 519 ms
82,816 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 8 ms
5,376 KB
testcase_29 AC 415 ms
65,664 KB
testcase_30 AC 532 ms
84,352 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 114 ms
19,968 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 489 ms
77,312 KB
testcase_36 AC 464 ms
74,112 KB
testcase_37 AC 542 ms
84,352 KB
testcase_38 AC 539 ms
84,352 KB
testcase_39 AC 538 ms
84,480 KB
testcase_40 AC 523 ms
84,352 KB
testcase_41 AC 549 ms
84,352 KB
testcase_42 AC 540 ms
84,480 KB
testcase_43 AC 539 ms
84,352 KB
testcase_44 AC 532 ms
84,480 KB
testcase_45 AC 539 ms
84,480 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 516 ms
82,432 KB
testcase_48 AC 523 ms
83,328 KB
testcase_49 AC 521 ms
84,096 KB
testcase_50 AC 533 ms
83,968 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

// #define int long long
#define int __int128
#define endl "\n"

constexpr long long INF = (long long)2e9;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


int cal(int num){
    int res = 0;
    
    for(int i = 1; i <= num; i++){
        if(num % i == 0) res++;
    }
    
    return res;
}

int input(){
    long long in;
    
    cin>>in;
    
    return in;
}

int check(int P, int K){
    int l = 0, r = INF, m = 0;
    
    while(l + 1 < r){
        m = (l + r) / 2;
        
        if(m * (m + K) == P) return true;
        else if(m * (m + K) < P) l = m;
        else r = m;
    }
    
    return false;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, K, M;
    int con = 0;
    map<int,int> mp;
    
    
    N = input();
    K = input();
    M = input();
	
    
    
    for(int A = 1; A * (A + K) * (A + 2 * K) <= N; A++){
        int pro = A * (A + K) * (A + 2 * K);
        for(int B = 2; pro <= N; B++){
            mp[pro]++;
            // cout<<"A = "<<(long long)A<<" B = "<<(long long)B<<" pro = "<<(long long)pro<<endl;
            pro *= A + K * (B + 1);
        }
    }
    
   if(M == 1) {
        int l = 0, r = INF, m;
        
        while(l + 1 < r){
            m = (l + r) / 2;
            
            if(m * (m + K) <= N) {
                l = m;
            } else {
                r = m;
            }
        }
        
        con = l;
        // cout<<"con = "<<(long long)con<<endl;
        
        for(pair<int,int> p : mp){
            // if((p.first) * (p.first + K) <= N) {
            if(check(p.first, K)) {
                con--;
            } else if(p.second == 1){
                con++;
            }
        }
    } else {
        
        for(pair<int,int> p : mp){
            int temp = p.second;
            
            // if((p.first) * (p.first + K) <= N) {
            if(check(p.first, K)) {
                temp++;
            }
            
            if(temp == M) con++;
        }
    }
    
    cout<<(long long)con<<endl;
    
	return 0;
}
0