Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <bitset>
- using namespace std;
- ifstream in("descmult.in");
- ofstream out("descmult.out");
- bitset <10000001> ciur;
- bitset <10000001> rasp;
- int d[21], e[21], n;
- bool verif[1000];
- int main()
- {
- int c, a, b;
- in >> c;
- in >> n >> a >> b;
- if(c == 1)
- {
- unsigned long long rez = 1;
- for(int i = 1; i <= n; i++)
- in >> d[i];
- for(int i = 1; i <= n; i++)
- {
- in >> e[i];
- rez *= (e[i] + 1);
- }
- out << rez;
- }
- else
- {
- for(int i = 1; i <= n; i++)
- {
- in >> d[i];
- verif[d[i]] = 1;
- }
- for(int i = 1; i <= n; i++)
- in >> e[i];
- ciur[0] = ciur[1] = 1;
- for(int i = 4; i <= b; i += 2)
- ciur[i] = 1;
- for(int i = 3; i * i <= b; i += 2)
- if(ciur[i] == 0)
- for(int j = i * i; j <= b; j += 2 * i)
- ciur[j] = 1;
- rasp[0] = 1;
- for(int i = 2; i <= b; i++)
- if(ciur[i] == 0)
- {
- if(i >= 1000 || verif[i] == 0)
- for(int j = i; j <= b; j += i)
- rasp[j] = 1;
- }
- for(int i = 1; i <= n; i++)
- {
- ///verific daca d[i] ^ (e[i] + 1) <= b
- int cb = b;
- for(int j = 1; j <= e[i] + 1; j++)
- cb /= d[i];
- if(cb != 0)
- {
- int nr = 1;
- for(int j = 1; j <= e[i] + 1; j++)
- nr *= d[i];
- for(int j = nr; j <= b; j += nr)
- rasp[j] = 1;
- }
- }
- for(int i = a; i <= b; i++)
- if(rasp[i] == 0)
- out << i << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement