Task: | Alkuluku |
Sender: | ollpu |
Submission time: | 2016-07-28 14:49:37 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.03 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.04 s | details |
#6 | ACCEPTED | 0.05 s | details |
#7 | ACCEPTED | 0.04 s | details |
#8 | ACCEPTED | 0.04 s | details |
#9 | ACCEPTED | 0.04 s | details |
#10 | ACCEPTED | 0.04 s | details |
#11 | ACCEPTED | 0.03 s | details |
Code
#include <iostream> #include <vector> #define N 32000 using namespace std; bool z[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long n; cin >> n; vector<long> primes; for (int i = 2; i < N; ++i) { if (!z[i]) { for(int j = i; j < N; j += i) { z[j] = 1; } primes.push_back(i); } } for (long i = n + 1 + n%2; i <= 1000000007; i+=2) { bool isprime = 1; for (long p : primes) { if (p*p > i) break; if (i % p == 0) { isprime = 0; break; } } if (isprime) { cout << i; break; } } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
267201760 |
correct output |
---|
267201811 |
user output |
---|
267201811 |
Test 2
Verdict: ACCEPTED
input |
---|
382365302 |
correct output |
---|
382365311 |
user output |
---|
382365311 |
Test 3
Verdict: ACCEPTED
input |
---|
922256703 |
correct output |
---|
922256707 |
user output |
---|
922256707 |
Test 4
Verdict: ACCEPTED
input |
---|
222350429 |
correct output |
---|
222350431 |
user output |
---|
222350431 |
Test 5
Verdict: ACCEPTED
input |
---|
425069279 |
correct output |
---|
425069287 |
user output |
---|
425069287 |
Test 6
Verdict: ACCEPTED
input |
---|
926005779 |
correct output |
---|
926005781 |
user output |
---|
926005781 |
Test 7
Verdict: ACCEPTED
input |
---|
422228751 |
correct output |
---|
422228761 |
user output |
---|
422228761 |
Test 8
Verdict: ACCEPTED
input |
---|
53852719 |
correct output |
---|
53852731 |
user output |
---|
53852731 |
Test 9
Verdict: ACCEPTED
input |
---|
347245593 |
correct output |
---|
347245603 |
user output |
---|
347245603 |
Test 10
Verdict: ACCEPTED
input |
---|
499175986 |
correct output |
---|
499176001 |
user output |
---|
499176001 |
Test 11
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
11 |
user output |
---|
11 |