結果
問題 | No.1532 Different Products |
ユーザー |
|
提出日時 | 2021-06-04 23:00:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 523 ms / 4,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 2,181 ms |
コンパイル使用メモリ | 189,864 KB |
実行使用メモリ | 22,868 KB |
最終ジャッジ日時 | 2024-11-20 06:17:10 |
合計ジャッジ時間 | 20,480 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 62 |
ソースコード
#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, ll>;int main(){int n;ll k;cin>>n>>k;int mid=min(30, n);unordered_map<ll, ll> ma, da;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<ll> kl;for(ll e : kse) kl.push_back(e);sort(kl.begin(), kl.end());ll c=0, tot=0;for(ll e : kl){if(ma.count(e)) c+=ma[e];if(da.count(e)) tot+=c*da[e];}tot-=1;cout<<tot<<endl;return 0;}