CF897C Nephren gives a riddle
思路:
递归。
比赛的时候脑抽了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的更多相关文章
- 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 ...
- 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> # ...
- 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 ...
- 寒假特训——搜索——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 ...
- 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 ...
- 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 ...
- Codeforces 897C Nephren gives a riddle:模拟【珂学】
题目链接:http://codeforces.com/contest/897/problem/C 题意: 给你一些字符串: A: [What are you doing at the end of t ...
- 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 ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
随机推荐
- maven bug之Maven:Non-resolvable parent POM: Failure to find错误
使用Maven编译淘宝的TimeTunnel项目时遇到如下错误: [INFO] Scanning for projects...[ERROR] The build could not read 1 p ...
- BSON结构
BSON结构 flyfish 2015-7-24 主要解释bsonspec.org站点上的两个样例 {"hello": "world"} hello为key. ...
- [Spring] Properties for project configuration
We might have some project specific configuration need to setup. The good approach to do this in Spr ...
- AE After Effect 渲染如何输出设置
各种输出设置值的对比情况. Microsoft Video1压缩方法情况(该模式下无法采用RGB+Alpha): 一 深度为"数千种颜色",缩放为1280×720(HDV/HDTV ...
- visio中怎样画线条或箭头
1.在"画图"工具栏上,单击"铅笔"工具 或"线条"工具 . (凝视 假设看不到"画图"工具栏,请单击" ...
- 安装Nginx须要系统的辅助软件(linux)
安装Nginx须要系统的辅助软件(linux): yum -y install make gcc gcc-c++ ncurses-devel yum -y install zlib zlib-deve ...
- boost::mpl::eval_if的使用方法
近期看boost的时候总是遇见这个eval_if,不知道啥意思,就没法看下去了,比方 前篇文章boost::serialization 拆分serialize函数分析时就出现这样一段代码: templ ...
- C++学习之构造函数中的异常处理
构造函数中可不可以抛出异常?当然可以.从语法上来说,是可以的:从实际情况来看,现在的软件系统日渐庞大和复杂,很难保证 Constructor 在执行过程中完全不发生一点异常. 那么,如果构造函数中抛出 ...
- Django打造大型企业官网(一)
一.nvm的安装 (1)下载:nvm1.16 (2)安装完成后添加环境变量 C:\Users\Administrator\AppData\Roaming\nvm (3)修改settings.txt,将 ...
- 百度编辑器拦截上传图片提交上传腾讯server并返回腾讯url
微信图文编辑时图片必须为上传到腾讯server的url,外连接所有屏蔽,则须要改动百度编辑器的源代码,源代码详细处理地方例如以下图.类为BinaryUploader.java InputStream ...