結果

問題 No.2947 Sing a Song
ユーザー lif4635lif4635
提出日時 2024-10-25 21:53:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 2,975 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 79,280 KB
最終ジャッジ日時 2024-10-25 21:53:38
合計ジャッジ時間 4,713 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
54,152 KB
testcase_01 AC 38 ms
53,812 KB
testcase_02 AC 41 ms
54,232 KB
testcase_03 AC 46 ms
62,168 KB
testcase_04 AC 49 ms
67,108 KB
testcase_05 AC 37 ms
53,276 KB
testcase_06 AC 47 ms
64,940 KB
testcase_07 AC 48 ms
65,332 KB
testcase_08 AC 49 ms
67,084 KB
testcase_09 AC 46 ms
64,432 KB
testcase_10 AC 46 ms
63,632 KB
testcase_11 AC 39 ms
54,076 KB
testcase_12 AC 50 ms
71,348 KB
testcase_13 AC 55 ms
72,972 KB
testcase_14 AC 41 ms
55,768 KB
testcase_15 AC 50 ms
64,976 KB
testcase_16 AC 47 ms
63,128 KB
testcase_17 AC 54 ms
68,336 KB
testcase_18 AC 66 ms
73,412 KB
testcase_19 AC 82 ms
76,608 KB
testcase_20 AC 71 ms
76,520 KB
testcase_21 AC 61 ms
69,560 KB
testcase_22 AC 66 ms
73,644 KB
testcase_23 AC 80 ms
76,560 KB
testcase_24 AC 81 ms
76,336 KB
testcase_25 AC 85 ms
76,808 KB
testcase_26 AC 81 ms
76,384 KB
testcase_27 AC 98 ms
79,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int-input
def II() -> int : return int(input())
def MI() -> int : return map(int, input().split())



class fenwick_tree():
    n=1
    data=[0 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.data=[0 for i in range(N)]
    def add(self,p,x):
        assert 0<=p<self.n,"0<=p<n,p={0},n={1}".format(p,self.n)
        p+=1
        while(p<=self.n):
            self.data[p-1]+=x
            p+=p& -p
    def sum(self,l,r):
        assert (0<=l and l<=r and r<=self.n),"0<=l<=r<=n,l={0},r={1},n={2}".format(l,r,self.n)
        return self.sum0(r)-self.sum0(l)
    def sum0(self,r):
        s=0
        while(r>0):
            s+=self.data[r-1]
            r-=r&-r
        return s
class dsu():
    n=1
    parent_or_size=[-1 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.parent_or_size=[-1 for i in range(N)]
    def merge(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        x=self.leader(a)
        y=self.leader(b)
        if x==y:
            return x
        if (-self.parent_or_size[x]<-self.parent_or_size[y]):
            x,y=y,x
        self.parent_or_size[x]+=self.parent_or_size[y]
        self.parent_or_size[y]=x
        return x
    def same(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        return self.leader(a)==self.leader(b)
    def leader(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        if (self.parent_or_size[a]<0):
            return a
        self.parent_or_size[a]=self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]
    def size(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        return -self.parent_or_size[self.leader(a)]
    def groups(self):
        leader_buf=[0 for i in range(self.n)]
        group_size=[0 for i in range(self.n)]
        for i in range(self.n):
            leader_buf[i]=self.leader(i)
            group_size[leader_buf[i]]+=1
        result=[[] for i in range(self.n)]
        for i in range(self.n):
            result[leader_buf[i]].append(i)
        result2=[]
        for i in range(self.n):
            if len(result[i])>0:
                result2.append(result[i])
        return result2

n = II()
s,t = input().split()
a = list(MI())

ls,lt = len(s),len(t)
def xgcd(a:int, b:int) -> tuple[int,int,int]: #Euclid互除法
    """ans = a*x0 + b*y0"""
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

g,x0,y0 = xgcd(ls,lt)

ls //= g
lt //= g

for ai in a:
    ans = []
    bi = ai//g
    
    #bi = ls*x0 + lt*y0
    y1 = y0*bi
    x1 = x0*bi
    ct = y1%ls
    
    ans.extend([t]*ct)
    cs = (bi - ct*lt)//ls
    ans.extend([s]*cs)
    
    print(*ans)
0