-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBee Maja.cpp
58 lines (49 loc) · 1.15 KB
/
Bee Maja.cpp
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
#include <bits/stdc++.h>
using namespace std;
struct point{
int x,y;
}p[100001];
int idx;
void create(){
p[1].x=0;
p[1].y=0;
idx=2;
int nowI=0,nowJ=0,count;
for(int num=1;idx<=100000;num++){
for(int count=0;count<num && idx<=100000;count++,idx++){//down
p[idx].x=nowI;
p[idx].y=++nowJ;
}
for(int count=0;count<num-1 && idx<=100000;count++,idx++){//left down
p[idx].x=--nowI;
p[idx].y=++nowJ;
}
for(int count=0;count<num && idx<=100000;count++,idx++){//up
p[idx].x=--nowI;
p[idx].y=nowJ;
}
for(int count=0;count<num && idx<=100000;count++,idx++){//right up
p[idx].x=nowI;
p[idx].y=--nowJ;
}
for(int count=0;count<num && idx<=100000;count++,idx++){//right
p[idx].x=++nowI;
p[idx].y=--nowJ;
}
for(int count=0;count<num && idx<=100000;count++,idx++){//right down
p[idx].x=++nowI;
p[idx].y=nowJ;
}
}
}
int main(int argc, char** argv) {
std::cin.sync_with_stdio(0);
std::cin.tie(0);
create();
int n;
while(cin>>n){
cout << p[n].x << " " << p[n].y << endl;
}
return 0;
}
//https://using-c.blogspot.com/2010/06/problem-10182-bee-maja.html