1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <vector> 6 #include <queue> 7 #include <stack> 8 #include <cstdlib> 9 #include <iomanip> 10 #include <cmath> 11 #include <cassert> 12 #include <ctime> 13 #include <map> 14 #include <set> 15 using namespace std; 16 #pragma comment(linker, "/stck:1024000000,1024000000") 17 #define lowbit(x) (x&(-x)) 18 #define max(x,y) (x>=y?x:y) 19 #define min(x,y) (x<=y?x:y) 20 #define MAX 100000000000000000 21 #define MOD 1000000007 22 #define pi acos(-1.0) 23 #define ei exp(1) 24 #define PI 3.1415926535897932384626433832 25 #define ios() ios::sync_with_stdio(true) 26 #define INF 0x3f3f3f3f 27 #define mem(a) (memset(a,0,sizeof(a))) 28 typedef long long ll; 29 const int s=8; 30 char ch[26]; 31 ll mult_mod(ll a,ll b,ll c) 32 { 33 a%=c; 34 b%=c; 35 ll ret=0; 36 ll tmp=a; 37 while(b) 38 { 39 if(b&1){ 40 ret+=tmp; 41 if(ret>c) ret-=c; 42 } 43 tmp<<=1; 44 if(tmp>c) tmp-=c; 45 b>>=1; 46 } 47 return ret; 48 } 49 ll pow_mod(ll a,ll n,ll mod) 50 { 51 ll ans=1; 52 ll tmp=a%mod; 53 while(n) 54 { 55 if(n&1) ans=mult_mod(ans,tmp,mod); 56 tmp=mult_mod(tmp,tmp,mod); 57 n>>=1; 58 } 59 return ans; 60 } 61 bool check(ll a,ll n,ll x,ll t) 62 { 63 ll ret=pow_mod(a,x,n); 64 ll last=ret; 65 for(int i=1;i<=t;i++) 66 { 67 ret=mult_mod(ret,ret,n); 68 if(ret==1 && last!=1 && last!=n-1) return true; 69 last=ret; 70 } 71 if(ret!=1) return true; 72 else return false; 73 } 74 bool miller_pabin(ll n) 75 { 76 if(n<2) return false; 77 if(n==2) return true; 78 if((n&1)==0) return false; 79 ll x=n-1; 80 ll t=0; 81 while((x&1)==0) {x>>=1;t++;} 82 srand(time(NULL)); 83 for(int i=0;i<s;i++){//宏定义s=8 84 ll a=rand()%(n-1)+1; 85 if(check(a,n,x,t)) return false; 86 } 87 return true; 88 } 89 int main() 90 { 91 ll x=0,y=0; 92 scanf("%s",&ch); 93 int k=strlen(ch); 94 for(int i=0;i<k;i++) 95 { 96 97 x=x*10+(ch[i]-'0'); 98 } 99 bool okx=miller_pabin(x); 100 if(okx ) printf("yes\n"); 101 else printf("no\n"); 102 return 0; 103 }