結果

問題 No.1532 Different Products
ユーザー spipipikespipipike
提出日時 2021-06-04 22:51:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 551 ms / 4,000 ms
コード長 1,235 bytes
コンパイル時間 2,597 ms
コンパイル使用メモリ 188,280 KB
実行使用メモリ 22,724 KB
最終ジャッジ日時 2023-08-12 16:19:42
合計ジャッジ時間 20,064 ms
ジャッジサーバーID
(参考情報)
judge7 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 82 ms
12,372 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 61 ms
11,284 KB
testcase_10 AC 96 ms
14,428 KB
testcase_11 AC 85 ms
14,168 KB
testcase_12 AC 193 ms
18,244 KB
testcase_13 AC 119 ms
17,284 KB
testcase_14 AC 325 ms
19,476 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 85 ms
10,892 KB
testcase_17 AC 93 ms
14,532 KB
testcase_18 AC 97 ms
14,820 KB
testcase_19 AC 188 ms
18,260 KB
testcase_20 AC 358 ms
19,972 KB
testcase_21 AC 126 ms
12,800 KB
testcase_22 AC 124 ms
16,004 KB
testcase_23 AC 101 ms
15,476 KB
testcase_24 AC 327 ms
19,412 KB
testcase_25 AC 174 ms
16,028 KB
testcase_26 AC 46 ms
9,416 KB
testcase_27 AC 159 ms
13,724 KB
testcase_28 AC 134 ms
13,876 KB
testcase_29 AC 108 ms
11,068 KB
testcase_30 AC 207 ms
15,596 KB
testcase_31 AC 208 ms
15,496 KB
testcase_32 AC 259 ms
16,292 KB
testcase_33 AC 192 ms
15,124 KB
testcase_34 AC 298 ms
19,196 KB
testcase_35 AC 258 ms
17,332 KB
testcase_36 AC 301 ms
18,280 KB
testcase_37 AC 70 ms
8,992 KB
testcase_38 AC 349 ms
19,248 KB
testcase_39 AC 300 ms
18,080 KB
testcase_40 AC 384 ms
18,464 KB
testcase_41 AC 478 ms
22,500 KB
testcase_42 AC 364 ms
19,940 KB
testcase_43 AC 387 ms
20,372 KB
testcase_44 AC 455 ms
22,380 KB
testcase_45 AC 455 ms
22,536 KB
testcase_46 AC 546 ms
22,272 KB
testcase_47 AC 551 ms
22,420 KB
testcase_48 AC 470 ms
22,440 KB
testcase_49 AC 448 ms
22,476 KB
testcase_50 AC 459 ms
22,500 KB
testcase_51 AC 460 ms
22,396 KB
testcase_52 AC 454 ms
22,496 KB
testcase_53 AC 454 ms
22,560 KB
testcase_54 AC 452 ms
22,276 KB
testcase_55 AC 458 ms
22,456 KB
testcase_56 AC 461 ms
22,588 KB
testcase_57 AC 439 ms
22,452 KB
testcase_58 AC 452 ms
22,300 KB
testcase_59 AC 403 ms
20,372 KB
testcase_60 AC 458 ms
22,492 KB
testcase_61 AC 2 ms
4,380 KB
testcase_62 AC 1 ms
4,380 KB
testcase_63 AC 448 ms
22,724 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;

	unordered_map<ll, ll> ma, da;

	const int mid=30;

	ll ans;
	if(n<=mid){
		ma[1]=1;
		for(int i=1; i<=n; 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;
		}
		ll tot=0;
		for(auto p : ma) tot+=p.second;
		ans=tot-1;
	}
	else{
		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];
		}
		ans=tot-1;
	}

	cout<<ans<<endl;
	return 0;
}
0