fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. const int mod = 1000000007;
  6. int x,n;
  7. cin>> x >> n;
  8. long long f = 0;
  9. long long power = 1;
  10. for(int i = 1; i<=n; i++){
  11. power = (power *x) % mod;
  12. f = (f+power) % mod;
  13.  
  14. }
  15. cout<<f;
  16. return 0;
  17. }
Success #stdin #stdout 0s 5316KB
stdin
2 4 
stdout
30