URAL 1881 Long problem statement
1881. Long problem statement
Memory limit: 64 MB
he realized that there might be not enough paper to print the statements.
He also discovered that his text editor didn't have the feature of
calculating the number of pages in a text. Then Fedya decided to write a
program that would calculate the number of pages for any given text.
line. Any two neighboring words in a line were separated by exactly one
space. If there was no place for a word in a line, Fedya didn't hyphen it
but put the whole word at the beginning of the next line.
Input
number of lines on a page, the number of symbols in a line, and the number
of words in the problem statement, respectively (1 ≤ h, w ≤ 100; 1 ≤ n ≤ 10 000). The statement written by Fedya is
given in the following n lines, one word per line. The words are
nonempty and consist of uppercase and lowercase English letters and
punctuation marks (period, comma, exclamation mark, and question mark);
the length of each word is at most w. The total length of all the words
is at most 10 000.
Output
Sample
| input | output |
|---|---|
3 5 6 |
2 |
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
char s[];
int a,b,c,d,x=,e,f=;
scanf("%d%d%d%",&a,&b,&c);
gets(s);
f=strlen(s);
e=;
c--;
while(c--)
{
gets(s);
d=strlen(s);
if(f+d+>b)
{
e++;
f=d;
}
else
f+=(d+);
if(e>a)
{
e=;
x++;
}
}
printf("%d\n",x);
return ;
}
URAL 1881 Long problem statement的更多相关文章
- C#学习日志 day10 -------------- problem statement
Revision History Date Issue Description Author 15/May/2015 1.0 Finish most of the designed function. ...
- Problem Statement
题目链接:https://vjudge.net/contest/239445#problem/E E - Problem Statement You are given nn strings ...
- ural 1113,jeep problem
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1113 网上的解答铺天盖地.我硬是花了两天才懂了点. wiki上的解释:https://e ...
- URAL 1837. Isenbaev's Number (map + Dijkstra || BFS)
1837. Isenbaev's Number Time limit: 0.5 second Memory limit: 64 MB Vladislav Isenbaev is a two-time ...
- URAL 1137Bus Routes (dfs)
Z - Bus Routes Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Subm ...
- Google Code Jam 2010 Round 1A Problem A. Rotate
https://code.google.com/codejam/contest/544101/dashboard#s=p0 Problem In the exciting game of Jo ...
- Google Code Jam 2010 Round 1B Problem A. File Fix-it
https://code.google.com/codejam/contest/635101/dashboard#s=p0 Problem On Unix computers, data is s ...
- URAL 1137 Bus Routes(欧拉回路路径)
1137. Bus Routes Time limit: 1.0 secondMemory limit: 64 MB Several bus routes were in the city of Fi ...
- http://codeforces.com/problemset/problem/594/A
A. Warrior and Archer time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
随机推荐
- 转载-struts中logic标签使用
Struts中Logic逻辑标签的作用及用法 Struts中Logic逻辑标签的作用及用法 2006年10月18日 星期三 21:34 Terry原创,转载请说明作者及出处 Logic标签大部分的功能 ...
- Android Studio配置opencv
安装过程参考:http://www.cnblogs.com/tail/p/4618476.html demo参考:http://blog.csdn.net/gao_chun/article/detai ...
- 关于 poScreenCenter 与 poDesktopCenter
主要是窗体水平方向与垂直方向的的 居中问题,由于水平方向 没有什么,所以不探讨.而垂直方向由于底部有个工具栏,工具栏自身有个高度,所以垂直方向的居中问题,需要探讨下. 结论: poScreenCent ...
- P2184 【贪婪大陆】
看到全是线段树或者树状数组写法,就来提供一发全网唯一cdq分治三维偏序解法吧 容易发现,这个题的查询就是对于每个区间l,r,查询有多少个修改区间li,ri与l,r有交集 转化为数学语言,就是查询满足l ...
- javaweb笔记二
web服务器:实现服务器的开启,监听端口,接收客户端请求,产生响应.响应信息只能是静态的HTML,缺乏灵活性.web容器:是辅助应用的一种方式,是为了解决web服务器缺陷而产生的.可以将请求信息处理完 ...
- MySQL学习笔记:三种组内排序方法
由于MySQ没有提供像Oracle的dense_rank()或者row_number() over(partition by)等函数,来实现组内排序,想实现这个功能,还是得自己想想办法,最终通过创建行 ...
- OneNote无法同时设置中英文字体设置解决办法
如果你是一位OneNote老用户,无论是2003.2007还是2010或者最新的2013版本,都一直存在一个Bug,就是无法同时设置中英文字体(比如在Word中就可以分别设置不同的).我搜了一下,在微 ...
- Chrome-Adobe Flash 无法正常使用
https://support.google.com/chrome/answer/6258784 该网站因是是google.com,被强了,所以一般打不开. 故将google官方说明记录以下: 如果 ...
- JavaScript闭包与变量的经典问题
许多人第一次接触闭包大概都是从高程里这段代码开始的: function createFunctions() { var result = new Array(); for(var i=0; i< ...
- HBase(二)CentOS7.5搭建HBase1.2.6HA集群
一.安装前提 1.HBase 依赖于 HDFS 做底层的数据存储 2.HBase 依赖于 MapReduce 做数据计算 3.HBase 依赖于 ZooKeeper 做服务协调 4.HBase源码是j ...