Skip to content

Instantly share code, notes, and snippets.

@naoyat

naoyat/dsim.cc Secret

Last active June 22, 2018 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoyat/013d4019e6f57096fd6629ae281873ea to your computer and use it in GitHub Desktop.
Save naoyat/013d4019e6f57096fd6629ae281873ea to your computer and use it in GitHub Desktop.
ARC066 DのSierpinski gasket
#include <bits/stdc++.h>
using namespace std;
void sim(int N) {
for (int u=0; u<=N; ++u) {
vector<int> line(N+1, 0);
for (int k=0; k<=(N-u)/2; ++k) {
if (u & k) continue;
line[u+k*2] = 1;
}
for (int v=0; v<=N; ++v) {
putchar(line[v]?'*':'.');
}
putchar('\n');
}
}
int main(int argc, char **argv) {
int N;
if (argc == 2) {
N = atoi(argv[1]);
} else {
N = 20;
}
sim(N);
return 0;
}
*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
.*...*...*...*...*...*...*...*...*...*...*...*...*...*...*...*...*.
..*.*.....*.*.....*.*.....*.*.....*.*.....*.*.....*.*.....*.*.....*
...*.......*.......*.......*.......*.......*.......*.......*.......
....*.*.*.*.........*.*.*.*.........*.*.*.*.........*.*.*.*........
.....*...*...........*...*...........*...*...........*...*.........
......*.*.............*.*.............*.*.............*.*..........
.......*...............*...............*...............*...........
........*.*.*.*.*.*.*.*.................*.*.*.*.*.*.*.*............
.........*...*...*...*...................*...*...*...*.............
..........*.*.....*.*.....................*.*.....*.*..............
...........*.......*.......................*.......*...............
............*.*.*.*.........................*.*.*.*................
.............*...*...........................*...*.................
..............*.*.............................*.*..................
...............*...............................*...................
................*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*....................
.................*...*...*...*...*...*...*...*.....................
..................*.*.....*.*.....*.*.....*.*......................
...................*.......*.......*.......*.......................
....................*.*.*.*.........*.*.*.*........................
.....................*...*...........*...*.........................
......................*.*.............*.*..........................
.......................*...............*...........................
........................*.*.*.*.*.*.*.*............................
.........................*...*...*...*.............................
..........................*.*.....*.*..............................
...........................*.......*...............................
............................*.*.*.*................................
.............................*...*.................................
..............................*.*..................................
...............................*...................................
................................*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
.................................*...*...*...*...*...*...*...*...*.
..................................*.*.....*.*.....*.*.....*.*.....*
...................................*.......*.......*.......*.......
....................................*.*.*.*.........*.*.*.*........
.....................................*...*...........*...*.........
......................................*.*.............*.*..........
.......................................*...............*...........
........................................*.*.*.*.*.*.*.*............
.........................................*...*...*...*.............
..........................................*.*.....*.*..............
...........................................*.......*...............
............................................*.*.*.*................
.............................................*...*.................
..............................................*.*..................
...............................................*...................
................................................*.*.*.*.*.*.*.*.*.*
.................................................*...*...*...*...*.
..................................................*.*.....*.*.....*
...................................................*.......*.......
....................................................*.*.*.*........
.....................................................*...*.........
......................................................*.*..........
.......................................................*...........
........................................................*.*.*.*.*.*
.........................................................*...*...*.
..........................................................*.*.....*
...........................................................*.......
............................................................*.*.*.*
.............................................................*...*.
..............................................................*.*..
...............................................................*...
................................................................*.*
.................................................................*.
..................................................................*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment