Submission #267076

#TimeUsernameProblemLanguageResultExecution timeMemory
267076Kenzo_1114Toys (CEOI18_toy)C++17
39 / 100
1042 ms640 KiB
#include<bits/stdc++.h> using namespace std; const int MAXV = 40; int n, s[MAXV], sz; vector<int> v; set<int> ans; set<int> :: iterator it; map<int, bool> marc; void BKT(int num, int sum) { if(num == 1){ ans.insert(num + sum - 1); return; } for(int i = 0; i < v.size(); i++) if(num % v[i] == 0) BKT(num / v[i], sum + v[i] - 1); } int main () { scanf("%d", &n); int N = n; for(long long int i = 2; i * i <= n; i++) { if(n % i == 0) v.push_back(i), marc[i] = true; while(n % i == 0) n /= i; } if(n > 1) v.push_back(n), marc[n] = true; for(int k = 0; k <= 30; k++) { vector<int> aux; for(int i = 0; i < v.size(); i++) { for(int j = 0; j < v.size(); j++) { int cur = v[i] * v[j]; if(!marc[cur] && N % cur == 0) marc[cur] = true, aux.push_back(cur); } } for(int i = 0; i < aux.size(); i++) v.push_back(aux[i]); } sort(v.begin(), v.end()); BKT(N, 0); 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 'void BKT(int, int)':
toy.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i = 0; i < v.size(); i++)
      |                 ~~^~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
toy.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for(int j = 0; j < v.size(); j++)
      |                   ~~^~~~~~~~~~
toy.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i = 0; i < aux.size(); i++) v.push_back(aux[i]);
      |                  ~~^~~~~~~~~~~~
toy.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  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...