結果

問題 No.942 プレゼント配り
ユーザー 37zigen37zigen
提出日時 2019-12-08 05:20:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 2,572 ms
コンパイル使用メモリ 74,896 KB
実行使用メモリ 69,584 KB
最終ジャッジ日時 2023-08-27 15:10:40
合計ジャッジ時間 10,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 114 ms
56,324 KB
testcase_03 AC 114 ms
55,800 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 115 ms
53,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 115 ms
56,180 KB
testcase_11 AC 115 ms
55,844 KB
testcase_12 AC 117 ms
56,460 KB
testcase_13 AC 113 ms
55,772 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 112 ms
54,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		if(N*(N+1)/2%K!=0){
			System.out.println("No");
			return;
		}
		// N/K%2==0 : Yes
		// (1,N),(1+N/(2K),N-N/(2K)),
		if(N/K%2==0){
			for(int i=0;i<K;++i){
				for(int j=0;j<N/K/2;++j){
					System.out.print((1+i)+(N/(2*K)*j));
					System.out.print(" ");
					System.out.print((N-i)-(N/(2*K)*j));
				}
				System.out.println();
			}
			System.out.println();
		}else{
			System.out.println("Yes");
		}
	}
	
	void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
	}
}
0