結果

問題 No.478 一般門松列列
ユーザー fjafjafja
提出日時 2017-09-02 00:09:49
言語 Java
(openjdk 23)
結果
AC  
実行時間 370 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 4,068 ms
コンパイル使用メモリ 78,932 KB
実行使用メモリ 50,868 KB
最終ジャッジ日時 2024-11-06 17:53:51
合計ジャッジ時間 14,346 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class N478
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int cnt=n-k-2;
		int ans=100000;
		int up=0;
		System.out.print(ans+" ");
		for(int j=0;j<cnt;j++)
		{
			ans=100000;ans=(j%2==0)?ans+(j+1):ans-(j+1);
			System.out.print(ans+" ");
		}
		up=(ans>=100000)?1:-1;
		for(int i=cnt+1;i<n;i++)
		{
			if(up==1){ans=100000-(ans-100000);up++;}
			else if(up==-1){ans=100000+(100000-ans);up--;}
			else
			{
				if(up==2){ans--;}
				if(up==-2){ans++;}
			}
			System.out.print(ans+" ");
		}
		System.out.println();
	}
}


0