結果

問題 No.1893 Cycle
ユーザー eagleeagle
提出日時 2022-05-28 14:00:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 2,421 ms
コンパイル使用メモリ 77,084 KB
実行使用メモリ 57,540 KB
最終ジャッジ日時 2023-10-20 23:05:25
合計ジャッジ時間 6,879 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
57,540 KB
testcase_01 AC 134 ms
57,340 KB
testcase_02 AC 131 ms
57,436 KB
testcase_03 AC 132 ms
57,360 KB
testcase_04 AC 129 ms
57,432 KB
testcase_05 AC 128 ms
57,244 KB
testcase_06 AC 131 ms
57,280 KB
testcase_07 AC 129 ms
57,068 KB
testcase_08 AC 132 ms
57,280 KB
testcase_09 AC 131 ms
55,368 KB
testcase_10 AC 131 ms
57,396 KB
testcase_11 AC 130 ms
57,364 KB
testcase_12 AC 128 ms
57,332 KB
testcase_13 AC 131 ms
57,440 KB
testcase_14 AC 138 ms
56,952 KB
testcase_15 AC 134 ms
57,392 KB
testcase_16 AC 128 ms
57,228 KB
testcase_17 AC 130 ms
57,348 KB
testcase_18 AC 129 ms
57,308 KB
testcase_19 AC 130 ms
57,324 KB
testcase_20 AC 130 ms
57,364 KB
testcase_21 AC 133 ms
57,332 KB
testcase_22 AC 130 ms
57,364 KB
testcase_23 AC 128 ms
57,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		//正三角形の頂点の組み合わせ
		int[][] delta = {
			{0, 4, 8},
			{1, 5, 9},
			{2, 6, 10},
			{3, 7, 11}
		};
		//与えられた値から小さい値と大きい値を取り出す
		int minVal;
		int maxVal;
		if(X > Y) {
			minVal = Y;
			maxVal = X;
		} else {
			minVal = X;
			maxVal = Y;
		}
		//どの組み合わせになるかを探す
		int index = -1;
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 3; j++) {
				if(delta[i][j] == minVal || delta[i][j] == maxVal) {
					index = i;
				}
			}
		}
		//最後の値を取り出す
		int ans = -1;
		for(int i = 0; i < 3; i++) {
			if(delta[index][i] != minVal && delta[index][i] != maxVal) {
				ans = delta[index][i];
			}
		}
		System.out.println(ans);
	}
}
0