結果

問題 No.1532 Different Products
ユーザー spipipikespipipike
提出日時 2021-06-04 23:00:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 428 ms / 4,000 ms
コード長 918 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 190,664 KB
実行使用メモリ 22,872 KB
最終ジャッジ日時 2024-04-30 11:29:36
合計ジャッジ時間 17,230 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 77 ms
12,528 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 6 ms
6,940 KB
testcase_09 AC 58 ms
11,376 KB
testcase_10 AC 86 ms
14,720 KB
testcase_11 AC 77 ms
14,344 KB
testcase_12 AC 176 ms
18,492 KB
testcase_13 AC 104 ms
17,568 KB
testcase_14 AC 316 ms
19,748 KB
testcase_15 AC 6 ms
6,944 KB
testcase_16 AC 78 ms
11,108 KB
testcase_17 AC 80 ms
14,748 KB
testcase_18 AC 79 ms
14,728 KB
testcase_19 AC 178 ms
18,724 KB
testcase_20 AC 329 ms
20,208 KB
testcase_21 AC 111 ms
12,972 KB
testcase_22 AC 107 ms
16,328 KB
testcase_23 AC 88 ms
15,604 KB
testcase_24 AC 298 ms
19,872 KB
testcase_25 AC 160 ms
16,296 KB
testcase_26 AC 39 ms
9,560 KB
testcase_27 AC 136 ms
14,076 KB
testcase_28 AC 106 ms
13,764 KB
testcase_29 AC 91 ms
11,124 KB
testcase_30 AC 184 ms
15,640 KB
testcase_31 AC 182 ms
15,832 KB
testcase_32 AC 237 ms
16,544 KB
testcase_33 AC 182 ms
15,336 KB
testcase_34 AC 265 ms
19,128 KB
testcase_35 AC 229 ms
17,568 KB
testcase_36 AC 268 ms
18,524 KB
testcase_37 AC 64 ms
9,060 KB
testcase_38 AC 320 ms
19,308 KB
testcase_39 AC 253 ms
18,380 KB
testcase_40 AC 313 ms
18,552 KB
testcase_41 AC 413 ms
22,560 KB
testcase_42 AC 319 ms
20,148 KB
testcase_43 AC 342 ms
20,476 KB
testcase_44 AC 405 ms
22,808 KB
testcase_45 AC 403 ms
22,688 KB
testcase_46 AC 402 ms
22,460 KB
testcase_47 AC 406 ms
22,724 KB
testcase_48 AC 403 ms
22,676 KB
testcase_49 AC 413 ms
22,708 KB
testcase_50 AC 403 ms
22,812 KB
testcase_51 AC 428 ms
22,720 KB
testcase_52 AC 412 ms
22,652 KB
testcase_53 AC 414 ms
22,732 KB
testcase_54 AC 409 ms
22,524 KB
testcase_55 AC 397 ms
22,704 KB
testcase_56 AC 405 ms
22,500 KB
testcase_57 AC 404 ms
22,612 KB
testcase_58 AC 400 ms
22,804 KB
testcase_59 AC 358 ms
20,476 KB
testcase_60 AC 411 ms
22,872 KB
testcase_61 AC 1 ms
6,940 KB
testcase_62 AC 1 ms
6,940 KB
testcase_63 AC 412 ms
22,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main(){
	int n;
	ll k;
	cin>>n>>k;

	int mid=min(30, n);
	unordered_map<ll, ll> ma, da;
	ma[1]=1;
	for(int i=1; i<=mid; i++){
		vector<P> al;
		for(auto p : ma){
			if((ll)i*p.first<=k) al.push_back(P((ll)i*p.first, p.second));
		}
		for(P p : al) ma[p.first]+=p.second;
	}

	da[k]=1;
	for(int i=mid+1; i<=n; i++){
		vector<P> al;
		for(auto p : da){
			if(p.first/i>0) al.push_back(P(p.first/i, p.second));
		}
		for(P p : al) da[p.first]+=p.second;
	}

	unordered_set<ll> kse;
	for(auto p : ma) kse.insert(p.first);
	for(auto p : da) kse.insert(p.first);
	vector<ll> kl;
	for(ll e : kse) kl.push_back(e);
	sort(kl.begin(), kl.end());

	ll c=0, tot=0;
	for(ll e : kl){
		if(ma.count(e)) c+=ma[e];
		if(da.count(e)) tot+=c*da[e];
	}
	tot-=1;

	cout<<tot<<endl;
	return 0;
}
0