結果

問題 No.2125 Inverse Sum
ユーザー HIcoderHIcoder
提出日時 2023-07-12 14:47:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 871 bytes
コンパイル時間 942 ms
コンパイル使用メモリ 103,048 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-12 05:04:01
合計ジャッジ時間 5,806 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);

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

    
}
0