Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- using namespace std;
- typedef long long ll;
- const int maxn = 1e5 + 10;
- const int INF = 2e9 + 10;
- int a, b, k;
- int number_of_divisors(int number, int i) {
- if(i == number) {
- return 1;
- }
- int cost = 0;
- if(number % i == 0) {
- cost = 1;
- }
- return number_of_divisors(number, i + 1) + cost;
- }
- bool is_k_divible(int number, int cnt_divs, int i) {
- if(i == number) {
- return true;
- }
- bool ret = true;
- int cnt_i_divs = number_of_divisors(i, 1);
- if(cnt_i_divs >= cnt_divs) {
- return false;
- }
- ret &= is_k_divible(number, cnt_divs, i + 1);
- return ret;
- }
- int rec(int i) {
- if(i == b + 1) {
- return 0;
- }
- int cost = 0;
- if(is_k_divible(i, number_of_divisors(i, 1), max(i - k, 1))) {
- cost = i;
- }
- return rec(i + 1) + cost;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin >> a >> b >> k;
- cout << rec(a) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment