이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll int
#define F first
#define S second
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int N = 10001;
using namespace std;
using namespace __gnu_pbds;
ll n, a;
map <vector<ll>, ll> mp;
map <ll, vector <ll>> del;
set <ll> ans;
void rec (vector <ll> v, ll sum){
mp[v]++;
ans.insert (sum - v.size());
vector <ll> q;
set <ll> k;
for (auto i: v){
k.insert(i);
}
for (auto i: k){
if (del[i].size() == 0){
for (int y = 2; y <= sqrt (i); y++){
if (i % y == 0){
del[i].pb(y);
if (i / y != i){
del[i].pb(i / y);
}
}
}
}
for (auto y: del[i]){
q.clear();
ll a = -1;
for (int j = 0; j < v.size(); j++){
if (i == v[j] && a == -1){
a = 1;
continue;
}
q.pb (v[j]);
}
q.pb(y);
q.pb(i / y);
sort (all (q));
if (mp[q] == 0)rec (q, sum - i + y + i / y);
}
}
}
signed main (){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
rec ({n}, n);
cout << ans.size() << '\n';
for (auto i: ans){
cout << i << ' ';
}
}
컴파일 시 표준 에러 (stderr) 메시지
toy.cpp: In function 'void rec(std::vector<int>, int)':
toy.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int j = 0; j < v.size(); j++){
| ~~^~~~~~~~~~
# | 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... |