結果

問題 No.665 Bernoulli Bernoulli
ユーザー tecchaxn
提出日時 2018-03-10 11:13:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 547 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 158,060 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-10-12 23:18:26
合計ジャッジ時間 4,829 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 TLE * 1
other -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;

//-----------------------------------------------------------------------

const int mod=1e9+7;
int mod_pow(int x,int n)
{
    int res=1;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

signed main()
{
    int N,K; cin>>N>>K;

    int ans=0;
    for(int i=1;i<=N;i++){
        ans+=mod_pow(i,K);
        ans%=mod;
    }
    cout<<ans<<endl;

}
0