Submission #124472

#TimeUsernameProblemLanguageResultExecution timeMemory
124472naderjemelToys (CEOI18_toy)C++14
100 / 100
1293 ms22268 KiB
#include <bits/stdc++.h> using namespace std; #define INF 1e9 #define fi first #define se second typedef long long ll; int n,rs; set<int> vis; map<int,vector<int> > mp; vector<int> solve(int u){ vector<int> st; if(vis.count(u)) return mp[u]; int less=sqrt(u); st.push_back(u-1); for(int i=2;i<=less;i++){ if(u%i==0){ vector<int> s=solve(u/i); for(int I:s) st.push_back(I+i-1); } } vis.insert(u); sort(st.begin(),st.end()); auto last = unique(st.begin(),st.end()); st.erase(last,st.end()); return mp[u]=st; } int main(){ scanf("%d",&n); if(n==1){ printf("1\n0\n"); return 0; } vector<int> st=solve(n); printf("%d\n", (int)st.size()); for(int i:st) printf("%d ", i); printf("\n"); }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:35:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i:st) printf("%d ", i); printf("\n");
  ^~~
toy.cpp:35:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i:st) printf("%d ", i); printf("\n");
                                  ^~~~~~
toy.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  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...