扎心题,当时想法完全正确,姿势不对(思维不够细腻)没过。
题意:给出四个字符串x,y,f0,z,并且给出递推公式:fi=x+fi-1+y+fi-1+z,对于每次询问,输入两个数n和k,表示fn的第k个字符。
思路:k表示第fn的第k个字符,既然fn是由递推公式得来,那么k同样可以通过由递推公式得到,那么我们就可以由已知的k,通过递推公式往回推n次,这样就会得到fn中第k个对应的字符在f1中的具体位置,返回输出就过了,用递归实现还是很好实现的,注意处理到n最大范围时的f[n]长度。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string f0 = "What are you doing at the end of the world? Are you busy? Will you save us?";
string x= "What are you doing while sending \"";
string y = "\"? Are you busy? Will you send \"";
string z = "\"?";
ll t,nn;
ll kk;
ll num[100001];
char solve(ll n,l