@@ -54,17 +54,17 @@ bool IsPrime(T n, const vector<T>& bases) {
5454 return true ;
5555}
5656
57- bool IsPrime (int64_t n) {
57+ bool IsPrime (long long n) {
5858 return IsPrime (n, {2 , 325 , 9375 , 28178 , 450775 , 9780504 , 1795265022 });
5959}
6060
6161bool IsPrime (int32_t n) {
6262 return IsPrime (n, {2 , 7 , 61 });
6363}
6464
65- // but if you really need uint64_t version...
65+ // but if you really need unsigned long long version...
6666/*
67- bool IsPrime(uint64_t n) {
67+ bool IsPrime(unsigned long long n) {
6868 if (n < 2) {
6969 return false;
7070 }
@@ -81,9 +81,9 @@ bool IsPrime(uint64_t n) {
8181 return true;
8282 }
8383 uint32_t s = __builtin_ctzll(n - 1);
84- uint64_t d = (n - 1) >> s;
85- function<bool(uint64_t )> witness = [&n, &s, &d](uint64_t a) {
86- uint64_t cur = 1, p = d;
84+ unsigned long long d = (n - 1) >> s;
85+ function<bool(unsigned long long )> witness = [&n, &s, &d](unsigned long long a) {
86+ unsigned long long cur = 1, p = d;
8787 while (p > 0) {
8888 if (p & 1) {
8989 cur = (__uint128_t) cur * a % n;
@@ -102,8 +102,8 @@ bool IsPrime(uint64_t n) {
102102 }
103103 return true;
104104 };
105- vector<uint64_t > bases_64bit = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
106- for (uint64_t a : bases_64bit) {
105+ vector<unsigned long long > bases_64bit = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
106+ for (unsigned long long a : bases_64bit) {
107107 if (a % n == 0) {
108108 return true;
109109 }
@@ -239,7 +239,7 @@ vector<pair<T, int>> Factorize(T x) {
239239 }
240240 return ret;
241241 }
242- if (x <= static_cast <int64_t >(precalculated) * precalculated) {
242+ if (x <= static_cast <long long >(precalculated) * precalculated) {
243243 vector<pair<T, int >> ret;
244244 if (!IsPrime (x)) {
245245 for (T i : primes) {
0 commit comments