ACM-ICPC 2018 徐州赛区网络预赛 I. Characters with Hash
Mur loves hash algorithm, and he sometimes encrypt another one's name, and call him with that encrypted value. For instance, he calls Kimura KMR, and calls Suzuki YJSNPI. One day he read a book about SHA-256,which can transit a string into just 256 bits. Mur thought that is really cool, and he came up with a new algorithm to do the similar work. The algorithm works this way: first we choose a single letter L as the seed, and for the input(you can regard the input as a string ss, s[i]s[i] represents the iith character in the string) we calculates the value(|(int) L - s[i]|∣, and write down the number(keeping leading zero. The length of each answer equals to 22because the string only contains letters and numbers). Numbers writes from left to right, finally transfer all digits into a single integer(without leading zero(ss)).
For instance, if we choose 'z' as the seed, the string "oMl" becomes "11 45 14".
It's easy to find out that the algorithm cannot transfer any input string into the same length. Though in despair, Mur still wants to know the length of the answer the algorithm produces. Due to the silliness of Mur, he can even not figure out this, so you are assigned with the work to calculate the answer.
Input
First line a integer T , the number of test cases (T≤10).
For each test case:
First line contains a integer N and a character z, (N≤1000000).
Second line contains a string with length N . Problem makes sure that all characters referred in the problem are only letters.
Output
A single number which gives the answer.
样例输入复制
2
3 z
oMl
6 Y
YJSNPI
样例输出复制
6
10
题目来源
int t,n;
char c;
char s[];
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d %c",&n,&c);
scanf("%s",s);
int i;
int ans=;
for( i=;i<n;i++)
{
if(s[i]!=c){
break;
}
}
if(i==n) {
printf("1\n");
continue;//000前俩个都是前导0
}
ans=abs(c-s[i])>=?:;//前面的0都不算
ans+=*(n-i-);//后面的都一定是两位了
printf("%d\n",ans);
}
return ;
}
ACM-ICPC 2018 徐州赛区网络预赛 I. Characters with Hash的更多相关文章
- ACM-ICPC 2018 徐州赛区网络预赛 I Characters with Hash(模拟)
https://nanti.jisuanke.com/t/31461 题意 一个hash规则,每个字母映射成一个两位数,求给的字符串最后的编码位数,要求去除最终结果的前导零 分析 按题意模拟就是了 # ...
- ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心)
ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心) Trace 问答问题反馈 只看题面 35.78% 1000ms 262144K There's a beach in t ...
- ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer (最大生成树+LCA求节点距离)
ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer ...
- 计蒜客 1460.Ryuji doesn't want to study-树状数组 or 线段树 (ACM-ICPC 2018 徐州赛区网络预赛 H)
H.Ryuji doesn't want to study 27.34% 1000ms 262144K Ryuji is not a good student, and he doesn't wa ...
- ACM-ICPC 2018 徐州赛区网络预赛 B(dp || 博弈(未完成)
传送门 题面: In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl n ...
- ACM-ICPC 2018 徐州赛区网络预赛 B. BE, GE or NE
In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named &qu ...
- ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn't want to study
262144K Ryuji is not a good student, and he doesn't want to study. But there are n books he should ...
- ACM-ICPC 2018 徐州赛区网络预赛 F. Features Track
262144K Morgana is learning computer vision, and he likes cats, too. One day he wants to find the ...
- ACM-ICPC 2018 徐州赛区网络预赛 D 杜教筛 前缀和
链接 https://nanti.jisuanke.com/t/31456 参考题解 https://blog.csdn.net/ftx456789/article/details/82590044 ...
随机推荐
- selenum autoit上传图片
目前,一般实现文件图片上传的方式都是有一个按钮,点击之后直接调用操作系统自身的弹框,选择文件后,实现上传.因为Selenium不支持调用操作系统的操作,所以这种情况下,利用Selenium无法完成图片 ...
- Vue2之页面 、js 、css分离
在编写vue的时候,页面数据少的时候,可以将所有的js和css都可以直接写在页面上,但是页面数据多,js.css的方法和样式多的时候,都放在一个页面的时候,就显得页面vue十分的臃肿. 所以写项目的时 ...
- nuxt.js实战踩坑记录
读万卷书不如行万里路,必须实践出真理! 看官方文档安装项目vue init nuxt-community/starter-template <project-name>注意:这是新手项目不 ...
- vuex填坑记录
vuex是需要等待页面加载完成后才会更新的,如果页面点击刷新有用到vuex的地方,那么vuex会保持旧的数据,等刷新完成后vuex的数据才会重置,所以要在页面加载后再调用vuex的数据才是正确的,如果 ...
- springMVC数据校验与单文件上传
spring表单标签: <fr:from/> 渲染表单元素 <fr:input/>输入框组件 <fr:password/>密码框组件标签 & ...
- 基于JAVA的设计模式之组合模式
概念 将所有对象组合成一种树形结构,有分支节点.叶子节点,分支节点可以有自己的子节点,子节点可以是分支节点.叶子节点,可以进行增删的操作,而叶子节点不可以.比如文件夹就是一个分支节点,而文件就是一个叶 ...
- 十六进制和ASCII之间的转换
2.关于两个byte[]数组的合并: public static byte[] byteMerger(byte[] byte_1, byte[] byte_2) { byte[] byte_3 = n ...
- Servlet中的初始化参数、上下文参数、以及@Resource资源注入
配置初始化参数.上下文参数.以及使用@Resource注解进行资源注入,目的是为了降低代码的耦合度.当项目需求进行变更的时候,不需要反复更改源代码,只需更改web.xml文件即可. 一:Servlet ...
- Lucene-如何编写Lucene程序
Lucene版本:7.1 使用Lucene的关键点 创建文档(Document),添加文件(Field),保存了原始数据信息: 把文档加入IndexWriter: 使用QueryParser.pars ...
- HTTP1.0工作原理
1.HTTP工作原理 <HTTP响应报文与工作原理详解>讲的比较详细了. 2.示例 (1)server端程序如下: package org.yeyouluo.demo.jsp; impor ...