이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
vector<multiset<ll>> res;
int main() {
cin.sync_with_stdio(false);
vector<ll> primes;
map<ll, bool> is_prime;
primes.push_back(2);
is_prime[2] = 1;
rep(i, 3, 1e5) {
ll val = sqrt(i);
val++;
ll ind = upper_bound(all(primes), val) - primes.begin();
bool done = true;
rep(j, 0, ind) {
if (i % primes[j] == 0) {
done = false;
break;
}
}
if (done) {
is_prime[i] = 1;
primes.push_back(i);
}
}
ll n;
cin >> n;
ll cur = n;
is_prime[1] = 1;
is_prime[0] = 1;
vector<ll> v;
while (!is_prime[cur]) {
rep(i, 0, primes.size()) {
if (cur % primes[i] == 0) {
v.push_back(primes[i]);
cur /= primes[i];
break;
}
}
}
v.push_back(cur);
vector<ll> pr;
map<multiset<ll>, bool> visited;
queue<pair<vector<ll>, multiset<ll>>> q;
multiset<ll>node;
vector<ll> maping(30);
set<ll> uniq;
trav(a, v)uniq.insert(a);
ll counter = 0;
vector<ll> v2;
trav(a, uniq) {
maping[counter] = a;
v2.push_back(count(all(v), a));
counter++;
}
q.emplace(v2, node);
while (!q.empty()) {
pair<vector<ll>, multiset<ll>> cur = q.front();
q.pop();
ll counter = 0;
rep(i, 0, cur.first.size()) {
if (cur.first[i] == 0) {
counter++;
if (cur.first.size() == counter) {
res.push_back(cur.second);
}
continue;
}
vector<ll> ny = cur.first;
multiset<ll> ny2;
vector<ll> ny20;
trav(a, cur.second)ny20.push_back(a);
ny[i]--;
rep(j, 0, cur.second.size()) {
ny2.clear();
rep(z, 0, cur.second.size()) {
if (z == j) {
ny2.insert(maping[i] * ny20[z]);
}
else ny2.insert(ny20[z]);
}
if (!visited[ny2]) {
visited[ny2] = 1;
q.emplace(make_pair(ny, ny2));
}
}
ny2 = cur.second;
ny2.insert(maping[i]);
if (!visited[ny2]) {
visited[ny2] = 1;
q.emplace(make_pair(ny, ny2));
}
}
}
set<ll> ans;
rep(i, 0, res.size()) {
ll val = 0;
trav(a, res[i]) {
val += a - 1;
}
ans.insert(val);
}
cout << ans.size() << endl;
trav(a, ans)cout << a << " ";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
toy.cpp: In function 'int main()':
toy.cpp:75:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
75 | if (cur.first.size() == counter) {
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~
# | 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... |