cses

solution to cses exercise problems
git clone git://git.superpozycja.net/cses
Log | Files | Refs | README

commit 8837a2396c1b3e8d06a0e55e9a6cb1fdaac72c19
parent 846e5bbc663fb34e99b12d0dfd0e922477eb01ec
Author: superpozycja <anna@superpozycja.net>
Date:   Thu, 24 Oct 2024 01:28:21 +0200

solve gray code

Diffstat:
Aintro/gray_code.cpp | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/intro/gray_code.cpp b/intro/gray_code.cpp @@ -0,0 +1,30 @@ +#include <bits/stdc++.h> + +using namespace std; + +using ui = unsigned int; +using l = long; +using ul = unsigned long; +using ll = long long; +using ull = unsigned long long; + +using vi = vector<int>; +using vui = vector<ui>; +using vl = vector<l>; +using vul = vector<ul>; +using vll = vector<ll>; +using vull = vector<ull>; + +void solve() +{ + int n; + cin >> n; + for (int i = 0; i < 1<<n; i++) { + printf("%0*b\n", n, (i ^ i >> 1)); + } +} + +int main() +{ + solve(); +}