ZOJ 3758 Singles' Day

原创 2015年07月10日 09:03:59

所以这道题,嗯,太相信模板了,FOR循环里面用了INT ,难怪超时。LONG LONG不确定够不够大,不够就再加,变成UNSIGNED LONG LONG.

#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;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

ZOJ - 3758 - Singles' Day(素数判定)

Singles’ Day Time Limit: 2 Seconds    Memory Limit: 65536 KB Singles’ Day(or One’s Day), an un...

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

Singles' Day(or One's Day), an unofficial holiday in China, is a pop culture entertaining holiday on...

H - May Day Holiday——ZOJ

H - May Day Holiday Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld &...

zoj3876May Day Holiday

May Day Holiday Time Limit: 2 Seconds      Memory Limit: 65536 KB As a university advocating...

ZOJ3876 May Day Holiday【日期计算】

May Day Holiday Time Limit: 2 Seconds      Memory Limit: 65536 KB As a university advocating...

ZOJ 3876 May Day Holiday(找规律||打表-基姆拉尔森计算公式(求某年某月某日星期几))

May Day Holiday Time Limit: 2 Seconds      Memory Limit: 65536 KB As a university advocating sel...

ZOJ3876 May Day Holiday

题目大意:求输入年份的那一年的五一劳动节,在Marjar University 的学生能够休息多少天。。。          题目并不难,只需要我们知道一个小常识:闰年的一年有366天,而判定闰年的...

ZOJ 3876 May Day Holiday

May Day Holiday Time Limit: 2 Seconds      Memory Limit: 65536 KB  As a university advoc...

ZOJ3876:May Day Holiday(浙江省赛2015)

As a university advocating self-learning and work-rest balance, Marjar University has so many days o...

zoj 1256 What Day Is It?

What Day Is It? Time Limit: 2 Seconds      Memory Limit: 65536 KB The calendar now in u...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)