結果
| 問題 |
No.2125 Inverse Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-12 17:39:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,334 bytes |
| コンパイル時間 | 939 ms |
| コンパイル使用メモリ | 100,644 KB |
| 最終ジャッジ日時 | 2025-02-15 10:05:47 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 7 WA * 23 |
ソースコード
#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;
}
}