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 ;
}

最新文章

  1. 如何通过JDBC访问数据库
  2. 发现一个国内牛逼的maven仓库,速度真的太快了
  3. Sublime Text3 常用快捷键
  4. Mac添加环境变量的三种方法
  5. access数据库密码破解
  6. VS连接远程数据库,连接sqlserver2008,显示“基础提供程序在 Open 上失败”
  7. UPDATE---修改表中数据
  8. STL中主要的算法(一)
  9. 域名动态解析到动态IP
  10. 分析easyswoole3.0源码,服务启动为例(一)
  11. jquery基础知识随笔
  12. SpringMVC+Spring+Mybatis+AngularJS 多规格保存示例代码
  13. The.Glory.of.Innovation 创新之路3放飞好奇
  14. React-Native 之 Navigator与NavigatorIOS使用
  15. idea缓存目录mac cache
  16. 标准库头文件 (CA2T)
  17. marquee 标签的鼠标放上去滚动效果 鼠标离开继续滚动
  18. 【转】javascript中值传递,地址传递,引用传递的问题(使用js创建list对象时会用到)
  19. nodejs Async详解之三:集合操作
  20. xshell评估过期解决办法

热门文章

  1. python进阶之函数和类内建魔法属性
  2. 那些代表性的HTTP状态码,你还只知道404吗?快来看看吧【转】
  3. idea中使用tomcat 方式启动spring boot项目
  4. 读书笔记 effective C++ Item 33 避免隐藏继承而来的名字
  5. Linux 多线程编程—使用条件变量实现循环打印
  6. Vue起步
  7. JAVA中分为基本数据类型和引用数据类型区别
  8. html-表格和列表
  9. 缓存数据库-redis(订阅发布)
  10. JavaScript之MV*模式