結果
問題 |
No.2125 Inverse Sum
|
ユーザー |
![]() |
提出日時 | 2022-11-18 22:14:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 2,012 ms |
コンパイル使用メモリ | 178,652 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-09-20 02:35:47 |
合計ジャッジ時間 | 5,312 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 1 -- * 27 |
ソースコード
#pragma GCC optimize("Ofast") #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=q/p;;i++){ ll z = i*p - q; if(z>=1 && i*q%z==0){ x.emplace_back(i); y.emplace_back(i*q/z); } if(z>=q) break; } int n = x.size(); rep(i,n){ if(x[n-1-i]==y[n-1-i]) continue; x.emplace_back(y[n-1-i]); y.emplace_back(x[n-1-i]); } n = x.size(); cout << n << '\n'; rep(i,n) cout << x[i] << " " << y[i] << '\n'; return 0; }