码迷,mamicode.com
首页 > 其他好文 > 详细

ZOJ1006 Do the Untwist

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

标签:i++   har   ret   string   max   pos   div   模拟   const   

简单模拟~

#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

标签:i++   har   ret   string   max   pos   div   模拟   const   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!