Submission #536839

#TimeUsernameProblemLanguageResultExecution timeMemory
536839jamezzzToys (CEOI18_toy)C++17
100 / 100
1975 ms59920 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define disc(x) sort(all(x));x.resize(unique(all(x))-x.begin()); typedef pair<int,int> ii; typedef long long ll; int n; unordered_set<ll> vis; set<int> ans; inline ll hh(int a,int b){ return (ll)a*1000000000+b; } void dp(int x,int c){ if(vis.find(hh(x,c))!=vis.end())return; for(int i=2;i*i<=x;++i){ if(x%i==0)dp(x/i,c+i-1); } ans.insert(c+x-1); vis.insert(hh(x,c)); } int main(){ sf("%d",&n); dp(n,0); pf("%d\n",sz(ans)); for(int i:ans)pf("%d ",i); pf("\n"); }

Compilation message (stderr)

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