結果

問題 No.84 悪の算盤
ユーザー soujikisoujiki
提出日時 2015-04-29 21:23:16
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 605 bytes
コンパイル時間 3,260 ms
コンパイル使用メモリ 72,492 KB
実行使用メモリ 56,036 KB
最終ジャッジ日時 2023-09-19 04:13:20
合計ジャッジ時間 5,796 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,768 KB
testcase_01 AC 127 ms
55,424 KB
testcase_02 AC 125 ms
55,776 KB
testcase_03 AC 126 ms
55,932 KB
testcase_04 AC 128 ms
55,728 KB
testcase_05 AC 128 ms
55,984 KB
testcase_06 WA -
testcase_07 AC 126 ms
55,704 KB
testcase_08 AC 128 ms
56,036 KB
testcase_09 AC 128 ms
55,840 KB
testcase_10 WA -
testcase_11 AC 128 ms
55,560 KB
testcase_12 AC 127 ms
55,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

	
import java.util.*;

public class Yukicoder_84{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		long R = stdIn.nextLong();
		long C = stdIn.nextLong();
		long ans = 0;
		if(R==1 && C==1){
			System.out.println(0);
		}
		else{
			if(R%2==0){
				if(C%2==0){
					if(R==C){
						ans = (long)Math.pow(R/2,2)-1;
					}
					else{
						ans = R*C/2;
					}
				}
				else{
					ans = (C-1)*R/2+R/2-1;
				}
			}
			else{
				if(C%2==0){
					ans = (R-1)*C/2+C/2-1;
				}
				else{
					ans = (R-1)*(C-1)/2+(C-1)/2+(R-1)/2;
				}
			}
			System.out.println(ans);
		}
	}
}
0