結果
問題 | No.2125 Inverse Sum |
ユーザー | HIcoder |
提出日時 | 2023-07-12 17:39:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,334 bytes |
コンパイル時間 | 977 ms |
コンパイル使用メモリ | 104,112 KB |
実行使用メモリ | 4,480 KB |
最終ジャッジ日時 | 2023-10-12 07:57:32 |
合計ジャッジ時間 | 2,787 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,352 KB |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
4,348 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 15 ms
4,352 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
4,352 KB |
testcase_10 | AC | 1 ms
4,352 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 1 ms
4,352 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 2 ms
4,348 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 1 ms
4,348 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
#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*p-q)>q) break; if(q<(m*p-q)) break; if(m*q%(m*p-q)==0){ ll n=m*q/(m*p-q); if(n<m) break; if(n*p>2*q) break; cand.emplace_back(m,n); } } /* for(ll n=1;n*n<=q;n++){ if(q%n==0){ { ll m=q/n; if(n+m==p){ //mn=q, m+n=p cand.emplace_back(n,m); } } } } */ 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; } }