Gcc_Gdb_7_8_1 @ 2024-11-16 16:05:12
https://www.luogu.com.cn/problem/U505175
juruo 的代码:
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define Pii pair<int, int>
#define ULL unsigned long long
namespace gdb7
{
bool goodnum[10000010], is_prime[10000010], cnt;
int prime[1000010];
int main() {
int n;
cin >> n;
is_prime[0] = is_prime[1] = true;
for (int i = 2; i <= n; ++i) {
if (!is_prime[i]) {
// cout << " i" << i << endl;
prime[++cnt] = i;
for (LL j = 1; j <= n; ++j) {
goodnum[j] = true;
}
}
for (int j = 1; j <= cnt && i * prime[j] <= n; ++j) {
is_prime[i * prime[j]] = true;
if (i % prime[j] == 0) {
break;
}
}
}
for (int i = 1; i <= n; ++i) {
cout << "("<< is_prime[i] << ", " << goodnum[i] << "), ";
}
cout << "\ncnt:" << cnt << endl;
for (int i = 1; i <= cnt; ++i) {
cout << prime[i] << " ";
}
cout << endl;
for (int i = n; i >= 1; --i) {
if (goodnum[i]) {
cout << i << endl;
break;
}
}
return 0;
}
};
int main()
{
return gdb7::main();
}
by MLE_Automaton @ 2024-11-16 16:16:03
应该是不用筛质数的
by Gcc_Gdb_7_8_1 @ 2024-11-16 16:16:16
@MLE_Automaton
by Gcc_Gdb_7_8_1 @ 2024-11-16 16:16:48
@MLE_Automaton 我说代码的 "枚举log n往下的数"
by MLE_Automaton @ 2024-11-16 16:16:52
@Gcc_Gdb_7_8_1 底为2
by hjb13357896690 @ 2024-11-16 17:10:18
@Gcc_Gdb_7_8_1说
by hjb13357896690 @ 2024-11-16 17:15:09
@TeaQiLang对啊,但你不是交了吗,UKE
by TeaQiLang @ 2024-11-16 17:54:14
@hjb13357896690 你猜有数据点吗
by hjb13357896690 @ 2024-11-16 18:10:24
@TeaQiLang没,但证明这是团队题
by TeaQiLang @ 2024-11-16 18:11:22
@hjb13357896690 为什么
by hjb13357896690 @ 2024-11-16 18:17:14
@TeaQiLang因为上面写着啊,还有你问的是猜,不是回答