結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー fmhr
提出日時 2015-05-22 18:22:33
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 673 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,954 ms
コンパイル使用メモリ 281,952 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-15 22:07:13
合計ジャッジ時間 14,000 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import (
	"fmt"
	"math"
)

func intabs(a int) int {
	return int(math.Abs(float64(a)))
}
func main() {
	var x, y, l, ans int
	fmt.Scan(&x, &y, &l)
	ans = intabs(x)/l + intabs(y)/l
	if intabs(x)%l != 0 {
		ans += 1
	}
	if intabs(y)%l != 0 {
		ans += 1
	}
	//fmt.Println(ans, (x+y)%l)
	if x == 0 && y == 0 {
		//ans := 0
	} else if x == 0 && y > 0 {
		//ans := 0
	} else if x < 0 && y > 0 {
		ans += 1
	} else if x < 0 && y == 0 {
		ans += 1
	} else if x < 0 && y < 0 {
		ans += 2
	} else if x == 0 && y < 0 {
		ans += 2
	} else if x > 0 && y < 0 {
		ans += 2
	} else if x > 0 && y == 0 {
		ans += 1
	} else if x > 0 && y > 0 {
		ans += 1
	}
	fmt.Println(ans)
}
0