CF 999B. Reversing Encryption【模拟/string reverse】

【链接】:CF
【代码】:

#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
#define debug puts
#define setp cout << fixed << setprecision(3)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int N=3e5+5;
const int MOD=1e9+7;
const ll INF=1e18+8;
int n,k;
int a[N];
/*
给一个长度为n的字符串,经过他的因子个数的几次翻转,让你求最初的字符串。
*/
int main()
{
    FAST_IO
    while(cin>>n)
    {
        string s;
        cin>>s;
        for(int i=2;i<=n;i++)
        {
            if(n%i==0)
                reverse(s.begin(),s.begin()+i);
        }
        cout<<s<<endl;
    }
}
/*
10
rocesfedoc
codeforces

16
plmaetwoxesisiht
thisisexampletwo

*/
posted @ 2018-06-22 23:45  Roni_i  阅读(147)  评论(0编辑  收藏  举报