void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.bigint; BigInt b, c, d; rd(b, c, d); const BigInt mod=1_000_000_000+7; BigInt pow(BigInt a, BigInt x){ if(x==0) return cast(BigInt)1; else if(x==1) return a; else if(x&1) return a*pow(a, x-1)%mod; else return pow(a*a%mod, x/2); } BigInt inv(BigInt x){ return pow(x, mod-2); } BigInt ret=b; if(c==1){ ret=ret*d; }else{ ret=ret*c; ret=ret*(pow(c, d)-1); ret=ret*inv(c-1); } writeln(ret%mod); } /+ 1. B*C 2. (B*C+B)*C 3. ((B*C+B)*C+B)*C 4. (((B*C+B)*C+B)*C+B)*C=B(C^4+C^3+C^2+C) C+C^2+...+C^D = C*(C^D-1)/(C-1) +/ void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x) e=l[i].to!(typeof(e)); }