結果
問題 |
No.2125 Inverse Sum
|
ユーザー |
![]() |
提出日時 | 2022-11-18 21:59:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 966 bytes |
コンパイル時間 | 1,503 ms |
コンパイル使用メモリ | 169,684 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-20 02:22:00 |
合計ジャッジ時間 | 4,983 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 1 -- * 27 |
ソースコード
#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; }