/ Randle /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 348.0 KiB
#2 Wrong Answer 3ms 340.0 KiB
#3 Wrong Answer 3ms 360.0 KiB
#4 Wrong Answer 105ms 4.348 MiB
#5 Wrong Answer 84ms 2.477 MiB
#6 Wrong Answer 108ms 2.473 MiB
#7 Wrong Answer 108ms 4.367 MiB
#8 Wrong Answer 107ms 3.832 MiB
#9 Wrong Answer 108ms 4.348 MiB
#10 Wrong Answer 110ms 2.617 MiB

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define ll long long
const int maxn=1200000+5;
inline int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}
ll n,ans=1; 
int a,k;
int c[maxn];
ll power(ll a,ll p){
	ll res=1,base=a;
	for(int i=p;i;i=i>>1,base=base*base%k)
		if(i&1) res=res*base%k;
	return res;
}
int main(){
	scanf("%d%lld%d",&a,&n,&k);
	c[0]=1;
	for(int i=1;i<=a;++i){
		c[i]=gcd(i,a)%k;
		c[i]=c[i]*c[i-1]%k;
	}
	ll tmp1=floor((double)n/(double)a);
	ll tmp2=n%a;
	ans=power(c[a],tmp1);
	ans=ans*c[tmp2]%k;
	printf("%lld",ans);
	return 0;
}
	

信息

递交者
类型
递交
题目
学前班数学(原创)
题目数据
下载
语言
C++
递交时间
2017-10-13 20:36:18
评测时间
2017-10-13 20:36:18
评测机
分数
0
总耗时
744ms
峰值内存
4.367 MiB