Submission #1000149

#TimeUsernameProblemLanguageResultExecution timeMemory
1000149daffuwuToys (CEOI18_toy)C++14
0 / 100
0 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; if (i == vc.size()-1 || vc[i-1].fr != dv) { 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()); 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 'void process(int)':
toy.cpp:17:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if (i == vc.size()-1 || vc[i-1].fr != dv)
      |             ~~^~~~~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:31:12: warning: unused variable 'j' [-Wunused-variable]
   31 |     int i, j;
      |            ^
toy.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     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...