1. 程式人生 > >CF 999B. Reversing Encryption【模擬/string reverse】

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

his amp for cout pro contest codeforce == mod

【鏈接】: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

*/

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