Title:
Given n, m, find the value of this expression
analyze:
Exponentiation operation, and also take the remainder of a large number, definitely fast power, board question
Code:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stdio.h>
#define mod 1000000007
#define ll long long
using namespace std;
ll f(ll a,ll b)
{
ll ans =1;
a = a %mod;
while(b)
{
if(b&1) ans = ans*a%mod;
a = a*a%mod;
b>>=1;
}
return ans;
}
int main()
{
int n,m;
cin >> n >> m;
ll sum = 0;
for(int i = 1; i <=n;i++)
{
sum = (sum+f(i,m))%mod;
}
cout << sum << endl;
return 0;
}