結果

問題 No.84 悪の算盤
ユーザー soujikisoujiki
提出日時 2015-04-29 21:52:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 3,433 ms
コンパイル使用メモリ 73,840 KB
実行使用メモリ 55,940 KB
最終ジャッジ日時 2023-09-19 04:14:35
合計ジャッジ時間 5,986 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,856 KB
testcase_01 AC 128 ms
55,516 KB
testcase_02 AC 128 ms
55,368 KB
testcase_03 AC 127 ms
55,628 KB
testcase_04 AC 126 ms
55,512 KB
testcase_05 AC 128 ms
55,692 KB
testcase_06 AC 129 ms
55,596 KB
testcase_07 AC 128 ms
55,400 KB
testcase_08 AC 127 ms
55,664 KB
testcase_09 AC 128 ms
55,452 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 126 ms
55,604 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{
					if(C==1){
						ans = R/2;
					}
					else{
						ans = (C-1)*R/2+R/2-1;
					}
				}
			}
			else{
				if(C%2==0){
					if(R==1){
						ans = C/2;
					}
					else{
						ans = (R-1)*C/2+C/2-1;
					}
				}
				else{
					if(R==C){
						if(R==999999999){
							ans = (long)499999999*(long)500000000;
						}
						else{
							ans = (long)1+R/(long)2;
							ans = ans*R/(long)2;
						}
					}
					else{
						ans = (R-1)*(C-1)/2+(C-1)/2+(R-1)/2;
					}
				}
			}
			System.out.println(ans);
		}
	}
}
0