luckYrat's library.

This documentation is automatically generated by competitive-verifier/competitive-verifier


:heavy_check_mark: cpp/z_test/yosupo-enumerate_quotients.cpp

Depends on

Required by

Code

#define PROBLEM "https://judge.yosupo.jp/problem/enumerate_quotients"

#include "../../cpp/template/template.cpp"

#include "../../cpp/math/quotients.cpp"

int main(){
  long long n;cin>>n;
  auto z = quotients(n);
  cout << z.size() << endl;
  for(int i = 0; z.size() > i; i++){
    cout << z[i] << " \n"[i+1 == z.size()];
  }
}
#line 1 "cpp/z_test/yosupo-enumerate_quotients.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/enumerate_quotients"

#line 2 "cpp/template/template.cpp"

//yukicoder@cpp17

#include <iostream>
#include <iomanip>

#include <algorithm>

#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

#include <random>

#include <bitset>

#include <complex>

#include <utility>

#include <numeric>

#include <functional>


using namespace std;
using ll = long long;
using P = pair<ll,ll>;


const ll MOD = 998244353;
const ll MODx = 1000000007;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62LL)-1;
const double EPS = (1e-10);


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};


template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }
 
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/

/* comment outed because can cause bugs
__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
*/
#line 4 "cpp/z_test/yosupo-enumerate_quotients.cpp"

#line 1 "cpp/math/quotients.cpp"
vector<long long> quotients(long long x){
  vector<long long> ret;
  long long nw = 1;
  while(!ret.size() || ret[ret.size()-1] != x/nw){
    if(x < nw)break;
    ret.push_back(x/nw);
    nw++;
  }
  while(ret[ret.size()-1] != 1){
    ret.push_back(ret[ret.size()-1]-1);
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
#line 6 "cpp/z_test/yosupo-enumerate_quotients.cpp"

int main(){
  long long n;cin>>n;
  auto z = quotients(n);
  cout << z.size() << endl;
  for(int i = 0; z.size() > i; i++){
    cout << z[i] << " \n"[i+1 == z.size()];
  }
}

Test cases

Env Name Status Elapsed Memory
g++ example_00 :heavy_check_mark: AC 6 ms 3 MB
g++ max_00 :heavy_check_mark: AC 128 ms 21 MB
g++ min_00 :heavy_check_mark: AC 6 ms 3 MB
g++ min_01 :heavy_check_mark: AC 5 ms 3 MB
g++ min_02 :heavy_check_mark: AC 5 ms 3 MB
g++ min_03 :heavy_check_mark: AC 5 ms 3 MB
g++ min_04 :heavy_check_mark: AC 5 ms 3 MB
g++ min_05 :heavy_check_mark: AC 5 ms 3 MB
g++ min_06 :heavy_check_mark: AC 5 ms 3 MB
g++ min_07 :heavy_check_mark: AC 5 ms 3 MB
g++ min_08 :heavy_check_mark: AC 5 ms 3 MB
g++ polynom_p1p1m1_00 :heavy_check_mark: AC 157 ms 20 MB
g++ polynom_p1p1m1_01 :heavy_check_mark: AC 63 ms 12 MB
g++ polynom_p1p1z_00 :heavy_check_mark: AC 129 ms 21 MB
g++ polynom_p1p1z_01 :heavy_check_mark: AC 76 ms 12 MB
g++ polynom_p1zm1_00 :heavy_check_mark: AC 127 ms 20 MB
g++ polynom_p1zm1_01 :heavy_check_mark: AC 77 ms 13 MB
g++ random_00 :heavy_check_mark: AC 80 ms 13 MB
g++ random_01 :heavy_check_mark: AC 91 ms 21 MB
g++ random_small_00 :heavy_check_mark: AC 6 ms 3 MB
g++ random_small_01 :heavy_check_mark: AC 6 ms 3 MB
g++ random_small_02 :heavy_check_mark: AC 6 ms 3 MB
g++ random_small_03 :heavy_check_mark: AC 6 ms 3 MB
g++ random_small_04 :heavy_check_mark: AC 5 ms 3 MB
g++ square_00 :heavy_check_mark: AC 53 ms 12 MB
g++ square_01 :heavy_check_mark: AC 76 ms 12 MB
Back to top page