結果

問題 No.478 一般門松列列
ユーザー shinwisteriashinwisteria
提出日時 2017-03-21 11:21:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 3,623 ms
コンパイル使用メモリ 76,856 KB
実行使用メモリ 60,908 KB
最終ジャッジ日時 2023-09-18 14:41:24
合計ジャッジ時間 15,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 WA -
testcase_17 RE -
testcase_18 WA -
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 WA -
testcase_31 RE -
testcase_32 RE -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
			}
		}
		System.out.println(list);
		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);
			}
		}
		System.out.println(list);

	}

}
0