結果

問題 No.942 プレゼント配り
ユーザー 37zigen37zigen
提出日時 2019-12-08 07:59:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 4,715 ms
コンパイル使用メモリ 75,908 KB
実行使用メモリ 67,860 KB
最終ジャッジ日時 2023-08-28 12:42:35
合計ジャッジ時間 12,355 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
56,828 KB
testcase_01 AC 1,046 ms
67,272 KB
testcase_02 AC 125 ms
55,788 KB
testcase_03 AC 125 ms
55,968 KB
testcase_04 WA -
testcase_05 AC 969 ms
62,288 KB
testcase_06 AC 127 ms
55,780 KB
testcase_07 AC 127 ms
55,804 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 126 ms
55,832 KB
testcase_11 AC 125 ms
55,764 KB
testcase_12 AC 127 ms
55,504 KB
testcase_13 AC 127 ms
55,624 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 126 ms
56,032 KB
testcase_19 AC 125 ms
55,788 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();//N個のプレゼント
		int K=sc.nextInt();//K人の子供
		// N%K=0
		if(N*(N+1)/2%K!=0){//必ず満たす
			System.out.println("No");
			return;
		}
		int q=N/K;
		if(N==K&&N>1){
			System.out.println("No");
		}if(K==1){
			System.out.println("Yes");
			for(int i=0;i<N;++i){
				System.out.print((i+1)+(i==N-1 ? "\n" : " "));
			}
		}else if(q%2==0){
			System.out.println("Yes");
			for(int i=0;i<K;++i){
				for(int j=0;j<q/2;++j){
					System.out.print((1+i)+(q/2*j));
					System.out.print(" ");
					System.out.print((N-i)-(q/2*j));
				}
				System.out.println();
			}
		}else if(K%2==1){
			System.out.println("Yes");
			for(int i=0;i<K;++i){
				long sum=3*(3*K+1)/2;
				long res=sum-(3*K-i)-(2*i%K+1);
				System.out.print((3*K-i)+" "+(2*i%K+1)+" "+res);
				for(int j=0;j<(q-3)/2;++j){
					System.out.print(" ");
					System.out.print((1+i+3*K)+(q/2*j));
					System.out.print(" ");
					System.out.print((N-i)-(q/2*j));
				}
				System.out.println();
			}
		}else{
			System.out.println("No");
		}
	}
	
	void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
	}
}
0