結果

問題 No.2125 Inverse Sum
ユーザー hiro71687khiro71687k
提出日時 2024-01-09 00:06:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,110 bytes
コンパイル時間 4,939 ms
コンパイル使用メモリ 267,856 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2024-01-09 00:06:39
合計ジャッジ時間 9,431 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,480 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 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>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ll inf=30000000000000000;//10^17
int main(){
    ll p,q;
    cin >> p >> q;
    ll ans=0;
    vector<pair<ll,ll>>a;
    for (ll i = max(q/p,1LL); i >=0; i++)
    {
        ll x=q*i,y=p*i-q;
        if (y<=0)
        {
            continue;
        }
        if (i*y>=x)
        {
            ll sz=a.size();
            for (ll j = 0; j < sz; j++)
            {
                a.push_back({a[j].second,a[j].first});
            }
            if (i*y==x)
            {
                a.push_back({i,i});
                ans*=2;
                ans++;
                break;
            }else{
                ans*=2;
                break;
            }
        }
        if (x%y==0)
        {
            ans++;
            a.push_back({i,x/y});
        }
    }
    cout << ans << endl;
    sort(a.begin(),a.end());
    for (ll i = 0; i < a.size(); i++)
    {
        cout << a[i].first << ' '<< a[i].second << endl;
    }
    
}
0