結果

問題 No.1532 Different Products
ユーザー 沙耶花沙耶花
提出日時 2021-06-04 21:09:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,126 bytes
コンパイル時間 4,690 ms
コンパイル使用メモリ 272,364 KB
実行使用メモリ 26,064 KB
最終ジャッジ日時 2023-11-28 02:13:48
合計ジャッジ時間 137,923 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 391 ms
14,336 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 7 ms
6,676 KB
testcase_09 AC 84 ms
11,136 KB
testcase_10 AC 423 ms
17,024 KB
testcase_11 AC 301 ms
16,000 KB
testcase_12 AC 1,264 ms
21,632 KB
testcase_13 AC 536 ms
20,864 KB
testcase_14 AC 3,524 ms
24,212 KB
testcase_15 AC 6 ms
6,676 KB
testcase_16 AC 606 ms
13,864 KB
testcase_17 AC 346 ms
17,408 KB
testcase_18 AC 190 ms
16,128 KB
testcase_19 AC 1,025 ms
21,376 KB
testcase_20 AC 2,997 ms
24,876 KB
testcase_21 AC 975 ms
15,104 KB
testcase_22 AC 577 ms
19,840 KB
testcase_23 AC 240 ms
18,560 KB
testcase_24 AC 2,543 ms
24,400 KB
testcase_25 AC 1,204 ms
19,584 KB
testcase_26 AC 122 ms
11,008 KB
testcase_27 AC 1,413 ms
16,640 KB
testcase_28 AC 894 ms
16,768 KB
testcase_29 AC 1,081 ms
13,556 KB
testcase_30 AC 2,221 ms
18,304 KB
testcase_31 AC 2,162 ms
18,688 KB
testcase_32 AC 2,440 ms
19,840 KB
testcase_33 AC 1,814 ms
17,920 KB
testcase_34 AC 2,743 ms
23,328 KB
testcase_35 AC 2,233 ms
19,968 KB
testcase_36 AC 2,839 ms
21,504 KB
testcase_37 AC 507 ms
9,856 KB
testcase_38 AC 3,093 ms
23,504 KB
testcase_39 AC 2,705 ms
21,376 KB
testcase_40 AC 2,779 ms
21,632 KB
testcase_41 AC 3,917 ms
25,944 KB
testcase_42 AC 3,476 ms
24,800 KB
testcase_43 AC 3,495 ms
25,296 KB
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 AC 3,983 ms
25,792 KB
testcase_53 AC 3,907 ms
26,028 KB
testcase_54 TLE -
testcase_55 TLE -
testcase_56 TLE -
testcase_57 AC 3,962 ms
25,668 KB
testcase_58 AC 3,993 ms
25,856 KB
testcase_59 AC 3,899 ms
25,268 KB
testcase_60 TLE -
testcase_61 AC 2 ms
6,676 KB
testcase_62 AC 2 ms
6,676 KB
testcase_63 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
long long ans=  0;
long long K;
vector<long long> x;
map<long long,long long> mp;
vector<long long> v,sum;
void dfs(int ind,long long cur){
	if(cur > K)return;
	if(ind == x.size()){
		int d = distance(v.begin(),upper_bound(v.begin(),v.end(),K/cur));
		ans += sum[d-1];
		return;
	}
	else{
		dfs(ind+1,cur);
		dfs(ind+1,cur*x[ind]);
	}
}

int main(){
	int N;
	cin>>N;
	cin>>K;
	vector<int> d = {2,3,5,7,11,13,17,19};
	mp[1]++;
	
	for(int i=1;i<=N;i++){
		int t = i;
		rep(j,d.size()){
			while(t%d[j]==0){
				t /= d[j];
			}
		}
		
		if(t!=1){
			x.push_back(i);
		}
		else{
			map<long long,long long> mp2 = mp;
			for(auto a:mp){
				if(a.first*i>K)break;
				mp2[a.first*i] += a.second;
			}
			swap(mp,mp2);
		}
	}
	
	v.push_back(0);
	sum.push_back(0);
	for(auto a:mp){
		v.push_back(a.first);
		long long t = sum.back();
		sum.push_back(a.second + t);
	}
	
	dfs(0,1);
	ans--;
	cout<<ans<<endl;
	
	return 0;
}
0