結果

問題 No.796 well known
ユーザー htensaihtensai
提出日時 2019-11-11 19:23:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 72,096 KB
実行使用メモリ 56,524 KB
最終ジャッジ日時 2023-10-13 08:10:29
合計ジャッジ時間 6,128 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
56,024 KB
testcase_01 AC 119 ms
56,044 KB
testcase_02 AC 122 ms
55,432 KB
testcase_03 AC 121 ms
55,924 KB
testcase_04 AC 144 ms
56,128 KB
testcase_05 AC 159 ms
56,132 KB
testcase_06 AC 161 ms
55,760 KB
testcase_07 AC 141 ms
54,208 KB
testcase_08 AC 152 ms
55,660 KB
testcase_09 AC 140 ms
56,176 KB
testcase_10 AC 156 ms
56,412 KB
testcase_11 AC 140 ms
56,116 KB
testcase_12 AC 147 ms
56,120 KB
testcase_13 AC 149 ms
56,524 KB
testcase_14 AC 142 ms
56,396 KB
testcase_15 AC 153 ms
56,312 KB
testcase_16 AC 161 ms
56,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static TreeSet<Integer> primes;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int mod = (n - 1) % 3;
		int count = (n - 1) / 3 * 3;
		if (mod == 0) {
		    count--;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < count; i++) {
		    sb.append(1).append(" ");
		}
		if (mod == 0) {
		    sb.append(2).append(" ");
		} else if (mod == 1) {
		    sb.append(1).append(" ");
		} else {
		    sb.append(2).append(" ").append(2).append(" ");
		}
		sb.append(3);
		System.out.println(sb);
	}
}
0