#include <iostream>
using namespace std;
long long power(long long x,long long y,long long m){
if(y==0)return 1;
long long p=power(x,y/2,m)%m;
p=(p*p)% m;
return (y%2==0)?p:(x*p)%m;
}
int main(){
long long x,y;while(cin>>x>>y&&x*y){
if(x==1)cout<<y+1<<endl;
else cout<<((power(x,y+1,1000000007)-1)*power(x-1,1000000005,1000000007))%1000000007<<endl;
}
}
Accept
您的答案為: 129554648806 正確答案為: 554647903