1881. Long problem statement

Time limit: 0.5 second
Memory limit: 64 MB
While Fedya was writing the statement of the problem GOV Chronicles,
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.
Fedya knew that there were h lines on each page and w symbols in each
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

The first line contains the integers h, w, and n, which are the
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

Output the number of pages in the problem statement.

Sample

input output
3 5 6
To
be
or
not
to
be
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的更多相关文章

  1. C#学习日志 day10 -------------- problem statement

    Revision History Date Issue Description Author 15/May/2015 1.0 Finish most of the designed function. ...

  2. Problem Statement

    题目链接:https://vjudge.net/contest/239445#problem/E     E - Problem Statement You are given nn strings ...

  3. ural 1113,jeep problem

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1113 网上的解答铺天盖地.我硬是花了两天才懂了点. wiki上的解释:https://e ...

  4. URAL 1837. Isenbaev&#39;s Number (map + Dijkstra || BFS)

    1837. Isenbaev's Number Time limit: 0.5 second Memory limit: 64 MB Vladislav Isenbaev is a two-time ...

  5. URAL 1137Bus Routes (dfs)

    Z - Bus Routes Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Subm ...

  6. 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 ...

  7. 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 ...

  8. URAL 1137 Bus Routes(欧拉回路路径)

    1137. Bus Routes Time limit: 1.0 secondMemory limit: 64 MB Several bus routes were in the city of Fi ...

  9. 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 ...

随机推荐

  1. from setuptools import setup ImportError: No module named setuptools【转】

    转自:http://www.cnblogs.com/chinacloud/archive/2010/12/24/1915644.html from setuptools import setupImp ...

  2. 从此编写 Bash 脚本不再难【转】

    从此编写 Bash 脚本不再难 原创 Linux技术 2017-05-02 14:30 在这篇文章中,我们会介绍如何通过使用 bash-support vim 插件将 Vim 编辑器安装和配置 为一个 ...

  3. setInterval做定时器

    <script src="/js/jquery-1.8.3.min.js"></script> <script> $(function () { ...

  4. java基础29 迭代器 listIterator() 及各种遍历集合的方法

    listIterator() 迭代器包含了 Iterator() 迭代器中的所有方法. 1.ListIterator的常用方法 hasPrevious() :判断是否还有上一个元素,有则返回true  ...

  5. luoguP2735 电网 Electric Fences

    一道校内模拟赛遇见的题 ** 不会正解就真的很麻烦的 数学题 ** 有一种东西叫 皮克定理 发现的千古神犇: 姓名:George Alexander Pick(所以叫皮克定理呀 国籍:奥地利(蛤!竟然 ...

  6. malloc和free的实现

     C++ Code  12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...

  7. Unix IPC之读写锁

    linux中读写锁的rwlock介绍 读写锁比mutex有更高的适用性,可以多个线程同时占用读模式的读写锁,但是只能一个线程占用写模式的读写锁: 1,当读写锁是写加锁状态时, 在这个锁被解锁之前, 所 ...

  8. 根据条件批量删除document

    curl -H "Content-Type:application/json"  -XPOST http://localhost:9200/devopsrealinfo/_dele ...

  9. MySQL慢查询优化

    MySQL数据库是常见的两个瓶颈是CPU和I/O的瓶颈,CPU在饱和的时候一般发生在大量数据进行比对或聚合时.磁盘I/O瓶颈发生在装入数据远大于内存容量的时候,如果应用分布在网络上,那么查询量相当大的 ...

  10. day7 socket网络编程

    Python Socket网络编程 Socket是进程间通信的一种方式,它与其他进程间通信的一个主要不同是:它能实现不同主机间的进程间通信,我们网络上各种各样的服务大多都是基于Socket来完成通信的 ...