結果

問題 No.1528 Not 1
ユーザー ks2mks2m
提出日時 2021-06-04 20:35:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 2,802 ms
コンパイル使用メモリ 71,524 KB
実行使用メモリ 58,724 KB
最終ジャッジ日時 2023-08-12 09:47:15
合計ジャッジ時間 7,560 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,008 KB
testcase_01 AC 186 ms
58,324 KB
testcase_02 AC 164 ms
56,576 KB
testcase_03 AC 163 ms
56,292 KB
testcase_04 AC 174 ms
58,216 KB
testcase_05 AC 146 ms
56,112 KB
testcase_06 AC 163 ms
58,356 KB
testcase_07 AC 188 ms
58,032 KB
testcase_08 AC 167 ms
56,468 KB
testcase_09 AC 158 ms
55,916 KB
testcase_10 AC 167 ms
56,612 KB
testcase_11 AC 121 ms
55,840 KB
testcase_12 AC 123 ms
54,368 KB
testcase_13 AC 122 ms
56,160 KB
testcase_14 AC 121 ms
55,516 KB
testcase_15 AC 122 ms
56,028 KB
testcase_16 AC 121 ms
56,120 KB
testcase_17 AC 119 ms
55,752 KB
testcase_18 AC 191 ms
58,508 KB
testcase_19 AC 196 ms
58,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		if (n % 2 == 0) {
			StringBuilder sb = new StringBuilder();
			for (int i = 2; i <= n; i += 2) {
				sb.append(i).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());

		} else if (n == 1) {
			System.out.println(1);

		} else if (n == 3 || n == 5) {
			System.out.println(-1);

		} else {
			StringBuilder sb = new StringBuilder();
			for (int i = 2; i <= n; i += 2) {
				if (i != 6) {
					sb.append(i).append(' ');
				}
			}
			sb.append("6 3");
			System.out.println(sb.toString());
		}
	}
}
0