[ create a new paste ] login | about

Link: http://codepad.org/dRBBvCN3    [ raw code | output | fork ]

didyxdi - C++, pasted on Sep 3:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<ctime>
using namespace std;

typedef long long ll;
ll a,p;

bool isprime(ll x)
{
	if(x<=1) return false;
	if(x==2) return true;
	for(ll i=3;i<=x/i;i++)
	{
		if(x % i==0) return false;
	}
	return true;
}

ll mod_pow(ll a,ll p,ll INF)
{
	if(p==0) return 1;
	ll tmp=mod_pow(a*a%INF,p/2,INF);
	if(p & 1) tmp=(tmp*a)%INF;
	return tmp;
}

int main()
{
	scanf("%I64d%I64d",&p,&a);
	while(p!=0 || a!=0)
	{
		if(isprime(p)) printf("no\n");
		else if(mod_pow(a,p,p)==a) printf("yes\n");
		else printf("no\n");
		scanf("%I64d%I64d",&p,&a);
	}
	return 0;
}


Output:
1
2
Line 15: error: ISO C++ does not support 'long long'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: