time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A string ss of length nn can be encrypted by the following algorithm:

  • iterate over all divisors of nn in decreasing order (i.e. from nn to 11),
  • for each divisor dd, reverse the substring s[1…d]s[1…d] (i.e. the substring which starts at position 11 and ends at position dd).

For example, the above algorithm applied to the string ss="codeforces" leads to the following changes: "codeforces" →→"secrofedoc" →→ "orcesfedoc" →→ "rocesfedoc" →→ "rocesfedoc" (obviously, the last reverse operation doesn't change the string because d=1d=1).

You are given the encrypted string tt. Your task is to decrypt this string, i.e., to find a string ss such that the above algorithm results in string tt. It can be proven that this string ss always exists and is unique.

Input

The first line of input consists of a single integer nn (1≤n≤1001≤n≤100) — the length of the string tt. The second line of input consists of the string tt. The length of tt is nn, and it consists only of lowercase Latin letters.

Output

Print a string ss such that the above algorithm results in tt.

Examples
input
Copy
10
rocesfedoc
output
Copy
codeforces
input
Copy
16
plmaetwoxesisiht
output
Copy
thisisexampletwo
input
Copy
1
z
output
Copy
z
Note

The first example is described in the problem statement.

ac代码为:

#include<bits/stdc++.h>
using namespace std;
char s1[110],s2[110];
void work(char *s1,int l,int r)
{
    int temp=r;
    for(int i=l;i<=r;i++) s2[temp--]=s1[i];
    for(int i=l;i<=r;i++) s1[i]=s2[i];
}
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",s1+1);
    for(int i=1;i<=n;i++)
    {
        if(n%i==0) work(s1,1,i);    
    }
    printf("%s\n",s1+1);
    return 0;
}

CoderForces999B- Reversing Encryption的更多相关文章

  1. CodeForces - 999B Reversing Encryption

    B - Reversing Encryption A string s of length n can be encrypted by the following algorithm: iterate ...

  2. Reversing Encryption(模拟水题)

    A string ss of length nn can be encrypted(加密) by the following algorithm: iterate(迭代) over all divis ...

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

    [链接]:CF [代码]: #include<bits/stdc++.h> #define PI acos(-1.0) #define pb push_back #define F fir ...

  4. CF999B Reversing Encryption 题解

    Content 给一个长度为 \(n\) 的字符串 \(s\),执行以下操作: 降序遍历 \(n\) 的所有因子(从 \(n\) 到 \(1\)). 对于每一个因子 \(i\) 翻转字符串 \(s_{ ...

  5. Codeforces Round #490 (Div. 3)

    感觉现在\(div3\)的题目也不错啊? 或许是我变辣鸡了吧....... 代码戳这里 A. Mishka and Contes 从两边去掉所有\(≤k\)的数,统计剩余个数即可 B. Reversi ...

  6. [Codeforces]Codeforces Round #490 (Div. 3)

    Mishka and Contest #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JU ...

  7. Dynamics CRM 2015-Data Encryption激活报错

    在CRM的日常开发中,Data Encryption经常是不得不开启的一个功能.但是有时,我们可能遇到一种情况,Organization导入之后,查看Data Encryption是已激活的状态,但是 ...

  8. backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized.

    昨天在检查YourSQLDba备份时,发现有台数据库做备份时出现了下面错误信息,如下所示: <Exec>   <ctx>yMaint.ShrinkLog</ctx> ...

  9. SQL Server 2014 Backup Encryption

    转载自: Microsoft MVP Award Program Blog 来源:Microsoft MVP Award Program Blog 的博客:https://blogs.msdn.mic ...

  10. Assembler : The Basics In Reversing

    Assembler : The Basics In Reversing Indeed: the basics!! This is all far from complete but covers ab ...

随机推荐

  1. vue-create 报错 command failed: yarn --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist 完美解决方案

    @vue/cli 3.x 创建项目失败解决方案 报错信息 command failed: yarn --registry=https://registry.npm.taobao.org --distu ...

  2. chrome中安装Vue调试工具vue-devtools

    一.前言 vue-devtools是一款基于浏览器的插件,用来调试vue应用.本篇文章将要总结的是如何在chrome中安装Vue的调试工具vue-devtools. 首先能想到的第一种方法就是直接在c ...

  3. Python数据强制类型转换

    本文链接:https://www.cnblogs.com/zyuanlbj/p/11909992.html 常用转换函数 函数 作用 int(x) 将x转换成整数类型 float(x) 将 x 转换成 ...

  4. SpringBoot 源码解析 (八)----- Spring Boot 精髓:事务源码解析

    本篇来讲一下SpringBoot是怎么自动开启事务的,我们先来回顾一下以前SSM中是如何使用事务的 SSM使用事务 导入JDBC依赖包 众所周知,凡是需要跟数据库打交道的,基本上都要添加jdbc的依赖 ...

  5. 初探SpringMVC,走进SpringMVC的世界

    1.Springmvc入门 1.1.Springmvc是什么 SpringMVC是Spring中的一个组件,目前(2019)在互联网公司用的很多,是必需学习的一门框架技术!SpringMVC用于web ...

  6. 新闻实时分析系统 SQL快速离线数据分析

    1.Spark SQL概述1)Spark SQL是Spark核心功能的一部分,是在2014年4月份Spark1.0版本时发布的. 2)Spark SQL可以直接运行SQL或者HiveQL语句 3)BI ...

  7. [ch03-02] 交叉熵损失函数

    系列博客,原文在笔者所维护的github上:https://aka.ms/beginnerAI, 点击star加星不要吝啬,星越多笔者越努力. 3.2 交叉熵损失函数 交叉熵(Cross Entrop ...

  8. yum运行报错:/usr/lib64/python2.7/site-packages/pycurl.so: undefined symbol: CRYPTO_num_locks

    是因为yum动态库使用了新安装libcurl库导致的.使用ldd查看动态库依赖关系: ldd /usr/lib64/python2.7/site-packages/pycurl.so 删除动态库配置中 ...

  9. Kibana笔记

    • 根据id查询 GET index_1/doc/1 • 全文检索 GET index_1/doc/_search GET index_1/doc/_search{ "query" ...

  10. 使用Cap解决.Netcore分布式事务

    一.什么是Cap    CAP 是一个基于 .NET Standard 的 C# 库,它是一种处理分布式事务的解决方案,同样具有 EventBus 的功能,它具有轻量级.易使用.高性能等特点. 在我们 ...