Submission #679180

#TimeUsernameProblemLanguageResultExecution timeMemory
679180KiprasToys (CEOI18_toy)C++17
100 / 100
1602 ms4476 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll n; set<ll> res; void gen(ll mult, ll sum, ll last){ if(mult==1){ res.insert(sum); return; } for(int i = 1; i*i <= mult; i++){ if(i!=1&&mult%i==0&&i>=last){ gen(mult/i, sum+i-1, i); } if(mult%i==0&&mult/i!=i&&mult/i>=last){ gen(i, sum-1+(mult/i), mult/i); } } } int main() { ios_base::sync_with_stdio(0);cin.tie(nullptr); cin>>n; res.insert(n-1); gen(n, 0, 0); cout<<res.size()<<"\n"; for(auto i : res){ cout<<i<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...