#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #ifdef LOCAL #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; #else #define debug(x) ; #endif #define mod 1000000007 //1e9+7(prime number) #define INF 1000000000 //1e9 #define LLINF 2000000000000000000LL //2e18 #define SIZE 200010 namespace MillerRabin { typedef __int128_t Int; Int power(Int k, Int n, ll M){ if(n==0) return 1; if(n==1) return k % M; Int res = power(k, n/2, M); res = res * res % M; return n%2 ? res % M * k % M : res; } bool isPrime(ll x) { int a[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, -1}; // x < 2^64 //int a[] = {2, 7, 61, -1}; // x < 2^32 if(x == 2) return true; if(x <= 1 || x % 2 == 0) return false; Int d = x-1; int s = 0; for(;d%2 == 0;s++) d >>= 1; for(int i=0;a[i] != -1 && a[i] < x;i++){ Int y = power(a[i], d, x); if(y == 1) continue; for(int j=0;j> n; for(int i=0;i> x; cout << x << " " << MillerRabin::isPrime(x) << endl; } return 0; }