結果
問題 | No.229 線分上を往復する3つの動点の一致 |
ユーザー | 👑 hos.lyric |
提出日時 | 2019-04-06 18:22:20 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 2,308 bytes |
コンパイル時間 | 838 ms |
コンパイル使用メモリ | 121,152 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 04:53:09 |
合計ジャッジ時間 | 2,478 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 1 ms
6,944 KB |
testcase_16 | AC | 1 ms
6,944 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,944 KB |
testcase_19 | AC | 1 ms
6,940 KB |
testcase_20 | AC | 1 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,944 KB |
testcase_22 | AC | 1 ms
6,940 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 1 ms
6,944 KB |
testcase_25 | AC | 1 ms
6,944 KB |
testcase_26 | AC | 1 ms
6,944 KB |
testcase_27 | AC | 1 ms
6,944 KB |
testcase_28 | AC | 1 ms
6,944 KB |
testcase_29 | AC | 2 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | AC | 1 ms
6,944 KB |
testcase_33 | AC | 1 ms
6,940 KB |
testcase_34 | AC | 1 ms
6,944 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 1 ms
6,940 KB |
testcase_37 | AC | 1 ms
6,944 KB |
testcase_38 | AC | 1 ms
6,940 KB |
testcase_39 | AC | 2 ms
6,944 KB |
testcase_40 | AC | 1 ms
6,944 KB |
testcase_41 | AC | 1 ms
6,940 KB |
testcase_42 | AC | 1 ms
6,944 KB |
testcase_43 | AC | 1 ms
6,944 KB |
testcase_44 | AC | 1 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,944 KB |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
ソースコード
/* 0 <= a <= 1/2 t / T_i = n_i + a t / T_i = n_i - a t / T_i + t / T_j in Z or t / T_i - t / T_j in Z (a / b) (p / q) in Z <=> b q | a p <=> b | p && q | q */ import std.conv, std.functional, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } long lcm(long a, long b) { return a / gcd(a, b) * b; } long T1, T2, T3; void main() { try { for (; ; ) { T1 = readLong(); T2 = readLong(); T3 = readLong(); long ansP = 1, ansQ = 0; foreach (s; 0 .. 8) { long a12 = (s & 1) ? (T2 + T1) : (T2 - T1); long a13 = (s & 2) ? (T3 + T1) : (T3 - T1); long a23 = (s & 4) ? (T3 + T2) : (T3 - T2); long b12 = T1 * T2; long b13 = T1 * T3; long b23 = T2 * T3; long g; g = gcd(a12, b12); a12 /= g; b12 /= g; g = gcd(a13, b13); a13 /= g; b13 /= g; g = gcd(a23, b23); a23 /= g; b23 /= g; debug { writefln("%s/%s %s/%s %s/%s", a12, b12, a13, b13, a23, b23); } const p = lcm(lcm(b12, b13), b23); const q = gcd(gcd(a12, a13), a23); if (ansP * q > p * ansQ) { ansP = p; ansQ = q; } } writeln(ansP, "/", ansQ); } } catch (EOFException e) { } }