結果

問題 No.2845 Birthday Pattern in Two Different Calendars
ユーザー dp_ijk
提出日時 2024-08-23 22:19:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 87,268 KB
最終ジャッジ日時 2024-08-23 22:19:06
合計ジャッジ時間 5,970 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(K, M, N):
   M -= 1
   if M == 0:
      return
   from math import gcd
   G = gcd(K, M)
   def gen(x):
      y = x
      while True:
         yield y
         y = (y+M)%K
         if y == x:
            break
   res = []
   for r in range(G):
      lst = list(gen(r))
      if len(lst) in (2, 3):
         res.append(lst[0])
      else:
         res.extend(lst[::3])
   if len(res) >= N:
      res = res[:N]
      return [x+1 for x in res]
   else:
      return
T = int(input())
for _ in range(T):
   K, M, N = map(int, input().split())
   ans = solve(K, M, N)
   if ans is None:
      print("No")
   else:
      print("Yes")
      print(*ans)
0