You are viewing a single comment's thread. Return to all comments →
C++
string cipher(int k, string s) { int n = (int)s.size(), m = n-k+1, t = k+1; string r(m, 0), x(t, 0); for (int i = 0; i < m; i++) { x[i%t] = x[(i+1)%t] ^ (s[n-1-i]-'0'); r[m-1-i] = (x[i%t] ^ x[(i+k)%t]) + '0'; } return r; }
Seems like cookies are disabled on this browser, please enable them to open this website
Cipher
You are viewing a single comment's thread. Return to all comments →
C++