Submission #490950

#TimeUsernameProblemLanguageResultExecution timeMemory
490950SanguineChameleonToys (CEOI18_toy)C++14
59 / 100
5100 ms1480 KiB
#include <bits/stdc++.h> using namespace std; const bool read_file = false; const char fi[] = "XX.INP"; const char fo[] = "XX.OUT"; void set_up() { if (read_file) { freopen(fi, "r", stdin); freopen(fo, "w", stdout); } cin.clear(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void just_do_it(); int main() { set_up(); just_do_it(); } set<long long> s; long long n; vector<long long> f; void backtrack(long long cc, long long cp, long long cs) { if (cc == 1) { s.insert(cs); return; } for (auto pp: f) { if (pp >= cp) { if (cc % pp == 0) { backtrack(cc / pp, pp, cs + pp - 1); } } else { return; } } } void just_do_it() { cin >> n; for (long long ff = 1; ff * ff <= n; ff++) { if (n % ff == 0) { if (ff * ff == n) { f.push_back(ff); } else { f.push_back(ff); f.push_back(n / ff); } } } sort(f.begin(), f.end(), greater<long long>()); backtrack(n, 2, 0); cout << s.size() << endl; for (auto x: s) { cout << x << " "; } }

Compilation message (stderr)

toy.cpp: In function 'void set_up()':
toy.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen(fi, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~
toy.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen(fo, "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~
#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...