dimanche 8 mars 2015

Decrypt the string of 0 and 1 if possible

Given an generator of 0 and 1 as below :



void encryptor(int N,unsigned S){
for(int i=1;i<=N;i++){
S=S*1103515245 + 12345;
int x=(S/65536)%32768;
x%=2;
cout<<x<<" ";
}
}


As we can see it will produce a string of 0 and 1. Now if we are given a string of 0 and 1 can we predict that weather this encryptor can generate that N length string for some S.


Like we can generate 011 with S=2 and N=3. The string can be 10^5 characters long and its assured that S can be at max 10^9. But we can't brute forcely test for each value of S as then complexity will be O(N*S).





Aucun commentaire:

Enregistrer un commentaire