Advertisement
Zeinab_Hamdy

Untitled

Mar 14th, 2024
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define nl "\n"
  4. #define fi first
  5. #define se second
  6. #define pb push_back
  7. #define ll long long
  8. #define ull unsigned ll
  9. #define RV  return void
  10. #define sz(x) int(x.size())
  11. #define all(v) v.begin(), v.end()
  12. #define rall(v) v.rbegin(), v.rend()
  13. #define fixed(n) fixed << setprecision(n)
  14. #define cin(v) for (auto&i:v) cin >> i;
  15. #define cout(v) for (auto&i:v) cout << i << " ";
  16. #define clr(memo, x) memset(memo, x, sizeof memo)
  17. #define FastCode ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  18.  
  19. void  Zainab(){
  20.             // #ifndef ONLINE_JUDGE
  21.               freopen("longpath.in", "r", stdin);
  22.               freopen("longpath.out", "w", stdout);
  23.             // #endif
  24. }
  25.  
  26. const ll N = 1e7;
  27. vector < bool > isPrime (N + 1 , true);
  28. vector < ll > primes ;
  29.  
  30. void pre(){
  31.     isPrime[0]= isPrime[1]=false;
  32.  
  33.     for(ll i = 2 ; i * i <= N ; i++)
  34.         if(isPrime[i])
  35.             for(ll j = i * i ; j <= N ; j +=i )
  36.                 isPrime[j] = false;
  37.  
  38.     for(ll i =0 ; i < N+1 ; ++i )
  39.         if(isPrime[i]) primes.pb(i);
  40.  
  41. }
  42.  
  43. void myCode(){
  44.  
  45.  
  46. ll n;
  47. cin >> n ;
  48.  
  49. // ll sum =0;
  50. // __int128 fact =1;
  51. // for(ll i =1 ; i <= 100 ; i++) {
  52. //     // long double temp = cos(  (fact + 1 )/i  *3.1415926 );
  53. //     // cout << i << " " << temp * temp << nl;
  54. //     if( (fact + 1 ) % i==0){
  55. //          sum ++;
  56. //         cout << i << " " << sum << nl;
  57. //     }
  58. //     fact *=i;
  59. // }
  60.  
  61. // cout << sum << nl << nl;
  62.  
  63.  
  64. long double mo = 1 , lg = ceil(log2(n));
  65. ll l =0 ,r = sz(primes) -1 ;
  66. while(l <= r ){
  67.     ll mid = r - (r-l)/2;
  68.     if(primes[mid] <= n) {
  69.         l = mid+1;
  70.         mo = mid + 2;
  71.     }
  72.     else
  73.         r = mid-1;
  74. }
  75.  
  76. // cout << mo << "  ";
  77.  
  78. cout << fixed(6) << pow( lg / mo , 1/lg) << nl;
  79.  
  80. }
  81.  
  82.  
  83. int main(){
  84.                                    FastCode ;
  85.                                     //  Zainab() ;
  86.  
  87.     int testCase=1;
  88.          cin >> testCase ;
  89.     pre();
  90.       for(int i=1 ; i<= testCase ; i++)
  91.         myCode();
  92.  
  93.     return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement