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 ...
随机推荐
- Codeforces 479B. Towers 暴力
纯暴力..... B. Towers time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- FTP Server完整篇 ubuntu 10.04
1. sudo apt-get install vsftpd #安裝FTP Server(vsftp:very secure FTP) 安装后,会自动生成ftp用户,和ftp的文件夹,如果没有自动 ...
- 复制class文件到as中出现非法字符,须要class,interface货enum
问题如题,出现此情况是在导入eclipse项目到Android Studio出现这种错误, 非法字符: '\ufeff' 解决方式|错误: 须要class, interface或enum,查阅后了解到 ...
- lambda和委托那点事
Lambda 简介 Lambda 表达式是一种可用于创建委托或表达式目录树类型的一种匿名函数(匿名方法+Lambda).通过使用 lambda 表达式,可以写入可作为参数传递或作为函数 调用值返回的本 ...
- SEO 搜索引擎优化培训01
百度搜索风云榜:http://top.baidu.com/boards 页面上的因素:对搜索引擎而言
- union关键字及大小端模式
1. union 关键字 union 维护足够的空间来置放多个数据成员中的“一种”,而不是为每一个数据成员配置空间,在 union 中所有的数据成员共用一个空间,同一时间只能储存其中一个数据成员,所有 ...
- Flex 页面启动事件
事件启动顺序 容器Preinitialize=>子组件preinitialize=>子组件initialize=>childAdd=>initialize =>子组件cr ...
- HDU 1018 Big Number (log函数求数的位数)
Problem Description In many applications very large integers numbers are required. Some of these app ...
- HDU4267 树状数组 不连续区间修改(三维)
A Simple Problem with Integers Problem Description Let A1, A2, ... ...
- 函数计算 触发式计算 日志 MP3 图片 合成视频
函数计算 触发式计算 日志 MP3 图片 合成视频 [start_time]:20120511 06:59:11 [20120511 06:59:11_0.4950568322522534]: ...