Submission #1167352

#TimeUsernameProblemLanguageResultExecution timeMemory
1167352SmuggingSpunToys (CEOI18_toy)C++20
100 / 100
1951 ms123224 KiB
#include<bits/stdc++.h> #define taskname "B" using namespace std; const int lim = 1e9 + 5; int n, current = 0; vector<int>d; bitset<lim>ans; void play(int N, int pre){ if(N == 1){ ans.set(current); return; } for(int i = pre; i < d.size() && d[i] <= N; i++){ if(N % d[i] == 0){ current += d[i] - 1; play(N / d[i], i); current -= d[i] - 1; } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n; for(int i = 2; i * i <= n; i++){ if(n % i == 0){ d.emplace_back(i); if(i * i != n){ d.emplace_back(n / i); } } } sort(d.begin(), d.end()); d.emplace_back(n); ans.reset(); play(n, 0); cout << ans.count() << "\n"; for(int i = 0; i <= n; i++){ if(ans.test(i)){ cout << i << " "; } } }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...