結果

問題 No.796 well known
ユーザー htensai
提出日時 2019-11-11 19:23:36
言語 Java
(openjdk 23)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 74,204 KB
実行使用メモリ 41,972 KB
最終ジャッジ日時 2024-09-15 05:20:40
合計ジャッジ時間 5,993 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

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