結果

問題 No.356 円周上を回る3つの動点の一致
ユーザー finefine
提出日時 2016-04-01 23:40:29
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 1,437 ms
コンパイル使用メモリ 158,044 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-02 09:53:04
合計ジャッジ時間 3,646 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int gcd(int m, int n) {
    int r = m % n;
    while (r != 0) {
        m = n;
        n = r;
        r = m % n;
    }
    return n;
}

int lcm(int m, int n) {
    return m / gcd(m,n) * n; 
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,tmp,x,y,z,tmp2;
    cin >> a >> b >> c;
    tmp = lcm(a, lcm(b,c));
    a = tmp / a;
    b = tmp / b;
    c = tmp / c;
    for(int i = max(a, max(b, c)); i >= 2; i--) {
        x = a % i;
        y = b % i;
        z = c % i;
        if (x == y && y == z) {
            tmp2 = gcd(tmp,i);
            cout << tmp / tmp2 << '/' << i / tmp2 << "\n";
            return 0;
        }
    }
    cout << tmp << '/' << 1 << "\n";
    return 0;
}
0