同标题。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
typedef long long ll;
#define endl '\n'
using namespace std;
map<ll, ll> mp;
int main(){
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
ll l, r, L, R, c;
cin >> l >> r >> L >> R >> c;
for(ll k = l; k <= r; ++k){
for(ll i = 1; i < k; ++i){
for(ll j = 0; j < k; ++j){
if(i != j){
ll num = 0;
ll tmp = 0;
while(num <= R){
if(tmp & 1){
num *= k;
num += j;
++tmp;
}else{
num *= k;
num += i;
++tmp;
}
if(num >= L && num <= R){
mp[num]++;
}
}
}
}
}
}
for(ll i = L; i <= R; ++i){
if(mp[i] == c){
cout << i << endl;
}
}
return 0;
}