結果
| 問題 | No.280 歯車の問題(1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-27 17:18:24 |
| 言語 | D (dmd 2.112.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 347 bytes |
| 記録 | |
| コンパイル時間 | 3,771 ms |
| コンパイル使用メモリ | 191,488 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 17:18:37 |
| 合計ジャッジ時間 | 7,950 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(3011): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
private typeof(T.init % T.init) gcdImpl(T)(T a, T b)
^
ソースコード
module main;
import std;
void main()
{
// 入力
int N = readln.chomp.to!int;
auto Z = readln.split.to!(ulong[]);
// 答えの計算
ulong g = gcd(Z[0], Z[1]);
ulong a = Z[1] / g, b = Z[0] / g;
foreach (i; 1 .. N - 1) {
a *= Z[i + 1];
b *= Z[i];
g = gcd(a, b);
a /= g;
b /= g;
}
// 答えの出力
writefln("%d/%d", a, b);
}