PhieuLang

fixme

Aug 29th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdint.h>
  3. #include <iomanip>
  4.  
  5.  
  6. void checkAllAdlers(uint32_t sofar, int depth, uint32_t a, uint32_t b) {
  7.     int modulus = 65521;
  8.     if (depth == 4) {
  9.         if ((b << 16) + a == sofar) {
  10.             std::cout << "Got a fixed point: 0x" <<
  11.                 std::hex << std::setw(8) << std::setfill('0') <<
  12.                 sofar << "\n";
  13.         }
  14.         return;
  15.     }
  16.     for (uint32_t i = 0; i < 256; ++i) {
  17.         uint32_t newa = a + i;
  18.         if (newa >= modulus) newa -= modulus;
  19.         uint32_t newb = b + a;
  20.         if (newb >= modulus) newb -= modulus;
  21.  
  22.         checkAllAdlers(sofar + (i << (depth*8)), depth + 1, newa, newb);
  23.     }
  24.     return;
  25. }
  26.  
  27. int main() {
  28.     put("abc");
  29.     system("pause");
  30.     checkAllAdlers(0, 0, 2, 0);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment