結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー augusuto04augusuto04
提出日時 2015-06-19 23:46:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 59,664 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 10:20:35
合計ジャッジ時間 1,879 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll GCD(int a, int b){
  if(b == 0)
    return a;
  return GCD(b, a % b);
}

ll calcGCD(int a, int b){
  if(a < b)
    swap(a, b);
  return GCD(a, b);
}

ll calcLCM2(ll a, ll b){
  if(a < b)
    swap(a, b);
  return a / GCD(a, b) * b;
}

ll calcLCM3(ll a, ll b, ll c){
  return calcLCM2(calcLCM2(a, b), c);
}

int main(){
  int t1, t2, t3;
  ll v1, v2, v3;
  cin >> t1 >> t2 >> t3;
  ll numer = calcLCM3(t1, t2, t3);
  v1 = numer / t1 + numer / t2;
  v2 = numer / t2 + numer / t3;
  v3 = numer / t3 + numer / t1;
  ll denom = calcGCD(v1, v2);
  denom = max(denom, calcGCD(v2, v3));
  denom = max(denom, calcGCD(v3, v1));
  ll tmp = calcGCD(numer, denom);
  cout << numer / tmp << "/" << denom / tmp << endl;
}
0