int calculatetta(char* a) { int b = 0; for (int c = 0; c < strlen(a); ++c) { b = (b + (c + 1) * (c + 2) * a[c]) % 1009; if (c % 3 == 0) ++b; if (c % 2 == 0) b *= 2; if (c > 0) b -= ((int) (a[c / 2] / 2)) * (b % 5); while (b < 0) b += 1009; while (b >= 1009) b -= 1009; } return b; }
def calculatetta(a: str): b = 0 for c in range(len(a)): b = (b + (c + 1) * (c + 2) * ord(a[c])) % 1009 if c % 3 == 0: b = b + 1 if c % 2 == 0: b = b * 2 if c > 0: b = b - (ord(a[c // 2]) // 2) * (b % 5) while b < 0: b = b + 1009 while b >= 1009: b = b - 1009 return b
public static int calculatetta(String a) { int b = 0; for (int c = 0; c < a.length(); ++c) { b = (b + (c + 1) * (c + 2) * ((int) a.charAt(c))) % 1009; if (c % 3 == 0) ++b; if (c % 2 == 0) b *= 2; if (c > 0) b -= (((int) a.charAt(c / 2)) / 2) * (b % 5); while (b < 0) b += 1009; while (b >= 1009) b -= 1009; } return b; }
首先输入一个正整数,表示案例组数,每组案例输入一个正整数
,表示
的值
对于每组样例输出一个长度为的字符串,表示
所对应的字符串,有多个答案输出任意即可,若无解输出
。注意,你输出的字符串,只能含有大写字母、小写字母、数字中的一种或几种(不能输出特殊字符)。