Submission #536812

#TimeUsernameProblemLanguageResultExecution timeMemory
536812dantoh000Toys (CEOI18_toy)C++14
100 / 100
1281 ms4560 KiB
#include <bits/stdc++.h> using namespace std; set<int> s; void dp(int n, int sum, int mx){ //printf("%d %d %d\n",n,sum,mx); s.insert(sum+n-1); for (int i = 2; i*i <= n && i <= mx; i++){ if (n%i == 0){ dp(n/i, sum+i-1, min(mx,i)); } } } int main(){ int n; scanf("%d",&n); dp(n, 0, n); printf("%d\n",(int)s.size()); for (auto x : s){ printf("%d ",x); } }

Compilation message (stderr)

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