結果
| 問題 |
No.1532 Different Products
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-04 22:42:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,239 bytes |
| コンパイル時間 | 2,155 ms |
| コンパイル使用メモリ | 189,472 KB |
| 実行使用メモリ | 21,196 KB |
| 最終ジャッジ日時 | 2024-11-20 04:55:33 |
| 合計ジャッジ時間 | 20,012 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 WA * 43 |
ソースコード
#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;
}