結果

問題 No.48 ロボットの操縦
ユーザー shi-moshi-mo
提出日時 2016-03-26 23:37:18
言語 D
(dmd 2.106.1)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 339 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 115,452 KB
最終ジャッジ日時 2024-04-27 02:18:08
合計ジャッジ時間 779 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.d(13): Error: `core.math.fabs` called with argument types `(int)` matches both:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(153):     `core.math.fabs(float x)`
and:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(155):     `core.math.fabs(real x)`
Main.d(14): Error: `core.math.fabs` called with argument types `(int)` matches both:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(153):     `core.math.fabs(float x)`
and:
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/math.d(155):     `core.math.fabs(real x)`

ソースコード

diff #

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