Submission #5896815


Source Code Expand

Copy
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
G = gcd(N,M)
if S[::N//G] == T[::M//G]:
    print(N*M//G)
else:
    print(-1) 

Submission Info

Submission Time
Task A - Two Abbreviations
User bio4eta
Language Python3 (3.4.3)
Score 300
Code Size 169 Byte
Status
Exec Time 35 ms
Memory 5304 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 300 / 300 sample-01.txt, sample-02.txt, sample-03.txt, sample-01.txt, sample-02.txt, sample-03.txt, subtask01-01.txt, subtask01-02.txt, subtask01-03.txt, subtask01-04.txt, subtask01-05.txt, subtask01-06.txt, subtask01-07.txt, subtask01-08.txt, subtask01-09.txt, subtask01-10.txt, subtask01-11.txt, subtask01-12.txt, subtask01-13.txt, subtask01-14.txt, subtask01-15.txt
Case Name Status Exec Time Memory
sample-01.txt 35 ms 5048 KB
sample-02.txt 35 ms 5048 KB
sample-03.txt 34 ms 5048 KB
subtask01-01.txt 35 ms 5048 KB
subtask01-02.txt 35 ms 5176 KB
subtask01-03.txt 35 ms 5176 KB
subtask01-04.txt 35 ms 5176 KB
subtask01-05.txt 35 ms 5304 KB
subtask01-06.txt 35 ms 5176 KB
subtask01-07.txt 35 ms 5176 KB
subtask01-08.txt 35 ms 5176 KB
subtask01-09.txt 35 ms 5176 KB
subtask01-10.txt 35 ms 5304 KB
subtask01-11.txt 35 ms 5176 KB
subtask01-12.txt 35 ms 5176 KB
subtask01-13.txt 35 ms 5176 KB
subtask01-14.txt 35 ms 5176 KB
subtask01-15.txt 35 ms 5176 KB