結果

問題 No.1532 Different Products
ユーザー spipipikespipipike
提出日時 2021-06-04 22:42:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,239 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 189,724 KB
実行使用メモリ 21,084 KB
最終ジャッジ日時 2024-04-30 10:44:57
合計ジャッジ時間 16,740 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 68 ms
11,628 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 52 ms
10,608 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 76 ms
10,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 108 ms
12,076 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 39 ms
9,048 KB
testcase_27 AC 132 ms
13,048 KB
testcase_28 AC 104 ms
12,864 KB
testcase_29 AC 88 ms
10,492 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 164 ms
14,440 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 63 ms
8,548 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 2 ms
6,940 KB
testcase_62 AC 1 ms
6,944 KB
testcase_63 WA -
権限があれば一括ダウンロードができます

ソースコード

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,int>;

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

	unordered_map<ll, int> 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<int> kl;
		for(int i : kse) kl.push_back(i);
		sort(kl.begin(), kl.end());

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

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