This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("popcnt")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=2e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
const ldb eps=1e-6;
const ldb PI=acos(-1.0);
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
template<typename T>
using vvector = vector<vector<T>>;
map<pii,vector<int>> dp;
void f(int n,int mx) {
if (dp.find({n,mx})!=dp.end()) return;
vector<int> &now = dp[{n,mx}];
now={};
for (int i=2;i<=min(mx,(int)sqrt(n));i++) {
if (n%i==0) {
f(n/i,i);
for (int j:dp[{n/i,i}]) now.push_back(j+i-1);
if (i*i!=n) {
int ni=n/i;
if (ni>mx) continue;
f(n/ni,ni);
for (int j:dp[{n/ni,ni}]) now.push_back(j+ni-1);
}
}
}
if (n<=mx) now.push_back(n-1);
sort(all(now));
now.resize(unique(all(now))-now.begin());
// cout<<n<<" "<<mx<<" n mx\n";
// for (int i:now) cout<<i<<" ";
// cout<<"\n";
}
int main() {
speed;
int n;
cin>>n;
f(n,n);
cout<<dp[{n,n}].size()<<"\n";
for (int i:dp[{n,n}]) cout<<i<<" ";
return 0;
}
# | 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... |