結果

問題 No.442 和と積
ユーザー astaxanthin
提出日時 2021-07-19 17:45:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 558 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 83,276 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-17 13:34:57
合計ジャッジ時間 1,860 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

#define _vi vector<int>
#define _vvi vector<vector<int>>
#define all(x) x.begin(),x.end()

long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); };
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; };

int main() {
	ll a, b;
	cin >> a >> b;

	ll g = gcd(a, b);
	a /= g, b /= g;

	cout << g * gcd(a + b, g) << endl;
}
0