###### ZOJ 3758 Singles' Day

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>
using namespace std;
typedef unsigned long long ll;
ll make_pow(ll x,ll n)
{
ll res =1;
while(n>0)
{
if(n&1)res = res*x;
x = x*x;
n>>=1;
}
return res;
}
bool isprime(ll n)
{
for(ll i=2;i*i<=n;i++)
if(n%i==0)return false;
return n!=1;
}
int main()
{

ll n,b;
while(scanf("%lld%lld",&b,&n)==2)
{
if(isprime((make_pow(b,n)-1)/(b-1)))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

#### ZOJ3758：Singles' Day(快速素数判定法)

2014-03-03 21:56:50

#### ZOJ 3758 —— Singles' Day

2014-03-02 18:21:48

#### zoj 3758 Singles' Day

2014-03-04 12:01:02

#### Singles' Day ZOJ - 3758

2018-04-05 17:37:35

#### ZOJ 3758 — Singles' Day（C++）

2014-03-22 14:44:49

#### ZOJ - 3758 - Singles' Day（素数判定）

2015-08-08 16:07:31

#### zoj 3758 Singles' Day(暴力)

2014-03-02 20:49:41

#### zoj 5194 Singles' Day

2014-03-02 16:29:03

#### ZOJ 3785 What day is that day?【思维+递推循环节】

2016-04-20 20:12:52

#### ACM刷题之ZOJ————What day is that day?

2017-03-05 20:51:10

## 不良信息举报

ZOJ 3758 Singles' Day