#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,sse2,sse,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC comment("/STACK:26666666")
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int mod = 1e9 + 7;
ll n;
vi divs, cans[1001000], canb[1001000];
int id[1001000];
const int C = 1299827;
const int B = 1237177;
bitset<C> *vis;
bitset<B> *vis2;
__attribute__((always_inline)) inline bool mark(ll i, ll cur) {
ll x = (i*i <= n ? id[i] : id[31628+(n/i)]);
ll z = (31ll*cur + 13)%C;
ll zz = (17ll*cur + 5)%B;
if(vis[x][z]&&vis2[x][zz]) return false;
vis[x][z] = 1;
vis2[x][zz] = 1;
return true;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vis =new bitset<C>[1<<11];
vis2 =new bitset<B>[1<<11];
cin >> n;
ll tn = n;
int x = 0;
for (ll d = 1; d * d <= tn; d++) {
if (tn % d)
continue;
divs.pb(d);
id[d] = x++;
if (d * d != n) {
id[31628+d]=x++;
divs.pb(n / d);
}
}
sort(all(divs));
cans[1].pb(0);
for (auto i : divs) {
vi &t = (i * i <= n ? cans[i] : canb[n / i]);
sort(all(t));
t.erase(unique(all(t)), t.end());
for (auto j : divs) {
if(j==1)continue;
if (i * j > n)
break;
if (n % (i * j))
continue;
ll _nxt = i * j;
vi &nxt = (_nxt * _nxt <= n ? cans[_nxt] : canb[n / _nxt]);
for (auto q : t) {
if(mark(_nxt, q+j-1))
nxt.pb(q + j - 1);
}
}
}
vi &t = (n * n <= n ? cans[n] : canb[n / n]);
sort(all(t));
cout << t.size() << "\n";
// for (auto i : t)
// cout << i << " ";
}
Compilation message
toy.cpp:4:0: warning: ignoring #pragma GCC comment [-Wunknown-pragmas]
#pragma GCC comment("/STACK:26666666")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
225 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
225 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
225 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
225 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
225 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |