#include <iostream>
#include <vector>
#define ll long long
#define MAX 50000000
using namespace std;

ll A, B, K, cnt, res, 
vector<ll> prime;

void f() {
    for(ll i=A; i<=B; i++) {
        int flag=1;
        for(ll j=2; j*j<=i; j++) {
            if(i%j==0) {
                flag=0;
                break;
            }
        }
        if(flag) {
            prime.push_back(i); cnt++;
        }
    }
}

void goldbaheuheugheug(ll idx, ll sum) {
    if(idx==cnt||sum>K) return;
    if(sum==K) {
        res++;
        return;
    }

    goldbaheuheugheug(idx+1, sum);
    goldbaheuheugheug(idx+1, sum+prime[idx]);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    cin >> A >> B >> K;
    f();

    //goldbaheuheugheug(0, 0);
    
    cout << res;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: