Submission #1096085

#TimeUsernameProblemLanguageResultExecution timeMemory
1096085marToys (CEOI18_toy)C++14
59 / 100
5035 ms164200 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll maxn =1000000008; map < ll, map < ll, bool > > m; ll n; ll sz; vector<ll>divs; void rec(ll cur, ll sum, ll last){ if(m[cur][sum]) return; m[cur][sum] = true; if(cur == n) return; for(ll i = last; i < sz; i++){ ll d = divs[i]; if(cur*d > n) continue; if(!m[cur * d][sum + d - 1]) rec(cur*d, sum+d-1, i); } } int main(){ cin>>n; for(ll i = 2; i*i <= n; i++){ if(n % i == 0) { divs.push_back(i); if(i*i != n) divs.push_back(n / i); } } divs.push_back(n); sz = divs.size(); sort(divs.begin(), divs.end()); rec(1,0,0); cout << m[n].size() << endl; for(auto x : m[n]) cout << x.first << " "; cout << endl; 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...