結果

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

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int gcd(int a, int b){return (b==0?a:gcd(b,a%b));}
int lcm(int a, int b){return a/gcd(a,b)*b;}

bool solve(ll T1, ll T2, ll T3, ll v, ll x){
  double d1 = v/(double)x/(double)T1;
  double d2 = v/(double)x/(double)T2;
  double d3 = v/(double)x/(double)T3;
  d1 -= (int)(d1);
  if(d1>0.5) d1 -= 0.5;
  d2 -= (int)(d2);
  if(d2>0.5) d2 -= 0.5;
  d3 -= (int)(d3);
  if(d3>0.5) d3 -= 0.5;

  //cout << d1 << " " << d2 << " " << d3 << endl;
  if(fabs(d1-d2)<1e-9 && fabs(d2-d3)<1e-9) return true;
  return false;
}


int main(){
  ll T1, T2, T3;
  cin >> T1;
  cin >> T2;
  cin >> T3;

  ll v = lcm(T1, lcm(T2, T3));
  for(ll i=v-1; i>0; i--){
    if(solve(T1, T2, T3, v, i)){
      cout << v << "/" << i << endl;
      return 0;
    }
  }
  
  return 0;
}
0