正文
增加 103 行删除 12 行
10 行未改动1112131415161718192021222324252627285 行未改动343536373839404142434445464748495051525354555657585960616263646566676869707110 行未改动$CodingTime$```cpp//為你明燈三千,為你花開滿城。#include <bits/stdc++.h>#define LL long longconst int N = 1e7 + 10, M = 7e6 + 10;int k, prime[M], tot;bool f[N];inline void solve() //线性筛素数{for (int i = 2; i < N; ++i){if (!f[i]) prime[++tot] = i;5 行未改动}return ;}inline bool check(int x, int num) //前面的所有数,在序列中有多少个,从而确定mid的位置{int cnt = 0; // 前面有多少个在序列中的数for (int i = 1; i <= tot && prime[i] <= x; ++i) // 若该素数本身就大于x,则没必要继续循环下去{LL pre = prime[i]; // 每个素数的正整数次幂while (pre <= x){cnt++; pre *= prime[i];if (cnt >= num) return true;}}return cnt >= num;}int main(){std::cin >> k;solve();int l = 1, r = 5e7 + 10, ans; // 二分答案while (l <= r){int mid = (l + r) >> 1;if (check(mid, k)) { r = mid - 1; ans = mid; }else l = mid + 1;}std::cout << ans << '\n';return 0;}```10 行未改动1112131415161718192021222324252627285 行未改动34353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116210 行未改动$CodingTime$```cpp//為你明燈三千,為你花開滿城。#include <bits/stdc++.h>#define LL long longconst int N = 1e7 + 10, M = 7e6 + 10;int k, prime[M], tot;bool f[N];inline void solve() //线性筛素数{for (int i = 2; i < N; ++i){if (!f[i]) prime[++tot] = i;5 行未改动}return ;}inline bool check(int x, int num) //前面的所有数,在序列中有多少个,从而确定mid的位置{int cnt = 0; // 前面有多少个在序列中的数for (int i = 1; i <= tot && prime[i] <= x; ++i) // 若该素数本身就大于x,则没必要继续循环下去{LL pre = prime[i]; // 每个素数的正整数次幂while (pre <= x){cnt++; pre *= prime[i];if (cnt >= num) return true;}}return cnt >= num;}int main(){std::cin >> k;solve();int l = 1, r = 5e7 + 10, ans; // 二分答案while (l <= r){int mid = (l + r) >> 1;if (check(mid, k)) { r = mid - 1; ans = mid; }else l = mid + 1;}std::cout << ans << '\n';return 0;}```$jijijijijijii$筛法```cpp#include<bits/stdc++.h>#define fio std::ios::sync_with_stdio(false);cin.tie(nullptr),cout.tie(nullptr);using std::cin;using std::cout;using std::endl;typedef long long ll;ll sfksm(ll x,ll p,ll lim){if(x==0) return 0;if(p==0) return 1ll;if(p==1) return x;__int128 ta=1;while(p){if(p&1)ta*=x;x*=x;p>>=1;if(ta>lim) return lim+1;}return ta;}ll nthRoot(ll x, ll n, double epsilon = 1e-10) {//快速开方(快速幂逆运算)if(x==0) return 0;if(n==1) return x;if(x==1) return 1;double guess = std::exp(std::log(x)/n); // 初始猜测double diff;do {double prev = guess;// 牛顿迭代公式:guess = guess - (guess^n - x) / (n * guess^(n-1))guess = ((n - 1) * guess + x / pow(guess, n - 1)) / n;diff = fabs(guess - prev);} while (diff > epsilon);ll ta=(ll)guess;//修正煮异while(sfksm(ta,n,x)<x)++ta;while(sfksm(ta,n,x)>x)--ta;return ta;}ll cnt,k;int isp[2000007]; //注:isp[i]=1:被标记为合数ll ps[200007];void eular(){for(ll i=2;i<=2000000;i++){if(!isp[i]){ps[++cnt]=i;isp[i]=cnt;}for(int j=1;ps[j]<=2000000/i&&j<=cnt;j++){isp[ps[j]*i]=-1;if(i%ps[j]==0)break;}}}bool check(ll x){if(x<2) return 0;ll ta=0,i=1,j=0;j=std::upper_bound(ps+1,ps+1+cnt,x)-ps-1;//j变为:当前质数是第几个(当前质数在ps数组中的下标)if(j<1)return 0;ll nrt=nthRoot(x,i+1);//cout<<nrt;for(;j>0;--j){//对 1~x 中的所有质数统计贡献while(ps[j]<=nrt&&i<60){//防止i越界(2^60≈1e18)++i;nrt=nthRoot(x,i+1);//为每个质数找到它所在的区间}ta+=i;//((i+1)th_root,(i)th_root] 中的质数贡献为 iif(ta>=k)return 1;}return ta>=k;}ll l=1,r=2000000,ans,mid;int main(){// fiocin>>k;eular();// for(int i=1;i<=;i++)cout<<ps[i]<<" ";while(l<=r){mid=l+((r-l)>>1);if(check(mid)){r=mid-1;ans=mid;}else l=mid+1;}cout<<ans;}```