結果
問題 | No.229 線分上を往復する3つの動点の一致 |
ユーザー |
![]() |
提出日時 | 2015-06-19 23:37:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 43 ms / 5,000 ms |
コード長 | 886 bytes |
コンパイル時間 | 588 ms |
コンパイル使用メモリ | 74,496 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 04:22:44 |
合計ジャッジ時間 | 3,452 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#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 <= 2000000; i++){LL r1 = c1 - c1 / i * i;LL r2 = c2 - c2 / i * i;LL r3 = c3 - c3 / i * i;if((r1 == r2 || r1 == i-r2)&& (r1 == r3 || r1 == i-r3)){d = i;}}if(t1 == t2 && t2 == t3){cout << "0/1" << endl;}LL d2 = gcd(m, d);cout << m/d2 << "/" << d/d2 << endl;return 0;}