Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <utility>
- using namespace std;
- int level(int n){
- return floor((-1+sqrt(n))/2)+1;
- }
- pair<int, int> coords(int n){
- int l = level(n);
- if (l == 0)
- return pair<int,int>(0,0);
- int dots_on_previous_levels = 4*l*(l-1) + 1;
- int cur = n - dots_on_previous_levels;
- if (cur <= l)
- return pair<int,int>(l,cur);
- else {
- cur -= l;
- if (cur<=2*l)
- return pair<int,int>(l-cur,l);
- else{
- cur -= 2*l;
- if (cur<=2*l)
- return pair<int,int>(-l,l-cur);
- else{
- cur-=2*l;
- if (cur<=2*l)
- return pair<int,int>(-l+cur,-l);
- else
- return pair<int,int>(l,-l+cur);
- }
- }
- }
- }
- int main(){
- int a, b, n;
- cin >> a >> b >> n;
- pair<int, int> p1, p2, p3;
- p1 = coords(a);
- p2 = coords(b);
- int x1,x2,y1,y2;
- x1 = p1.first; y1 = p1.second;
- x2 = p2.first; y2 = p2.second;
- while (n != -1){
- p3 = coords(n);
- int x, y;
- x = p3.first;
- y = p3.second;
- if (x*(y1-y2)+y*(x2-x1) == x2*y1-x1*y2)
- cout << "1 ";
- else
- cout << "0 ";
- cin >> n;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement