kyopro-lib

This documentation is automatically generated by online-judge-tools/verification-helper

View on GitHub

:x: test/aoj/ITP1_3_D/main.test.cpp

Depends on

Code

#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D"

#include <iostream>
#include "Mylib/Number/Divisor/enumerate_divisors.cpp"

namespace hl = haar_lib;

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;

  int ans = 0;

  for (auto d : hl::enumerate_divisors(c)) {
    if (a <= d and d <= b) ++ans;
  }

  std::cout << ans << std::endl;

  return 0;
}
#line 1 "test/aoj/ITP1_3_D/main.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D"

#include <iostream>
#line 2 "Mylib/Number/Divisor/enumerate_divisors.cpp"
#include <algorithm>
#include <vector>

namespace haar_lib {
  std::vector<int64_t> enumerate_divisors(int64_t n) {
    std::vector<int64_t> temp, ret;

    {
      int64_t i;
      for (i = 1LL; i * i < n; ++i) {
        if (n % i == 0) {
          temp.push_back(n / i);
          ret.push_back(i);
        }
      }
      if (i * i == n) ret.push_back(i);
    }

    std::reverse(temp.begin(), temp.end());
    ret.insert(ret.end(), temp.begin(), temp.end());

    return ret;
  }
}  // namespace haar_lib
#line 5 "test/aoj/ITP1_3_D/main.test.cpp"

namespace hl = haar_lib;

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;

  int ans = 0;

  for (auto d : hl::enumerate_divisors(c)) {
    if (a <= d and d <= b) ++ans;
  }

  std::cout << ans << std::endl;

  return 0;
}
Back to top page