結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー shi-mo
提出日時 2016-03-26 23:37:18
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 339 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 876 ms
コンパイル使用メモリ 96,000 KB
最終ジャッジ日時 2026-05-10 04:21:49
合計ジャッジ時間 1,719 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.d(13): Error: `core.math.fabs` called with argument types `(int)` matches multiple overloads after implicit conversions:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(144):     `core.math.fabs(float x)`
and:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(146):     `core.math.fabs(real x)`
    int nx = (to!int(fabs(x)) + l - 1) / l;
                         ^
Main.d(14): Error: `core.math.fabs` called with argument types `(int)` matches multiple overloads after implicit conversions:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(144):     `core.math.fabs(float x)`
and:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(146):     `core.math.fabs(real x)`
    int ny = (to!int(fabs(y)) + l - 1) / l;
                         ^

ソースコード

diff #
raw source code

import std.stdio;
import std.conv;
import core.math;

int numRotations(int x, int y) {
    return (y < 0) ? 2 : ((0 == x) ? 0 : 1);
}

void main() {
    int x, y, l;
    readf("%s\n%s\n%s\n", &x, &y, &l);

    int nx = (to!int(fabs(x)) + l - 1) / l;
    int ny = (to!int(fabs(y)) + l - 1) / l;
    writeln(nx + ny + numRotations(x, y));
}
0