#include #include #include #include #include #include #include using namespace std; vector vysl; long p[10]; int N; long a,b; void printv() { if (vysl.size() == 0) { cout << "none" << endl; return; } int posledni = -1; for (vector::iterator it = vysl.begin(); it != vysl.end(); it++) { if (*it == posledni) continue; posledni = *it; if (it == vysl.begin()) cout << *it; else cout << "," << *it; } cout << endl; } bool vypocti(long int vysledek, int index) { //printf("\t%d @ %d\n", vysledek, index); if (vysledek >= a && vysledek <= b) vysl.push_back(vysledek); if (index > N) return false; if (vysledek > b) return false; long mezivysl = vysledek; for (int i = 0; i <= 31; ++i) { if (mezivysl * p[index] < mezivysl) break; if (vypocti(mezivysl, index + 1) == false) break; mezivysl = mezivysl * p[index]; } return true; } int main(void) { while (true) { vysl.clear(); cin >> N; if (N == 0) return 0; for (int i = 0; i < N; ++i) { cin >> p[i]; } cin >> a >> b; ///printf("N=%d, a=%d, b=%d\n", N, a,b); //if (a == 1) vysl.push_back(1); unsigned int mezivysl; for(int i = a; i <= b; ++i) { mezivysl = i; for (int j = 0; j < N; ++j) { while (mezivysl % p[j] == 0) { mezivysl = mezivysl / p[j]; } } if (mezivysl == 1) vysl.push_back(i); } //vypocti(1, 0); //sort(vysl.begin(), vysl.end()); //unique(vysl.begin(), vysl.end()); printv(); //cout << "end" << endl; } return 0; }