Submission #1000154

#TimeUsernameProblemLanguageResultExecution timeMemory
1000154daffuwuToys (CEOI18_toy)C++14
19 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, tmp, cur; vector<pair<int, vector<int> > > vc; void process(int dv) { int i; vc.push_back({dv, {}}); for (cur=1, i=vc.size()-1; i>=1; i--) { cur *= vc[i].fr; for (auto x:vc[i-1].sc) { vc.back().sc.push_back(x+cur-1); } } cur *= vc[0].fr; vc.back().sc.push_back(cur-1); } int main() { int i, j; scanf("%d", &n); for (i=2, tmp=n; i*i<=n; i++) { for (; tmp%i == 0; tmp/=i) process(i); } if (tmp>1) process(tmp); if (n == 1) vc.push_back({0, {0}}); sort(vc.back().sc.begin(), vc.back().sc.end()); vc.back().sc.resize(unique(vc.back().sc.begin(), vc.back().sc.end())-vc.back().sc.begin()); printf("%d\n", (int)vc.back().sc.size()); for (auto x:vc.back().sc) printf("%d ", x); printf("\n"); }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:28:12: warning: unused variable 'j' [-Wunused-variable]
   28 |     int i, j;
      |            ^
toy.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     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...