-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0023.cc
More file actions
51 lines (49 loc) · 871 Bytes
/
0023.cc
File metadata and controls
51 lines (49 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
constexpr ll n{28123};
auto s = [](ll n) -> ll {
ll k{__builtin_ctzll(n)};
n >>= k;
ll res{(1LL << (k + 1)) - 1};
for (ll i{3}; i <= n / i; i += 2) {
ll t{1};
while (n % i == 0) {
n /= i;
t = t * i + 1;
}
res *= t;
}
if (n > 1) {
res *= n + 1;
}
return res;
};
set<ll> st;
for (ll i{2}; i <= n; ++i) {
if (s(i) - i > i) {
st.insert(i);
}
}
ll ans{};
for (ll i{1}; i <= n; ++i) {
bool bl{};
for (ll x : st) {
if (i - x < 2) {
break;
}
if (st.find(i - x) != st.end()) {
bl = true;
break;
}
}
if (bl) {
continue;
}
ans += i;
}
cout << ans << '\n';
}