結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-04-21 14:46:56 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 1,500 ms | 
| コード長 | 1,053 bytes | 
| コンパイル時間 | 1,412 ms | 
| コンパイル使用メモリ | 164,224 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-05 17:50:43 | 
| 合計ジャッジ時間 | 2,028 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 | 
ソースコード
//↓template↓
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;
long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}
void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}
//↑template↑
int main() {
	long long a, b, ans = -1;
	cin >> a >> b;
	if (2 * a == b) { ans = a * 3; }
	else if (2 * b == a) { ans = b * 3; }
	else if (3 * b == a) { ans = 2 * b; }
	else if (a * 3 == b) { ans = 2 * a; }
	else if (a % 2 == 0 && a / 2 * 3 == b) { ans = a / 2; }
	else if (b % 2 == 0 && b / 2 * 3 == a) { ans = b / 2; }
	cout << ans << endl;
}
            
            
            
        