Submission #64518032
Source Code Expand
#include<bits/stdc++.h>
#define M 1000005
#define int long long
using namespace std;
int seq[M], vis[M], tot, ok[M], ans[M];
void init()
{
for(int i = 2; i < M; i++)
{
if(!vis[i])
{
seq[++tot] = i;
for(int j = i * 2; j < M; j += i) vis[j] = 1;
}
}
for(int i = 1; i <= tot; i++)
{
int mul = 1;
for(int j = 1; j <= 100; j++)
{
mul *= seq[i];
if(mul > M) break;
for(int k = i + 1; k <= tot; k++)
{
if(mul * seq[k] > M) break;
int mul1 = 1;
for(int w = 1; w <= 100; w++)
{
mul1 *= seq[k];
if(mul * mul1 > M) break;
ok[mul * mul1] = 1;
}
}
}
}
for(int i = 1; i < M; i++)
{
ans[i] = ans[i - 1];
if(ok[i]) ans[i] = i * i;
}
}
signed main()
{
init();
int T;
scanf("%lld", &T);
while(T--)
{
int x;
scanf("%lld", &x);
printf("%lld\n", ans[(int)sqrt(x)]);
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Ringo's Favorite Numbers 3 |
| User | jiamengtong |
| Language | C++ 20 (gcc 12.2) |
| Score | 425 |
| Code Size | 907 Byte |
| Status | AC |
| Exec Time | 82 ms |
| Memory | 27944 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
46 | scanf("%lld", &T);
| ~~~~~^~~~~~~~~~~~
Main.cpp:50:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | 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 | 21 ms | 27864 KiB |
| testcase00.txt | AC | 57 ms | 27868 KiB |
| testcase01.txt | AC | 58 ms | 27760 KiB |
| testcase02.txt | AC | 78 ms | 27808 KiB |
| testcase03.txt | AC | 82 ms | 27732 KiB |
| testcase04.txt | AC | 57 ms | 27884 KiB |
| testcase05.txt | AC | 38 ms | 27940 KiB |
| testcase06.txt | AC | 74 ms | 27808 KiB |
| testcase07.txt | AC | 78 ms | 27884 KiB |
| testcase08.txt | AC | 76 ms | 27876 KiB |
| testcase09.txt | AC | 80 ms | 27728 KiB |
| testcase10.txt | AC | 80 ms | 27936 KiB |
| testcase11.txt | AC | 79 ms | 27944 KiB |
| testcase12.txt | AC | 76 ms | 27760 KiB |
| testcase13.txt | AC | 79 ms | 27872 KiB |
| testcase14.txt | AC | 78 ms | 27876 KiB |
| testcase15.txt | AC | 78 ms | 27736 KiB |