Submission #581695

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

using namespace std;

typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii; 
typedef vector<vii> wgraf;
typedef pair<int,ii> edge;
 
#define UNVISITED 0
#define VISITED 1
#define pb push_back
#define F first
#define S second

vi d;
set <int> v;

void j (int p, int n, int 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);
}
 
void SOLVE(){
  int n, di;

  cin >> n;

  if (n==1) {
    cout << "1\n" << "0\n";
  } else {
    
    for (int i=2; i*i<=n; i++){
      if (n%i==0) d.pb(i);
    }
    
    j(0, n, 0);

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  while(t--){
    SOLVE();
  }
}

Compilation message

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