思路:

递归。

比赛的时候脑抽了len[]没算够,wa了几次。

实现:

 #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const string s = "What are you doing at the end of the world? Are you busy? Will you save us?";
const string t = "What are you doing while sending \"";
const string v = "\"? Are you busy? Will you send \"";
const ll len_s = s.length();
const ll len_t = t.length();
const ll len_v = v.length();
ll len[];
char dfs(ll n, ll k)
{
if (n == )
{
if (k >= && k <= len_s) return s[k - ];
else return '.';
}
else if (n >= )
{
if (k <= len_t) return t[k - ];
return dfs(n - , k - len_t);
}
else
{
if (k <= len_t) return t[k - ];
else if (k > len_t && k <= len_t + len[n - ])
return dfs(n - , k - len_t);
else if (k > len_t + len[n - ] && k <= len_t + len[n - ] + len_v)
return v[k - len_t - len[n - ] - ];
else if (k > len_t + len[n - ] + len_v && k <= len_t + * len[n - ] + len_v)
return dfs(n - , k - len_t - len[n - ] - len_v);
else if (k == len_t + * len[n - ] + len_v + )
return '\"';
else if (k == len_t + * len[n - ] + len_v + )
return '?';
else return '.';
}
}
int main()
{
len[] = (ll)len_s;
for (int i = ; i <= ; i++)
{
len[i] = len[i - ] * + len_t + len_v + ;
}
ll q, n, k;
cin >> q;
while (q--)
{
cin >> n >> k;
cout << dfs(n, k);
}
return ;
}

CF897C Nephren gives a riddle的更多相关文章

  1. CodeForces - 896A Nephren gives a riddle

    A. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. CF&&CC百套计划1 Codeforces Round #449 A. Nephren gives a riddle

    http://codeforces.com/contest/896/problem/A 第i个字符串嵌套第i-1个字符串 求第n个字符串的第k个字母 dfs #include<map> # ...

  3. Codeforces Round #449 [ C/A. Nephren gives a riddle ] [ D/B. Ithea Plays With Chtholly ]

    PROBLEM C/A. Nephren gives a riddle 题 http://codeforces.com/contest/896/problem/A codeforces 896a 89 ...

  4. 寒假特训——搜索——H - Nephren gives a riddle

    What are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a gam ...

  5. A. Nephren gives a riddle

    What are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a gam ...

  6. Codeforces Round #449 (Div. 2)-897A.Scarborough Fair(字符替换水题) 897B.Chtholly's request(处理前一半) 897C.Nephren gives a riddle(递归)

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces 897C Nephren gives a riddle:模拟【珂学】

    题目链接:http://codeforces.com/contest/897/problem/C 题意: 给你一些字符串: A: [What are you doing at the end of t ...

  8. Codeforces 897 C.Nephren gives a riddle-递归

    C. Nephren gives a riddle   time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. Mybatis教程(一)

    1      Mybatis教程(一) 学习过的持久层框架:DBUtils , Hibernate Mybatis就是类似于hibernate的orm持久层框架. 为什么学Mybatis? 目前最主流 ...

  2. 冲刺Offer - 二叉树的深度

    https://www.nowcoder.net/practice/435fb86331474282a3499955f0a41e8b?tpId=13&tqId=11191&tPage= ...

  3. Cocos2d-x v3.1.1 创建以及编译项目

    1.安装python, 并将安装路径增加系统环境变量中; 2. 执行cocos2d-x根文件夹下的setup.py; 3. 进入cmd, 输入: cocos new 项目名称 -p 包名 -l 语言类 ...

  4. CentOS 7最小安装后,手动连接网络

    时间:2015-12-12 00:53来源:blog.51cto.com 作者:XD 举报 点击:3679次 CentOS中最小安装,由于默认的网卡没有激活,所以无法连接到网络. 设置如下: sucd ...

  5. web开发常见性能优化方式

    经常使用的高并发. 高性能web,数据库server.  1.html 静态化 : 如新闻频道更新的非常快,都是通过cms静态生成(门户,信息公布类型的站点,交互性高的如猫扑的大杂烩也是静态化,实时静 ...

  6. C# .NET 如何修改代码字体

    工具-选项-字体和颜色

  7. PHP导入和导出CSV文件

    CREATE TABLE `student` ( `id` ) NOT NULL auto_increment, `name` varchar() NOT NULL, `sex` varchar() ...

  8. B. Error Correct System (CF Round #296 (Div. 2))

    B. Error Correct System time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  9. Chrome插件(扩展)

    [干货]Chrome插件(扩展)开发全攻略   写在前面 我花了将近一个多月的时间断断续续写下这篇博文,并精心写下完整demo,写博客的辛苦大家懂的,所以转载务必保留出处.本文所有涉及到的大部分代码均 ...

  10. hdu 4864 Task(贪心)

    pid=4864">http://acm.hdu.edu.cn/showproblem.php?pid=4864 大致题意:有n台机器和m个任务,都有两个參数工作时间time和难度le ...