結果
問題 |
No.2947 Sing a Song
|
ユーザー |
![]() |
提出日時 | 2025-02-03 23:05:59 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,519 bytes |
コンパイル時間 | 514 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 68,236 KB |
最終ジャッジ日時 | 2025-02-03 23:06:07 |
合計ジャッジ時間 | 5,617 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 25 |
ソースコード
import sys, math; sys.setrecursionlimit(10**8); sys.set_int_max_str_digits(0) inf = 1<<60; MOD = 998244353 from bisect import bisect_left, bisect_right from collections import deque, defaultdict, Counter from sortedcontainers import SortedList def I(): return sys.stdin.readline().rstrip() def II(): return int(sys.stdin.readline().rstrip()) def IS(): return sys.stdin.readline().rstrip().split() def MII(): return map(int, sys.stdin.readline().rstrip().split()) def LI(): return list(sys.stdin.readline().rstrip()) def TII(): return tuple(map(int, sys.stdin.readline().rstrip().split())) def LII(): return list(map(int, sys.stdin.readline().rstrip().split())) def LSI(): return list(map(str, sys.stdin.readline().rstrip().split())) def GMI(): return list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split())) def kiriage(a, b): return (a+b-1)//b N = int(input()) S, T = input().split() s, t = len(S), len(T) A = list(map(int, input().split())) def abm(a, b, m): d = math.gcd(a, b, m) a //= d b //= d m //= d #if math.gcd(a, m) != 1: # res = 'No Answer' #else: x = pow(a, -1, m)*b x %= m res = x return res # s, t は定数 def solve(a:int): # s*x + t*y == a を満たし、 # かつ x が最大になるような解を求める # mod s を取ると # t*y ≡ a (mod s) を解く y = abm(t, a, s) x = (a - t*y)//s return x, y for a in A: x, y = solve(a) #print(x, y) memo = [S]*x + [T]*y print(*memo)