結果

問題 No.942 プレゼント配り
ユーザー titiatitia
提出日時 2019-12-05 02:11:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 19,396 KB
最終ジャッジ日時 2023-08-21 15:30:44
合計ジャッジ時間 3,635 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,104 KB
testcase_01 AC 159 ms
19,368 KB
testcase_02 AC 16 ms
7,716 KB
testcase_03 AC 16 ms
7,852 KB
testcase_04 AC 162 ms
16,348 KB
testcase_05 AC 159 ms
19,396 KB
testcase_06 AC 15 ms
7,808 KB
testcase_07 AC 15 ms
7,780 KB
testcase_08 AC 119 ms
14,084 KB
testcase_09 AC 137 ms
14,912 KB
testcase_10 AC 15 ms
7,768 KB
testcase_11 AC 15 ms
7,876 KB
testcase_12 AC 15 ms
7,800 KB
testcase_13 AC 15 ms
7,856 KB
testcase_14 AC 136 ms
15,692 KB
testcase_15 AC 93 ms
12,380 KB
testcase_16 AC 108 ms
13,304 KB
testcase_17 AC 106 ms
13,332 KB
testcase_18 AC 15 ms
7,808 KB
testcase_19 AC 14 ms
7,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
if N==K==1:
    print("Yes")
    print(1)
    exit()

if N*(N+1)//2%K!=0 or N==K:
    print("No")
else:
    ANS=[[0]*(N//K) for i in range(K)]

    rest=N//K
    col=0

    if rest%2==1:

        start=0

        for i in range(K):
            ANS[i][0]=1+i

        for i in range(K):
            ANS[(i+K//2)%K][1]=K+i+1

        for i in range(K):
            ANS[i][2]=3*(K*3+1)//2-ANS[i][0]-ANS[i][1]

        col+=3

    for i in range(K):
        for j in range(col,rest):
            if j%2==0:
                ANS[i][j]=1+i+j*K
            else:
                ANS[i][j]=K-i+j*K

    print("Yes")
    for ans in ANS:
        print(*ans)
                
0