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 ...
随机推荐
- Mycat集群方案收集(待实践)
先收集,后续再实践. 我想,市面上开源方案中,涉及到高可用和负载均衡的部署,无论是哪一个产品应用,都基本离不开LVS+Keepalived+HAProxy+Nginx等等. 下面是收集的教程: htt ...
- atom的react自动补全插件
atom-react-autocomplete–项目内,组件名及状态的自动补全 autocomplete-js-import–模块导入智能提示 emmet-jsx-css-modules– React ...
- paramiko错误信息:Paramiko error: size mismatch in put
在使用paramiko的put往远处服务器上传资源的时候,出现类似下面的错误信息 The code in paramiko's sftp_client.py:putfo() reads at the ...
- 使用RoboCopy 命令[转载]
经常进行文件管理操作的朋友们,不满意于Windows系统内置的复制功能,因为它太龟速了.于是大家就使用FastCopy.TeraCopy之类的软件来加速复制,但是你是否知道Windows 7已经内置快 ...
- Hadoop 执行过程中出现 name node is in safe mode 问题
解决方法: 1.进入hadoop安装根目录 如 :我的hadoop 安装在/usr/local/hadoop 执行 cd /usr/local/hadoop bin/hadoop dfsadmin - ...
- JSP自己定义标签入门实例具体解释
JSP自己定义标签主要能用到的两个包 javax.servlet.jsp.*;javax.servlet.jsp.tagext.*; 自己定义标签<userInfo:showUserInfo/& ...
- docker (1) ---简介,使用
一.docker简介: 容器( container-based )虚拟化方案,充分利用了操作系统本身已有的机 制和特性,以实现轻量级的虚拟化(每个虚拟机安装的不是完整的虚拟机), 甚至有人把他称为新一 ...
- 工作总结 default Console.WriteLine(default(Guid));
泛型代码中的默认关键字 在泛型类和泛型方法中产生的一个问题是,在预先未知以下情况时,如何将默认值分配给参数化类型 T: T 是引用类型还是值类型. 如果 T 为值类型,则它是数值还是结构. 给定参数化 ...
- hdu 4778 Gems Fight!
第一次写状压dp-- 题意:http://blog.csdn.net/dyx404514/article/details/15506601 状压dp+博弈吧-- #include<iostrea ...
- js 对有“命名空间”的表单做深度解析
问题描写叙述:一个大表单中,可能包括几十个字段.这些字段在数据库中的映射非常可能不在一张表中,为了降低后台操作的工作量,我们应该在前台提交的时候对数据做初步处理. 举例说明: watermark/2/ ...