結果
| 問題 | 
                            No.1532 Different Products
                             | 
                    
| コンテスト | |
| ユーザー | 
                             沙耶花
                         | 
                    
| 提出日時 | 2021-06-04 21:09:59 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2,789 ms / 4,000 ms | 
| コード長 | 1,126 bytes | 
| コンパイル時間 | 3,979 ms | 
| コンパイル使用メモリ | 260,216 KB | 
| 最終ジャッジ日時 | 2025-01-21 23:12:03 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 62 | 
ソースコード
#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;
}
            
            
            
        
            
沙耶花