G
N
I
D
A
O
L

蓝桥杯-皮亚诺曲线


蓝桥杯-皮亚诺曲线

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include<iostream>
#include<cmath>
using namespace std;
int n,k,x,y;
void add(int a,int b,int sss){
    if(a==1){
        switch(sss){
            case 0:
                switch(b){
                    case 1:x+=1;y+=1;break;
                    case 2:x+=1;y+=2;break;
                    case 3:x+=2;y+=2;break;
                    case 4:x+=2;y+=1;break;
                }
            break;
            case 1:
                switch(b){
                    case 1:x+=1;y+=1;break;
                    case 2:x+=2;y+=1;break;
                    case 3:x+=2;y+=2;break;
                    case 4:x+=1;y+=2;break;
                }
            break;
            case 2:
                switch(b){
                    case 1:x+=2;y+=2;break;
                    case 2:x+=1;y+=2;break;
                    case 3:x+=1;y+=1;break;
                    case 4:x+=2;y+=1;break;
                }
            break;
            case 3:
                switch(b){
                    case 1:x+=2;y+=2;break;
                    case 2:x+=2;y+=1;break;
                    case 3:x+=1;y+=1;break;
                    case 4:x+=1;y+=2;break;
                }
            break;
        }
        return;
    }
    int one=pow(2,2*a-2),ss=0;
    while(b-one>0) b-=one,ss++;
    switch(sss){
        case 0:
            switch(ss){
                case 0:add(a-1,b,1);break;
                case 1:y+=pow(2,a-1);add(a-1,b,0);break;
                case 2:x+=pow(2,a-1);y+=pow(2,a-1);add(a-1,b,0);break;
                case 3:x+=pow(2,a-1);add(a-1,b,2);break;
            }
            break;
        case 1:
            switch(ss){
                case 0:add(a-1,b,0);break;
                case 1:x+=pow(2,a-1);add(a-1,b,1);break;
                case 2:x+=pow(2,a-1);y+=pow(2,a-1);add(a-1,b,1);break;
                case 3:y+=pow(2,a-1);add(a-1,b,3);break;
            }
        break;
        case 2:
            switch(ss){
                case 0:x+=pow(2,a-1);y+=pow(2,a-1);add(a-1,b,3);break;
                case 1:y+=pow(2,a-1);add(a-1,b,2);break;
                case 2:add(a-1,b,2);break;
                case 3:x+=pow(2,a-1);add(a-1,b,0);break;
            }
        break;
        case 3:
            switch(ss){
                case 0:x+=pow(2,a-1);y+=pow(2,a-1);add(a-1,b,2);break;
                case 1:x+=pow(2,a-1);add(a-1,b,3);break;
                case 2:add(a-1,b,3);break;
                case 3:y+=pow(2,a-1);add(a-1,b,1);break;
            }
        break;
        }
}
int main(void){
    cin>>n>>k;
    int i=0;
    while(n/=2)  i++;
    x=y=0;
    add(i,k,0);
    cout << x << ' ' << y;
    return 0;
}

文章作者: AnglesD
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 AnglesD !
评论