Submission #267049

#TimeUsernameProblemLanguageResultExecution timeMemory
267049Kenzo_1114Toys (CEOI18_toy)C++17
19 / 100
1 ms384 KiB
#include<bits/stdc++.h> using namespace std; int n, s[40]; vector<int> v; vector<int> ans[40]; set<int> ANS; set<int> :: iterator it; int main () { scanf("%d", &n); int sq = sqrt(n) + 1; for(int i = 2; i <= sq; i++) while(n % i == 0) n /= i, v.push_back(i); if(n > 1) v.push_back(n); v.push_back(0); sort(v.begin(), v.end()); int sz = v.size(); s[0] = 1; for(int i = 1; i < sz; i++) s[i] = s[i - 1] * v[i]; ans[0].push_back(0); for(int i = 1; i < sz; i++) for(int j = 1; j <= i; j++) for(int k = 0; k < ans[j - 1].size(); k++) ans[i].push_back(ans[j - 1][k] + s[i] / s[j - 1] - 1); /* for(int i = 0; i < sz; i++) { printf("\nans[%d] : \n", i); for(int j = 0; j < ans[i].size(); j++) printf("%d ", ans[i][j]); printf("\n"); } */ for(int i = 0; i < ans[sz - 1].size(); i++) ANS.insert(ans[sz - 1][i]); printf("%d\n", (int) ANS.size()); for(it = ANS.begin(); it != ANS.end(); it++) printf("%d ", (*it)); printf("\n"); }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |    for(int k = 0; k < ans[j - 1].size(); k++)
      |                   ~~^~~~~~~~~~~~~~~~~~~
toy.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i = 0; i < ans[sz - 1].size(); i++) ANS.insert(ans[sz - 1][i]);
      |                 ~~^~~~~~~~~~~~~~~~~~~~
toy.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  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...