下雪了

HelloWorld!

测试!

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<stack>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<list>
#include<map>
#define ffor(i, a, b) for(int i = a; i <= b; i++)
#define rfor(i, a, b) for(int i = a; i >= b; i--)
#define mes(a,b) memset(a, b, sizeof(a))
#define cos(x) cos(x*PI/180.0)
#define sin(x) sin(x*PI/180.0)
#define stop system("pause")
#define see(s,x) cout<<(s)<<'='<<(x)<<endl
#define IMAX 0x7fffffff
#define PI 3.141592654
#define INF 0x3f3f3f3f
#define eps 1e-6
#define lowbit(x) (x&(-x))
typedef long long ll;
const ll mod = (ll)1e9 + 7;
ll max(ll a, ll b) { return(a > b) ? a : b; }
ll min(ll a, ll b) { return(a < b) ? a : b; }
using namespace std;

struct Tab
{
	ll tab[3][3];
};
Tab x;
const char* s = "xCOFFEECHICKEN";

Tab xcal(Tab a, Tab b)
{
	Tab res;
	memset(res.tab, 0, sizeof(res.tab));
	for (int i = 1; i <= 2; i++)
		for (int k = 1; k <= 2; k++)
			for (int j = 1; j <= 2; j++)
			{
				res.tab[i][k] += a.tab[i][j] * b.tab[j][k];
				res.tab[i][k] %= mod;
			}
	return res;
}

Tab xfastpow(Tab a, int b)
{
	Tab res;
	mes(res.tab, 0);
	for (int i = 1; i <= 2; i++)
		res.tab[i][i] = 1;
	while (b)
	{
		if (b % 2)
			res = xcal(res, a);
		a = xcal(a, a);
		b /= 2;
	}
	return res;
}

ll getfib(int n)
{
	if (n == 1) return 6ll;
	Tab cache = xfastpow(x, n-2);
	return cache.tab[1][1] * 7ll + cache.tab[1][2] * 6ll;
}

void print(ll pos,ll num)
{
	ffor(i, pos, pos + num - 1)
	{
		if (s[i] == '\0')break;
		printf("%c", s[i]);
	}
}

void deal(int n, ll pos,ll num)
{
	if (n == 1)
	{
		print(pos, min(num,6-pos+1));
		return;
	}
	else if (n == 2)
	{
		print(pos + 6, num);
		return;
	}
	else if (n == 3)
	{
		print(pos, num);
		return;
	}
	else
	{
		pos = min(pos, (ll) 1e12);
		ll pr = getfib(n - 2);
		ll pr2 = getfib(n - 3);
		if (pos + num - 1 <= pr)//1
			deal(n - 2, pos, num);
		else if (pos > pr && pos + num - 1 <= pr+pr2)//2
			deal(n - 3, pos - pr, num);
		else if (pos > pr + pr2 && pos + num - 1 <= pr * 2 + pr2)//3
			deal(n - 2, pos - pr - pr2, num);
		else if (pos > pr + pr2 && pos + num - 1 > pr * 2 + pr2)//3撞墙
			deal(n - 2, pos - pr - pr2, pr * 2 + pr2 - pos + 1);
		else if (pos <= pr && pos + num - 1 <= pr + pr2 && pos + 10 > pr)//1+2
		{
			deal(n - 2, pos, pr - pos + 1);
			deal(n - 3, 1, num - (pr - pos + 1));
		}
		else if (pos > pr && pos <= pr + pr2 && pos + num - 1 > pr + pr2 && pos + num - 1 <= pr * 2 + pr2)//2+3
		{
			deal(n - 3, pos - pr, pr + pr2 - pos + 1);
			deal(n - 2, 1, 10 - (pr + pr2 - pos + 1));
		}
		else if (pos > pr && pos <= pr + pr2 && pos + num - 1 > pr + pr2 && pos + num - 1 > pr * 2 + pr2)//2+3撞墙
		{
			deal(n - 3, pos - pr, pr + pr2 - pos + 1);
			deal(n - 2, 1, pr);
		}
		else//1+2+3
		{
			deal(n - 2, pos, pr - pos + 1);
			deal(n - 3, 1, pr2);
			deal(n - 2, 1, pos + num - pr - pr2 - 1);
		}
	}
}

int main()
{
	
	x.tab[1][1] = 1;x.tab[1][2] = 1;
	x.tab[2][1] = 1;x.tab[2][2] = 0;
	int T;
	cin >> T;
	while (T--)
	{
		int n, pos;
		cin >> n >> pos;
		deal(n, pos, 10);
		puts("");
	}
}

测试测试!