正文
增加 27 行删除 27 行
10 行未改动1112131415161718192021222324252627285 行未改动34353637383940414243444546474849505152535455565758596061626364656667686970717214 行未改动878889909192939495969798991001011021031041051061071081091101111121131141151161176 行未改动12412512612712812913013113213313413513613713813914014114214314418 行未改动10 行未改动$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$筛法14 行未改动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]){6 行未改动}}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;}18 行未改动10 行未改动1112131415161718192021222324252627285 行未改动34353637383940414243444546474849505152535455565758596061626364656667686970717214 行未改动878889909192939495969798991001011021031041051061071081091101111121131141151161176 行未改动12412512612712812913013113213313413513613713813914014114214314418 行未改动10 行未改动$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$筛法14 行未改动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]){6 行未改动}}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;}18 行未改动