結果

問題 No.942 プレゼント配り
ユーザー 37zigen37zigen
提出日時 2019-12-08 05:21:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 2,648 ms
コンパイル使用メモリ 74,916 KB
実行使用メモリ 68,656 KB
最終ジャッジ日時 2023-08-27 15:13:07
合計ジャッジ時間 9,961 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 111 ms
55,504 KB
testcase_03 AC 114 ms
56,136 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 113 ms
55,980 KB
testcase_07 AC 112 ms
55,876 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 115 ms
55,812 KB
testcase_11 AC 113 ms
55,940 KB
testcase_12 AC 113 ms
55,644 KB
testcase_13 AC 116 ms
56,148 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 111 ms
56,220 KB
testcase_19 AC 112 ms
56,156 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){
			System.out.println("Yes");
			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("No");
		}
	}
	
	void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
	}
}
0