이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// made by Tima
// 2025 will be a golden year...
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
// #define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int,int>
#define tpii pair <pair <int,int> , int>
#define bruh cout << "NO\n"
using namespace std;
using namespace __gnu_pbds;
const int N = 3e5 + 5;
int mod = 1e9 + 7;
// const int INF = 1e18;
int n;
vector <int> q,z;
map <int , vector <int>> g;
map <int,int> mp;
map <int , vector <int>> used;
void calc(int x){
if(x == 1 || mp[x]) return;
q.pb(x);
mp[x] = 1;
for(int i = 2 ; i * i <= x ; i++){
if(x % i == 0){
g[x].pb(i);
calc(i) , calc(x / i);
}
}
}
void Gold(){
cin >> n;
q.pb(1);
calc(n);
sort(all(q));
for(auto x : q){
used[x].pb(x - 1);
if(x == 1) continue;
for(auto i : g[x]){
int f = i , s = x / i;
vector <int> st1 = used[f] , st2 = used[s];
for(auto it : st1){
for(auto ti : st2){
used[x].pb(ti + it);
}
}
}
}
vector <int> st;
sort(all(used[n]));
for(int i = 0 ; i < used[n].size() ; i++){
if(i == used[n].size() || used[n][i] != used[n][i + 1]) st.pb(used[n][i]);
}
cout << st.size() << '\n';
for(auto it : st){
cout << it << ' ';
}
}
//https://codeforces.com/blog/entry/133289
signed main(/*Zhunussov Temirlan*/){
//freopen("txt.in","r",stdin);freopen("txt.out","w",stdout);
ios_base::sync_with_stdio(0);cin.tie(0);
srand(time(0));
int TT = 1;
// cin >> TT;
for(int i = 1 ; i <= TT ; i++){
//cout << "Case " << i << ": ";
Gold();
}
}
컴파일 시 표준 에러 (stderr) 메시지
toy.cpp: In function 'void Gold()':
toy.cpp:58:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i = 0 ; i < used[n].size() ; i++){
| ~~^~~~~~~~~~~~~~~~
toy.cpp:59:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | if(i == used[n].size() || used[n][i] != used[n][i + 1]) st.pb(used[n][i]);
| ~~^~~~~~~~~~~~~~~~~
# | 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... |