ამ გვერდზე თქვენ იხილავთ გაგზავნილი ამოხსნების სტატუსს.
გაგზავნის თარიღი: 22.06.2022 23:12:50
ამოცანა: მარტივი რიცხვები ინტერვალზე
მომხმარებელი: GeorgeM
ვერდიქტი: ნაწილობრივი ამოხსნა
შეფასება: 60.0 ქულა
#include <bits/stdc++.h> using namespace std; unordered_set<int> allPrimes(); main(){ unordered_set<int> sets = allPrimes(); int n;cin >> n; while(n--) { int cnt=0; int a,b;cin >> a >> b; for(int i=a;i<=b;i++){ if(sets.find(i)!=sets.end()) cnt++; } cout << cnt << endl; } } unordered_set<int> allPrimes() { unordered_set<int> sets; for(int i=2;i<=1000000;i++) { bool check = true; for(int j=2;j<=sqrt(i);j++) { if(i%j==0) { check = false; break; } } if(check) sets.insert(i); } return sets; }
2 10 20 15 23
4 3
4 3
YES
3 2 20 2 1000 4 20000
8 168 2260
8 168 2260
YES
5 2 3789 1000 1000 96 100 2 1000000 2 999999
526 0 1 78498 78498
526 0 1 78498 78498
YES
10 2 1000000 3 1000000 4 1000000 6 1000000 8 1000000 9 1000000 10 1000000 11 1000000 12 1000000 13 1000000
78498 78497 78496 78495 78494 78494 78494 78494 78493 78493
78498 78497 78496
NO
30 2 1000000 3 1000000 4 1000000 6 1000000 8 1000000 9 1000000 10 1000000 11 1000000 12 1000000 13 1000000 2 999999 3 999999 4 999999 6 999999 8 999999 9 999999 10 999999 11 999999 12 999999 13 999999 2 999998 3 999998 4 999998 6 999998 8 999998 9 999998 1...
78498 78497 78496 78495 78494 78494 78494 78494 78493 78493 78498 78497 78496 78495 78494 78494 78494 78494 78493 78493 78498 78497 78496 78495 78494 78494 78494 78494 78493 78493
78498 78497 78496
NO