Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss10182 - | Accepted | C++11 | 0.000 | 0.000 | 874 | 55 secs ago |
Suggest:
We need to find the rules of grid, i will speak as image:
We need to find the rules of grid, i will speak as image:
Image 1
Red: down
Green: down_left
Purple: up_left
Blue: up
Yellow: up_right
Pink: down_right
Image 2
Image 2
Yellow: cycle 1
Green: cycle 2
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
const int N= 1000111;
typedef pair<int, int> ii;
ii a[N];
ii down(ii p){ return ii(p.X, p.Y+1);}
ii down_left(ii p){ return ii(p.X-1, p.Y+1);}
ii up_left(ii p){ return ii(p.X-1, p.Y);}
ii up(ii p) { return ii(p.X, p.Y-1);}
ii up_right(ii p){ return ii(p.X+1, p.Y-1);}
ii down_right(ii p){ return ii(p.X+1, p.Y);}
int main() {
a[1]= ii(0, 0);
a[2]= ii(0, 1);
a[3]= ii(-1, 1);
a[4]= ii(-1, 0);
a[5]= ii(0,- 1);
a[6]= ii(1, -1);
a[7]= ii(1, 0);
int state=7, c=1;
while(state <= 100000){
int i= state;
for(i; i<=state+c; ++i) //7 8
a[i]= down(a[i-1]);
state= i;
for(i; i<=state+c-1; ++i) //7 8
a[i]= down_left(a[i-1]); //9
state= i; //10
for(i; i<=state+c; ++i) //10 11
a[i]= up_left(a[i-1]);
state= i; //12
for(i; i<=state+c; ++i) //12 13
a[i]= up(a[i-1]);
state= i; //14
for(i; i<=state+c; ++i) //14 15
a[i]= up_right(a[i-1]);
state= i; //16
for(i; i<=state+c; ++i) //16 17
a[i]= down_right(a[i-1]);
state= i; //18
c++;
}
ios::sync_with_stdio(0); cin.tie(0);
int n;
while(cin >> n){
cout<<a[n].X<<" "<<a[n].Y<<"\n";
}
}
No comments:
Post a Comment