fork(16) download
  1. #include <iostream>
  2. #include <chrono>
  3. using namespace std;
  4.  
  5. typedef unsigned long long ull;
  6. typedef unsigned long long _EuclideanRingElement;
  7. ull nzd(ull a, ull b)
  8. {
  9. if(b==0) return a;
  10. a%=b;
  11. return nzd(b,a);
  12. }
  13. ull n,m;
  14.  
  15. _EuclideanRingElement __gcd(_EuclideanRingElement __m,
  16. _EuclideanRingElement __n)
  17. {
  18. while (__n != 0) {
  19. _EuclideanRingElement __t = __m % __n;
  20. __m = __n;
  21. __n = __t;
  22. }
  23. return __m;
  24. }
  25.  
  26. int main() {
  27. ull A = 1100087778366101931ull, B = 1779979416004714189ull;
  28. auto beg = std::chrono::high_resolution_clock::now();
  29. ull a1 = nzd(A, B);
  30. auto mid = std::chrono::high_resolution_clock::now();
  31. ull a2 = __gcd(A, B);
  32. auto en = std::chrono::high_resolution_clock::now();
  33.  
  34. auto t1 = 1e-9 * std::chrono::duration_cast<std::chrono::nanoseconds>(mid - beg).count();
  35. auto t2 = 1e-9 * std::chrono::duration_cast<std::chrono::nanoseconds>(en - mid).count();
  36. cout.precision(10);
  37. cout << fixed << t1 << " " << t2;
  38. return 0;
  39. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
0.0000058190 0.0000033860