Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
a watery problem#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int toint(char c){ if(c == '_') return 0; if(c == '.') return 27; return c-'a'+1; } char tochar(int n){ if(n == 0) return '_'; if(n == 27) return '.'; return (char)(n+'a'-1); } int main() { int k; char str[1000]; while(1){ scanf("%d", &k); if(k == 0) break; scanf("%s", str); int n = strlen(str); int ans[1000]; for(int i = 0; i < n; i++){ ans[(k*i)%n] = (toint(str[i])+i)%28; } for(int i = 0; i < n; i++){ printf("%c", tochar(ans[i])); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator