結果

問題 No.478 一般門松列列
ユーザー shinwisteriashinwisteria
提出日時 2017-03-21 11:25:24
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 702 bytes
コンパイル時間 3,464 ms
コンパイル使用メモリ 80,504 KB
実行使用メモリ 65,680 KB
最終ジャッジ日時 2023-09-18 14:42:13
合計ジャッジ時間 13,768 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,596 KB
testcase_01 AC 138 ms
55,852 KB
testcase_02 AC 135 ms
55,896 KB
testcase_03 AC 137 ms
56,080 KB
testcase_04 AC 139 ms
55,588 KB
testcase_05 AC 137 ms
55,788 KB
testcase_06 AC 141 ms
54,016 KB
testcase_07 RE -
testcase_08 AC 139 ms
56,080 KB
testcase_09 AC 141 ms
56,036 KB
testcase_10 RE -
testcase_11 AC 364 ms
65,024 KB
testcase_12 AC 362 ms
65,680 KB
testcase_13 AC 361 ms
65,336 KB
testcase_14 AC 365 ms
65,188 KB
testcase_15 RE -
testcase_16 AC 280 ms
62,480 KB
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 AC 341 ms
65,516 KB
testcase_21 AC 323 ms
65,080 KB
testcase_22 RE -
testcase_23 WA -
testcase_24 AC 309 ms
63,464 KB
testcase_25 AC 337 ms
64,948 KB
testcase_26 AC 202 ms
56,320 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 205 ms
56,376 KB
testcase_30 AC 306 ms
63,192 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 284 ms
62,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class Kadomatsuretsu {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		s.close();
		ArrayList<Integer> list = new ArrayList<>();
		list.add(2);
		for(int i = 1;i < n;i++){
			if(i%2 == 1){
				list.add(list.get(i-1) - 2);
			}else if(i%2 == 0){
				list.add(list.get(i-1) + 4);
			}
		}
		if(k % 2 == 0){
			for(int i = 0;i < k;i++){
				list.set(4*i+1, list.get(4*i+1)+3);
			}
		}else{
			for(int i = 0;i < (k+1)/2;i++){
				list.set(2*i+1, list.get(2*i+1) + 3);
			}
		}
		for(int i : list){
			System.out.print(i + " ");
		}
		System.out.println();

	}

}
0