#include #include #include #include #include #include #include #include #include #include #include #include #include #define p(s) cout<<(s)<=n;i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define F first #define S second typedef long long ll; using namespace std; ll N,ans; vector hurui_v(int n) { vector v; bool *isPrime_v; isPrime_v = new bool[n + 1]; // 処理用のメモリ確保 // 初期化 isPrime_v[0] = isPrime_v[1] = isPrime_v[2] = false; for (int i = 3; i < n + 1; i++) isPrime_v[i] = true; // isPrime[0~n]で素数のものだけtrueにする for (int i = 3; i*i <= n; i++) { for (int j = i * 2; j < n + 1; j += i) { isPrime_v[j] = false; } } // 素数のみ追加 for (int i = 0; i < n + 1; i++) { if (isPrime_v[i]) v.push_back(i); } delete[] isPrime_v; //メモリ解放 return v; } int main(){ cin>>N; vector prime = hurui_v(1e6); for(auto pr:prime){ if(N%pr==0){ ans=pr; break; } if(N<=pr*pr){ ans=N; break; } } p(ans); return 0; }