結果

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

ソースコード

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))
      res.extend(lst[:-1:2])
   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