fork(1) download
  1. #include <iostream>
  2. #define mod 1000000007
  3. using namespace std;
  4. int a, b, c, p, q, r;
  5. int power(int x, int y) {
  6. int ret = 1;
  7. for (int i = 30; i >= 0; i--) {
  8. ret = 1LL * ret * ret % mod;
  9. if (y & (1 << i)) ret = 1LL * ret * x % mod;
  10. }
  11. return ret;
  12. }
  13. int inv(int x) {
  14. return power(x, mod - 2);
  15. }
  16. int main() {
  17. cin >> a >> b >> c; p = 1, q = 1;
  18. for (int i = 0; i < a; i++) p = 1LL * p * b % mod;
  19. for (int i = a - 1; i >= 0; i--) {
  20. p = 1LL * p * inv(b) % mod;
  21. r = (r + 1LL * p * q) % mod;
  22. q = 1LL * q * inv(a - i) % mod;
  23. q = 1LL * q * (a + c - i - 1) % mod;
  24. }
  25. cout << r << endl;
  26. return 0;
  27. }
Success #stdin #stdout 0s 3416KB
stdin
4 3 2
stdout
58