Nyaan's Library

This documentation is automatically generated by online-judge-tools/verification-helper

View on GitHub

:heavy_check_mark: Gray code
(math/gray-code.hpp)

Verified with

Code

#pragma once



vector<int> gray_code(int n) {
  vector<int> ret(1 << n);
  for (int i = 0; i < (int)ret.size(); i++) ret[i] = i ^ (i >> 1);
  return ret;
};

/**
 * @brief Gray code
 */ 
#line 2 "math/gray-code.hpp"



vector<int> gray_code(int n) {
  vector<int> ret(1 << n);
  for (int i = 0; i < (int)ret.size(); i++) ret[i] = i ^ (i >> 1);
  return ret;
};

/**
 * @brief Gray code
 */ 
Back to top page