| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 872788 | bobbilyking | Toys (CEOI18_toy) | C++17 | 5043 ms | 68996 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = (l); i < r; ++i)
using dp_t=array<ll, 10>;
vector<pl> glob_facs;
set<pair<dp_t, ll>> dp;
set<ll> vis;
void dfs(dp_t& facs, ll sm){
ll ans = accumulate(A(facs), 0ll);
if (!ans) {
vis.insert(sm);
return;
}
if (dp.count({facs, sm})) return;
dp.emplace(facs, sm);
function<void(ll, ll)> gen = [&](ll idx, ll csm) {
if (idx == glob_facs.size()) {
if (csm == 1) return;
dfs(facs, csm + sm - 1);
return;
}
ll prod = 1;
F(j, 0, facs[idx]+1) {
facs[idx] -= j;
gen(idx+1, prod * csm);
prod = prod * glob_facs[idx].K;
facs[idx] += j;
}
};
gen(0, 1);
}
int main(){
// freopen("a.in", "r", stdin);
// freopen("a.out", "w", stdout);
ios_base::sync_with_stdio(false); cin.tie(0);
cout << fixed << setprecision(20);
G(n)
for (ll i = 2; i *i <=n ;++i) if (n%i == 0) {
ll cnt = 0;
while (n%i==0) cnt++, n/=i;
glob_facs.emplace_back(i, cnt);
}
if (n-1) glob_facs.emplace_back(n, 1);
sort(A(glob_facs), [&](const auto &a, const auto &b) {
return a.V > b.V;
});
dp_t cur = {};
F(j, 0, glob_facs.size()) cur[j] = glob_facs[j].V;
dfs(cur, 0);
cout << vis.size() << '\n';
for (auto x: vis) cout << x << " "; cout << '\n';
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
