codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

548A.md (1394B)


      1 Source: https://codeforces.com/problemset/problem/548/A
      2 
      3 A. Mike and Fax
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string *s*.
     22 
     23  ![](https://espresso.codeforces.com/bf91dd1798c0160282a69436cd3b80c3d77d7428.png) 
     24 
     25 He is not sure if this is his own back-bag or someone else's. He remembered that there were exactly *k* messages in his own bag, each was a palindrome string and all those strings had the same length.
     26 
     27 He asked you to help him and tell him if he has worn his own back-bag. Check if the given string *s* is a concatenation of *k* palindromes of the same length.
     28 
     29 Input
     30 
     31 The first line of input contains string *s* containing lowercase English letters (1 ≤ |*s*| ≤ 1000).
     32 
     33 The second line contains integer *k* (1 ≤ *k* ≤ 1000).
     34 
     35 Output
     36 
     37 Print "YES"(without quotes) if he has worn his own back-bag or "NO"(without quotes) otherwise.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 saba  
     45 2
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 NO
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 saddastavvat  
     58 2
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 YES
     65 ```
     66 
     67 Note
     68 
     69 Palindrome is a string reading the same forward and backward.
     70 
     71 In the second sample, the faxes in his back-bag can be "saddas" and "tavvat".