/ Randle /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 4ms 364.0 KiB
#2 Wrong Answer 2ms 364.0 KiB
#3 Wrong Answer 3ms 384.0 KiB
#4 Wrong Answer 3ms 256.0 KiB
#5 Wrong Answer 3ms 384.0 KiB
#6 Wrong Answer 3ms 256.0 KiB
#7 Wrong Answer 3ms 368.0 KiB
#8 Wrong Answer 5ms 256.0 KiB
#9 Wrong Answer 46ms 380.0 KiB
#10 Wrong Answer 58ms 348.0 KiB

代码

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int n,m;
ll powMod(ll a,int b){
    ll ans=1;
    for(;b;b>>=1,a=(a*a)%MOD)
        if(b&1) ans=(ans*a)%MOD;
    return ans;
}
void exgcd(ll a,ll b,ll &d,ll &x,ll &y){
    if(b==0) {d=a;x=1;y=0;}
    else {exgcd(b,a%b,d,y,x);y-=(a/b)*x;}
}
ll inv(ll a,ll n){
    ll d,x,y;
    exgcd(a,n,d,x,y);
    return d==1?(x+n)%n:-1;
}
int main(){
    scanf("%d%d",&n,&m);
    ll ans=m;
    for(int i=2;i<=n;i++){
        ll p=powMod(i,m);
        ll tmp=i*(p-1)%MOD*inv(i-1,MOD)%MOD;
        ans=(ans+tmp)%MOD;
    }
    printf("%lld",ans);
}

信息

递交者
类型
递交
题目
幸运数 T3
题目数据
下载
语言
C++
递交时间
2018-04-17 20:01:27
评测时间
2018-04-17 20:01:27
评测机
分数
0
总耗时
134ms
峰值内存
384.0 KiB