답안 #168835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168835 2019-12-16T16:17:57 Z kostia244 Toys (CEOI18_toy) C++17
0 / 100
100 ms 95864 KB
#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];
const int C = 673117;
bitset<C> *vis;
__attribute__((always_inline)) inline bool mark(ll i, ll cur) {
	ll x = (i*i <= n ? i : 31628+(n/i));
	ll z = (31ll*cur + 1)%C;
	if(vis[x][z]) return false;
	vis[x][z] = 1;
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	vis =new bitset<C>[2*31628+33];
	cin >> n;
	ll tn = n;
	for (ll d = 1; d * d <= tn; d++) {
		if (tn % d)
			continue;
		divs.pb(d);
		if (d * d != n) {
			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 100 ms 95864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 100 ms 95864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 100 ms 95864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 100 ms 95864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 100 ms 95864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -