fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. typedef long long ll;
  6.  
  7. std::vector<int> divisors(int k) {
  8. std::vector<int> answer{1}, stack{k};
  9. for (int i = 2; i * i <= k; ++i) {
  10. const int j = k / i;
  11. if (j * i == k) {
  12. answer.push_back(i);
  13. stack.push_back(j);
  14. }
  15. }
  16. while (stack.back() == answer.back()) stack.pop_back();
  17. while (!stack.empty()) { answer.push_back(stack.back()); stack.pop_back(); }
  18. return answer;
  19. }
  20.  
  21. const int mod = (int)1e9+7;
  22.  
  23. int main() {
  24. int n, m, k;
  25. std::cin >> n >> m >> k;
  26. int answer = 0;
  27. for (int side1 : divisors(k)) {
  28. const int side2 = k / side1;
  29. answer += (ll)std::max(0,n-side1) * std::max(0, m-side2) % mod;
  30. if (answer >= mod) answer -= mod;
  31. }
  32. std::cout << answer;
  33. return 0;
  34. }
Success #stdin #stdout 0s 4268KB
stdin
4 4 2
stdout
12