fork download
  1. /**
  2.  * author: orzvanh14 ( )
  3.  * created: 23.12.2022 10:08:02
  4.  * too lazy to update time
  5. **/
  6. // i wants to take ioi
  7. //binhtinhtutinkhongcaycunhungmotkhikhongcontutinnualatuyetvong
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define int long long
  13. #define nn "\n"
  14. #define pi pair<int, int>
  15. #define fi first
  16. #define se second
  17. #define lb lower_bound
  18. #define ub upper_bound
  19. #define eb emplace_back
  20. #define pb push_back
  21. #define TASK " "
  22.  
  23. #define ms(a, x) memset(a, x, sizeof(a))
  24. #define all(a) a.begin(), a.end()
  25. #define All(a, n) a + 1, a + 1 + n
  26.  
  27. #define LOG 19
  28.  
  29.  
  30. const int INF = 1e18;
  31. const int mod = 1e9+7;
  32. const int N = 1e6 + 5;
  33. const int maxN = 2e5 + 3;
  34. int MOD = 998244353;
  35. int bit[200000];
  36. struct node{
  37. int kc, u, hk;
  38. bool operator<(const node& other) const {
  39. return kc > other.kc;
  40. }
  41. };
  42. struct edge{
  43. int v, w, h;
  44. };
  45.  
  46. void nhap(){
  47.  
  48. }
  49. bool p[N];
  50. void sieve(){
  51. p[1] = 1;
  52. for(int i = 2; i * i < N; i++){
  53. if(!p[i]){
  54. for(int j = i * i; j < N ; j += i){
  55. p[j] = 1;
  56. }
  57. }
  58. }
  59.  
  60. }
  61. void solve(){
  62. int n; cin >> n;
  63. sieve();
  64. int ans = 0;
  65. for(int i = 1; i * i <= n; i++){
  66. if(!p[n / i] && n % i == 0){
  67. ans = max(ans, n / i);
  68. }
  69. if(!p[i] && n % i == 0){
  70. ans = max({ans, i});
  71.  
  72. }
  73. }
  74. cout << ans << nn;
  75. }
  76. signed main() {
  77. // freopen("uocnt.inp", "r", stdin);
  78. // freopen("uocnt.out", "w", stdout);
  79. ios_base::sync_with_stdio(0);
  80. cin.tie(0);
  81. cout.tie(0);
  82. // int t;
  83. // cin >> t;
  84. // while(t--) solve();
  85. solve();
  86. return 0;
  87.  
  88. }
  89.  
Success #stdin #stdout 0.01s 5316KB
stdin
2016
stdout
7