結果

問題 No.2845 Birthday Pattern in Two Different Calendars
ユーザー titia
提出日時 2024-08-25 03:44:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,088 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 18,580 KB
最終ジャッジ日時 2024-08-25 03:45:05
合計ジャッジ時間 7,418 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())

for tests in range(T):
    K,M,N=map(int,input().split())
    M-=1

    if M==0:
        print("No")
        continue

    USE=[0]*K
    ANS=[]
    now=0


    while True:
        
        if USE[now]==0 and USE[(now+M)%K]==0:
            ANS.append(now+1)
            USE[now]=1
            USE[(now+M)%K]=1
            now=now+2*M
            now%=K
            flag=0
        else:
            pp=now
            while USE[now]==1 or USE[(now+M)%K]==1:
                #print(now,pp)
                now=now+M
                now%=K

                if pp==now:
                    break

            #print(pp,now,"!")

            if pp==now:
                now=(now+1)%K

                if USE[now]==1 or USE[(now+M)%K]==1:
                    break


    if len(ANS)>=N:
        print("Yes")
        print(*ANS[:N])
    else:
        print("No")
0