Submission #944242

#TimeUsernameProblemLanguageResultExecution timeMemory
944242phoenix0423Toys (CEOI18_toy)C++17
59 / 100
5049 ms1832 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define fastio ios::sync_with_stdio(false), cin.tie(0) #define pb push_back #define eb emplace_back #define f first #define s second #define int long long const int maxn = 2e5 + 5; signed main(void){ fastio; int n; cin>>n; vector<int> p; for(int i = 1; i <= sqrt(n); i++){ if(n % i == 0){ if(i != 1) p.pb(i); if(i != n / i) p.pb(n / i); } } sort(p.begin(), p.end()); map<int, int> mp; set<int> ans; for(int i = 0; i < p.size(); i++) mp[p[i]] = i; auto dfs = [&](auto dfs, int cur, int lst, int cnt) ->void{ if(cur == n){ ans.insert(cnt); return; } for(int i = lst; i < p.size(); i++){ if(n % (cur * p[i])) continue; dfs(dfs, cur * p[i], i, cnt + p[i] - 1); } }; dfs(dfs, 1, 0, 0); cout<<ans.size()<<"\n"; for(auto x : ans) cout<<x<<" "; cout<<"\n"; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:27:22: 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]
   27 |     for(int i = 0; i < p.size(); i++) mp[p[i]] = i;
      |                    ~~^~~~~~~~~~
toy.cpp: In instantiation of 'main()::<lambda(auto:23, long long int, long long int, long long int)> [with auto:23 = main()::<lambda(auto:23, long long int, long long int, long long int)>]':
toy.cpp:38:21:   required from here
toy.cpp:33:28: 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]
   33 |         for(int i = lst; i < p.size(); i++){
      |                          ~~^~~~~~~~~~
#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...