Yet Another Broken Keyboard[双指针]
题目大意:
求贡献,已知公式n*(n+1)/2,求总和
收获:
long long的转换技巧只能在乘或除上进行
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=2e5+; int main()
{
int n,k;cin>>n>>k;
set<char>st;string s,s1;
cin>>s;
char tmp;
for(int i=;i<k;++i) cin>>tmp,st.insert(tmp);
ll ans=;
for(int i=;i<s.size();++i){
int j=i;
while(j<s.size()&&st.count(s[j])) ++j;
ans+=1ll*(j-i)*(j-i+)/;
i=j;
}
cout<<ans<<endl;
return ;
}
Yet Another Broken Keyboard[双指针]的更多相关文章
- UVa 11998 Broken Keyboard (数组模拟链表问题)
题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int m ...
- UVa 11988 Broken Keyboard(链表->数组实现)
/*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end ...
- 1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- B - Broken Keyboard (a.k.a. Beiju Text)
Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well ...
- uva - Broken Keyboard (a.k.a. Beiju Text)(链表)
11988 - Broken Keyboard (a.k.a. Beiju Text) You’re typing a long text with a broken keyboard. Well i ...
- PAT1084:Broken Keyboard
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...
- PAT 1084 Broken Keyboard
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type ...
- A1084. Broken Keyboard
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- B - Broken Keyboard (a.k.a. Beiju Text) 数组模拟链表
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem wi ...
随机推荐
- 第二阶段冲刺个人任务——six
今日任务: 搭建网络服务器,上传数据库及程序. 昨日成果: 合并程序(统计团队博客).
- 阿里巴巴Jetcache springboot使用教程
原文地址:https://www.jianshu.com/p/03b289439de2 springboot中使用说明 jetcache原理参见:https://www.jianshu.com/p/8 ...
- Creating Form Elements --Using BeginForm and EndForm 使用内建的Form辅助器方法 精通ASP.NET MVC 5
Using the BeginForm and EndForm Helper Methods in the CreatePerson.cshtml File
- 使用Azure CLI创建Linux虚拟机
Azure提供了三种方式创建虚拟机,分别是Azure CLI.Azure PowerShell和Azure门户.本文介绍使用Azure CLI来创建Linux虚拟机. 使用Azure CLI创建Lin ...
- Spring5.x源码分析 | 从踩坑到放弃之环境搭建
Spring5.x源码分析--从踩坑到放弃之环境搭建 前言 自从Spring发行4.x后,很久没去好好看过Spring源码了,加上最近半年工作都是偏管理和参与设计为主,在技术细节上或多或少有点疏忽,最 ...
- AWS 入门使用
AWS官方参考文档:https://docs.aws.amazon.com/s3/index.html AWS基本介绍:https://docs.aws.amazon.com/zh_cn/Amazon ...
- Java虚拟机系列一:一文搞懂 JVM 架构和运行时数据区
前言 之前写博客一直比较随性,主题也很随意,就是想到什么写什么,对什么感兴趣就写什么.虽然写起来无拘无束,自在随意,但也带来了一些问题,每次写完一篇后就要去纠结下一篇到底写什么,看来选择太多也不是好事 ...
- gulp的简单打包示例(一)
引言 前端开发,打包工具是必不可少的,虽然有很多别人帮你封装好的打包工具,但自己配置一个,自身的实力也会大增呀.这篇博文主要讲的是使用gulp对html.js.less.css.图片的压缩合并等配置. ...
- 注册并加入dn42网络的方法
简介 https://dn42.net/howto/Getting-started 注册要求: 一个24小时运行的linux/BSD设备 该设备必须支持创建隧道,例如GRE,OpenVpn,IPSec ...
- BeetleX.AdminUI介绍
BeetleX.AdminUI是基于Beetlexjs+Vuejs+Bootstrap相结合的后台管理框架,主要介绍在不使用Webpack的情况下,如何用VS来开发一个单页面的Web后台管理应用.如果 ...