Submission #64553517
Source Code Expand
#include <bits/stdc++.h>
#define int long long
using namespace std;
constexpr int MAXN = 1e6;
int q, x, T[MAXN + 5];
bool isprime[MAXN + 5];
vector<int> prime, vec;
inline void getprime() {
for (int i = 2; i <= MAXN; i ++) {
if (!isprime[i])
prime.push_back(i);
for (int j : prime) {
if (i * j > MAXN) break;
isprime[i * j] = true;
if (!(i % j)) break;
}
}
}
signed main() {
getprime();
for (int i : prime) {
for (int j = i; j <= MAXN; j += i) T[j] ++;
}
for (int i = 1; i <= MAXN; i ++) {
if (T[i] == 2)
vec.push_back (i * i);
}
scanf ("%lld", &q);
while (q --) {
scanf ("%lld", &x);
printf ("%lld\n", *(upper_bound (vec.begin(), vec.end(), x) - 1));
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Ringo's Favorite Numbers 3 |
| User | YZP_AK_IOI |
| Language | C++ 20 (gcc 12.2) |
| Score | 425 |
| Code Size | 865 Byte |
| Status | AC |
| Exec Time | 88 ms |
| Memory | 16636 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:31:11: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf ("%lld", &q);
| ~~~~~~^~~~~~~~~~~~
Main.cpp:33:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf ("%lld", &x);
| ~~~~~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 425 / 425 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample00.txt |
| All | sample00.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample00.txt | AC | 19 ms | 16500 KiB |
| testcase00.txt | AC | 64 ms | 16508 KiB |
| testcase01.txt | AC | 65 ms | 16492 KiB |
| testcase02.txt | AC | 87 ms | 16492 KiB |
| testcase03.txt | AC | 88 ms | 16400 KiB |
| testcase04.txt | AC | 64 ms | 16492 KiB |
| testcase05.txt | AC | 40 ms | 16560 KiB |
| testcase06.txt | AC | 81 ms | 16588 KiB |
| testcase07.txt | AC | 85 ms | 16452 KiB |
| testcase08.txt | AC | 83 ms | 16444 KiB |
| testcase09.txt | AC | 85 ms | 16532 KiB |
| testcase10.txt | AC | 85 ms | 16636 KiB |
| testcase11.txt | AC | 86 ms | 16536 KiB |
| testcase12.txt | AC | 83 ms | 16452 KiB |
| testcase13.txt | AC | 85 ms | 16440 KiB |
| testcase14.txt | AC | 84 ms | 16452 KiB |
| testcase15.txt | AC | 85 ms | 16492 KiB |