/ Randle /

记录详情

Runtime Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:23:29: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
  scanf("%d%lld%lld",&a,&n,&k);
                           ~~^
# 状态 耗时 内存占用
#1 Runtime Error 4ms 344.0 KiB
#2 Runtime Error 4ms 368.0 KiB
#3 Runtime Error 3ms 340.0 KiB
#4 Wrong Answer 3ms 368.0 KiB
#5 Runtime Error 3ms 356.0 KiB
#6 Runtime Error 3ms 356.0 KiB
#7 Runtime Error 4ms 344.0 KiB
#8 Runtime Error 4ms 384.0 KiB
#9 Runtime Error 3ms 336.0 KiB
#10 Runtime Error 3ms 368.0 KiB

代码

#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%lld",&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:16:55
评测时间
2017-10-13 20:16:55
评测机
分数
0
总耗时
38ms
峰值内存
384.0 KiB