Submission #93398

#TimeUsernameProblemLanguageResultExecution timeMemory
93398SpeedOfMagicToys (CEOI18_toy)C++17
100 / 100
3337 ms86800 KiB
/** MIT License Copyright (c) 2018-2019(!) Vasilyev Daniil **/ #include <bits/stdc++.h> using namespace std; template<typename T> using v = vector<T>; typedef long long longlong; #define int longlong typedef long double ld; typedef string str; typedef vector<int> vint; #define rep(a, l, r) for(int a = (l); a < (r); a++) #define pb push_back #define fs first #define sc second #define sz(a) ((int) a.size()) const long long inf = 4611686018427387903; //2^62 - 1 #if 0 //FileIO const string fileName = ""; ifstream fin ((fileName == "" ? "input.txt" : fileName + ".in" )); ofstream fout((fileName == "" ? "output.txt" : fileName + ".out")); #define get fin>> #define put fout<< #else #define get cin>> #define put cout<< #endif #define eol put endl void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg) ;read(args...) ;} void print(){} template<typename Arg,typename... Args> void print(Arg arg,Args... args){put (arg)<<" ";print(args...);} int getInt(){int a; get a; return a;} //code starts here void run() { /* 36 = 1 2 3 4 6 9 12 18 36 dp[1] = {0} dp[2] = {1} dp[3] = {2} dp[4] = {3, 2} dp[6] = {5, 3} dp[9] = {8, 4} dp[12] = {11, 6, 5, 4} dp[18] = {17, } */ int n; get n; vint divs; rep(i, 1, ceil(sqrt(n)) + 1) if (n % i == 0) { divs.pb(i); if (n / i != i) divs.pb(n / i); } sort(divs.begin(), divs.end()); int m = sz(divs); set<int> dp[m]; dp[0] = {0}; rep(i, 1, m) rep(j, 0, i) if (divs[i] % divs[j] == 0) for (int k : dp[j]) dp[i].insert(divs[i] / divs[j] - 1 + k); put sz(dp[m - 1]); eol; for (int i : dp[m - 1]) print(i); } signed main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); put fixed << setprecision(12); run(); return 0;}
#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...