結果
| 問題 |
No.2125 Inverse Sum
|
| コンテスト | |
| ユーザー |
hiro71687k
|
| 提出日時 | 2024-01-09 00:06:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,110 bytes |
| コンパイル時間 | 4,183 ms |
| コンパイル使用メモリ | 254,764 KB |
| 最終ジャッジ日時 | 2025-02-18 16:36:31 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 27 |
ソースコード
#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;
}
}
hiro71687k