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 ...
随机推荐
- 华为,小米部分机型微信浏览器rem不适配的解决方案
针对近日华为,小米的部分机型,在升级系统或升级微信之后,微信内置浏览器产生的rem不能正确填充满的问题,有如下解决方案 目前来看,产生这个情况的原因是因为给html附font-size时,附上的fon ...
- kubernetes concepts (一)
Concepts The Concepts section helps you learn about the parts of the Kubernetes system and the abstr ...
- python 进程管道
数据不安全,不常用 import time from multiprocessing import Pipe, Process def producer(prod, cons, name, food) ...
- 10.JavaSE之包机制
包机制: 为了更好的组织类,Java提供了包机制,用于区别类名的命名空间 包语句的语法格式为: package pkg1[ . pkg2[ . pkg3...]]; package com.duan. ...
- Java入门 - 语言基础 - 02.开发环境配置
原文地址:http://www.work100.net/training/java-environment-setup.html 更多教程:光束云 - 免费课程 开发环境配置 序号 文内章节 视频 1 ...
- 关于Error executing aapt的问题
这两天装了ubuntu 14.0.4系统,在这个系统上装了eclipse的android开发环境.原以为一切顺利,结果开发环境装完导入工程后,工程提示有红叉. R文件不能自动生成,按R文件不能自动生成 ...
- 基于javaSwing的贪食蛇游戏
这个项目时,是我好几年前写的了.但对刚入门,或者想瞧瞧java的图形的界面swing的同学,还是有点用处的. 在这推荐给你. 涉及技术点 swing,多线程,文件读写,多媒体文件播放等 游戏简介 该游 ...
- NOI2.5 1817:城堡问题
描述 1 2 3 4 5 6 7 ############################# 1 # | # | # | | # #####---#####---#---#####---# 2 # # ...
- Dart语言学习(九) 运算符
一.运算符及其描述 二.Dart运算符注意点 1. 除法运算符"/" 和 整除运算法"~/" 的区别 除法运算符 "/" 结果是浮点型 整 ...
- djgango装饰器
from django.http import HttpResponse from django.views import View class MyView(View): def get(self, ...