Submission #124053

#TimeUsernameProblemLanguageResultExecution timeMemory
124053semiautoToys (CEOI18_toy)C++14
100 / 100
2641 ms4616 KiB
#include <bits/stdc++.h> #define se second #define fi first using namespace std; int n,i; priority_queue <int> ans; vector <int> d; unordered_map <int,bool> mymap; void go(int x,int s,int k) { if (x==1) { if (!mymap[s]) { ans.push(-s); mymap[s]=1; } return; } int i; for (i=k;i<d.size();i++) {if (!(x%d[i])) go(x/d[i],s+d[i]-1,i); if (d[i]>x)break;} } int main() { cin>>n; for (i=2;(i*i)<=n;i++) if (!(n%i)) d.push_back(i); for (i=d.size()-1;i>=0;i--) if (d[i]*d[i]<n) d.push_back(n/d[i]); d.push_back(n); go(n,0,0); cout<<ans.size()<<endl; while (ans.size()) { printf("%d ",(-(ans.top()))); ans.pop(); } cout<<endl; return 0; }

Compilation message (stderr)

toy.cpp: In function 'void go(int, int, int)':
toy.cpp:19:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i=k;i<d.size();i++)
              ~^~~~~~~~~
toy.cpp:20:10: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         {if (!(x%d[i]))
          ^~
toy.cpp:22:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
             if (d[i]>x)break;}
             ^~
#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...