题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6
题目大意:给你加密方式,请你求出解密。
直接逆运算搞,用到同余定理
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define PB push_back
#define MP make_pair
#define SZ size()
#define CL clear()
#define AA first
#define BB second
#define EPS 1e-8
#define ZERO(x) memset((x),0,sizeof(x))
const int INF = ~0U>>;
const double PI = acos(-1.0); int get_num(char c){
if( c=='_' ) return ;
if( c=='.') return ;
return c-'a'+;
} char get_char(int n){
if( n== ) return '_';
if( n== ) return '.';
return n+'a'-;
} int main(){
int k;
while( scanf("%d",&k),k ){
char buff[];
scanf("%s",buff);
int plaincode[],ciphercode[];
ZERO(plaincode); ZERO(ciphercode);
int n = strlen(buff);
for(int i=;i<n;i++){
ciphercode[i] = get_num(buff[i]);
}
for(int i=;i<n;i++){
plaincode[(k*i)%n] = (ciphercode[i] + i)%;
}
for(int i=;i<n;i++){
putchar(get_char(plaincode[i]));
}
puts("");
}
return ;
}