結果

問題 No.84 悪の算盤
コンテスト
ユーザー yuki2006
提出日時 2015-03-07 09:13:29
言語 Go
(1.25.5)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 743 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,391 ms
コンパイル使用メモリ 242,672 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-01-01 17:38:32
合計ジャッジ時間 13,330 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

// 参考 http://yukicoder.me/submissions/9329
var s = bufio.NewScanner(os.Stdin)

func next() string {
	// s.Split(bufio.ScanWords) // 削除: Scan後に呼ぶとPanicになるため
	s.Scan()
	return s.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}
func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// Scan開始前にSplitを設定しないとPanicになるため、ここに移動
	s.Split(bufio.ScanWords)

	R := nextLong()
	C := nextLong()
	ans := int64(0)
	n := R * C

	if R == C {
		ans = n/4+n%4
	}else {
		ans = n/2+n%2
	}
	fmt.Println(ans - 1)
}
0