結果
問題 |
No.2125 Inverse Sum
|
ユーザー |
|
提出日時 | 2023-07-12 14:47:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 871 bytes |
コンパイル時間 | 962 ms |
コンパイル使用メモリ | 100,924 KB |
最終ジャッジ日時 | 2025-02-15 10:04:50 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 1 -- * 27 |
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<int,int> P; typedef pair<int,P> PP; const ll MOD=998244353; const double PI=acos(-1); int main(){ ll p,q; cin>>p>>q; ll lb=(q+(p-1))/p; ll ub=2*q/p; vector<pair<ll,ll>> cand; for(ll m=lb;m<=ub;m++){ if(m*p==q) continue; if(m*q%(m*p-q)==0){ ll n=m*q/(m*p-q); cand.emplace_back(m,n); } } vector<pair<ll,ll>> ans; for(auto [m,n]:cand){ ans.emplace_back(m,n); if(m!=n){ ans.emplace_back(n,m); } } cout<<ans.size()<<endl; for(auto [m,n]:ans){ cout<<m<<' '<<n<<endl; } }