結果
問題 |
No.473 和と積の和
|
ユーザー |
![]() |
提出日時 | 2019-02-22 18:57:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,217 bytes |
コンパイル時間 | 2,796 ms |
コンパイル使用メモリ | 203,740 KB |
最終ジャッジ日時 | 2025-01-06 21:26:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 38 WA * 1 TLE * 4 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> vector<T> compress(vector<T> v){ sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); return v; } template<typename T> map<T, Int> dict(const vector<T> &v){ map<T, Int> res; for(Int i=0;i<(Int)v.size();i++) res[v[i]]=i; return res; } //INSERT ABOVE HERE signed main(){ Int n,x; cin>>n>>x; x++; if(n>=32){ Int a=x-(1<<(n-1)); if(a>0&&(a%(1<<(n-1))==0)) cout<<1<<endl; else cout<<0<<endl; return 0; } Int ans=0; vector<Int> vs; for(Int i=1;i*i<=x;i++){ if(x%i) continue; vs.emplace_back(i); vs.emplace_back(x/i); } vs=compress(vs); vs.erase(vs.begin()); function<void(Int, Int, Int)> dfs= [&](Int k,Int l,Int b){ // cout<<k<<" "<<l<<" "<<b<<endl; if(x%b) return; if(k==n){ ans+=b==x; return; } for(Int i=l;i<(Int)vs.size()&&b*vs[i]<=x;i++){ dfs(k+1,i,b*vs[i]); } }; dfs(0,0,1); cout<<ans<<endl; return 0; }