結果
| 問題 | No.186 中華風 (Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-15 11:17:38 |
| 言語 | D (dmd 2.111.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 610 bytes |
| 記録 | |
| コンパイル時間 | 3,355 ms |
| コンパイル使用メモリ | 195,580 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-01-15 11:17:44 |
| 合計ジャッジ時間 | 5,039 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
コンパイルメッセージ
/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;
// https://kmjp.hatenablog.jp/entry/2015/04/20/0900 より
// 中国剰余定理、総当たり
import std;
void main()
{
// 入力
long[3] X, Y;
foreach (i; 0 .. 3)
readln.chomp.formattedRead("%d %d", X[i], Y[i]);
// 答えの計算と出力
long x = 0, y;
foreach (i; 0 .. Y[1] + 1) {
long xx = X[0] + Y[0] * i;
if (xx > 0 && xx % Y[1] == X[1]) {
x = xx;
y = lcm(Y[0], Y[1]);
break;
}
}
if (x == 0) {
writeln(-1);
return;
}
foreach (i; 0 .. Y[2] + 1) {
long xx = x + y * i;
if (xx > 0 && xx % Y[2] == X[2]) {
writeln(xx);
return;
}
}
writeln(-1);
}