Notice
Recent Posts
Recent Comments
:: ADVANCE ::
83일차 1. cantoring 본문
반응형
http://183.106.113.109/30stair/cantoring/cantoring.php?pname=cantoring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 |
#include <iostream>
using namespace std;
char data[540000];
long total;
void init(long n)
{
for(int i = 1; i <= n; i++) {
data[i] = ' ';
}
return ;
}
long mypow(int n, int m)
{
int result = 1;
for(int i = 0; i < m; i++) {
result *= n;
}
return result;
}
void func(int start, long end, long length)
{
if(start > total || end > total) return;
if(start < 1 || end < 1) return;
if(start > end) return ;
if(length == 1) {
data[start] = '-';
return ;
}
func(start, start-1+length/3, length/3);
func(end-length/3+1, end, length/3);
}
int main(void)
{
int n;
cin >> n;
total = mypow(3, n);
init(total);
func(1, total, total);
for(long i = 1; i <= total; i++) {
cout << data[i];
}
cout << endl;
return 0;
} |
반응형
'Algorithm > 일일알고리즘' 카테고리의 다른 글
90일차 1. sprime (0) | 2014.10.08 |
---|---|
91일차 1. eratosthenes (0) | 2014.10.07 |
86일차 1. ncpc_event (0) | 2014.10.02 |
85일차 1. ladder (0) | 2014.10.02 |
84일차 1. cryption (0) | 2014.09.30 |
Comments