結果

問題 No.84 悪の算盤
ユーザー scache
提出日時 2014-12-03 00:05:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 554 bytes
コンパイル時間 3,341 ms
コンパイル使用メモリ 74,056 KB
実行使用メモリ 41,848 KB
最終ジャッジ日時 2024-10-13 08:42:58
合計ジャッジ時間 5,635 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #


import java.util.Scanner;

public class Main84 {
	public static void main(String[] args) {
		Main84 p = new Main84();
	}

	public Main84() {
		Scanner sc = new Scanner(System.in);
		long R = sc.nextLong();
		long C = sc.nextLong();
		solve(R, C);
	}

	public void solve(long r, long c) {
		
		long res = -1;
		if(r==1 || c==1)
			res += (r*c+1)/2;
		else if(r==c){
			res += (r*c-r-c+1)/4+r/2 + (r%2==0 ? 0 : 1);
		}else{
			res += r*(c/2);
			if(c%2==1)
				res += (r+1)/2;
		}
		
		
		System.out.println(res);
	}

}
0