結果

問題 No.1383 Numbers of Product
ユーザー 沙耶花沙耶花
提出日時 2021-02-07 21:08:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 947 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 207,352 KB
実行使用メモリ 68,352 KB
最終ジャッジ日時 2024-05-02 10:15:06
合計ジャッジ時間 27,180 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,248 KB
testcase_01 AC 11 ms
5,376 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 11 ms
5,376 KB
testcase_04 AC 11 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 12 ms
5,376 KB
testcase_07 AC 583 ms
43,136 KB
testcase_08 AC 570 ms
42,752 KB
testcase_09 AC 703 ms
52,096 KB
testcase_10 AC 933 ms
67,712 KB
testcase_11 AC 919 ms
66,560 KB
testcase_12 AC 920 ms
67,456 KB
testcase_13 AC 906 ms
64,896 KB
testcase_14 AC 746 ms
55,296 KB
testcase_15 AC 618 ms
45,568 KB
testcase_16 AC 918 ms
66,944 KB
testcase_17 AC 21 ms
5,376 KB
testcase_18 AC 21 ms
5,376 KB
testcase_19 AC 21 ms
5,376 KB
testcase_20 AC 21 ms
5,376 KB
testcase_21 AC 22 ms
5,376 KB
testcase_22 AC 21 ms
5,376 KB
testcase_23 AC 22 ms
5,376 KB
testcase_24 AC 21 ms
5,376 KB
testcase_25 AC 21 ms
5,376 KB
testcase_26 AC 22 ms
5,376 KB
testcase_27 AC 34 ms
5,376 KB
testcase_28 AC 46 ms
5,376 KB
testcase_29 AC 726 ms
53,120 KB
testcase_30 AC 937 ms
68,224 KB
testcase_31 AC 33 ms
5,376 KB
testcase_32 AC 229 ms
16,768 KB
testcase_33 AC 34 ms
5,376 KB
testcase_34 AC 34 ms
5,376 KB
testcase_35 AC 866 ms
62,592 KB
testcase_36 AC 836 ms
60,032 KB
testcase_37 AC 947 ms
68,352 KB
testcase_38 AC 946 ms
68,352 KB
testcase_39 AC 929 ms
68,352 KB
testcase_40 AC 923 ms
68,352 KB
testcase_41 AC 917 ms
68,352 KB
testcase_42 AC 927 ms
68,352 KB
testcase_43 AC 931 ms
68,224 KB
testcase_44 AC 919 ms
68,352 KB
testcase_45 AC 930 ms
68,352 KB
testcase_46 AC 21 ms
5,376 KB
testcase_47 AC 924 ms
66,688 KB
testcase_48 AC 909 ms
67,328 KB
testcase_49 AC 915 ms
68,096 KB
testcase_50 AC 906 ms
67,968 KB
testcase_51 AC 21 ms
5,376 KB
testcase_52 AC 21 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int main(){
	
	long long N,K,M;
	cin>>N>>K>>M;
	
	map<long long,long long> mp;
	
	for(long long i=1;i<=1000000;i++){
		long long temp = N;
		
		long long x = 1LL;
		for(int j=0;true;j++){
			temp /= i + K * j;
			if(temp<=0)break;
			x *= i + K * j;
			if(j>=2)mp[x] ++;
		}
	}
	long long cnt = 0LL;
	for(auto &a:mp){
		long long tt = a.first;
		
		long long ok = 0LL,ng = 1000000001;
		while(ng-ok>1){
			long long mid = (ok+ng)/2;
			long long t = N;
			t /= mid;
			t /= mid+K;
			if(t<=0){
				ng = mid;
				continue;
			}
			if(mid * (mid+K)<=tt)ok = mid;
			else ng = mid;
		}
		if(ok * (ok+K) == tt){
			a.second++;
			cnt++;
		}
	}

	long long ans = 0LL;
	if(M>=2){
		for(auto a:mp){
			if(a.second==M)ans++;
		}
	}
	else{
		long long ok = 0LL,ng = 1000000001;
		while(ng-ok>1){
			long long mid = (ok+ng)/2;
			long long t = N;
			t /= mid;
			t /= mid+K;
			if(t<=0){
				ng = mid;
				continue;
			}
			if(mid * (mid+K)<=N)ok = mid;
			else ng = mid;
		}

		ans = ok;
		ans -= cnt;
		
		for(auto a:mp){
			if(a.second==1)ans++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}
0