-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
47 lines (41 loc) · 964 Bytes
/
B.cpp
File metadata and controls
47 lines (41 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# include <vector>
# include <algorithm>
# include <iostream>
# include <map>
# include <unordered_map>
# include <set>
# include <unordered_set>
# include <string>
# define vi vector<int>
# define vs vector<string>
# define vvi vector<vector<int>>
# define vvs vector<vector<string>>
# define ll long long
# define ull unsigned long long
# define lp(n) for (int i=0; i<n; i++)
# define lp1(s, e, st) for (int i=s; i<e; i+=st)
using namespace std;
void solve()
{
int n;
string s;
cin >> n >> s;
for (int i=1; i<=n; i++)
{
if (n % i == 0)
{
string sub = s.substr(0, i);
reverse(sub.begin(), sub.end());
s = sub + s.substr(i, s.length() - i);
}
}
cout << s << endl;
}
int main()
{
int cases = 1;
//cin >> cases;
while (cases--)
solve();
return (0);
}