当前位置:网站首页>洛谷每日三题之第四天
洛谷每日三题之第四天
2022-07-17 01:00:00 【小唐同学(๑><๑)】
P3741 honoka的键盘
题目背景
honoka 有一个只有两个键的键盘。
题目描述
一天,她打出了一个只有这两个字符的字符串。当这个字符串里含有
VK这个字符串的时候,honoka 就特别喜欢这个字符串。所以,她想改变至多一个字符(或者不做任何改变)来最大化这个字符串内VK出现的次数。给出原来的字符串,请计算她最多能使这个字符串内出现多少次VK(只有当V和K正好相邻时,我们认为出现了VK。)输入格式
第一行给出一个数字 nn,代表字符串的长度。
第二行给出一个字符串 ss。
输出格式
第一行输出一个整数代表所求答案。
输入输出样例
输入 #1复制
2 VK输出 #1复制
1输入 #2复制
2 VV输出 #2复制
1输入 #3复制
1 V输出 #3复制
0输入 #4复制
20 VKKKKKKKKKVVVVVVVVVK输出 #4复制
3输入 #5复制
4 KVKV输出 #5复制
1说明/提示
对于 100\%100% 的数据,1\le n\le 1001≤n≤100。
# include <cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
string s;
cin>>s;
int count=0;
int l=s.length();
int blp=-1;
//s[blp]='x';
//s[blp+1]='x';
while(s.find("VK",blp+1)!=-1)
{
count++;
blp=s.find("VK",blp+1);
s[blp]='T';
s[blp+1]='T';
}
// cout<<count<<endl;
// cout<<s;
for(int i=0;i<l-1;i++)
{
string w="KK";
string e="VV";
if(s.find(w)!=-1)
{
count++;
break;
}
if(s.find(e)!=-1)
{
count++;
break;
}
// if((s[i-1]=='V'&&s[i]=='V')||(s[i+1]=='K'&&s[i]=='K'))
// {
// count++;
// break;
// }
}
cout<<count;
}P1000 超级玛丽游戏
这道题是来凑数的(时间原因)
题目背景
本题是洛谷的试机题目,可以帮助了解洛谷的使用。
另外强烈推荐新用户必读贴
题目描述
超级玛丽是一个非常经典的游戏。请你用字符画的形式输出超级玛丽中的一个场景。
******** ************ ####....#. #..###.....##.... ###.......###### ### ### ........... #...# #...# ##*####### #.#.# #.#.# ####*******###### #.#.# #.#.# ...#***.****.*###.... #...# #...# ....**********##..... ### ### ....**** *****.... #### #### ###### ###### ############################################################## #...#......#.##...#......#.##...#......#.##------------------# ###########################################------------------# #..#....#....##..#....#....##..#....#....##################### ########################################## #----------# #.....#......##.....#......##.....#......# #----------# ########################################## #----------# #.#..#....#..##.#..#....#..##.#..#....#..# #----------# ########################################## ############输入格式
无
输出格式
如描述
输入输出样例
无
# include <stdio.h>
int main()
{
printf(
" ********\n"
" ************\n"
" ####....#.\n"
" #..###.....##....\n"
" ###.......###### ### ###\n"
" ........... #...# #...#\n"
" ##*####### #.#.# #.#.#\n"
" ####*******###### #.#.# #.#.#\n"
" ...#***.****.*###.... #...# #...#\n"
" ....**********##..... ### ###\n"
" ....**** *****....\n"
" #### ####\n"
" ###### ######\n"
"##############################################################\n"
"#...#......#.##...#......#.##...#......#.##------------------#\n"
"###########################################------------------#\n"
"#..#....#....##..#....#....##..#....#....#####################\n"
"########################################## #----------#\n"
"#.....#......##.....#......##.....#......# #----------#\n"
"########################################## #----------#\n"
"#.#..#....#..##.#..#....#..##.#..#....#..# #----------#\n"
"########################################## ############\n"
);
return 0;}
P1001 A+B Problem
这道题也是很久之前写的凑数的
题目背景
强烈推荐新用户必读帖。
不熟悉算法竞赛的选手请看这里:
算法竞赛中要求的输出格式中,不能有多余的内容,这也包括了“请输入整数 \bm aa 和 \bm bb” 这一类的提示用户输入信息的内容。若包含了这些内容,将会被认为是
Wrong Answer,即洛谷上的WA。在对比代码输出和标准输出时,系统将忽略每一行结尾的空格,以及最后一行之后多余的换行符。若因此类问题出现本机(看起来)
AC,提交WA的现象,请勿认为是洛谷评测机出了问题,而是你的代码中可能存在多余的输出信息。用户可以参考在题目末尾提供的代码。另外请善用应用中的在线 IDE 功能,以避免不同平台的评测中所产生的一些问题。
还有一点很重要的是,请不要在对应的题目讨论区中发布自己的题解,请发布到题解区域中,否则将处以删除或禁言的处罚。若发现无法提交题解则表明本题题解数量过多,仍不应发布讨论。
题目描述
输入两个整数 a, ba,b,输出它们的和(|a|,|b| \le {10}^9∣a∣,∣b∣≤109)。
注意
- Pascal 使用
integer会爆掉哦!- 有负数哦!
- C/C++ 的 main 函数必须是
int类型,而且 C 最后要return 0。这不仅对洛谷其他题目有效,而且也是 NOIP/CSP/NOI 比赛的要求!好吧,同志们,我们就从这一题开始,向着大牛的路进发。
任何一个伟大的思想,都有一个微不足道的开始。
输入格式
两个以空格分开的整数。
输出格式
一个整数。
输入输出样例
输入 #1复制
20 30输出 #1复制
50
# include <stdio.h>
int main()
{
long long a,b;
scanf("%lld",&a);
scanf("%lld",&b);
printf("%lld",a+b);
return 0;
}
边栏推荐
- Snapshot: data snapshot (data disclosure method)
- SQL classic exercises (x30)
- Thinking for half a year
- This is a mathematical problem
- Vscode+ros2 environment configuration
- Data source object management (third-party object resources) & load properties file
- 04_ Service registration Eureka
- While loop
- Specifications, multi table query basis
- It's good to take more exercise
猜你喜欢

Labelme starts normally, but cannot be opened

Leetcode: subsequence problem in dynamic programming

Latest installation tutorial of VMware Tools (rhel8)

leetcode:50. Pow(x, n)

Redis和其他数据库的比较

Yolov5 opencv DNN reasoning

代理模式——B站动力节点
![[MySQL] data query operation (select statement)](/img/22/9c20d80296622c4516f361654075d6.png)
[MySQL] data query operation (select statement)

Has DDD surpassed MVC

Graphql first acquaintance
随机推荐
Yolov5 ncnn reasoning
Solve the error of 0x00000709 when win10 connects to the shared printer
Theoretical basis of double Q-learning and its code implementation [pendulum-v0]
Leetcode: 0-1 knapsack problem in dynamic programming [come and set the template directly]
Visual analysis of ncnn param file and bin model
This is a mathematical problem
KubeCon + CloudNativeCon Europe 2022
zsh: command not found: mysql
Install Net prompt "cannot establish a certificate chain to trust the root authority" (simple method with download address)
It's good to take more exercise
支持工业级瘦设备4G接入,润和软件DAYU120通过OpenHarmony兼容性测评
2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)
RTX3090安装pytorch3D
Envi: (the most detailed tutorial in 2022) custom coordinate system
Backup kubernetes backup etcd data
Comparison between redis and other databases
ncnn DataReader&Extractor&blob
[single chip microcomputer simulation] (10) instruction system - multiplication instruction and division of arithmetic operation instruction
Yolov6 learning first chapter
By voting for the destruction of STI by Dao, seektiger is truly community driven