結果
| 問題 | 
                            No.2125 Inverse Sum
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-07-12 17:49:29 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,183 bytes | 
| コンパイル時間 | 890 ms | 
| コンパイル使用メモリ | 105,812 KB | 
| 最終ジャッジ日時 | 2025-02-15 10:06:09 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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;
    set<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);
                    cand.insert(make_pair(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;
     }
    
}