Submission #1261333

#TimeUsernameProblemLanguageResultExecution timeMemory
1261333son2008Toys (CEOI18_toy)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define ii pair<int, int> #define fi first #define se second #define int long long #define ll long long #define ld double #define mp make_pair #define lg2 30 #define iii pair<int, ii> #define iiii pair<ii, ii> #define base 29 #define eps 1e-8 #define MASK(i) (1LL << (i)) #define BIT(S, i) (((S) >> (i)) & 1) int dx[] = {0LL, 0LL, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0LL, 0LL, 1, -1, 1, -1}; const int maxn = 4e5 + 5; const int mod = 1e9 + 7; int n; vector<int> ans; void dfs(int x, int cuoi, int sum) { if (x >= cuoi) { ans.push_back(sum + x - 1); } for (int i = cuoi; i * i <= x; i++) { if (x % i == 0) { dfs(x / i, i, sum + i - 1); } } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "task" if (fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } cin >> n; dfs(n, 2, 0); sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); cout << ans.size() << '\n'; for (int x : ans) { cout << x << " "; } cerr << endl << "TIME : " << clock() * 0.001 << "s" << endl; }

Compilation message (stderr)

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