Submission #457872

#TimeUsernameProblemLanguageResultExecution timeMemory
457872hhhhauraToys (CEOI18_toy)C++14
79 / 100
5032 ms123992 KiB
#define wiwihorz #pragma GCC optimize("Ofast") #pragma loop-opt(on) #include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define int long long int #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "Line " << __LINE__ <<": ", kout("[" + string(#a) + "] = ", a) void kout() {cerr << endl;} void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;} template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); } #else #define print(...) 0 #define vprint(...) 0 #endif namespace solver { vector<int> ans; set<pii> vis; void solve(int n, int sum, int big) { if(n == 1) { ans.push_back(sum); return; } for(int i = 2; i * i <= n; i ++) { if(n % i) continue; if(i >= big) solve(n / i, sum + i - 1, i); if(i >= big) solve(i, sum + n / i - 1, n / i); } solve(1, sum + n - 1, n); vis.insert({n, sum}); return; } }; using namespace solver; signed main() { ios::sync_with_stdio(false), cin.tie(0); int n; cin >> n; solve(n, 0, 0); sort(all(ans)); ans.resize(unique(all(ans)) - ans.begin()); cout << ans.size() << "\n"; rep(i, 0, signed(ans.size()) - 1) { cout << ans[i] << " \n"[i + 1 == ans.size()]; } return 0; }

Compilation message (stderr)

toy.cpp:3: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    3 | #pragma loop-opt(on)
      | 
toy.cpp:25:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
toy.cpp:25:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
toy.cpp: In function 'int main()':
toy.cpp:62:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   cout << ans[i] << " \n"[i + 1 == ans.size()];
      |                           ~~~~~~^~~~~~~~~~~~~
#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...