#include <iostream>
//This function returns the same result for given values but should be somewhat random.
double PRH(unsigned iterations, int x, int y) {
unsigned long long hash;
x &= 0xFFF;
y &= 0xFFF;
iterations &= 0xFF;
hash = (iterations << 24);
hash |= (y << 12);
hash |= x;
unsigned long long rem = hash & 3;
unsigned long long h = hash;
switch (rem) {
case 3:
hash += h;
hash ^= hash << 32;
hash ^= h << 36;
hash += hash >> 22;
break;
case 2:
hash += h;
hash ^= hash << 22;
hash += hash >> 34;
break;
case 1:
hash += h;
hash ^= hash << 20;
hash += hash >> 2;
}
hash ^= hash << 6;
hash += hash >> 10;
hash ^= hash << 8;
hash += hash >> 34;
hash ^= hash << 50;
hash += hash >> 12;
return (hash & 0xFFFF) / static_cast<double>(0xFFFF);
}
int main()
{
std::cout << PRH(25, 6, 7);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKLy9UaGlzIGZ1bmN0aW9uIHJldHVybnMgdGhlIHNhbWUgcmVzdWx0IGZvciBnaXZlbiB2YWx1ZXMgYnV0IHNob3VsZCBiZSBzb21ld2hhdCByYW5kb20uCmRvdWJsZSBQUkgodW5zaWduZWQgaXRlcmF0aW9ucywgaW50IHgsIGludCB5KSB7CiAgICAgICAgdW5zaWduZWQgbG9uZyBsb25nIGhhc2g7CiAgICAgICAgeCAmPSAweEZGRjsKICAgICAgICB5ICY9IDB4RkZGOwogICAgICAgIGl0ZXJhdGlvbnMgJj0gMHhGRjsKICAgICAgICBoYXNoID0gKGl0ZXJhdGlvbnMgPDwgMjQpOwogICAgICAgIGhhc2ggfD0gKHkgPDwgMTIpOwogICAgICAgIGhhc2ggfD0geDsKICAgICAgICB1bnNpZ25lZCBsb25nIGxvbmcgcmVtID0gaGFzaCAmIDM7CiAgICAgICAgdW5zaWduZWQgbG9uZyBsb25nIGggPSBoYXNoOwoKICAgICAgICBzd2l0Y2ggKHJlbSkgewogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgICBoYXNoICs9IGg7CiAgICAgICAgICAgICAgICBoYXNoIF49IGhhc2ggPDwgMzI7CiAgICAgICAgICAgICAgICBoYXNoIF49IGggPDwgMzY7CiAgICAgICAgICAgICAgICBoYXNoICs9IGhhc2ggPj4gMjI7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgaGFzaCArPSBoOwogICAgICAgICAgICAgICAgaGFzaCBePSBoYXNoIDw8IDIyOwogICAgICAgICAgICAgICAgaGFzaCArPSBoYXNoID4+IDM0OwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgIGhhc2ggKz0gaDsKICAgICAgICAgICAgICAgIGhhc2ggXj0gaGFzaCA8PCAyMDsKICAgICAgICAgICAgICAgIGhhc2ggKz0gaGFzaCA+PiAyOwogICAgICAgIH0KICAgICAgICBoYXNoIF49IGhhc2ggPDwgNjsKICAgICAgICBoYXNoICs9IGhhc2ggPj4gMTA7CiAgICAgICAgaGFzaCBePSBoYXNoIDw8IDg7CiAgICAgICAgaGFzaCArPSBoYXNoID4+IDM0OwogICAgICAgIGhhc2ggXj0gaGFzaCA8PCA1MDsKICAgICAgICBoYXNoICs9IGhhc2ggPj4gMTI7CgogICAgICAgIHJldHVybiAoaGFzaCAmIDB4RkZGRikgLyBzdGF0aWNfY2FzdDxkb3VibGU+KDB4RkZGRik7CiAgICB9CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6Y291dCA8PCBQUkgoMjUsIDYsIDcpOwp9