結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー machymachy
提出日時 2015-06-19 23:29:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 73,868 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 10:15:01
合計ジャッジ時間 2,354 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 WA -
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 3 ms
4,380 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long LL;

LL gcd(LL a, LL b){
    if(a > b) swap(a, b);
    if(a == 0) return b;
    return gcd(b % a, a);
}

LL lcm(LL a, LL b){
    return a * b / gcd(a, b);
}

int main(){
    LL t1, t2, t3;
    cin >> t1 >> t2 >> t3;
    LL m = lcm(t1, lcm(t2, t3));
    LL c1 = m / t1;
    LL c2 = m / t2;
    LL c3 = m / t3;
    LL d = 1;
    for(LL i = 1; i <= 20000; i++){
        LL r1 = c1 - c1 / i * i;
        LL r2 = c2 - c2 / i * i;
        LL r3 = c3 - c3 / i * i;
        if((r1 == r2 || (r1*2 <= i && r1 == i-r2) || (i-r1 == r2 && r2*2 <= i))
            && (r1 == r3 || (r1*2 <= i && r1 == i-r3) || (i-r1 == r3 && r3*2 <= i))){
            d = i;
        }
    }
    cout << m << "/" << d << endl;
    return 0;
}
0