Submission #32223421
Source Code Expand
#include <bits/stdc++.h>
template<typename T>
inline T chkmin(T& x, const T& y){if (x > y) x = y; return x;}
template<typename T>
inline T chkmax(T& x, const T& y){if (x < y) x = y; return x;}
using namespace std;
int sqr(int x){return x * x;}
const int NN = 2e5 + 500, N = 2e5;
int n, notprime[NN], mu[NN];
vector<int> plist;
inline void linear_sieve(int n)
{
notprime[1] = true; mu[1] = 1;
for (int i=2; i<=n; i++)
{
if (!notprime[i]){plist.emplace_back(i); mu[i] = -1;}
for (auto x : plist)
{
int now = i*x;
if (now > n) break;
notprime[now] = true;
if (!(i%x)){mu[now] = 0; break;}
mu[now] = mu[i] * mu[x];
}
}
}
int main()
{
scanf("%d", &n); double ans = 0;
linear_sieve(n);
for (int i=1; i<=n; i++)
if (mu[i]) ans += sqr(sqrt(1.0 * n / i));
printf("%.0f", ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Together Square |
| User | Jijidawang |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 922 Byte |
| Status | AC |
| Exec Time | 9 ms |
| Memory | 5544 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:29:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
29 | scanf("%d", &n); double ans = 0;
| ~~~~~^~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 7 ms | 3748 KiB |
| example_01.txt | AC | 2 ms | 3660 KiB |
| test_00.txt | AC | 4 ms | 4456 KiB |
| test_01.txt | AC | 2 ms | 3936 KiB |
| test_02.txt | AC | 3 ms | 4068 KiB |
| test_03.txt | AC | 4 ms | 5256 KiB |
| test_04.txt | AC | 2 ms | 3888 KiB |
| test_05.txt | AC | 9 ms | 5308 KiB |
| test_06.txt | AC | 6 ms | 5544 KiB |
| test_07.txt | AC | 6 ms | 5232 KiB |
| test_08.txt | AC | 7 ms | 5544 KiB |
| test_09.txt | AC | 6 ms | 5240 KiB |
| test_10.txt | AC | 2 ms | 3620 KiB |
| test_11.txt | AC | 7 ms | 5492 KiB |