結果

問題 No.1532 Different Products
ユーザー V_MelvilleV_Melville
提出日時 2021-06-26 18:17:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 559 ms / 4,000 ms
コード長 1,017 bytes
コンパイル時間 2,119 ms
コンパイル使用メモリ 204,632 KB
実行使用メモリ 207,936 KB
最終ジャッジ日時 2023-09-07 15:25:28
合計ジャッジ時間 23,602 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
163,788 KB
testcase_01 AC 90 ms
167,956 KB
testcase_02 AC 38 ms
163,852 KB
testcase_03 AC 39 ms
163,768 KB
testcase_04 AC 38 ms
163,780 KB
testcase_05 AC 39 ms
163,768 KB
testcase_06 AC 39 ms
163,660 KB
testcase_07 AC 39 ms
163,652 KB
testcase_08 AC 39 ms
163,800 KB
testcase_09 AC 45 ms
164,072 KB
testcase_10 AC 89 ms
166,348 KB
testcase_11 AC 75 ms
165,940 KB
testcase_12 AC 216 ms
175,764 KB
testcase_13 AC 118 ms
169,720 KB
testcase_14 AC 509 ms
204,048 KB
testcase_15 AC 38 ms
163,684 KB
testcase_16 AC 92 ms
167,956 KB
testcase_17 AC 75 ms
166,216 KB
testcase_18 AC 62 ms
165,832 KB
testcase_19 AC 187 ms
174,708 KB
testcase_20 AC 455 ms
202,372 KB
testcase_21 AC 131 ms
172,952 KB
testcase_22 AC 116 ms
168,864 KB
testcase_23 AC 77 ms
168,012 KB
testcase_24 AC 414 ms
202,240 KB
testcase_25 AC 187 ms
176,640 KB
testcase_26 AC 48 ms
164,524 KB
testcase_27 AC 176 ms
176,828 KB
testcase_28 AC 142 ms
174,236 KB
testcase_29 AC 103 ms
166,368 KB
testcase_30 AC 271 ms
187,272 KB
testcase_31 AC 282 ms
188,980 KB
testcase_32 AC 388 ms
202,172 KB
testcase_33 AC 239 ms
185,220 KB
testcase_34 AC 406 ms
202,240 KB
testcase_35 AC 367 ms
202,508 KB
testcase_36 AC 424 ms
203,276 KB
testcase_37 AC 73 ms
164,464 KB
testcase_38 AC 447 ms
202,372 KB
testcase_39 AC 407 ms
202,512 KB
testcase_40 AC 411 ms
202,516 KB
testcase_41 AC 522 ms
205,956 KB
testcase_42 AC 475 ms
203,640 KB
testcase_43 AC 493 ms
204,000 KB
testcase_44 AC 551 ms
207,480 KB
testcase_45 AC 546 ms
207,476 KB
testcase_46 AC 536 ms
207,244 KB
testcase_47 AC 537 ms
207,696 KB
testcase_48 AC 538 ms
207,600 KB
testcase_49 AC 543 ms
207,744 KB
testcase_50 AC 540 ms
207,480 KB
testcase_51 AC 559 ms
207,860 KB
testcase_52 AC 529 ms
207,220 KB
testcase_53 AC 546 ms
207,672 KB
testcase_54 AC 537 ms
207,220 KB
testcase_55 AC 540 ms
207,876 KB
testcase_56 AC 528 ms
207,068 KB
testcase_57 AC 530 ms
207,220 KB
testcase_58 AC 548 ms
207,408 KB
testcase_59 AC 507 ms
206,428 KB
testcase_60 AC 531 ms
207,856 KB
testcase_61 AC 39 ms
163,648 KB
testcase_62 AC 39 ms
163,736 KB
testcase_63 AC 520 ms
207,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e11;
const int N=205,M=1e5+5;
ll n,k,fac[N],two[N],ans;
unordered_map<ll,ll>dp2;
ll dp[N][M];
ll dfs(ll x,ll now){
	if(now>=M){
		ll hash=x*INF+now;
		if(dp2.count(hash)){
			return dp2[hash];
		}
		if(now>=fac[x]){
			return dp2[hash]=two[x];
		}
		ll ans=0;
		ans=(ans+dfs(x-1,now));
		ans=(ans+dfs(min(now/x,x-1),now/x));
		return dp2[hash]=ans;
	}
	else{
		if(~dp[x][now]){
			return dp[x][now];
		}	
		if(now>=fac[x]){
			return dp[x][now]=two[x];
		}
		ll ans=0;
		ans=(ans+dfs(x-1,now));
		ans=(ans+dfs(min(now/x,x-1),now/x));
		return dp[x][now]=ans;
	}
}
int main(){
	scanf("%lld%lld",&n,&k);
	memset(dp,-1,sizeof dp);
	fac[0]=two[0]=1;
	for(int i=1;i<=40;++i){
		two[i]=2ll*two[i-1];
	}
	for(int i=1;i<=n;++i){ 
		fac[i]=1ll*fac[i-1]*i;
		fac[i]=min(fac[i],INF);
	}
	for(ll i=1;i<=min(n,k);++i){
		ans+=dfs(min(k/i,i-1),k/i);
	}
	printf("%lld\n",ans);
	return 0; 
}
/*
100 1000000000
1480348241
200 10000000000
44692356573
*/ 
0