Submission #9263189


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<int> makePrimes(int n) { // [2,n]
    vector<int> res, pr(n + 1, 1);
    pr[0] = pr[1] = 0;
    rep(p, 2, sqrt(n) + 2) if (pr[p]) for (int x = p * 2; x <= n; x += p) pr[x] = 0;
    rep(p, 2, n + 1) if (pr[p]) res.push_back(p);
    return res;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int X;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X;

	auto vp = makePrimes(1000000);
	int ans = *lower_bound(all(vp), X);
	cout << ans << endl;
}





Submission Info

Submission Time
Task C - Next Prime
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1784 Byte
Status AC
Exec Time 11 ms
Memory 4860 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-small-01.txt, 01-small-02.txt, 01-small-03.txt, 01-small-04.txt, 01-small-05.txt, 02-large-01.txt, 02-large-02.txt, 02-large-03.txt, 02-large-04.txt, 02-large-05.txt, 03-len-21.txt, 03-len-33.txt, 03-len-35.txt, 03-len-43.txt, 03-len-51.txt, 03-len-71.txt, 04-max-01.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 10 ms 4860 KB
00-sample-02.txt AC 9 ms 4860 KB
00-sample-03.txt AC 9 ms 4860 KB
01-small-01.txt AC 9 ms 4860 KB
01-small-02.txt AC 9 ms 4860 KB
01-small-03.txt AC 9 ms 4860 KB
01-small-04.txt AC 9 ms 4860 KB
01-small-05.txt AC 9 ms 4860 KB
02-large-01.txt AC 9 ms 4860 KB
02-large-02.txt AC 9 ms 4860 KB
02-large-03.txt AC 9 ms 4860 KB
02-large-04.txt AC 11 ms 4860 KB
02-large-05.txt AC 9 ms 4860 KB
03-len-21.txt AC 9 ms 4860 KB
03-len-33.txt AC 10 ms 4860 KB
03-len-35.txt AC 9 ms 4860 KB
03-len-43.txt AC 9 ms 4860 KB
03-len-51.txt AC 9 ms 4860 KB
03-len-71.txt AC 9 ms 4860 KB
04-max-01.txt AC 9 ms 4860 KB