![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/cfb57ce3ffb884926f619a46723bdd77.png)
package string;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static java.lang.Integer.parseInt;
import static java.lang.System.in;
public class StringEncryption {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
int num = parseInt(bf.readLine());
List<String> lines = new ArrayList<>();
for (int i = 0; i < num; i++) {
char[] chars = bf.readLine().toCharArray();
String tran = tran(chars);
lines.add(tran);
}
bf.close();
lines.forEach(System.out::println);
}
public static int fun(int loc) {
if (loc == 0) {
return 1;
} else if (loc == 1) {
return 2;
} else if (loc == 2) {
return 4;
}
return fun(loc - 1) + fun(loc - 2) + fun(loc - 3);
}
public static String tran(char[] arr) {
Character[] res = new Character[arr.length];
for (int i = 0; i < arr.length; i++) {
int step = fun(i);
int newChar = arr[i] + step;
if ('a' <= newChar && newChar <= 'z') {
res[i] = (char) newChar;
} else {
res[i] = (char) ((newChar - 'a') % 26 + 'a');
}
}
return Arrays.stream(res).map(String::valueOf).collect(Collectors.joining(""));
}
}