Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4. #include <vector>
  5. #include <string>
  6.  
  7. int main(int argc, char* argv[]) {
  8.   std::vector<long long> seeds;
  9.   std::string line;
  10.   std::ifstream seedsFile(argv[1]);
  11.   if (seedsFile.is_open()) {
  12.     while (std::getline(seedsFile, line)) {
  13.       seeds.push_back(std::stoll(line, NULL));
  14.     }
  15.   }
  16.   long long len = seeds.size(), checks = len*(len-1)/2, k, xtest = len-2, ystart = 1;
  17.   __int128 SolX, SolZ, SolBetterX, SolBetterZ, Diff;
  18.   for(long long c = 0, x = 0, y = ystart; c < checks; c++, x++, y++) {
  19.     Diff = seeds[y]-seeds[x];
  20.     SolX = -126780825563*Diff;
  21.     SolZ = 49284120807*Diff;
  22.     k = round((SolX+SolZ)/208975141171);
  23.     SolBetterX = SolX-k*341873128712;
  24.     SolBetterZ = SolZ+k*132897987541;
  25.     if (SolBetterX < 58594 && SolBetterX > -58594 && SolBetterZ < 58594 && SolBetterZ > -58594) {
  26.       std::cout << "Found: " << seeds[x] << "/" << seeds[y] << std::endl
  27.       << "Distance: " << (long long)SolBetterX << " X " << (long long)SolBetterZ << " Z " << std::endl;
  28.     }
  29.  
  30.     if (c%100000000 == 0) std::cout << (float)c/checks*100 << "%" << std::endl;
  31.  
  32.     if (x == xtest) {
  33.       x = -1;
  34.       xtest += x;
  35.     }
  36.     if (y == len-1) {
  37.       y = ystart;
  38.       ystart++;
  39.     }
  40.   }
  41.   return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement