# [BZOJ 2440][中山市选2011]完全平方数

4
1
13
100
1234567

1
19
163
2030745

## 题解

 1 //It is made by Awson on 2018.1.23
2 #include <set>
3 #include <map>
4 #include <cmath>
5 #include <ctime>
6 #include <queue>
7 #include <stack>
8 #include <cstdio>
9 #include <string>
10 #include <vector>
11 #include <cstdlib>
12 #include <cstring>
13 #include <iostream>
14 #include <algorithm>
15 #define LL long long
16 #define Abs(a) ((a) < 0 ? (-(a)) : (a))
17 #define Max(a, b) ((a) > (b) ? (a) : (b))
18 #define Min(a, b) ((a) < (b) ? (a) : (b))
19 #define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
20 #define writeln(x) (write(x), putchar('\n'))
21 #define lowbit(x) ((x)&(-(x)))
22 using namespace std;
23 const int K = 1e9;
24 const int N = 1e5;
26     char ch; bool flag = 0;
27     for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
28     for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
29     x *= 1-2*flag;
30 }
31 void write(LL x) {
32     if (x > 9) write(x/10);
33     putchar(x%10+48);
34 }
35
36 int n, m, mu[N+5];
37 int isprime[N+5], prime[N+5], tot;
38
39 void get_mu() {
40     memset(isprime, 1, sizeof(isprime)); isprime[1] = 0, mu[1] = 1;
41     for (int i = 2; i <= N; i++) {
42     if (isprime[i]) prime[++tot] = i, mu[i] = -1;
43     for (int j = 1; j <= tot && i*prime[j] <= N; j++) {
44         isprime[i*prime[j]] = 0;
45         if (i%prime[j]) mu[i*prime[j]] = -mu[i];
46         else {mu[i*prime[j]] = 0; break; }
47     }
48     }
49 }
50 int cal(int m, int k) {
51     int n = sqrt(m); LL ans = m;
52     for (int i = 2; i <= n; i++) ans += (LL)mu[i]*(m/i/i);
53     return ans >= k;
54 }
55 void work() {
56     read(n); int L = 1, R = n<<1, ans = n;
57     while (L <= R) {
58     int mid = ((LL)L+R)>>1;
59     if (cal(mid, n)) ans = mid, R = mid-1;
60     else L = mid+1;
61     }
62     writeln(ans);
63 }
64 int main() {
68 }