codeforces 999B Reversing Encryption

网友投稿 776 2022-08-29

codeforces 999B Reversing Encryption

codeforces 999B Reversing Encryption

​​ 题目描述 A string

s

s of length

n

n can be encrypted by the following algorithm:

iterate over all divisors of n

n in decreasing order (i.e. from n

n to 1

1 ), for each divisor d

d , reverse the substring s[1 \dots d]

s[1…d] (i.e. the substring which starts at position 1

1 and ends at position d

d ). For example, the above algorithm applied to the string

s

s =”codeforces” leads to the following changes: “codeforces”

\to

→ “secrofedoc”

\to

→ “orcesfedoc”

\to

→ “rocesfedoc”

\to

→ “rocesfedoc” (obviously, the last reverse operation doesn’t change the string because

d=1

d=1 ).

You are given the encrypted string

t

t . Your task is to decrypt this string, i.e., to find a string

s

s such that the above algorithm results in string

t

t . It can be proven that this string

s

s always exists and is unique.

输入输出格式 输入格式:

The first line of input consists of a single integer

n

n (

1 \le n \le 100

1≤n≤100 ) — the length of the string

t

t . The second line of input consists of the string

t

t . The length of

t

t is

n

n , and it consists only of lowercase Latin letters.

输出格式:

Print a string

s

s such that the above algorithm results in

t

t .

输入输出样例 输入样例#1: 复制

10 rocesfedoc 输出样例#1: 复制

codeforces 输入样例#2: 复制

16 plmaetwoxesisiht 输出样例#2: 复制

thisisexampletwo 输入样例#3: 复制

1 z 输出样例#3: 复制

z 说明 The first example is described in the problem statement.

reverse 末端指针+1

#includeusing namespace std;char s[110];int main(){// freopen("b.in","r",stdin); int n;scanf("%d",&n); scanf("%s",s+1); for (int i=1;i<=n;++i){ if (n%i) continue; reverse(s+1,s+i+1); } printf("%s",s+1); return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:mysql优化——查询优化(mysqlsql优化)
下一篇:bzoj 5407 girls
相关文章

 发表评论

暂时没有评论,来抢沙发吧~