Hello Kitty |
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB |
Total submit users: 295, Accepted users: 282 |
Problem 10639 : No special judgement |
Problem description |
Kitty sends a kind of original email messages to her friend Garf. To write a message, she chooses a word W and a number n and replicates W n times horizontally. Then she repeats this string in the next line, but rotating the characters once to the left. And she repeats this ‘rotateand- output’ process until the word W appears displayed as the first column of the rectangular pattern that she produces. As an example, when she chooses the word Hello and the number 3, she gets the pattern: Kitty has been sending such emails during the last three years. Recently, Garf told her that perhaps her work may be automatized with a software to produce Kitty’s patterns. Could you help her? |
Input |
The input file contains several test cases, each one of them in a separate line. Each test case has a word and a positive integer that should generate the corresponding rectangular pattern. The word is a string of alphabetic characters (a..z). The number is less than 10. A line whose contents is a single period character means the end of the input (this last line is not to be processed). |
Output |
Output texts for each input case are presented in the same order that input is read. For each test case the answer must be a left aligned Kitty pattern corresponding to the input. The output must be written to standard output. |
Sample Input |
Love 1 Kitty 2 . |
Sample Output |
Love oveL veLo eLov KittyKitty ittyKittyK ttyKittyKi tyKittyKit yKittyKitt |
Problem Source |
XX Colombian National Programming Contest |
1 #include<iostream> 2 #include<string> 3 using namespace std; 4 5 int main() 6 { 7 char s[100002]; 8 int n,len,i,k,j,m; 9 while(cin>>s&&strcmp(s,".")!=0) 10 { 11 cin>>n; 12 len=strlen(s); 13 m=len; 14 for(k=0;k<m;k++) 15 { 16 for(j=0;j<n;j++) 17 for(i=0;i<len;i++) 18 { 19 if(i+k>=len) cout<<s[i+k-len]; 20 else cout<<s[i+k]; 21 } 22 cout<<"\n"; 23 } 24 } 25 return 0; 26 }