結果

問題 No.2125 Inverse Sum
ユーザー hourenhouren
提出日時 2022-11-18 21:59:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 966 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 170,920 KB
実行使用メモリ 7,756 KB
最終ジャッジ日時 2023-10-20 06:49:53
合計ジャッジ時間 5,160 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll p,q;
    cin >> p >> q;
    vector<ll> x, y;
    for(ll i=1;;i++){
        ll z = i*p - q;
        if(z>=1 && i*q%z==0){
            x.push_back(i);
            y.push_back(i*q/z);
        }
        if(z>=1 && i>=i*q/z) break;
    }
    int n = x.size();
    rep(i,n){
        if(x[n-1-i]==y[n-1-i]) continue;
        x.push_back(y[n-1-i]);
        y.push_back(x[n-1-i]);
    }
    n = x.size();
    cout << n << '\n';
    rep(i,n) cout << x[i] << " " << y[i] << '\n';
    return 0;
}
0