結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
bamboo_circle
|
| 提出日時 | 2019-04-19 21:31:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,500 ms |
| コード長 | 874 bytes |
| コンパイル時間 | 1,425 ms |
| コンパイル使用メモリ | 160,076 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 16:46:38 |
| 合計ジャッジ時間 | 1,893 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
ll a,b;
cin >> a >> b;
ll ans = -1;
ll ab = a + b;
for(int i = 1; i * i <= ab; i++){
if(ab % i != 0) continue;
ll next = ab / i;
if((i+a)%b == 0 && (i+b)%a == 0){
ans = i;
break;
}
if((next+a)%b == 0 && (next+b)%a == 0){
ans = next;
break;
}
}
cout << ans << endl;
}
bamboo_circle