結果
| 問題 | No.442 和と積 | 
| コンテスト | |
| ユーザー |  sahiya | 
| 提出日時 | 2020-12-28 02:29:32 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 1,000 ms | 
| コード長 | 1,249 bytes | 
| コンパイル時間 | 1,642 ms | 
| コンパイル使用メモリ | 110,912 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-08 13:38:48 | 
| 合計ジャッジ時間 | 2,511 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 | 
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;
struct edge {
    int to, cost, id;
};
const ll MOD = 1E+09 + 7; // =998244353;
const ll INF = 1E18;
const int MAX_N = 1E+05;
ll dx[4] = { -1, 1, 0, 0 }, dy[4] = { 0, 0, -1, 1 };
template <typename T>
T gcd(T a, T b);
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */
    cout << g * gcd(g, A / g + B / g) << "\n";
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
            
            
            
        