mirror of
https://github.com/tiennm99/codeforces.git
synced 2026-06-09 06:13:28 +00:00
32 lines
576 B
C#
32 lines
576 B
C#
using System;
|
|
|
|
namespace problem_999B
|
|
{
|
|
class problem_999B
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
int n = int.Parse(Console.ReadLine());
|
|
string s = Console.ReadLine();
|
|
for (int i = 1; i <= n; i++)
|
|
{
|
|
if (n%i == 0)
|
|
{
|
|
s = Reverse(s.Substring(0, i)) + s.Substring(i);
|
|
}
|
|
}
|
|
Console.Write(s);
|
|
}
|
|
public static string Reverse(string s)
|
|
{
|
|
char[] a = s.ToCharArray();
|
|
char[] b = new char[s.Length];
|
|
for (int i = 0; i < s.Length; i++)
|
|
{
|
|
b[i] = a[s.Length - 1 - i];
|
|
}
|
|
return new string(b);
|
|
}
|
|
}
|
|
}
|