Submission #153694

#TimeUsernameProblemLanguageResultExecution timeMemory
153694Ruxandra985Toys (CEOI18_toy)C++14
100 / 100
590 ms4608 KiB
#include <cstdio> #include <set> #include <algorithm> using namespace std; set <int> st; int v[50000],elem; void back (int n , int sum , int prev){ int d; if (n == 1){ st.insert(sum); } else { for (int i = prev; i<= elem && v[i] * v[i] <= n ; i++){ if (n%v[i] == 0) back (n/v[i],sum + v[i] - 1,i); } back(1 , sum + n - 1, n); } } int main() { FILE *fin = stdin; FILE *fout = stdout; int n,d; fscanf (fin,"%d",&n); d = 2; elem = 0; while (d*d<=n){ if (n%d == 0) v[++elem] = d; d++; } /// trb sa generez cumva toate seturile de divizori back (n , 0 , 1); fprintf (fout,"%d\n",st.size()); for (set <int> :: iterator it = st.begin() ; it!=st.end() ; it++){ fprintf (fout,"%d ",*it); } return 0; }

Compilation message (stderr)

toy.cpp: In function 'void back(int, int, int)':
toy.cpp:9:9: warning: unused variable 'd' [-Wunused-variable]
     int d;
         ^
toy.cpp: In function 'int main()':
toy.cpp:36:35: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::set<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fout,"%d\n",st.size());
                          ~~~~~~~~~^
toy.cpp:26:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%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...