algorithm

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

View the Project on GitHub gtnao/algorithm

:heavy_check_mark: test/aoj/atp1_3_d.test.cpp

Depends on

Code

#define PROBLEM                                                                \
  "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/3/ITP1_3_D"

#include <bits/stdc++.h>
using namespace std;

#include "../../src/math/divisor.hpp"

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (auto d : divisor(c)) {
    if (a <= d && d <= b) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
#line 1 "test/aoj/atp1_3_d.test.cpp"
#define PROBLEM                                                                \
  "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/3/ITP1_3_D"

#include <bits/stdc++.h>
using namespace std;

#line 2 "src/math/divisor.hpp"

#line 4 "src/math/divisor.hpp"
using namespace std;

template <typename T = long long> vector<T> divisor(T n) {
  vector<T> res;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n) {
        res.push_back(n / i);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}
#line 8 "test/aoj/atp1_3_d.test.cpp"

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (auto d : divisor(c)) {
    if (a <= d && d <= b) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
Back to top page