1112 Stucked Keyboard
代码:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define GOOD 1
#define BAD 0
int main()
{
int k;
cin>>k;
string str;
cin>>str;
];
fill(Hash,Hash+,-);
;
while(i<str.size()){
int s=i;
char ch=str[i];
while(i<str.size() && str[i]==ch) i++;
int len=i-s;
&& Hash[ch]!=GOOD)//当前字符ch恰出现k的整数倍次,且确定不是好键,针对如"aabbbaaa" Hash[ch]=BAD;
else Hash[ch]=GOOD;
}
i=;
string oriStr;
while(i<str.size()){
oriStr+=str[i];
if(Hash[str[i]]!=GOOD) {
if(Hash[str[i]]==BAD){
cout<<str[i];
Hash[str[i]]=;//避免坏键重复输出
}
i+=k;
}else{
i++;
}
}
cout<<"\n"<<oriStr;
;
}
1112 Stucked Keyboard的更多相关文章
- PAT 1112 Stucked Keyboard
1112 Stucked Keyboard (20 分) On a broken keyboard, some of the keys are always stucked. So when yo ...
- 1112 Stucked Keyboard (20 分)
1112 Stucked Keyboard (20 分) On a broken keyboard, some of the keys are always stucked. So when you ...
- PAT 1112 Stucked Keyboard[比较]
1112 Stucked Keyboard(20 分) On a broken keyboard, some of the keys are always stucked. So when you t ...
- PAT甲级——1112 Stucked Keyboard (字符串+stl)
此文章同步发布在我的CSDN上:https://blog.csdn.net/weixin_44385565/article/details/90041078 1112 Stucked Keyboa ...
- PAT 甲级 1112 Stucked Keyboard
https://pintia.cn/problem-sets/994805342720868352/problems/994805357933608960 On a broken keyboard, ...
- PAT甲题题解-1112. Stucked Keyboard (20)-(map应用)
题意:给定一个k,键盘里有些键盘卡住了,按一次会打出k次,要求找出可能的坏键,按发现的顺序输出,并且输出正确的字符串顺序. map<char,int>用来标记一个键是否为坏键,一开始的时候 ...
- PAT (Advanced Level) 1112. Stucked Keyboard (20)
找出一定没问题的字符(即一连串的额字符x个数能被k整除的),剩下的字符都是可能有问题的. #include<cstdio> #include<cstring> #include ...
- 【PAT甲级】1112 Stucked Keyboard (20分)(字符串)
题意: 输入一个正整数K(1<K<=100),接着输入一行字符串由小写字母,数字和下划线组成.如果一个字符它每次出现必定连续出现K个,它可能是坏键,找到坏键按照它们出现的顺序输出(相同坏键 ...
- PAT甲级 1112 Stucked Keyboard
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805357933608960 这道题初次写的时候,思路也就是考虑 ...
随机推荐
- Red Hat OpenStack 10的新特性
这是Red Hat有史以来最好的版本,同时也是第一个长生命周期版本(最长五年支持),这篇文章会介绍为什么这是你私有云最好的礼物. 由于要使用命令行,以前安装OpenStack是很繁重的工作.这个版本提 ...
- Ajax-02 iframe实现伪“Ajax”
需求: 用户输入URL,使用iframe将目标URL的内容加载到页面指定位置(局部刷新) <!DOCTYPE html> <html lang="en"> ...
- ICE 中后台开发
1.https://alibaba.github.io/ice/#/block 2.https://www.zhihu.com/question/266529857/answer/309604282 ...
- 【nyoj-1274】信道安全(SPFA)
题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=1274 题目描述 Alpha 机构有自己的一套网络系统进行信息传送.情报员 A 位于 ...
- python基础之面向对象(二)
面向对象对程序设计OOD 找对象---->找类(归纳对象相同的特征与技能,还有没和对象独有的特征)面向对象编程OOP 先定义类---->实例化出对象查看成绩,交作业 在python3中,所 ...
- LeetCode OJ:Lowest Common Ancestor of a Binary Tree(最近公共祖先)
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...
- Puzzle Game HihoCoder - 1634
题目链接:https://cn.vjudge.net/problem/HihoCoder-1634 题目意思:可以让矩阵里的某一个数变成p,或者不修改.求最大子矩阵最小,输出最小值. 思路:请看下图 ...
- New Concept English three (36)
21 54 We are less credulous than we used to be. In the nineteenth century, a novelist would bring hi ...
- Leetcode 1019. Next Greater Node In Linked List
单调栈的应用. class Solution: def nextLargerNodes(self, head: ListNode) -> List[int]: stack = [] ret = ...
- canvas 创建颜色渐变柱状图
最终结果: 代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset=" ...