Language: C++

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <complex>
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef vector<vector<string> > vss;
typedef pair<int, int> pii;
#define INF 0x7fffffff
//#define INFLL 0x7fffffffffffffff
#define INFLL LLONG_MAX
#define SIZE(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
#define FOR(i,x) for(int i=0;i<x;i++)
#define FORic(i,y,x) for(int i=y;i<=x;i++)
#define FORdc(i,y,x) for(int i=y;i>=x;i--)
#define FILL(a,v) memset(a, v, sizeof(a))
#define PI 3.1415926535897932384

using namespace std;

const double EPS = 1e-7;
typedef complex<double> P; /* _ */
struct L { P p, q; L(P p, P q) : p(p), q(q) {} };
typedef vector<P> G;

// complexÉå¬ÖWªKvÈê
bool operator < (const P &a, const P &b) {
	return make_pair(real(a),imag(a)) < make_pair(real(b),imag(b));
}

// àÏEOÏEpx(xNga,bÌZ)
double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }
double angle(P a, P b) { return arg(conj(a)*b); }

// üªaÆüªbªð··é©ð»è·é(crossPolygonâdistPolygonPolygonÅgp)
bool intersSS(L a, L b){
	if(abs(imag((a.q-a.p)/(b.q-b.p)))<EPS) return false;
	return cross(a.q-a.p, b.p-a.p)*cross(a.q-a.p, b.q-a.p) < 0 &&
    	   cross(b.q-b.p, a.p-b.p)*cross(b.q-b.p, a.q-b.p) < 0;
}

// üªsÆ_pÌ£ðßé(distPolygonPointÅgp)
double distSP(L s, P p){
	if(dot(s.q-s.p,p-s.p)<-EPS) return abs(p-s.p);
	if(dot(s.p-s.q,p-s.q)<-EPS) return abs(p-s.q);
	return abs(cross(s.q-s.p,p-s.p))/abs(s.q-s.p);
}

// üªsÆüªtÌ£ðßé(distPolygonPolygonÅgp)
double distSS(L s, L t) {
  if (intersSS(s, t)) return 0;
  return min(min(distSP(s, t.p), distSP(s, t.q)),
             min(distSP(t, s.p), distSP(t, s.q)));
}

// ½p`gÌÊÏðßé
double polygonArea(G g){
	double res = 0.0;
	for(int i=0;i<g.size();i++)
		res += cross(g[i],g[(i+1)%g.size()]);
	return abs(0.5*res);
}

// _pªêÊ½p`gÌàÉ é©Ç¤©ð»è·é
bool contains(G g, P p){
	bool in = false;
	for(int i=0;i<g.size();i++){
		P a(g[i]-p), b(g[(i+1)%g.size()]-p);
		if(imag(a) > imag(b)) swap(a,b);
		if(imag(a)<=0&&0<imag(b))
			if(cross(a,b)<0) in = !in;
		if(abs(cross(a,b))<EPS&&dot(a,b)<EPS) return true; // üãÉpª¶Ý
	}
	return in;
}

// êÊ½p`gÆêÊ½p`hª½ÊãÅíÁÄ¢é©Ç¤©ð»è·éiÚµÄ¢Äàtruej
bool intersPolygon(G g, G h){
	int n = g.size();
	int m = h.size();
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			L l1 = L(g[i], g[(i+1)%n]);
			L l2 = L(h[j], h[(j+1)%m]);
			if(intersSS(l1,l2)) return true;
		}
	}
	for(int i=0;i<n;i++){
		if(contains(h, g[i])) return true;
	}
	for(int j=0;j<m;j++){
		if(contains(g, h[j])) return true;
	}
	return false;
}

// Ê½p`gðC2_p, qðÔüªÅØf·é
G convexCut(G g, P p, P q){
	G res;
	int n = g.size();
	for(int i=0;i<n;i++){
		P A(g[i]), B(g[(i+1)%n]);
		double p1 = cross(q-p,A-p);
		double p2 = cross(q-p,B-p);
		if(p1 > -EPS) res.push_back(A);
		if(p1*p2 < -EPS)
			res.push_back(A+cross(q-p,q-A)/cross(q-p,B-A)*(B-A));
	}
	return res;
}

// êÊ½p`gÆ_pÌ£ðÔ·
double distPolygonPoint(G g, P p){
	double ans = 1.0e100;
	int n = g.size();
	for(int i=0;i<g.size();i++){
		ans = min(distSP(L(g[i], g[(i+1)%n]), p), ans);
	}
	return ans;
}

// êÊ½p`gÆ_pÌ£ðÔ·
double distPolygonPolygon(G g, G h){
	double ans = 1.0e100;
	int n = g.size();
	int m = h.size();
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			L l1 = L(g[i], g[(i+1)%n]);
			L l2 = L(h[j], h[(j+1)%m]);
			ans = min(distSS(l1,l2), ans);
			if(ans==0) return 0;
		}
	}
	return ans;
}

// _ÌWðó¯æèCÊïðÔ·(¼üãÉ é_ÍEÁÄ¢È¢)
// EPSð-EPSÉÏ¦éÆ¼üãÉ é_àE¤çµ¢ªEEH
G convexHull(G ps){
	int n = ps.size();
	int k = 0;
	if(n<3) return ps;
	sort(ps.begin(), ps.end());
	G g(2*n);
	for(int i=0; i<n; g[k++] = ps[i++]){
		while(k>1 && cross((g[k-1]-g[k-2]),(ps[i]-g[k-1])) <= EPS) k--;
	}
	for(int i=n-2, t=k; i>=0; g[k++] = ps[i--]){
		while(k>t && cross((g[k-1]-g[k-2]),(ps[i]-g[k-1])) <= EPS) k--;
	}
	g.resize(k-1);
	return g;
}

int main(){
	int N, R, Q;
	while(cin>>N>>R>>Q){
		if(!N&&!R&&!Q) break;
		G all;
		FOR(i, N){
			int x, y;
			cin>>x>>y;
			all.push_back(P(x,y));
		}
		int start;
		P now;
		FOR(i,N){
			double dist = all[i].real()*all[i].real() + all[i].imag()*all[i].imag();
			if(dist+EPS>R*R){
				start = i;
				now = all[i];
			}
		}
		vector<double> dlist;
		FOR(i, Q){
			int tugi = start-1;
			if(tugi<0) tugi = N-1;
			P nagasa = all[start] - all[tugi];
			double d2 = nagasa.real()*nagasa.real() + nagasa.imag()*nagasa.imag();
			double d = sqrt(d2);
			dlist.push_back(d);
		}
		FOR(i, Q){
			double coss = (R*R*2-dlist[i]*dlist[i])/(2*R*R);
			double ang = acos(coss);
			P rot = P(cos(ang),sin(ang));
			P next = now*rot;
			cout<<next.real()<<" "<<next.imag()<<endl;
			now = next;
		}
	}
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<std::complex<double>*, std::vector<std::complex<double> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::complex<double>*, std::vector<std::complex<double> > >]':
/usr/include/c++/14/bits/stl_algo.h:1777:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<complex<double>*, vector<complex<double> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1777 |           if (__comp(__i, __first))
      |               ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<complex<double>*, vector<complex<double> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<complex<double>*, vector<complex<double> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4772:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<complex<double>*, vector<complex<double> > >]'
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:158:6:   required from here
  158 |         sort(ps.begin(), ps.end());
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'std::complex<double>' and 'std::complex<double>')
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1241 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1249 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const std::reverse_iterator<_Iterator>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const std::reverse_iterator<_Iterator>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const std::move_iterator<_IteratorL>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const std::move_iterator<_IteratorL>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const std::pair<_T1, _T2>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
  673 |     operator< (basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
  680 |     operator< (basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
  688 |     operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3874 |     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'std::complex<double>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3888 |     operator<(const ba