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 ...
随机推荐
- Batch梯度下降
1.之前讲到随机梯度下降法(SGD),如果每次将batch个样本输入给模型,并更新一次,那么就成了batch梯度下降了. 2.batch梯度下降显然能够提高算法效率,同时相对于一个样本,batch个样 ...
- 用canvas裁剪图片
var selectObj = null; function ImageCrop(canvasId, imageSource, x, y, width, height) { var canvas = ...
- A(光圈)S(快门) P(程序) M(手动)曝光模式
摄影笔记:http://mp.weixin.qq.com/s/SCzXybbCCE8VzfAQKTqlDw 曝光模式,指的就是M档(手动曝光).A档(Av档,光圈优先).S档(Tv档,快门优先),Au ...
- placeholder的兼容处理方法
placeholder是html5新增的一个属性,极大的减轻了表单提示功能的实现,但是对于IE6-IE9真的是只能靠自己写啦! 但是在自己写时会掉进了一个坑里,还好用了一会时间还是爬出来啦. 最终的解 ...
- 《移动Web前端高效开发实战》笔记3--代码检查任务
在项目的开发过程中,统一的代码风格对于项目的可协作性以及可维护性来说相当重要,因此可以采用一些插件来进行代码风格的检查. 本例中的源文件包含两类:Sass文件和采用ECMAScript 6规范的Jav ...
- Kendo DataSource 概述
Kendo DataSource 概述 Kendo 的数据源支持本地数据源( JavaScript 对象数组),或者远程数据源(XML, JSON, JSONP),支持 CRUD 操作(创建,读取,更 ...
- HttpServeletRequest
一.HttpServeletRequest 接口(javax.servlet.http) 定义:public interface HttpServletRequestextends ServletRe ...
- JavaScript笔记4-数组
一.概述: 1.数组是无类型的:同一数组的各元素可以是任意类型,也可以是数组或对象; 2.索引从0开始,最大到2^32-2=4294967294;最多容纳4294967295个元素; 3.数组是动态的 ...
- 常用浏览器User-Agent大全
=======================PC浏览器======================== OperaMozilla/5.0 (Windows NT 6.1; WOW64) AppleW ...
- Cordova for iOS
Cordova,对这个名字大家可能比较陌生,大家肯定听过 PhoneGap 这个名字,Cordova 就是 PhoneGap 被 Adobe 收购后所改的名字. Cordova 是一个可以让 JS 与 ...