結果

問題 No.1383 Numbers of Product
ユーザー 沙耶花沙耶花
提出日時 2021-02-07 21:08:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,027 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 206,916 KB
実行使用メモリ 68,452 KB
最終ジャッジ日時 2023-08-14 22:09:33
合計ジャッジ時間 30,118 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
4,376 KB
testcase_01 AC 12 ms
4,376 KB
testcase_02 AC 12 ms
4,380 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 12 ms
4,380 KB
testcase_05 AC 12 ms
4,376 KB
testcase_06 AC 13 ms
4,376 KB
testcase_07 AC 635 ms
43,148 KB
testcase_08 AC 634 ms
42,576 KB
testcase_09 AC 775 ms
51,936 KB
testcase_10 AC 1,015 ms
67,528 KB
testcase_11 AC 997 ms
66,556 KB
testcase_12 AC 1,005 ms
67,380 KB
testcase_13 AC 973 ms
64,884 KB
testcase_14 AC 821 ms
55,260 KB
testcase_15 AC 671 ms
45,404 KB
testcase_16 AC 1,002 ms
67,008 KB
testcase_17 AC 24 ms
4,380 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 23 ms
4,380 KB
testcase_20 AC 23 ms
4,376 KB
testcase_21 AC 24 ms
4,376 KB
testcase_22 AC 23 ms
4,376 KB
testcase_23 AC 23 ms
4,380 KB
testcase_24 AC 24 ms
4,380 KB
testcase_25 AC 23 ms
4,376 KB
testcase_26 AC 24 ms
4,376 KB
testcase_27 AC 38 ms
4,380 KB
testcase_28 AC 51 ms
4,380 KB
testcase_29 AC 795 ms
53,248 KB
testcase_30 AC 1,027 ms
68,140 KB
testcase_31 AC 38 ms
4,376 KB
testcase_32 AC 252 ms
16,668 KB
testcase_33 AC 38 ms
4,380 KB
testcase_34 AC 38 ms
4,376 KB
testcase_35 AC 936 ms
62,780 KB
testcase_36 AC 894 ms
59,956 KB
testcase_37 AC 1,023 ms
68,452 KB
testcase_38 AC 1,021 ms
68,248 KB
testcase_39 AC 1,022 ms
68,264 KB
testcase_40 AC 1,024 ms
68,268 KB
testcase_41 AC 1,021 ms
68,172 KB
testcase_42 AC 1,019 ms
68,180 KB
testcase_43 AC 1,019 ms
68,252 KB
testcase_44 AC 1,024 ms
68,252 KB
testcase_45 AC 1,020 ms
68,360 KB
testcase_46 AC 23 ms
4,376 KB
testcase_47 AC 1,003 ms
66,776 KB
testcase_48 AC 1,014 ms
67,312 KB
testcase_49 AC 1,020 ms
68,004 KB
testcase_50 AC 1,015 ms
67,884 KB
testcase_51 AC 24 ms
4,376 KB
testcase_52 AC 24 ms
4,380 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