Problem:
Problem E: Legend of Storia
In Storia Kingdom, there is an artifact called "Perfect Sphere" made by a great meister Es. This is handed down for generations in the royal palace as a treasure. Es left a memo and filled mysterious values in it. Within achievements of researches, it has been revealed that the values denote coordinate values. However it is still unknown the definition of the coordinate system.
By the way, you are a person who lived in age of Es lived. The values which meister Es left are defined by following. Es set an moving object in the artifact sphere. Surprisingly, that is rigid body and perpetual organization. The object rotates inside the sphere and it is always touching the inside surface of the sphere. This value is a coordinate of the tangent point by the object and the sphere, but it is not a three dimensional value. The object is a plate and this is a simple polygon. Here, "simple" means "non self-intersected". This rotates while touching a great circle of the sphere. Here, assume that the great circle is a circle
O
centered in the origin in the xy plane. (It is two-dimensional Cartesian coordinate system, the direction of positive x-value is right and the direction of positive y-value is up). This plate touches the circle
O
with a single point at the beginning of the movement. And it rotates in counterclockwise as the current touching point is the rotation fulcrum. When another point
X
of the plate touches the circle
O
newly, the plate continue to rotate as described above, but in the next rotation, the rotation fulcrum point is changed.  This will be the point
X
. If two or more points can be interpreted as the point
X
, the point
X
is a most distant point from the currently touching point
X'
. Here, that distance is the length of the arc of the circle
O
from the point
X'
to the point
X
in clockwise.
Es asked you, an excellent assistant, to write a program that enumerates
Q
tangent points (fulcrum points while the movement) by the plate and the circle
O
while the movement of the plate described above in the chronological order. Of course, one and the previous one must be distinct points. Following figures show you examples of the movement of the plate inside the circle
O
.
1
2
3
4
Input
Input consists of multiple datasets.
A dataset is given in a following format.
N
R
Q
x
1
y
1
x
2
y
2
...
x
N
y
N
N
,
R
,
Q
are integers that represent the number of points of the plate, the radius of the circle, and the number of points Es needs respectively.
Following
N
lines contain 2
N
integers that represent coordinates of the plate's points (
x
k
,
y
k
) in the circle.(1≤
k
≤
N
)
You can assume following conditions.
Points of the plate are given in counterclockwise.
No three points are co-linear.
N
-1 points of the plate are given inside of the circle (distances between the center of the circle and these points are less than
R
). And 1 point is on the circle edge.
N
=
R
=
Q
=0 shows the end of input.
Constraints
The number of dataset
...(truncated)

Submitted solutions:

code_snippet: #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#define eps 1e-9
#define PI acos(-1.0)
#define M 100
using namespace std;

typedef struct N{
	double x,y;
	N(){;}
	N(double tx,double ty){
		x=tx; y=ty;
	}
}Node;

class Geometry{
	public:
		int cort(double x){
			if(fabs(x)<=eps) return 0;
			else if(x>eps) return 1;
			else return -1;
		}
		double dist(Node a,Node b){//两点距离 
			return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
		}
		double xmul(Node a,Node b,Node o){//(o,a),(o,b)叉积 
			return (a.x-o.x)*(b.y-o.y)-(b.x-o.x)*(a.y-o.y);
		}
		double pmul(Node a,Node b,Node o){//(o,a),(o,b)点积 
			return (a.x-o.x)*(b.x-o.x)+(a.y-o.y)*(b.y-o.y);
		}
		Node rotate(Node p,Node o,double alpha){//p绕o逆时针旋转alpha
			Node ans;
			p.x-=o.x; p.y-=o.y;
			ans.x=p.x*cos(alpha)-p.y*sin(alpha)+o.x;
			ans.y=p.y*cos(alpha)+p.x*sin(alpha)+o.y;
			return ans;
		}
		double angle(Node a,Node b,Node o){//(o,a),(o,b)夹角 
			double cf,fi,norm;
			cf=pmul(a,b,o)/(dist(a,o)*dist(b,o));
			
			if(cf>=1.0) return 0;
			else if(cf<=-1.0) return PI;
			else return acos(cf);
		}
};

Geometry method;
Node point[M+10];
double calu(Node s,Node t,double r){
	Node ori(0.0,0.0);
	double dis=method.dist(s,t),alpha=2*asin(dis/(2*r));
	Node cross=method.rotate(s,ori,-alpha);
	return method.angle(cross,t,s);
}
void solve(int &cur,int n,double r){
	int ct=(cur+1)%n;
	int nt=-1;
	double alpha;
	while(ct!=cur){
		if(nt==-1||method.cort(alpha-calu(point[cur],point[ct],r))>0){
			nt=ct;
			alpha=calu(point[cur],point[ct],r);
		}
		ct=(ct+1)%n;
	}
	for(int i=0;i<n;i++) point[i]=method.rotate(point[i],point[cur],alpha);
	cur=nt;
}

int main(){
	int n,q;
	double r;
	while(scanf("%d%lf%d",&n,&r,&q),n||r||q){
		for(int i=0;i<n;i++) scanf("%lf%lf",&point[i].x,&point[i].y);
		
		int cur;
		for(int i=0;i<n;i++)
			if(method.cort(method.dist(point[i],Node(0.0,0.0))-r)>=0)
				cur=i;
		
		while(q--){
			solve(cur,n,r);
			printf("%.12f %.12f\n",point[cur].x,point[cur].y);
		}
	}
	return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3360
final_rank: 8

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
int n, r, q, r2;
P p[30];
int cur;
D min_s[30], SIN[30], COS[30], x, y;
inline P rotate(const P &v, const D &s) {
  return P(real(v) * cos(s) - imag(v) * sin(s),
           real(v) * sin(s) + imag(v) * cos(s));
}
inline D arg(const P &a, const P &b, const P &c) {
  return real(conj(b - a) * (c - a)) / (abs(b - a) * abs(c - a));
}
inline D rot_seta(const int &end) {
  D seta = acos(1 - norm(p[end] - p[cur]) / r2);
  P nxt = rotate(p[cur], -seta);
  return arg(p[cur], p[end], nxt);
}
int main() {
  while (scanf("%d%d%d", &n, &r, &q), n) {
    r2 = 2 * r * r;
    rep(i, n) {
      scanf("%lf%lf", &x, &y);
      p[i] = P(x, y);
      if (abs(abs(p[i]) - r) < EPS)
        cur = i;
    }
    vector<int> nxt(n, -1);
    bool f = false;
    rep(i, q) {
      if (nxt[cur] >= 0)
        f = true;
      if (!f) {
        min_s[cur] = 5;
        rep(j, n) {
          if (cur == j)
            continue;
          D s = rot_seta(j);
          if (nxt[cur] < 0 || s > min_s[cur] + EPS)
            nxt[cur] = j, min_s[cur] = s;
        }
        min_s[cur] = acos(min_s[cur]);
        SIN[cur] = sin(min_s[cur]);
        COS[cur] = cos(min_s[cur]);
      }
      rep(j, n) {
        if (j == cur || (f && nxt[cur] < 0))
          continue;
        x = p[j].real() - p[cur].real();
        y = p[j].imag() - p[cur].imag();
        p[j] = P(x * COS[cur] - y * SIN[cur], x * SIN[cur] + y * COS[cur]) +
               p[cur];
      }
      printf("%.9lf %.9lf\n", p[nxt[cur]].real(), p[nxt[cur]].imag());
      if (!i) {
        int tmp = nxt[cur];
        nxt[cur] = -1;
        cur = tmp;
      } else {
        cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 30
memory_kb: 3540
final_rank: 11

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
int n, r, q, r2;
P p[30];
int cur;
D min_s[30], SIN[30], COS[30], x, y;
inline P rotate(const P &v, const D &s) {
  return P(real(v) * cos(s) - imag(v) * sin(s),
           real(v) * sin(s) + imag(v) * cos(s));
}
inline D arg(const P &a, const P &b, const P &c) {
  return real(conj(b - a) * (c - a)) / (abs(b - a) * abs(c - a));
}
inline D rot_seta(const int &end) {
  D seta = acos(1 - norm(p[end] - p[cur]) / r2);
  P nxt = rotate(p[cur], -seta);
  return arg(p[cur], p[end], nxt);
}
int main() {
  while (scanf("%d%d%d", &n, &r, &q), n) {
    r2 = 2 * r * r;
    rep(i, n) {
      scanf("%lf%lf", &x, &y);
      p[i] = P(x, y);
      if (abs(abs(p[i]) - r) < EPS)
        cur = i;
    }
    vector<int> nxt(n, -1);
    bool f = false;
    rep(i, q) {
      if (nxt[cur] >= 0)
        f = true;
      if (!f) {
        min_s[cur] = 5;
        rep(j, n) {
          if (cur == j)
            continue;
          D s = rot_seta(j);
          if (nxt[cur] < 0 || s > min_s[cur] + EPS)
            nxt[cur] = j, min_s[cur] = s;
        }
        min_s[cur] = acos(min_s[cur]);
        SIN[cur] = sin(min_s[cur]);
        COS[cur] = cos(min_s[cur]);
      }
      rep(j, n) {
        if ((f && nxt[j] < 0) || j == cur)
          continue;
        x = p[j].real() - p[cur].real();
        y = p[j].imag() - p[cur].imag();
        p[j] = P(x * COS[cur] - y * SIN[cur], x * SIN[cur] + y * COS[cur]) +
               p[cur];
      }
      printf("%.9lf %.9lf\n", p[nxt[cur]].real(), p[nxt[cur]].imag());
      if (!i) {
        int tmp = nxt[cur];
        nxt[cur] = -1;
        cur = tmp;
      } else {
        cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 30
memory_kb: 3508
final_rank: 9

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
const D PI = acos(-1);
int n, r, q, r2;
P p[30];
int cur;
D min_s[30], x, y;
inline D dot(const P &x, const P &y) { return real(conj(x) * y); }
inline P rotate(const P &v, const D &s) {
  return P(real(v) * cos(s) - imag(v) * sin(s),
           real(v) * sin(s) + imag(v) * cos(s));
}
inline D arg(const P &a, const P &b, const P &c) {
  return dot(b - a, c - a) / (abs(b - a) * abs(c - a));
}
inline D rot_seta(const int &end) {
  D seta = acos(1 - norm(p[end] - p[cur]) / r2);
  P nxt = rotate(p[cur], -seta);
  return arg(p[cur], p[end], nxt);
}
int main() {
  while (scanf("%d%d%d", &n, &r, &q), n) {
    r2 = 2 * r * r;
    rep(i, n) {
      scanf("%lf%lf", &x, &y);
      p[i] = P(x, y);
      if (abs(abs(p[i]) - r) < EPS)
        cur = i;
    }
    vector<int> nxt(n, -1);
    rep(i, q) {
      if (nxt[cur] < 0) {
        min_s[cur] = PI;
        rep(j, n) {
          if (cur == j)
            continue;
          D s = rot_seta(j);
          if (nxt[cur] < 0 || s > min_s[cur] + EPS)
            nxt[cur] = j, min_s[cur] = s;
        }
        min_s[cur] = acos(min_s[cur]);
      }
      rep(j, n) {
        if (j == cur)
          continue;
        p[j] = rotate(p[j] - p[cur], min_s[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n", p[nxt[cur]].real(), p[nxt[cur]].imag());
      if (i == 0) {
        int tmp = nxt[cur];
        nxt[cur] = -1;
        cur = tmp;
      } else {
        cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 40
memory_kb: 3584
final_rank: 12

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
int n, r, q, r2;
P p[30];
int cur;
D min_s[30], x, y;
inline D dot(const P &x, const P &y) { return real(conj(x) * y); }
inline P rotate(const P &v, const D &s) {
  return P(real(v) * cos(s) - imag(v) * sin(s),
           real(v) * sin(s) + imag(v) * cos(s));
}
inline D arg(const P &a, const P &b, const P &c) {
  return dot(b - a, c - a) / (abs(b - a) * abs(c - a));
}
inline D rot_seta(const int &end) {
  D seta = acos(1 - norm(p[end] - p[cur]) / r2);
  P nxt = rotate(p[cur], -seta);
  return arg(p[cur], p[end], nxt);
}
int main() {
  while (scanf("%d%d%d", &n, &r, &q), n) {
    r2 = 2 * r * r;
    rep(i, n) {
      scanf("%lf%lf", &x, &y);
      p[i] = P(x, y);
      if (abs(abs(p[i]) - r) < EPS)
        cur = i;
    }
    vector<int> nxt(n, -1);
    bool f = false;
    rep(i, q) {
      if (nxt[cur] >= 0)
        f = true;
      if (!f) {
        min_s[cur] = 5;
        rep(j, n) {
          if (cur == j)
            continue;
          D s = rot_seta(j);
          if (nxt[cur] < 0 || s > min_s[cur] + EPS)
            nxt[cur] = j, min_s[cur] = s;
        }
        min_s[cur] = acos(min_s[cur]);
      }
      rep(j, n) {
        if (j == cur || (f && nxt[cur] < 0))
          continue;
        p[j] = rotate(p[j] - p[cur], min_s[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n", p[nxt[cur]].real(), p[nxt[cur]].imag());
      if (i == 0) {
        int tmp = nxt[cur];
        nxt[cur] = -1;
        cur = tmp;
      } else {
        cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 50
memory_kb: 3504
final_rank: 10

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define EQ(a, b) (abs((a) - (b)) < EPS)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
const D PI = acos(-1);
int n, r, q;
P p[30];
int cur;
inline D dot(const P &x, const P &y) { return real(conj(x) * y); }
inline P rotate(const P &v, const D &s) {
  return P(real(v) * cos(s) - imag(v) * sin(s),
           real(v) * sin(s) + imag(v) * cos(s));
}
inline D arg(const P &a, const P &b, const P &c) {
  return acos(dot(b - a, c - a) / (abs(b - a) * abs(c - a)));
}
inline D rot_seta(const int &end) {
  D dis = abs(p[end] - p[cur]);
  D seta = acos((2 * r * r - dis * dis) / (2 * r * r));
  P nxt = rotate(p[cur], -seta);
  return arg(p[cur], p[end], nxt);
}
int main() {
  while (cin >> n >> r >> q, n) {
    rep(i, n) {
      D x, y;
      cin >> x >> y;
      p[i] = P(x, y);
      if (EQ(abs(p[i]), r))
        cur = i;
    }
    vector<int> nxt(n, -1);
    rep(i, q) {
      int id = -1;
      D min_s = PI;
      if (nxt[cur] >= 0)
        id = nxt[cur];
      else {
        rep(j, n) {
          if (cur == j)
            continue;
          D s = rot_seta(j);
          if (id < 0 || s + EPS < min_s)
            id = j, min_s = s;
        }
        nxt[cur] = id;
      }
      D seta = rot_seta(id);
      rep(i, n) {
        if (i == cur)
          continue;
        p[i] = rotate(p[i] - p[cur], seta) + p[cur];
      }
      cout << fixed << setprecision(10) << p[id].real() << " " << p[id].imag()
           << endl;
      cur = id;
    }
  }
}
accuracy: 1
time_ms: 70
memory_kb: 3592
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
const D PI = acos(-1);
int n, r, q, r2;
P p[30];
int cur;
inline D dot(const P &x, const P &y) { return real(conj(x) * y); }
inline P rotate(const P &v, const D &s) {
  return P(real(v) * cos(s) - imag(v) * sin(s),
           real(v) * sin(s) + imag(v) * cos(s));
}
inline D arg(const P &a, const P &b, const P &c) {
  return acos(dot(b - a, c - a) / (abs(b - a) * abs(c - a)));
}
inline D rot_seta(const int &end) {
  D dis = norm(p[end] - p[cur]);
  D seta = acos((r2 - dis) / (r2));
  P nxt = rotate(p[cur], -seta);
  return arg(p[cur], p[end], nxt);
}
int main() {
  while (scanf("%d%d%d", &n, &r, &q), n) {
    r2 = 2 * r * r;
    rep(i, n) {
      D x, y;
      scanf("%lf%lf", &x, &y);
      p[i] = P(x, y);
      if (abs(abs(p[i]) - r) < EPS)
        cur = i;
    }
    vector<int> nxt(n, -1);
    rep(i, q) {
      int id = -1;
      D min_s = PI;
      if (nxt[cur] >= 0)
        id = nxt[cur];
      else {
        rep(j, n) {
          if (cur == j)
            continue;
          D s = rot_seta(j);
          if (id < 0 || s + EPS < min_s)
            id = j, min_s = s;
        }
        nxt[cur] = id;
      }
      D seta = rot_seta(id);
      rep(i, n) {
        if (i == cur)
          continue;
        p[i] = rotate(p[i] - p[cur], seta) + p[cur];
      }
      printf("%.9lf %.9lf\n", p[id].real(), p[id].imag());
      cur = id;
    }
  }
}
accuracy: 1
time_ms: 50
memory_kb: 3588
final_rank: 13

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
int n, r, q, r2;
P p[30];
int cur;
D min_s[30], x, y;
inline D dot(const P &x, const P &y) { return real(conj(x) * y); }
inline P rotate(const P &v, const D &s) {
  return P(real(v) * cos(s) - imag(v) * sin(s),
           real(v) * sin(s) + imag(v) * cos(s));
}
inline D arg(const P &a, const P &b, const P &c) {
  return dot(b - a, c - a) / (abs(b - a) * abs(c - a));
}
inline D rot_seta(const int &end) {
  D seta = acos(1 - norm(p[end] - p[cur]) / r2);
  P nxt = rotate(p[cur], -seta);
  return arg(p[cur], p[end], nxt);
}
int main() {
  while (scanf("%d%d%d", &n, &r, &q), n) {
    r2 = 2 * r * r;
    rep(i, n) {
      scanf("%lf%lf", &x, &y);
      p[i] = P(x, y);
      if (abs(abs(p[i]) - r) < EPS)
        cur = i;
    }
    vector<int> nxt(n, -1);
    bool f = false;
    rep(i, q) {
      if (nxt[cur] >= 0)
        f = true;
      if (!f) {
        min_s[cur] = 5;
        rep(j, n) {
          if (cur == j)
            continue;
          D s = rot_seta(j);
          if (nxt[cur] < 0 || s > min_s[cur] + EPS)
            nxt[cur] = j, min_s[cur] = s;
        }
        min_s[cur] = acos(min_s[cur]);
      }
      rep(j, n) {
        if (j == cur || (f && nxt[cur] < 0))
          continue;
        p[j] = rotate(p[j] - p[cur], min_s[cur]) + p[cur];
      }
      printf("%.4lf %.4lf\n", p[nxt[cur]].real(), p[nxt[cur]].imag());
      if (i == 0) {
        int tmp = nxt[cur];
        nxt[cur] = -1;
        cur = tmp;
      } else {
        cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 40
memory_kb: 3604
final_rank: 14

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001



struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}


	/*void debug(){

		printf("(%.3lf,%.3lf)\n",x,y);
	}*/

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;


struct Circle{
	Point center;
	double r;
};

struct Line{
	Line(){

	}
	Line(Point a,Point b){
		p[0] = a;
		p[1] = b;
	}
	/*void outPut(){

		printf("(%.3lf,%.3lf)-(%.3lf,%.3lf)\n",p[0].x,p[0].y,p[1].x,p[1].y);
	}*/
	Point p[2];
};

int N,num_Q;
double R;
Circle C;
Point point[30],work[30];

double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}


double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}


double arg(Vector p){
	return atan2(p.y,p.x);
}

Vector polar(double a,double r){
	return Point(cos(r)*a,sin(r)*a);
}

//円と円の交点
vector<Point> getCrossPoints(Circle c1,Circle c2){

	vector<Point> res;

	double d = abs(c1.center-c2.center);
	double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
	double t = arg(c2.center-c1.center);

	res.push_back(Point(c1.center+polar(c1.r,t+a)));
	res.push_back(Point(c1.center+polar(c1.r,t-a)));

	return res;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

/*
 * p0を基準点として、p1から見てp2が
 * 反時計回り側にあれば
 * COUNTER_CLOCKWISE
 * */
int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}



//2つのvectorがなすラジアンを求める関数
double calc_rad(Vector vec1,Vector vec2){

	double tmp = dot(vec1,vec2)/(abs(vec1)*abs(vec2));

	if(fabs(tmp+1.0) < EPS){

		return M_PI;
	}

	if(fabs(tmp-1.0) < EPS){

		return  0.0;
	}

	return acos(dot(vec1,vec2)/(abs(vec1)*abs(vec2)));
}

//3点がなすラジアンを求める関数(ccw(base,a,b) == CCW)
double calc_rad(Point base,Point a,Point b){

	Vector vec1 = b-base;
	Vector vec2 = a-base;

	return calc_rad(vec1,vec2);
}

/*点moveをbaseを中心にradラジアン回転させる
rad > 0なら反時計回り、rad < 0なら時計周り
*/
Point rotate(Point base,Point move,double rad){

	Point ret;
	move = move-base;

	ret.x = move.x*cos(rad)-move.y*sin(rad);
	ret.y = move.x*sin(rad)+move.y*cos(rad);

	ret = ret+base;

	return ret;
}

void func(){

	C.r = R;

	vector<Point> ANS;

	int base = -1;

	for(int i = 0; i < N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
		double tmp_dist = calc_dist(C.center,point[i]);

		if(fabs(tmp_dist-R) < EPS){

			base = i;
		}
	}

	Circle TMP;

	for(int loop = 0; loop < num_Q; loop++){

		TMP.center = point[base];

		double mini = 3*M_PI;
		int next_base = -1;

		for(int i = 0; i < N; i++){
			if(i == base)continue;

			TMP.r = calc_dist(point[base],point[i]);

			vector<Point> vec = getCrossPoints(C,TMP);

			double tmp_rad;

			//★point[i] == vec[0]の場合に注意★
			if(calc_dist(point[i],vec[0]) > EPS && ccw(point[base],point[i],vec[0]) == COUNTER_CLOCKWISE){

				tmp_rad = calc_rad(point[base],point[i],vec[0]);

			}else{

				tmp_rad = calc_rad(point[base],point[i],vec[1]);
			}

			if(mini > tmp_rad+EPS){

				mini = tmp_rad;
				next_base = i;
			}
		}

		for(int i = 0; i < N; i++){
			if(i == base){

				work[i] = point[i];
			}else{

				work[i] = rotate(point[base],point[i],mini);
			}
		}

		base = next_base;

		printf("%.10lf %.10lf\n",work[base].x,work[base].y);
		for(int i = 0; i < N; i++){

			point[i] = work[i];
		}
	}
}


int main(){

	C.center = Point(0,0);

	while(true){

		scanf("%d %lf %d",&N,&R,&num_Q);
		if(N == 0)break;

		func();
	}

	return 0;
}
accuracy: 1
time_ms: 190
memory_kb: 3600
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001



struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}


	/*void debug(){

		printf("(%.3lf,%.3lf)\n",x,y);
	}*/

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;


struct Circle{
	Point center;
	double r;
};

struct Line{
	Line(){

	}
	Line(Point a,Point b){
		p[0] = a;
		p[1] = b;
	}
	/*void outPut(){

		printf("(%.3lf,%.3lf)-(%.3lf,%.3lf)\n",p[0].x,p[0].y,p[1].x,p[1].y);
	}*/
	Point p[2];
};

int N,num_Q;
double R;
Circle C;
Point point[30],work[30];

double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}


double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}


double arg(Vector p){
	return atan2(p.y,p.x);
}

Vector polar(double a,double r){
	return Point(cos(r)*a,sin(r)*a);
}

//円と円の交点
vector<Point> getCrossPoints(Circle c1,Circle c2){

	vector<Point> res;

	double d = abs(c1.center-c2.center);
	double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
	double t = arg(c2.center-c1.center);

	res.push_back(Point(c1.center+polar(c1.r,t+a)));
	res.push_back(Point(c1.center+polar(c1.r,t-a)));

	return res;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

/*
 * p0を基準点として、p1から見てp2が
 * 反時計回り側にあれば
 * COUNTER_CLOCKWISE
 * */
int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}



//2つのvectorがなすラジアンを求める関数
double calc_rad(Vector vec1,Vector vec2){

	double tmp = dot(vec1,vec2)/(abs(vec1)*abs(vec2));

	if(fabs(tmp+1.0) < EPS){

		return M_PI;
	}

	if(fabs(tmp-1.0) < EPS){

		return  0.0;
	}

	return acos(dot(vec1,vec2)/(abs(vec1)*abs(vec2)));
}

//3点がなすラジアンを求める関数(ccw(base,a,b) == CCW)
double calc_rad(Point base,Point a,Point b){

	Vector vec1 = b-base;
	Vector vec2 = a-base;

	return calc_rad(vec1,vec2);
}

/*点moveをbaseを中心にradラジアン回転させる
rad > 0なら反時計回り、rad < 0なら時計周り
*/
Point rotate(Point base,Point move,double rad){

	Point ret;
	move = move-base;

	ret.x = move.x*cos(rad)-move.y*sin(rad);
	ret.y = move.x*sin(rad)+move.y*cos(rad);

	ret = ret+base;

	return ret;
}

void func(){

	C.r = R;

	vector<Point> ANS;

	int base = -1;

	for(int i = 0; i < N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
		double tmp_dist = calc_dist(C.center,point[i]);

		if(fabs(tmp_dist-R) < EPS){

			base = i;
			//printf("最初の base:%d\n",base);
		}
	}

	Circle TMP;

	for(int loop = 0; loop < num_Q; loop++){

		TMP.center = point[base];
		//printf("\nloop:%d center:%.3lf %.3lf\n",loop,point[base].x,point[base].y);

		double mini = 3*M_PI;
		int next_base = -1;

		for(int i = 0; i < N; i++){
			if(i == base)continue;

			TMP.r = calc_dist(point[base],point[i]);

			vector<Point> vec = getCrossPoints(C,TMP);

			/*//printf("\n点:%d\n",i);
			//point[i].debug();
			printf("vec[0]:");
			vec[0].debug();
			printf("vec[1]:");
			vec[1].debug();*/

			double tmp_rad;

			if(calc_dist(point[i],vec[0]) > EPS && ccw(point[base],point[i],vec[0]) == COUNTER_CLOCKWISE){

				//printf("vec[0]を選んだ\n");
				tmp_rad = calc_rad(point[base],point[i],vec[0]);

			}else{
				//printf("vec[1]を選んだ\n");
				tmp_rad = calc_rad(point[base],point[i],vec[1]);
			}
			//printf("tmp_rad:%.3lf\n",tmp_rad);

			if(mini > tmp_rad+EPS){

				mini = tmp_rad;
				next_base = i;
			}
		}

		//printf("mini:%.3lf\n",mini);

		for(int i = 0; i < N; i++){
			if(i == base){

				work[i] = point[i];
			}else{

				work[i] = rotate(point[base],point[i],mini);
			}
		}

		//反時計回りで最も近い点
		/*for(int i = 1; i <= N-1; i++){

			int k = (base+i)%N;
			double tmp_dist = calc_dist(C.center,work[k]);

			//printf("k:%d tmp_dist:%.3lf\n",k,tmp_dist);

			if(fabs(tmp_dist-R) < EPS){

				base = k;
				break;
			}
		}*/

		base = next_base;

		printf("%.10lf %.10lf\n",work[base].x,work[base].y);
		for(int i = 0; i < N; i++){

			point[i] = work[i];
		}
	}
}


int main(){

	C.center = Point(0,0);

	while(true){

		scanf("%d %lf %d",&N,&R,&num_Q);
		if(N == 0)break;

		func();
	}

	return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 3640
final_rank: 19

code_snippet: #include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};

P unit(const P &a){
    return a/abs(a);
}
double getangle(P a, P b){
    return abs(arg(a/b));
}
VP crosspointCC(C a, C b){
    VP ret;
    double dist = abs(b.p-a.p);
    P dir = a.r*unit(b.p-a.p);
    double cos = (a.r*a.r +dist*dist -b.r*b.r)/(2*a.r*dist);
    double sin = sqrt(1 -cos*cos);
    ret.push_back(a.p +dir*P(cos, sin));
    ret.push_back(a.p +dir*P(cos, -sin));
    return ret;
}

int main(){
    while(1){
        int n,q;
        double r;
        cin >> n >> r >> q;
        if(n==0) break;

        VP p(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            p[i] = P(x, y);
        }
        int st=-1;
        for(int i=0; i<n; i++){
            if(EQ(abs(p[i]), r)){
                st = i;
                break;
            }
        }

        for(int i=0; i<q; i++){
            double minangle = INF;
            int minidx = -1;
            P center = p[st];
            for(int j=0; j<n; j++){
                if(j == st) continue;
                VP cp = crosspointCC(C(center, abs(p[j] -center)), C(P(0,0), r));
                double angle = getangle(cp[0] -center, p[j] -center);
                if(angle < minangle){
                    minangle = angle;
                    minidx = j;
                }
            }
            P rot = P(cos(minangle), sin(minangle));
            st = minidx;
            for(int j=0; j<n; j++){
                p[j] -= center;
                p[j] *= rot;
                p[j] += center;
            }
            cout << fixed << setprecision(10);
            cout << p[st].X << " " << p[st].Y << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 3676
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef double D;
typedef complex<D> P;
typedef vector<P>VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define EQ(n,m) (abs(n-m)<EPS)
D dot(P a,P b){return (conj(a)*b).X;}
D cross(P a,P b){return (conj(a)*b).Y;}
int ccw(P a,P b,P c){
  b-=a;c-=a;
  if(cross(b,c)>EPS)return 1;
  if(cross(b,c)< -EPS)return -1;
  if(dot(b,c)< -EPS)return 2;
  if(norm(b)<norm(c))return -2;
}
VP crosspointCC(P a, D ar, P b, D br) {
  VP ps;
  P ab=b-a;
  D d=abs(ab);
  D crL=(norm(ab)+ar*ar-br*br)/(2*d);
  if(EQ(d,0)||ar<abs(crL))return ps;
  P abN=ab*P(0,sqrt(ar*ar-crL*crL)/d);
  P cp=a+crL/d*ab;
  ps.push_back(cp + abN);
  if(!EQ(norm(abN),0)) ps.push_back(cp-abN);
  return ps;
}
namespace std {
  bool operator<(const P a,const P b) {
    return a.X!=b.X?a.X<b.X:a.Y<b.Y;
  }
}
VP convexHull(VP ps){
  int n=ps.size(),k=0;
  sort(ps.begin(),ps.end());
  VP ch(2*n);
  for(int i=0;i<n;ch[k++]=ps[i++])
    while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  for(int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])
    while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  ch.resize(k-1);
  return ch;
}

P rot(P p, double a,double x,double y){
  a=a*M_PI/180.0;
  P p1=P(x,y);
  p-=p1;
  return P(p.X*cos(a)+p.Y*(-sin(a))+x,p.X*sin(a)+p.Y*cos(a)+y);
}

int n,q;
D r;

int main(){
  //cout<<acos(cos(M_PI))/M_PI*180<<endl;
  while(cin>>n>>r>>q,n){
  VP v;
  r(i,n){
    double x,y;
    cin>>x>>y;
    v.push_back(P(x,y));
  }
  v=convexHull(v);
  int p;
  double t=1e9;
  double y,x;
  r(i,v.size()){
    if(v[i].Y<t){
      x=v[i].X;
      y=v[i].Y;
      t=v[i].Y;
      p=i;
    }
  }
  //for(int i=p,c=0;c<4;i=(i+1)%4,c++){
  //cout<<v[i].X<<' '<<v[i].Y<<endl;
  //}
  r(i,q){//cout<<p<<endl;
    int ppp=p;
    for(;;p=(p-1+v.size())%v.size()){//cout<<p<<endl;
      VP p1=crosspointCC( P(0,0) ,r , P(x,y) , abs(v[ppp]-v[(p-1+v.size())%v.size()]) );
      P pt;
      if(ccw(p1[0],P(x,y),P(0,0))==1)pt=p1[0];
      else pt=p1[1];
      // r(k,2){
      //cout<<pt.X<<' '<<pt.Y<<endl;
      //cout<<v[(p-1+v.size())%v.size()].X<<' '<<v[(p-1+v.size())%v.size()].Y<<endl;
      //}//cou
      D a=abs(v[ppp]-v[(p-1+v.size())%v.size()]);
      // D b=abs(v[p]-v[(p+1)%v.size()]);
      D c=abs(v[(p-1+v.size())%v.size()]-pt)*abs(v[(p-1+v.size())%v.size()]-pt);

      //cout<<sqrt(c)<<endl;
      //return 0;
      
      double radi=acos((a*a+a*a-c)/(2*a*a));

      // cout<<a<<endl;
      
      radi=radi/M_PI*180;
      //cout<<radi<<endl;
      
      VP vt=v;

      r(k,vt.size()){
	vt[k]=rot(vt[k],radi,x,y);
      }
      
      int flag=0;
      r(k,vt.size()){
	if(abs(vt[k]-P(0,0))-EPS>r)flag++;
      }
      if(flag)continue;
      v=vt;
      y=v[(p-1+v.size())%v.size()].Y;
      x=v[(p-1+v.size())%v.size()].X;
      printf("%.12f %.12f\n",x,y);
      p=(p-1+v.size())%v.size();
      break;
    }
  }
}
}
accuracy: 1
time_ms: 60
memory_kb: 3616
final_rank: 16

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps = 1e-7;


/* ??????????????¬ */

#include <complex>

typedef complex<ld> Point;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()


const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;

namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		if (lhs.real() < rhs.real() - eps) return true;
		if (lhs.real() > rhs.real() + eps) return false;
		return lhs.imag() < rhs.imag();
	}
}

// ????????\???
Point input_Point() {
	ld x, y;
	cin >> x >> y;
	return Point(x, y);
}

// ????????????????????????
bool eq(const ld a, const ld b) {
	return (abs(a - b) < eps);
}

// ??????
ld dot(const Point& a, const Point& b) {
	return real(conj(a) * b);
}

// ??????
ld cross(const Point& a, const Point& b) {
	return imag(conj(a) * b);
}

// ??´????????????
class Line {
public:
	Point a, b;
	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
	Point operator[](const int _num)const {
		if (_num == 0)return a;
		else if (_num == 1)return b;
		else {
			assert(false);
			return Point();
		}
	}
};

// ????????????
class Circle {
public:
	Point p;
	ld r;
	Circle() : p(Point(0, 0)), r(0) {}
	Circle(Point p, ld r) : p(p), r(r) {}
};

// ccw
// 1: a,b,c??????????¨???¨?????????????????¶
//-1: a,b,c???????¨???¨?????????????????¶
// 2: c,a,b???????????´???????????¶
//-2: a,b,c???????????´???????????¶
// 0: a,c,b???????????´???????????¶
int ccw(const Point& a, const Point &b, const Point &c) {
	const Point nb(b - a);
	const Point nc(c - a);
	if (cross(nb, nc) > eps) return 1;   // a,b,c??????????¨???¨?????????????????¶
	if (cross(nb, nc) < -eps) return -1; // a,b,c???????¨???¨?????????????????¶
	if (dot(nb, nc) < 0) return 2;       // c,a,b???????????´???????????¶
	if (norm(nb) < norm(nc)) return -2;  // a,b,c???????????´???????????¶
	return 0;                          // a,c,b???????????´???????????¶
}


/* ???????????? */

// ??´?????¨??´??????????????????
bool isis_ll(const Line& l, const Line& m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}

// ??´?????¨?????????????????????
bool isis_ls(const Line& l, const Line& s) {
	return isis_ll(l, s) &&
		(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

// ????????¨?????????????????????
bool isis_ss(const Line& s, const Line& t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

// ????????´????????????
bool isis_lp(const Line& l, const Point& p) {
	return (abs(cross(l.b - p, l.a - p)) < eps);
}

// ?????????????????????
bool isis_sp(const Line& s, const Point& p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}

// ??????????¶?
Point proj(const Line &l, const Point& p) {
	ld t = dot(p - l.a, l.b - l.a) / norm(l.a - l.b);
	return l.a + t * (l.b - l.a);
}

//???????±??????????????????????
Point reflect(const Line &l, const Point &p) {
	Point pr = proj(l, p);
	return pr * 2.l - p;
}

// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line& t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line& t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	if (cross(sv, tv) != 0)return vector<Point>(1, is_ll(s, t));
	else {
		vector<Point>ans;
		for (int k = 0; k < 2; ++k) {
			if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())ans.push_back(t[k]);
			if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())ans.push_back(s[k]);
		}
		return ans;
	}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line& t) {
	if (isis_ss(s, t)) {
		for (int k = 0; k < 2; ++k) {
			for (int l = 0; l < 2; ++l) {
				if (s[k] == t[l])return s[k];
			}
		}
		return is_ll(s, t);
	}
	else {
		//??????isis_ss?????????
		assert(false);
		return Point(0, 0);
	}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line& t) {
	vector<Point> kouho(is_ll2(s, t));
	vector<Point>ans;
	for (auto p : kouho) {
		if (isis_sp(s, p) && isis_sp(t, p))ans.emplace_back(p);
	}
	return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line& l, const Point& p) {
	return abs(p - proj(l, p));
}

//??´?????¨??´???????????¢
ld dist_ll(const Line& l, const Line& m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}

// ??´?????¨??????????????¢
ld dist_ls(const Line& l, const Line& s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}

// ????????¨???????????¢
ld dist_sp(const Line& s, const Point& p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

// ????????¨??????????????¢
ld dist_ss(const Line& s, const Line& t) {
	if (isis_ss(s, t)) return 0;
	return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}


//??´?????¨??´?????????????????????????????????
Line bisection(const Line &s, const Line &t) {
	const Point laglanju(is_ll(s, t));
	const Point avec = !(abs(laglanju - s[0])<eps) ? s[0] - laglanju : s[1] - laglanju;
	const Point bvec = !(abs(laglanju - t[0])<eps) ? t[0] - laglanju : t[1] - laglanju;

	return Line(laglanju, laglanju + (abs(bvec)*avec + abs(avec)*bvec) / (abs(avec) + abs(bvec)));
}


//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point  inner_center(const vector<Line>&ls) {
	vector<Point>vertics;
	for (int i = 0; i <static_cast<int>(ls.size()); ++i) {
		vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
	}
	if (vertics[0] == vertics[1] || vertics[1] == vertics[2] || vertics[2] == vertics[0])return vertics[0];
	Line bi1(bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
	Line bi2(bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
	if (bi1[0] == bi2[0])return bi1[0];
	else {
		return is_ll(bi1, bi2);
	}
}

//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point>  ex_center(const vector<Line>&ls) {
	vector<Point>vertics;
	for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
		vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
	}
	if (abs(vertics[0] - vertics[1])<eps || abs(vertics[1] - vertics[2])<eps || (abs(vertics[2] - vertics[0])<eps))return vector<Point>();
	vector<Point>ecs;
	for (int i = 0; i < 3; ++i) {
		Line bi1(bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[i], vertics[(i + 1) % 3])));
		Line bi2(bisection(Line(vertics[(i + 1) % 3], vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[(i + 1) % 3], vertics[i])));
		ecs.push_back(is_ll(bi1, bi2));
	}
	return ecs;
}


//a,b:??????
//c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point>  same_dis(const vector<Line>&ls) {
	vector<Point>vertics;
	vertics.push_back(is_ll(ls[0], ls[2]));
	vertics.push_back(is_ll(ls[1], ls[2]));

	if (abs(vertics[0] - vertics[1]) < eps)return vector<Point>{vertics[0]};
	Line bis(bisection(ls[0], ls[1]));
	vector<Point>ecs;

	Line abi(bisection(Line(vertics[0], vertics[1]), ls[0]));
	ecs.push_back(is_ll(bis, abi));


	Line bbi(bisection(Line(vertics[0], 2.l*vertics[0] - vertics[1]), ls[0]));
	ecs.push_back(is_ll(bis, bbi));

	return ecs;
}
/* ??? */

// ?????¨????????????
vector<Point> is_cc(const Circle& c1, const Circle& c2) {
	vector<Point> res;
	ld d = abs(c1.p - c2.p);
	ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
	ld dfr = c1.r * c1.r - rc * rc;
	if (abs(dfr) < eps) dfr = 0.0;
	else if (dfr < 0.0) return res; // no intersection
	ld rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff * Point(rc, rs));
	if (dfr != 0.0) res.push_back(c1.p + diff * Point(rc, -rs));
	return res;
}

//???????????????????????????
/*  0 => out
1 => on
2 => in*/
int is_in_Circle(const Circle &cir, const  Point& p) {
	ld dis = abs(cir.p - p);
	if (dis > cir.r + eps)return 0;
	else if (dis < cir.r - eps)return 2;
	else return 1;
}
//???lc??????rc??????????????????
/*0 => out
1 => on
2 => in*/
int Circle_in_Circle(const Circle &lc, const  Circle&rc) {
	ld dis = abs(lc.p - rc.p);
	if (dis < rc.r - lc.r - eps)return 2;
	else if (dis>rc.r - lc.r + eps)return 0;
	else return 1;
}

// ?????¨??´????????????
vector<Point> is_lc(const Circle& c, const Line& l) {
	vector<Point> res;
	ld d = dist_lp(l, c.p);
	if (d < c.r + eps) {
		ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); //safety;
		Point nor = (l.a - l.b) / abs(l.a - l.b);
		res.push_back(proj(l, c.p) + len * nor);
		res.push_back(proj(l, c.p) - len * nor);
	}
	return res;
}

// ?????¨??????????????¢
vector<Point> is_sc(const Circle& c, const Line& l) {
	vector<Point> v = is_lc(c, l), res;
	for (Point p : v)
		if (isis_sp(l, p)) res.push_back(p);
	return res;
}

// ?????¨????????\???
vector<Line> tangent_cp(const Circle& c, const Point& p) {
	vector<Line> ret;
	Point v = c.p - p;
	ld d = abs(v);
	ld l = sqrt(norm(v) - c.r * c.r);
	if (isnan(l)) { return ret; }
	Point v1 = v * Point(l / d, c.r / d);
	Point v2 = v * Point(l / d, -c.r / d);
	ret.push_back(Line(p, p + v1));
	if (l < eps) return ret;
	ret.push_back(Line(p, p + v2));
	return ret;
}

// ?????¨????????\???
vector<Line> tangent_cc(const Circle& c1, const Circle& c2) {
	vector<Line> ret;
	if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
		Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
		ret = tangent_cp(c1, center);
	}
	if (abs(c1.r - c2.r) > eps) {
		Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
		vector<Line> nret = tangent_cp(c1, out);
		ret.insert(ret.end(), all(nret));
	}
	else {
		Point v = c2.p - c1.p;
		v /= abs(v);
		Point q1 = c1.p + v * Point(0, 1) * c1.r;
		Point q2 = c1.p + v * Point(0, -1) * c1.r;
		ret.push_back(Line(q1, q1 + v));
		ret.push_back(Line(q2, q2 + v));
	}
	return ret;
}
//??????????????????????????¢???
ld two_Circle_area(const Circle&l, const Circle&r) {
	ld dis = abs(l.p - r.p);
	if (dis > l.r + r.r)return 0;
	else if (dis + r.r < l.r) {
		return r.r*r.r*pi;
	}
	else if (dis + l.r < r.r) {
		return l.r*l.r*pi;
	}
	else {
		ld ans = (l.r)*(l.r)*acos((dis*dis + l.r*l.r - r.r*r.r) / (2 * dis*l.r)) +
			(r.r)*(r.r)*acos((dis*dis + r.r*r.r - l.r*l.r) / (2 * dis*r.r)) -
			sqrt(4 * dis*dis*l.r*l.r - (dis*dis + l.r*l.r - r.r*r.r)*(dis*dis + l.r*l.r - r.r*r.r)) / 2;
		return ans;
	}

}

/* ????§???¢ */

typedef vector<Point> Polygon;

// ??¢???
ld area(const Polygon &p) {
	ld res = 0;
	int n = p.size();
	rep(j, n) res += cross(p[j], p[(j + 1) % n]);
	return res / 2;
}

//????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
	ld angle = 0;
	int n = poly.size();
	rep(i, n) {
		Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
		angle += arg((c - b) / (b - a));
	}
	return angle > eps;
}

// ??????????????????
/*0 => out
1 => on
2 => in*/
int is_in_Polygon(const Polygon &poly, const  Point& p) {
	ld angle = 0;
	int n = poly.size();
	rep(i, n) {
		Point a = poly[i], b = poly[(i + 1) % n];
		if (isis_sp(Line(a, b), p)) return 1;
		angle += arg((b - p) / (a - p));
	}
	return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { out, on, in };
int convex_contains(const Polygon &P, const Point &p) {
	const int n = P.size();
	Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
	int a = 0, b = n;
	while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
		int c = (a + b) / 2;
		if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
			if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0) b = c;
			else                                                  a = c;
		}
		else {
			if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0) a = c;
			else                                                  b = c;
		}
	}
	b %= n;
	if (cross(P[a] - p, P[b] - p) < 0) return 0;
	if (cross(P[a] - p, P[b] - p) > 0) return 2;
	return 1;
}

// ??????
//???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
	int n = ps.size();
	int k = 0;
	sort(ps.begin(), ps.end());
	Polygon ch(2 * n);
	for (int i = 0; i < n; ch[k++] = ps[i++])
		while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
		while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	ch.resize(k - 1);
	return ch;
}



//????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line& l) {
	int n = ps.size();
	Polygon q;
	Polygon r;
	rep(i, n) {
		Point a = ps[i], b = ps[(i + 1) % n];
		Line m = Line(a, b);
		if (ccw(l.a, l.b, a) != -1) q.push_back(a);
		if (ccw(l.a, l.b, a) != 1) r.push_back(a);
		if (ccw(l.a, l.b, a) * ccw(l.a, l.b, b) < 0 && isis_ll(l, m)) {
			q.push_back(is_ll(l, m));
			r.push_back(is_ll(l, m));
		}
	}
	const vector<Polygon>polys{ q,r };
	return polys;
}


/* ??¢??¬??????????????? */
void add_Point(vector<Point> &ps, const Point p) {
	for (Point q : ps) if (abs(q - p) < eps) return;
	ps.push_back(p);
}

typedef int Weight;
struct edge {
	int src, dst;
	Weight weight;
	edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};

typedef vector<edge> edges;
typedef vector<edges> graph;

void add_edge(graph &g, const int from, const int to, const Weight& weight) {
	g[from].push_back(edge{ from, to, weight });
}

graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
	int n = p.size(), m = s.size();
	graph g(n);
	rep(i, m) {
		vector<pair<ld, int>> vec;
		rep(j, n) if (isis_sp(s[i], p[j]))
			vec.emplace_back(abs(s[i].a - p[j]), j);
		sort(all(vec));
		rep(j, vec.size() - 1) {
			int from = vec[j].second, to = vec[j + 1].second;
			add_edge(g, from, to, static_cast<Weight>(abs(p[from] - p[to])));
		}
	}
	return g;
}
graph sennbunn_arrangement(const vector<Line>&s) {
	vector<Point>crss;
	for (int i = 0; i < static_cast<int>(s.size()); ++i) {
		for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
			if (isis_ss(s[i], s[j])) {
				crss.push_back(is_ll2(s[i], s[j])[0]);
			}
		}
	}
	for (int i = 0; i <static_cast<int>(s.size()); ++i) {
		crss.push_back(s[i][0]);
		crss.push_back(s[i][1]);
	}
sort(crss.begin(), crss.end());
crss.erase(unique(crss.begin(), crss.end()), crss.end());
	return segment_arrangement(s, crss);
}

graph Circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
	int n = p.size(), m = c.size();
	graph g(n);
	rep(i, m) {
		vector<pair<ld, int>> vec;
		rep(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
			vec.emplace_back(arg(c[i].p - p[j]), j);
		sort(all(vec));
		rep(j, vec.size() - 1) {
			int from = vec[j].second, to = vec[j + 1].second;
			ld angle = vec[j + 1].first - vec[j].first;
			add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
		}
		if (vec.size() >= 2) {
			int from = vec.back().second, to = vec.front().first;
			ld angle = vec.front().first - vec.back().first;
			add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
		}
	}
	return g;
} 

bool check(const int cen_id, const vector<Point>&poly,const Circle&c,const ld theta) {
	vector<Point> nextpoly(poly);
	for (auto& c : nextpoly) {
		c = poly[cen_id]+ (c - poly[cen_id])*Point(cos(theta), sin(theta));
	}
	for (int i = 0; i < nextpoly.size(); ++i) {
		if (abs(nextpoly[i])>c.r+eps/10) {
			return false;
		}
	}
	return true;
}

int main() {
	cout << fixed << setprecision(12);
	while (1) {
		int N, R, Q; cin >> N >> R >> Q;
		if (!N)break;
		Circle c(Point(0, 0), R);
		vector<Point>poly;
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y;
			poly.emplace_back(x, y);
		}
		Q++;
		vector<Point>anss;
		int from = -1;

		while (Q--) {
			int s = -1;
			ld dis = 0;
			for (int i = 0; i < N;++i) {
				Point p(poly[i]);
				ld aa = abs(abs(p) - R);
				if (abs(abs(p) - R)<eps&&from != i) {
					if (from != -1) {
						ld adis = abs(poly[from] - p);
						if (dis + eps < adis) {
							s = i;
							dis = adis;
						}
					}
					else {
						s = i;
					}
				}
			}
			Point center = poly[s];
			anss.emplace_back(center);
			

			ld amin = 0;
			ld amax = pi;

			int num =51;
			while (num--) {
				ld amid = (amin + amax) / 2;
				if (check(s, poly, c, amid)) {
					amin = amid;
				}
				else {
					amax = amid;
				}
			}


			vector<Point> nextpoly(poly);
			for (auto& c : nextpoly) {
				c = poly[s] + (c - poly[s])*Point(cos(amin), sin(amin));
			}
			poly = nextpoly;
			from = s;
		}
		for (int i = 1; i < anss.size(); ++i) {
			cout << anss[i].real() << " " << anss[i].imag() << endl;
		}

	}
	return 0;
}
accuracy: 1
time_ms: 1750
memory_kb: 3496
final_rank: 20

code_snippet: #include <string> 
#include <algorithm> 
#include <cfloat> 
#include <climits> 
#include <cmath> 
#include <complex> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <functional> 
#include <iostream> 
#include <map> 
#include <memory> 
#include <queue> 
#include <set> 
#include <sstream> 
#include <stack> 
#include <utility> 
#include <vector> 

#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define ALL(x) (x).begin(),(x).end() 
typedef long long ll;
using namespace std; 
const double eps = 1e-10;

typedef complex<double> P;
namespace std{
    bool operator<(const P &a, const P &b){
        if(a.real() == b.real()) return a.imag() < b.imag();
        else return a.real() < b.real();
    }
}
inline double dot(const P &a, const P &b){
    return real(conj(a) * b);
}
inline double cross(const P &a, const P &b){
    return imag(conj(a) * b);
}
int ccw(const P &a, P b, P c){
    b -= a; c -= a;
    if (cross(b, c) > eps)  return +1;  // ccw
    if (cross(b, c) < -eps) return -1;  // cw
    if (dot(b,c) < 0)       return +2;  // c-a-b
    if (norm(b) < norm(c))  return -2;  // a-b-c
    return 0;                           // a-c-b
}
struct Line : public vector<P> {
    Line() { }
    Line(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};
inline bool parallel(const Line &s, const Line &t){
    return abs(cross(s[1]-s[0], t[1]-t[0])) < eps;
}
inline bool orthogonal(const Line &s, const Line &t){
    return abs(dot(s[1]-s[0], t[1]-t[0])) < eps;
}
P projection(const Line &s, const P &a){
    P v = s[1] - s[0];
    return s[0] + dot(v, a - s[0]) / abs(v) / abs(v) * v;
}
P reflection(const Line &s, const P &a){
    P p = projection(s, a);
    return 2.0 * p - a;
}
struct Segment : public Line {
    Segment(const P &a, const P &b) : Line(a,b) { }
};
struct Circle{
    P o;
    double r;
    Circle() { }
    Circle(const P &o, double r) : o(o), r(r) { }
    Circle(double x, double y, double r) : o(x,y), r(r) { }
    inline bool contains(const P &p) const{
        return abs(p-o) < r + eps;
    }
    inline bool inside(const P &p) const{
        return abs(p-o) < r - eps;
    }
    pair<Line,Line> tangent(const P &p) const{
        vector<Line> res;
        double d = abs(p - o), s = r*r / d, t = sqrt(r*r-s*s);
        P q = o + s/d * (p - o), e = (p - o) * P(0, 1/d); 
        return make_pair(Line(p,q+e*t), Line(p,q-e*t));
    }
};
typedef vector<P> Polygon;
#define curr(p,i) p[i]
#define next(p,i) p[(i+1)%p.size()]

pair<P,P> crosspointCC(const Circle &a, const Circle &b){
    double d = abs(b.o - a.o);
    double x = (a.r * a.r - b.r * b.r + d * d) / (d * 2);
    P v = (b.o - a.o) * (1.0 / d);
    P n = P(0,1) * v;
    double h = sqrt(a.r * a.r - x * x);
    return make_pair(a.o + v * x + n * h,
                     a.o + v * x - n * h);
}

Polygon convex_hull(vector<P> &ps){
    int n = ps.size(), k = 0;
    sort(ALL(ps));
    vector<P> qs(n*2);
    for(int i = 0; i < n; qs[k++] = ps[i++])
        while(k > 1 && ccw(qs[k-2], qs[k-1], ps[i]) <= 0) --k;
    for(int i = n-2, t=k; i >= 0; qs[k++] = ps[i--])
        while(k>t && ccw(qs[k-2],qs[k-1], ps[i]) <= 0) --k;
    qs.resize(k-1);
    return qs;
}

P rotate(P &p, P &o, double theta){
    return o + (p - o) * polar(1.0, theta);
}

int N, R, Q;
void solve(Polygon &pol){
    Circle O(P(0,0), R);
    Polygon p = convex_hull(pol);
    N = p.size();

    int idx = 0;
    for(int i = 1; i < N; ++i) if(abs(p[i]) > abs(p[idx])) idx = i;
    // for(int i = 0; i < N; ++i) printf("(%.10f %.10f\n", p[i].real(), p[i].imag());
    for(int _ = 0; _ < Q; ++_){
        int nidx = idx;
        double ph = -1;
        for(int i = (idx + N-1) % N; i != idx; i = (i+N-1)%N){
            pair<P, P> pp = crosspointCC(Circle(p[idx], abs(p[i]-p[idx])), O);
            double t = dot(pp.first-p[idx], p[i]-p[idx]) / abs(p[i]-p[idx]) / abs(p[i]-p[idx]);
            // cout << "[" << pp.first.real() << "," << pp.second.imag() << "," << t << endl;
            if(t > ph-eps){ nidx = i; ph = t; }
        }
        for(int i = 0; i < N; ++i) p[i] = rotate(p[i], p[idx], acos(ph));
        // cout << ">" << nidx << endl;
        // cout << abs(p[nidx]) << endl;
        idx = nidx;
        printf("%.10f %.10f\n", p[idx].real(), p[idx].imag());
        // for(int i = 0; i < N; ++i) printf("(%.10f %.10f\n", p[i].real(), p[i].imag());
    }
}
int main(){
    for(;;){
        cin >> N >> R >> Q;
        if(N == 0) return 0;
        Polygon p;
        for(int i = 0; i < N; ++i){
            int x, y;
            cin >> x >> y;
            p.push_back(P(x,y));
        }
        solve(p);
    }
}
accuracy: 1
time_ms: 60
memory_kb: 1316
final_rank: 3

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}

D arg(P base, P a, P b) {return arg((b - base) / (a - base));}

int main() {
  while (true) {
    int n, q;
    D r;
    cin >> n >> r >> q;
    if (n == 0) break;
    Pol pol;
    rep (i, n) {
      D x, y;
      cin >> x >> y;
      pol.push_back(P(x, y));
    }
    int pre = -1;
    rep (_, q) {
      int k = -1;
      rep (i, n) if (i != pre && sig(abs(pol[i]), r) == 0) {
	k = i;
	break;
      }
      rep (i, n) if (i != k) {
	D theta = asin(abs(pol[k] - pol[i]) / 2 / r);
	P p = polar(r, arg(pol[k]) - theta * 2);
	theta = arg(pol[k], pol[i], p);
	Pol pol2;
	rep (j, n) pol2.push_back(pol[k] + (pol[j] - pol[k]) * polar((D)1, theta));
	rep (j, n) if (sig(abs(pol2[j]), r) > 0) goto next;
	printf("%.12Lf %.12Lf\n", p.X, p.Y);
	pol = pol2;
	pre = k;
	break;
      next:;
      }
    }
  }
}
accuracy: 1
time_ms: 510
memory_kb: 1292
final_rank: 7

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],SIN[30],COS[30],x,y;

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return real(conj(b-a)*(c-a))/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
	SIN[cur] = sin(min_s[cur]); COS[cur] = cos(min_s[cur]);
      }

      rep(j,n){
	if( (!f || nxt[j]>=0) && j!=cur){
	  x = p[j].real()-p[cur].real(); y = p[j].imag()-p[cur].imag();
	  p[j] = P(x*COS[cur] - y*SIN[cur] + p[cur].real(), x*SIN[cur] + y*COS[cur] + p[cur].imag());
	}
      }
      printf("%.9lf %.9lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(!i){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 40
memory_kb: 1336
final_rank: 1

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],SIN[30],COS[30],x,y;

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return real(conj(b-a)*(c-a))/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
	SIN[cur] = sin(min_s[cur]); COS[cur] = cos(min_s[cur]);
      }

      rep(j,n){
	if((f&&nxt[j]<0) || j==cur)continue;
	x = p[j].real()-p[cur].real(); y = p[j].imag()-p[cur].imag();
	p[j] = P(x*COS[cur] - y*SIN[cur], x*SIN[cur] + y*COS[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(!i){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 40
memory_kb: 1336
final_rank: 1

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],SIN[30],COS[30],x,y;

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return real(conj(b-a)*(c-a))/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
	SIN[cur] = sin(min_s[cur]); COS[cur] = cos(min_s[cur]);
      }

      rep(j,n){
	if(j==cur || (f&&nxt[cur]<0))continue;
	x = p[j].real()-p[cur].real(); y = p[j].imag()-p[cur].imag();
	p[j] = P(x*COS[cur] - y*SIN[cur], x*SIN[cur] + y*COS[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(!i){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 50
memory_kb: 1336
final_rank: 4

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],x,y;

inline D dot(const P &x, const P &y){return real(conj(x)*y);}

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return dot(b-a,c-a)/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
      }

      rep(j,n){
	if(j==cur || (f&&nxt[cur]<0))continue;
	p[j] = rotate(p[j]-p[cur],min_s[cur]) + p[cur];
      }
      printf("%.4lf %.4lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(i==0){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 60
memory_kb: 1336
final_rank: 6

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],x,y;

inline D dot(const P &x, const P &y){return real(conj(x)*y);}

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return dot(b-a,c-a)/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
      }

      rep(j,n){
	if(j==cur || (f&&nxt[cur]<0))continue;
	p[j] = rotate(p[j]-p[cur],min_s[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(i==0){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}
accuracy: 1
time_ms: 60
memory_kb: 1332
final_rank: 5