Submission #600127

#TimeUsernameProblemLanguageResultExecution timeMemory
600127gary940610Toys (CEOI18_toy)C++14
100 / 100
1575 ms33328 KiB
#include <iostream> #include <vector> #include <set> #include <map> #include <queue> #include <deque> #include <algorithm> #include <cstring> #include <cmath> #include <iomanip> #include <unordered_map> #define pb push_back #define pii pair<int, int> #define tup tuple<int, int, int> #define g0 get<0>(i) #define g1 get<1>(i) #define g2 get<2>(i) #define f first #define s second #define lowbit(x) (x & -x) #define endl '\n' #define i1 (i << 1) #define i2 (i << 1 | 1) #define Hash(x, y) (maxn * x + y) #define iofaster ios::sync_with_stdio(0);cin.tie(0) #define fr(a) freopen((a), "r", stdin) #define fw(a) freopen((a), "w", stdout) #define mset(a, b) memset(a, b, sizeof(a)) #define all(x) x.begin(), x.end() #define int long long #define double long double #pragma GCCoptimize("Ofast") using namespace std; const int maxn = 2e5 + 5; const int mod = 1e9 + 7; const int inf = 2e18 + 9; const int mxn = 1e9; const double eps = 1e-7; vector<int> arr; void dfs(int prv, int ans, int rem) { if(rem == 1) { arr.pb(ans); return ; } for(int i = 1; i * i <= rem; i++) { if(rem % i == 0) { if(i >= prv) dfs(i, ans + i - 1, rem / i); if(rem / i >= prv) dfs(rem / i, ans + rem / i - 1, i); } } } signed main() { iofaster; int n; cin >> n; dfs(2, 0, n); sort(all(arr)); arr.resize(unique(all(arr)) - arr.begin()); cout << arr.size() << endl; for(auto i: arr) cout << i << ' '; }

Compilation message (stderr)

toy.cpp:32: warning: ignoring '#pragma GCCoptimize ' [-Wunknown-pragmas]
   32 | #pragma GCCoptimize("Ofast")
      |
#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...