A string
s of length
n
), for each divisor d, reverse the substring s[1…d] (i.e. the substring which starts at position 1 and ends at position d
Note
can be encrypted by the following algorithm:
- iterate over all divisors of n
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <set>
char a[110];
char b[110];
using namespace std;
int main()
{
int n,i,j,k;
cin>>n;
scanf("%s",a+1);
for(k=2;k<=n;k++)
{
if(n%k==0)
{
for(i=1;i<=n;i++)
{
if(i<=k)
{
b[i] = a[k+1-i];
}
else
b[i] = a[i];
}
strcpy(a+1,b+1);
//printf("%s\n",a+1);
}
}
printf("%s\n",a+1);
return 0;
}
), for each divisor d, reverse the substring s[1…d] (i.e. the substring which starts at position 1 and ends at position d
- ).
For example, the above algorithm applied to the string s
=" codeforces" leads to the following changes: " codeforces" → " secrofedoc" → " orcesfedoc" → " rocesfedoc" → " rocesfedoc" (obviously, the last reverse operation doesn't change the string because d=1).
You are given the encrypted string t
. Your task is to decrypt this string, i.e., to find a string s such that the above algorithm results in string t. It can be proven that this string salways exists and is unique.
InputThe first line of input consists of a single integer n
( 1≤n≤100) — the length of the string t. The second line of input consists of the string t. The length of t is n, and it consists only of lowercase Latin letters.
OutputPrint a string s
such that the above algorithm results in t.
Examples
Input
10 rocesfedoc
Output
codeforces
Input
16 plmaetwoxesisiht
Output
thisisexampletwo
Input
1 z
Output
z
The first example is described in the problem stateme