結果
問題 |
No.2125 Inverse Sum
|
ユーザー |
|
提出日時 | 2023-07-12 17:48:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,135 bytes |
コンパイル時間 | 883 ms |
コンパイル使用メモリ | 102,000 KB |
最終ジャッジ日時 | 2025-02-15 10:06:04 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 7 WA * 23 |
ソースコード
#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); ll gcd(ll x,ll y){ return y==0?x:gcd(y,x%y); } int main(){ ll P,Q; cin>>P>>Q; ll g=gcd(P,Q); P/=g; Q/=g; vector<pair<ll,ll>> cand; for(ll c=1;c*c<=Q;c++){ if(Q*Q%c==0){ { ll d1=Q*Q/c; ll d2=c; if((d1+Q)%P==0 && (d2+Q)%P==0){ ll n=(d1+Q)/P; ll m=(d2+Q)/P; cand.emplace_back(n,m); } } } } 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; } }