首页 > 其他 > 详细

ZOJ1006 Do the Untwist

时间:2020-02-15 13:31:38      阅读:58      评论:0      收藏:0      [点我收藏+]

简单模拟~

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+14;
int a[maxn];
unordered_map<char,int> pos;
string s="_abcdefghijklmnopqrstuvwxyz.";
int len;
char ch[maxn];
int main () {
    for (int i=0;i<28;i++)pos[s[i]]=i;
    int n;
    while (scanf("%d",&n)&&n) {
        scanf("%s",ch);
        len=strlen(ch);
        for (int i=0;i<len;i++) a[n*i%len]=(pos[ch[i]]+i)%28;
        for (int i=0;i<len;i++) printf ("%c",s[a[i]]);
        printf ("\n");
    }
    return 0;
}

 

ZOJ1006 Do the Untwist

原文:https://www.cnblogs.com/zhanglichen/p/12311148.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!