Submission #73452

#TimeUsernameProblemLanguageResultExecution timeMemory
73452jiaqing23Toys (CEOI18_toy)C++14
79 / 100
5098 ms3972 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define pop pop_back typedef long long ll; set<ll> ans; ll n; vector<ll> fac,factor_tem, factor; ll sum = 0; void factorize(ll n, ll now, ll smallfac){ if(now == n) ans.insert(sum); for(int i = smallfac; factor[i]*now <= n ; i++){ if((n/now) % factor[i] == 0){ fac.pb(factor[i]); sum+=(factor[i]-1); factorize(n, now*factor[i], i); sum-=(factor[i]-1); fac.pop(); } } } int main() { scanf("%lld",&n); for(int i = 1; i * i <= n; i++){ if(n%i==0) { factor.pb(i); if(i*i!=n)factor_tem.pb(n/i); } } reverse(factor_tem.begin(),factor_tem.end()); factor_tem.pb((ll)1e10); factor.resize(factor_tem.size()+factor.size()); copy_backward(factor_tem.begin(),factor_tem.end(),factor.end()); factorize(n, 1, 1); printf("%d\n",ans.size()); for(set<ll>::iterator it = ans.begin(); it!=ans.end(); it++){ printf("%lld ",*it); } return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:50:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<long long int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",ans.size());
                   ~~~~~~~~~~^
toy.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
#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...