Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <queue>
- using namespace std;
- int number_of_divisors(int n, int i = 1) {
- if(i == n) {
- return 1;
- }
- int is_divisor = 0;
- if(n % i == 0) {
- is_divisor = 1;
- }
- return number_of_divisors(n, i + 1) + is_divisor;
- }
- int is_k(int n, int k, int N) {
- if(n == 0) {
- return 1;
- }
- if(k == 0) {
- return 1;
- }
- if(number_of_divisors(N) <= number_of_divisors(n)) {
- return 0;
- }
- return is_k(n - 1, k - 1, N);
- }
- int sum(int a, int b, int k) {
- if(a > b) {
- return 0;
- }
- int number = 0;
- if(is_k(a - 1, k, a)) {
- number = a;
- }
- return sum(a + 1, b, k) + number;
- }
- int main() {
- int a, b;
- cin >> a >> b;
- int k;
- cin >> k;
- cout << sum(a, b, k) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement