Accepted
/in/foo.cc:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] main() ^ /in/foo.cc: In function 'int main()': /in/foo.cc:23:7: warning: unused variable 'j' [-Wunused-variable] ll i,j,x; ^
代码
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll base=1000000007;
ll m,n,ans=0;
ll f(ll a,ll b)
{
int res=1;
while(b)
{
if(b%2==1)
res=res*a%base;
b/=2;
a=a*a%base;
}
return res;
}
main()
{
ll i,j,x;
cin>>n>>m;
ans=m;
for(i=2;i<=n;i++)
{
x=i*(f(i,m)-1+base)%base;
ans=(ans+x*f(i-1,base-2))%base;
}
cout<<ans%base;
}