結果

問題 No.3108 Luke or Bishop
コンテスト
ユーザー Angga
提出日時 2025-04-19 15:19:09
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 0 ms / 2,000 ms
コード長 506 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,945 ms
コンパイル使用メモリ 272,020 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2026-07-09 23:24:20
合計ジャッジ時間 14,596 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import (
	"fmt"
)

func getRook (gx int, gy int) int {
	if (gx == 0 || gy == 0) {return 1}
	return 2
}

func getBishop (gx int, gy int) int {
	if ((gx + gy) % 2 != 0) {return 999}
	if (gx == 0 && gy == 0) {return 0}
	if (abs(gx) == abs(gy)) {return 1}
	return 2
}

func abs(x int) int{
	if(x < 0) {return -x}
	return x
}

func main(){
	var gx, gy int
	fmt.Scan(&gx, &gy)

	rook := getRook(gx,gy)
	bishop := getBishop(gx,gy)

	ans := rook
	if(bishop < ans) {ans = bishop}

	fmt.Println(ans)

}
0