1410. Crack
http://acm.timus.ru/problem.aspx?space=1&num=1410
题目倒是不难,水题DP
就是题意理解起来有点困难,意思就是给你一段话,提取里面的单词
单词有小写字母和大写字母(某些单词的首部)组成 其他字符均为间隔,
而且不止一行,提取单词后,从里面选一定的单词,这些单词在原段中
不能相邻,然后让提取后所有单词总长最大
代码:
#include<iostream>
#include<stack>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<cmath> using namespace std; typedef long long ll;
typedef pair<int,int> pp;
const int INF=0x3f3f3f3f;
const int N=10003;
int d1[N],d2[N];
int a[N];
char s[N*100];
int main()
{
//freopen("data.in","r",stdin); int ln=0;
char c;
while(scanf("%c",&c)!=EOF)
s[ln++]=c; int l=0;
while(s[l]==' '&&l<ln)++l; int n=0;
int k=0;
for(int i=l;i<=ln;++i)
{
if((s[i]<='z'&&s[i]>='a')||(s[i]<='Z'&&s[i]>='A'))
++k;
else
{
if(k>0)
a[n++]=k;
k=0;
}
if(i==ln) break;
}
memset(d1,0,sizeof(d1));
memset(d2,0,sizeof(d2));
d1[0]=a[0];d2[0]=0;
for(int i=1;i<=n-1;++i)
{
d1[i]=a[i]+d2[i-1];
d2[i]=max(d1[i-1],d2[i-1]);
} cout<<max(d1[n-1],d2[n-1]);
return 0;
}
1410. Crack的更多相关文章
- id0-rsa WP合集
忙里偷闲做做题wwwwwwwwwwwww Intro to Hashing Intro to PGP Hello PGP Hello OpenSSL Intro to RSA Caesar Hello ...
- reversing-Easy Crack
Easy Crack 程序启动后输入任意字符会显示一个MessageBox的Incorrect Password. 打开OllyDbg,载入程序后查找到目标字符串Incorrect Password, ...
- crack.vbs病毒,优盘里所有文件全变成快捷方式
去了一趟学校打印店,用优盘copy打印了点东西,当时在打印店电脑里打开优盘的时候里面就变成了快捷方式,但没怎么在意.回来之后在自己电脑上居然也这样了.网上一搜是中了crack.vbs病毒了.格式化优盘 ...
- MATLAB的crack安装小曲
MATLAB的crack安装小曲 本学期要学数学模型和数值分析,需要用MATLAB,便琢磨着装MATLAB.我同专业的同学会装MATLAB的crack,他是数学协会的理事长,平时爱吹牛,问他一个简单的 ...
- sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)
Crack Mathmen Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take securit ...
- poj 1410 线段相交判断
http://poj.org/problem?id=1410 Intersection Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- MITM to crack Https connections
Everybody knows that https is http over SSL, and https is a secure way for protecting confidential d ...
- URAL1410. Crack
1410 dp水题 题意读了好一会 是不能连续读两个及以上单词 #include <iostream> #include<cstdio> #include<cstring ...
- 线段和矩形相交 POJ 1410
// 线段和矩形相交 POJ 1410 // #include <bits/stdc++.h> #include <iostream> #include <cstdio& ...
随机推荐
- js_css_dl.dt实现列表展开、折叠效果
第一种方式:不提倡 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...
- MVC返回JSON数据格式书写方式
返回json数据格式,多个返回值加,隔开 [Route("api/users/web")] //如果不加这个路由请这样调用:/api/users/web?schoolname=十五 ...
- ExtJs Panel 滚动条设置
设置autoscroll:true同时出现横向和纵向滚动条. 不要设置autoscroll属性,或者autoscroll:false,然后设置bodyStyle : 'overflow-x:hidde ...
- SpringMVC集成AOP错误:java lang classnotfoundexception org aspectj lang joinpoint
记录自己出现的问题,Spring AOP 使用测试类测试没问题,在SpringMVC启动服务器时出现java lang classnotfoundexception org aspectj lang ...
- LeetCode----172. Factorial Trailing Zeroes(Java)
package singlenumber136; //Given an array of integers, every element appears twice except for one. F ...
- 如何通过iframe以post方式提交form表单
以前用过一次这种技术,这次用居然忘了,现纪录下来,下次再用就来看看. 首先在html中需要准备好form和iframe元素代码如下: <form id="speaker_form&qu ...
- (8) 深入理解Java Class文件格式(七)
转载:http://blog.csdn.net/zhangjg_blog/article/details/22091529 本专栏列前面的一系列博客, 对Class文件中的一部分数据项进行了介绍. 本 ...
- 【leetcode❤python】 400. Nth Digit
#-*- coding: UTF-8 -*- class Solution(object): def findNthDigit(self, n): ""&quo ...
- Oracle的使用
启动: 1.win+R ---> cmd -----> sqlplus "/as sysdba" //以sysdba身份登录(此时可以创建用户,分配权限等) win ...
- 【转载】C++中的位拷贝和值拷贝
---恢复内容开始--- 原文:C++中的位拷贝和值拷贝 原文:http://blog.csdn.net/liam1122/article/details/1966617 为了便于说明我们以Strin ...