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 ...
随机推荐
- operamasks—omBorderLayout布局
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- MySQL JDBC URL参数(转)
MySQL的 JDBC URL格式: jdbc:mysql://[host][,failoverhost...][:port]/[database] » [?propertyName1][=prope ...
- USB2.0的最高传输速率
USB2.0除了拥有USB1.1中规定的1.5Mbps和12Mbps两个传输模式以外,还增加了480Mbps高速数据传输模式(注:第二版USB2.0的传输速率将达800Mbps,最高理想值1600Mb ...
- Java使用Memcached和Redis简单示例
package xmq.study.memcached; import java.io.IOException; import java.net.InetSocketAddress; import n ...
- 淘宝后台添加颜色尺码动态sku
废话不多说,直接上代码,用了vue,可直接copy运行 <!DOCTYPE html> <html lang="en"> <head> < ...
- 条款三:尽量用new和delete而不用malloc和free
malloc和free(及其变体)会产生问题的原因在于它们太简单:他们不知道构造函数和析构函数. 假设用两种方法给一个包含10个string对象的数组分配空间,一个用malloc,另一个用new: s ...
- Codeforces 479B. Towers 暴力
纯暴力..... B. Towers time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- xode5.1.1设置IOS欢迎界面的方法
先准备3张不同尺寸的欢迎图.文件名称分别为: Default.png iPhone 320X480分辨率屏幕默认启动图片. Default@2x.png iPhone 640X960分辨率屏幕默认启 ...
- 【跟我一步一步学Struts2】——登陆样例
本篇博客通过一个简单的登陆小样例来入门,简单了解一下struts2是怎样工作的: 第一步引入Jar包: commons-fileupload-1.2.1.jar,文件上传 commons-loggin ...
- poj 3621(最优比率环)
Sightseeing Cows Farmer John has decided to reward his cows for their hard work by taking them on a ...