
[문제 링크]
https://www.acmicpc.net/problem/11729
[입출력 예]
입력 |
출력 |
3 |
7 1 3 1 2 3 2 1 3 2 1 2 3 1 3 |
[소스코드]
| #include <bits/stdc++.h> |
| using namespace std; |
| |
| void func(int a, int b, int n){ |
| if (n==1){ cout<<a<<" "<<b<<'\n'; |
| return;} |
| func(a,6-a-b,n-1); |
| cout<<a<<" "<<b<<"\n"; |
| func(6-a-b,b,n-1); |
| } |
| |
| |
| int main(){ |
| ios::sync_with_stdio(0); |
| cin.tie(0); |
| |
| int n; |
| cin>>n; |
| cout<<(1<<n)-1<<'\n'; |
| func(1,3,n); |
| return 0; |
| } |
댓글을 사용할 수 없습니다.