/ Randle /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 3ms 320.0 KiB
#2 Accepted 2ms 312.0 KiB
#3 Accepted 2ms 320.0 KiB
#4 Accepted 1ms 316.0 KiB
#5 Accepted 1ms 320.0 KiB
#6 Accepted 1ms 320.0 KiB
#7 Accepted 1ms 312.0 KiB
#8 Accepted 1ms 320.0 KiB
#9 Accepted 1ms 320.0 KiB
#10 Accepted 1ms 316.0 KiB
#11 Accepted 1ms 320.0 KiB
#12 Accepted 1ms 316.0 KiB
#13 Accepted 1ms 320.0 KiB
#14 Accepted 1ms 320.0 KiB
#15 Accepted 1ms 320.0 KiB
#16 Accepted 1ms 316.0 KiB
#17 Accepted 1ms 316.0 KiB
#18 Accepted 1ms 320.0 KiB
#19 Accepted 1ms 320.0 KiB
#20 Accepted 1ms 320.0 KiB

代码

#include <cstdio>  
#include <iostream>
#include <cstring> 
#include <cstdlib>

using namespace std;
 
long long pow_mod(long long a,long long n,long long m)
{
	if (n==0) return 1;
	if (n==1) return a%m;
	long long x=pow_mod(a,n/2,m);
	long long ans=(long long)x*x%m;
	if (n%2) ans=ans*a%m;
	return (long long)ans;
}

long long n,k;  
long long w;

int main() 
{
    cin>>n>>k;
    w=pow_mod(n,n,k)-n%k+1;
    for (;w<0;w+=k);
    cout<<w%k<<endl;
	return 0; 
}

信息

递交者
类型
递交
题目
郊游
题目数据
下载
语言
C++
递交时间
2017-09-22 19:59:45
评测时间
2017-09-22 19:59:45
评测机
分数
100
总耗时
35ms
峰值内存
320.0 KiB