結果

問題 No.2125 Inverse Sum
ユーザー HIcoderHIcoder
提出日時 2023-07-12 17:49:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,183 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 108,012 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 08:07:24
合計ジャッジ時間 2,689 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,352 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,352 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,348 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
     }

    
}
0