結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-04-19 21:24:43 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 648 bytes | 
| コンパイル時間 | 796 ms | 
| コンパイル使用メモリ | 115,788 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-22 00:48:18 | 
| 合計ジャッジ時間 | 1,333 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 WA * 5 | 
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
    auto s = readln.split.map!(to!long);
    auto A = s[0];
    auto B = s[1];
    long ans =10L^^18 + 10;
    bool ok(long C) {
        return (A + B) % C == 0 && (B + C) % A == 0 && (C + A) % B == 0;
    }
    for (long i = 1; i * i <= A + B; ++i) {
        if ((A + B) % i != 0) continue;
        if (ok(i)) ans = min(ans, i);
        if (ok((A+B/i))) ans = min(ans, (A+B)/i);
    }
    writeln(ans == 10L^^18 + 10 ? -1 : ans);
}
            
            
            
        