CoderForces999B- Reversing Encryption
1 second
256 megabytes
standard input
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.
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.
Print a string ss such that the above algorithm results in tt.
10
rocesfedoc
codeforces
16
plmaetwoxesisiht
thisisexampletwo
1
z
z
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的更多相关文章
- CodeForces - 999B Reversing Encryption
B - Reversing Encryption A string s of length n can be encrypted by the following algorithm: iterate ...
- Reversing Encryption(模拟水题)
A string ss of length nn can be encrypted(加密) by the following algorithm: iterate(迭代) over all divis ...
- CF 999B. Reversing Encryption【模拟/string reverse】
[链接]:CF [代码]: #include<bits/stdc++.h> #define PI acos(-1.0) #define pb push_back #define F fir ...
- CF999B Reversing Encryption 题解
Content 给一个长度为 \(n\) 的字符串 \(s\),执行以下操作: 降序遍历 \(n\) 的所有因子(从 \(n\) 到 \(1\)). 对于每一个因子 \(i\) 翻转字符串 \(s_{ ...
- Codeforces Round #490 (Div. 3)
感觉现在\(div3\)的题目也不错啊? 或许是我变辣鸡了吧....... 代码戳这里 A. Mishka and Contes 从两边去掉所有\(≤k\)的数,统计剩余个数即可 B. Reversi ...
- [Codeforces]Codeforces Round #490 (Div. 3)
Mishka and Contest #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JU ...
- Dynamics CRM 2015-Data Encryption激活报错
在CRM的日常开发中,Data Encryption经常是不得不开启的一个功能.但是有时,我们可能遇到一种情况,Organization导入之后,查看Data Encryption是已激活的状态,但是 ...
- 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> ...
- SQL Server 2014 Backup Encryption
转载自: Microsoft MVP Award Program Blog 来源:Microsoft MVP Award Program Blog 的博客:https://blogs.msdn.mic ...
- Assembler : The Basics In Reversing
Assembler : The Basics In Reversing Indeed: the basics!! This is all far from complete but covers ab ...
随机推荐
- python中字典的基础操作
dict1 = { 'name':'王麻子', 'age':25, 'phone':12580, 'high':160 } dict2 = { 'name':'张三', 'age':38, 'phon ...
- ES6学习笔记01 -- 暂时性死区 ( temporal dead zone )
参考文档: let 和 const 命令 - ECMAScript6入门 暂时性死区(temporal dead zone) 理解ES6中的TDZ(暂时性死区) ES6 中 let 暂时性死区详解 ...
- Hbase简介以及简单的入门操作
Hbase是一个分布式的.面向列的开源数据库,可实时的读写.随机访问超大规模的数据集. Hbase主要分为两种模型: 逻辑模型和物理模型 1. 逻辑模型 Hbase的名字的来源是Hadoop data ...
- RocketMQ消息轨迹-设计篇
目录 1.消息轨迹数据格式 2.记录消息轨迹 3.如何存储消息轨迹数据 @(本节目录) RocketMQ消息轨迹主要包含两篇文章:设计篇与源码分析篇,本节将详细介绍RocketMQ消息轨迹-设计相关. ...
- Unity加载AB包
Unity制作游戏AB包 需要注意的是在游戏场景运行的情况下,不能编译AB包,不运行的情况下编译AB包需要使用Unity的扩展菜单功能,首先需要建立菜单用来编译AB包. 1.建立AB包的名字,首先选中 ...
- [LC]21题 Merge Two Sorted Lists (合并两个有序链表)(链表)
①英文题目 Merge two sorted linked lists and return it as a new list. The new list should be made by spli ...
- 力扣(LeetCode)亲密字符串 个人题解
给定两个由小写字母构成的字符串 A 和 B ,只要我们可以通过交换 A 中的两个字母得到与 B 相等的结果,就返回 true :否则返回 false . 示例 1: 输入: A = "ab& ...
- Andorid开发中遇到的问题
最近开始学习开发Android App,找了本教程,学了一些基本知识后,就开始着手做一个例子. 我始终觉得在做中学,可能会稍微快一点.很快,一个具有初步功能的App被我撸出来了. 在模拟器上运行,我发 ...
- vim的查找功能
vim是一款强大的编辑器. 在vim下要查找字符串: 一,全匹配: 1,从上往下查找,比如“string” : /string 2,从下往上查找,比如“string” : ?string 二,模糊 ...
- ProxySQL读写分离代理
实现ProxySQL反向代理Mysql读写分离 简介 ProxySQL相当于小型的数据库,在磁盘上有存放数据库的目录:ProxySQL用法和mysql相似 启动ProxySQL后会有两个监听端口: 6 ...