Algorithm 版 (精华区)
发信人: Lerry (life is waiting...), 信区: Algorithm
标 题: 1006K-DoTheUntwist-ZJU
发信站: 哈工大紫丁香 (2002年10月11日13:36:17 星期五), 站内信件
找到一一对应的关系就解决了
#include "stdio.h"
#include "string.h"
int change(char* c,int i)
{
if(c[i]=='.') c[i]=27;
else if(c[i]=='_') c[i]=0;
else c[i]=c[i]-96;
return 0;
}
int unchange(char* c,int i)
{
if(c[i]==0) c[i]='_';
else if(c[i]==27) c[i]='.';
else c[i]=c[i]+96;
return 0;
}
int main(int argc, char* argv[])
{
int k;
char p[100];
char c[100];
int i,j;
int m,n;
#ifndef ONLINE_JUDGE
freopen("data.in","r",stdin);
#endif
scanf("%d",&k);
while(k>0)
{
scanf("%s",c);
n=strlen(c);
for(i=0;i<n;i++) change(c,i);
for(i=0;i<n;i++)
for(j=0;j<28;j++)
if((j-i+280)%28==c[i]){p[(k*i)%n]=j;break;}
for(i=0;i<n;i++){unchange(p,i);printf("%c",p[i]);}
printf("\n");
scanf("%d ",&k);
}
return 0;
}
--
RULE 2 - The world won't care about your self-esteem.
The world will expect you to accomplish something
BEFORE you feel good about yourself.
——Bill Gates
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.249.235]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.991毫秒