XidianOJ 1154 Nhywieza 的串
题目描述
输入
输出
对于每组数据输出 1 行,表示最少的操作次数。
--正文
找到连续的0一起变就好
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std; char str[]; void Solve(char* str){
int len = strlen(str);
int flag = ,now = ,before = -;
int len0 = ;
while (now < len) {
if (str[now] == ''){
if (!flag) {
now ++;
continue;
}
if (before == ){
before = ; len0 ++;
}
before = ;
}
if (str[now] == ''){
flag = ;
if (before == ){
before = ;
}
before = ;
}
now ++;
}
if (str[len-] == ''){
len0 ++;
} printf("%d\n",len0);
} int main(){
while (scanf("%s",str) != EOF){
Solve(str);
}
return ;
}
XidianOJ 1154 Nhywieza 的串的更多相关文章
- 1154 回文串划分(DP+Manacher)
1154 回文串划分 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 有一个字符串S,求S最少可以被划分为多少个回文串. 例如:abbaabaa,有多种划分方式. ...
- 51nod 1154 回文串划分
1154 回文串划分 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 有一个字符串S,求S最少可以被划分为多少个回文串. 例如:abbaabaa,有 ...
- 51Nod - 1154 回文串划分(最少回文串dp)
回文串划分 有一个字符串S,求S最少可以被划分为多少个回文串. 例如:abbaabaa,有多种划分方式. a|bb|aabaa - 3 个回文串 a|bb|a|aba|a - 5 个回文串 a|b ...
- 51NOD 1154 回文串的划分(DP)
思路:参考了网上,思路很清奇,借助vis[i][j]来表示从i到j是否为回文串,回文串这边是用的双重循环来写的:dp[i]用来表示以i结尾的字符串最少的回文串有多长. #include<cstr ...
- 51nod 1154 dp
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1154 1154 回文串划分 基准时间限制:1 秒 空间限制:131072 ...
- NOIP2018提高组金牌训练营——字符串专题
NOIP2018提高组金牌训练营——字符串专题 1154 回文串划分 有一个字符串S,求S最少可以被划分为多少个回文串. 例如:abbaabaa,有多种划分方式. a|bb|aabaa - 3 个 ...
- 【51nod 1154】 回文串划分
有一个字符串S,求S最少可以被划分为多少个回文串. 例如:abbaabaa,有多种划分方式. a|bb|aabaa - 3 个回文串 a|bb|a|aba|a - 5 个回文串 a|b|b|a|a|b ...
- 1154 能量项链[区间dp]
1154 能量项链 2006年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 在Ma ...
- wikioi 1154 能量项链 (2006年NOIP全国联赛提高组)
题目描述 Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子 ...
随机推荐
- OAF_开发系列07_实现OAF下拉菜单的上下联动Poplist Synchor(案例)
20150706 Created By BaoXinjian
- Kafka深度解析,众人推荐,精彩好文!
作者: Jason Guo 背景介绍 Kafka简介 Kafka是一种分布式的,基于发布/订阅的消息系统.主要设计目标如下: 以时间复杂度为O(1)的方式提供消息持久化能力,并保证即使对TB级以上数据 ...
- LeetCode 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1] ...
- C#:String.Format数字格式化输出 {0:N2} {0:D2} {0:C2}等等
int a = 12345678; //格式为sring输出// Label1.Text = string.Format("asdfadsf{0}adsfasdf",a); / ...
- Creating a radius based VPN with support for Windows clients
This article discusses setting up up an integrated IPSec/L2TP VPN using Radius and integrating it wi ...
- mac-android-虚机加速
mac下进行android编程不可避免会碰到android虚拟机问题,macbook pro启动虚机时报错: Starting emulator for AVD 'NEW' emulator: ERR ...
- Socket网络编程-基础篇
Socket网络编程 网络通讯三要素: IP地址[主机名] 网络中设备的标识 本地回环地址:127.0.0.1 主机名:localhost 端口号 用于标识进程的逻辑地址 有效端口:0~65535 其 ...
- View & draw
When an iOS application is launched, it starts a run loop. The run loop’s job is to listen for event ...
- Struts2:效验器——声明式
就是用xml配置的方式,而不是Java代码的形式,那个是“编程式” Action: package org.ah.s2; import com.opensymphony.xwork2.ActionSu ...
- Objective-C之run loop详解[转]
做了一年多的IOS开发,对IOS和Objective-C深层次的了解还十分有限,大多还停留在会用API的级别,这是件挺可悲的事情.想学好一门语言还是需要深层次的了解它,这样才能在使用的时候得心应手,出 ...