Submission #538011

#TimeUsernameProblemLanguageResultExecution timeMemory
538011jamielimToys (CEOI18_toy)C++14
59 / 100
5079 ms4868 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb emplace_back #define ALL(x) x.begin(),x.end() #define SZ(x) (int)x.size() typedef long long ll; typedef pair<int,int> ii; typedef pair<ii,ii> i4; const int MOD=1000000007; const int INF=1012345678; const ll LLINF=1012345678012345678LL; const double PI=3.1415926536; const double EPS=1e-14; int n; vector<int> memo[100005]; vector<int> dp(int n){ if(n<100005&&!memo[n].empty())return memo[n]; set<int> s; for(int i=2;i*i<=n;i++){ if(n%i!=0)continue; vector<int> y=dp(n/i); for(int j:y){ s.insert(j+i-1); } } s.insert(n-1); vector<int> ans; for(int i:s)ans.pb(i); if(n<100005)memo[n]=ans; return ans; } int main(){ scanf("%d",&n); vector<int> ans=dp(n); sort(ALL(ans)); printf("%d\n",SZ(ans)); for(int i:ans){ printf("%d ",i); } }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  scanf("%d",&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...