#include #include int sbox1[] = {4, 10, 11, 15, 24, 16, 17, 1, 6, 9, 3, 22, 19, 2, 0, 23, 25, 18, 13, 8, 5, 21, 7, 12, 14, 20}; int sbox2[] = {2, 0, 20, 13, 11, 17, 4, 3, 9, 18, 23, 15, 24, 6, 16, 14, 22, 10, 25, 12, 21, 8, 7, 5, 19, 1}; #define NUM_ROUNDS 2234567890123ll char key[] = "bazavektorovehopriestoru"; long long countpoints(char *a) { long long ret = 0; for(int i = 0; i < 32; i++) for(int j = i + 1; j < 32; j++) if(sbox1[a[i]-'a'] == sbox2[a[j]-'a']) ret++; return ret; } void round(char *in, char *out) { for(int i = 0; i < 16; i++) out[i+16] = 'a' + sbox2[in[i]-'a']; for(int i = 16; i < 32; i++) out[i-16] = 'a' + sbox1[(in[i-16]-'a' + in[i]-'a' + key[i-16]-'a') % 26]; out[32] = 0; } int main() { char text[2][35]; int ind = 0; scanf("%s", text[ind]); for(long long i = 0; i < NUM_ROUNDS; i++){ round(text[ind], text[1 - ind]); ind = 1 - ind; } printf("%s\n", text[ind]); printf("%d\n", (int)sqrt(countpoints(text[ind]) / 2.0 + 8) - 1); }