Submission #161940

#TimeUsernameProblemLanguageResultExecution timeMemory
161940AkashiToys (CEOI18_toy)C++14
100 / 100
3321 ms87292 KiB
#pragma GCC optimze("Ofast") #include <bits/stdc++.h> using namespace std; int n, k = 1; map <int, int> f; set <int> s[10005]; void solve(int n, int K){ s[K].insert(n - 1); int r = sqrt(n); for(int i = 2; i <= r ; ++i){ if(n % i) continue ; if(f[i] == 0){ ++k; f[i] = k; solve(i, k); } if(f[n / i] == 0){ ++k; f[n / i] = k; solve(n / i, k); } int x1 = f[i]; int x2 = f[n / i]; for(auto it : s[x1]) s[K].insert(it + n / i - 1); for(auto it : s[x2]) s[K].insert(it + i - 1); } } int main() { // freopen("1.in", "r", stdin); scanf("%d", &n); f[n] = 1; solve(n, 1); printf("%d\n", s[1].size()); for(auto it : s[1]) printf("%d ", it); return 0; }

Compilation message (stderr)

toy.cpp:1:0: warning: ignoring #pragma GCC optimze [-Wunknown-pragmas]
 #pragma GCC optimze("Ofast")
 
toy.cpp: In function 'int main()':
toy.cpp:37:31: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n", s[1].size());
                    ~~~~~~~~~~~^
toy.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
#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...