/ Randle /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 360.0 KiB
#2 Wrong Answer 3ms 340.0 KiB
#3 Wrong Answer 3ms 344.0 KiB
#4 Wrong Answer 105ms 3.586 MiB
#5 Wrong Answer 106ms 3.207 MiB
#6 Wrong Answer 104ms 3.238 MiB
#7 Wrong Answer 108ms 3.234 MiB
#8 Wrong Answer 108ms 3.711 MiB
#9 Wrong Answer 109ms 3.969 MiB
#10 Wrong Answer 110ms 4.0 MiB

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
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:17:35
评测时间
2017-10-13 20:17:39
评测机
分数
0
总耗时
765ms
峰值内存
4.0 MiB