Submission #537243

#TimeUsernameProblemLanguageResultExecution timeMemory
537243perchutsToys (CEOI18_toy)C++17
59 / 100
5038 ms460 KiB
#include <bits/stdc++.h> #define maxn (int)(1e5+51) #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' #define ll long long #define pb push_back #define ull unsigned long long #define ii pair<int,int> #define iii tuple<int,int,int> #define inf 2000000001 #define mod 1000000007 //998244353 #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; } template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; } set<int>res; int n; void test(int x, int sum){ if(x==n){ res.insert(sum); return; }else if(x>n)return; for(int i=1;i<=n/x;++i){ if(n%x*(i+1)!=0)continue; test(x*(i+1),sum+i); } } int main(){_ cin>>n; // int sq = sqrt(n)+1; // int tmp = n; // vector<int>factors; // for(int i=2;i<=sq;++i){ // while(tmp%i==0){ // factors.pb(i); // tmp/=i; // } // } // if(tmp!=1)factors.pb(tmp); test(1,0); cout<<sz(res)<<endl; for(auto x:res)cout<<x<<" "; }
#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...