Submission #581717

# Submission time Handle Problem Language Result Execution time Memory
581717 2022-06-23T04:41:52 Z Osplei Toys (CEOI18_toy) C++17
0 / 100
1 ms 392 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector <ll> d;
set <ll> v;

void j (ll p, ll n, ll c){
  v.insert(c+n-1);
  if (n==1) return;
  if (n<d[p]*d[p]) return;
  if (p==d.size()) return;
  if (n%d[p]==0) j(p, n/d[p], c+d[p]-1);
  j(p+1, n, c);
}

int main(){
  ll n;

  cin >> n;

  for (ll i=1; i*i<=n; i++){
    if (n%i) continue; 
    if (i>1) d.push_back(i);
  }
    
  sort (d.begin(), d.end());
  j(0, n, 0);

  cout << v.size() << "\n";
  for (auto &i : v) cout << i << " ";
  cout << "\n";
}

Compilation message

toy.cpp: In function 'void j(ll, ll, ll)':
toy.cpp:14:8: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   if (p==d.size()) return;
      |       ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 392 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 392 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 392 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 392 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 392 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -