Power String Matching
시간 제한3초메모리 제한2048 MB
s를 연속한 조각으로 나눈 뒤 각 조각을 0회 이상 반복해 이어 붙여 t를 만들 수 있는지 판정한다.
문제
For two strings and , let denote their concatenation, e.g. abc + cda is the string abccda.
Now for a string and an integer we let denote the result of concatenating copies of , i.e. abababab. If , then is just the empty string.
Finally, a collection of nonempty strings is said to partition a string if .
For this problem, you will be given two strings , . The goal is to determine if there is a partition of and integers such that .
입력
The first line of input contains two integers () and (). The second line contains a string of length and the third line contains a string of length . Both strings contain only the characters 0 and 1.
출력
Output yes if it there is a partition of and integers such that , otherwise output no.