Submission #3392922

Source Code Expand

Copy
N, M = gets.split.map(&:to_i)
S = gets.chomp
T = gets.chomp

g = N.gcd(M)
l = N.lcm(M)

g.times do |i|
    if S[N/g*i] != T[M/g*i]
        puts -1
        exit
    end
end
puts l

Submission Info

Submission Time
Task A - Two Abbreviations
User betrue12
Language Ruby (2.3.3)
Score 300
Code Size 191 Byte
Status
Exec Time 10 ms
Memory 2044 KB

Compile Error

./Main.rb:10: warning: ambiguous first argument; put parentheses or a space even after `-' operator

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 8 ms 1788 KB
sample-02.txt 8 ms 1788 KB
sample-03.txt 8 ms 1788 KB
subtask01-01.txt 8 ms 1788 KB
subtask01-02.txt 8 ms 1916 KB
subtask01-03.txt 8 ms 2044 KB
subtask01-04.txt 8 ms 2044 KB
subtask01-05.txt 8 ms 2044 KB
subtask01-06.txt 8 ms 2044 KB
subtask01-07.txt 8 ms 1916 KB
subtask01-08.txt 10 ms 1916 KB
subtask01-09.txt 8 ms 2044 KB
subtask01-10.txt 8 ms 2044 KB
subtask01-11.txt 8 ms 2044 KB
subtask01-12.txt 10 ms 2044 KB
subtask01-13.txt 8 ms 2044 KB
subtask01-14.txt 9 ms 2044 KB
subtask01-15.txt 10 ms 2044 KB