/ Randle /

记录详情

Wrong Answer

/in/foo.cc: In function 'long long int fastmi(int, int)':
/in/foo.cc:14:9: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   if(j&1==1)
        ~^~~
# 状态 耗时 内存占用
#1 Accepted 3ms 292.0 KiB
#2 Wrong Answer 2ms 256.0 KiB
#3 Wrong Answer 3ms 380.0 KiB
#4 Wrong Answer 3ms 256.0 KiB
#5 Wrong Answer 1ms 256.0 KiB
#6 Wrong Answer 4ms 256.0 KiB
#7 Wrong Answer 3ms 328.0 KiB
#8 Wrong Answer 5ms 340.0 KiB
#9 Wrong Answer 13ms 332.0 KiB
#10 Wrong Answer 18ms 340.0 KiB

代码

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define mod 1000000009
int n,m;
long long fastmi(int i,int j)
{
	long long ans=1;
	long long a=i;
	while(j)
	{
		if(j&1==1)
		{
			ans=((ans%mod)*(a%mod))%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		j=j>>1;
	}
	return ans;
}
long long sum=0;
int main()
{
	cin>>n>>m;
	sum=m;
	for(int i=2;i<=n;i++)
	{
		long long t;
		t=1-fastmi(i,m);
		
		t=((t%mod)*(i%mod))%mod;
		
		long long q=1-i;
		q%=mod;
		
		
		t/=q;
		
		sum=((sum%mod)+(t%mod))%mod;
	
		
		
	}
	cout<<sum;
	
	return 0;
}

信息

递交者
类型
递交
题目
和 T1
题目数据
下载
语言
C++
递交时间
2017-09-10 11:29:52
评测时间
2017-09-10 11:29:52
评测机
分数
1
总耗时
58ms
峰值内存
380.0 KiB