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 ...
随机推荐
- 如何使用vs2012单步调试uGUI(unity3d 5.3f4)
下载uGUI源代码 uGUI源代码地址:https://bitbucket.org/Unity-Technologies/ui 下载代码工具:tortoisehg-3.6.2-x64.msi http ...
- 安装mysql5.5的时候出现Error Nr.1045
解决办法: 1.删除注册表几个键值:HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL HKEY_L ...
- C# LINQ语句
1.select 和 selectMany SelectMany() 将中间数组序列串联为一个最终结果值,其中包含每个中间数组中的每个值 2.join语句 from x in xx join d in ...
- the server ssl certificate failed to verify
很久没上传项目之后,远程端断开联系 如果是git,就git clone,重新把项目拉下来. svn的话,就svn ls,拉下项目.
- hdu 4813(2013长春现场赛A题)
把一个字符串分成N个字符串 每个字符串长度为m Sample Input12 5 // n mklmbbileay Sample Outputklmbbileay # include <iost ...
- 开发 Material Design+RxJava+Retrofit+MVP App 参考资料
前言 在开发一个基于 Material Design+RxJava+Retrofit+MVP 框架的 App 过程中学习的资料整理 —— 由G军仔分享 这里记录了我开发 大象 项目时,所学习的 ...
- Kafka(五)Kafka的API操作和拦截器
一 kafka的API操作 1.1 环境准备 1)在eclipse中创建一个java工程 2)在工程的根目录创建一个lib文件夹 3)解压kafka安装包,将安装包libs目录下的jar包拷贝到工程的 ...
- scrapy 设置cookie池
代码已经很详细了,可以直接拿来使用了. 包含了: 从网页获取cookie 存入mongodb 定期删除cookie scrapy中间件对cookie池的取用 #!/usr/bin/python #co ...
- python使用cookie登陆网页
python2: Python 爬虫入门六之 Cookie 的使用 python3: Python3 网络爬虫 (六):Python3 使用 Cookie - 模拟登陆获取妹子联系方式 python ...
- ASP.NET MVC5+ 路由特性
概述 ASP.NET MVC 5支持一种新的路由协议,称为路由特性. MVC5也支持以前定义路由的方式,你可以在一个项目中混合使用这两种方式来定义路由. 案例 1.使用Visual Studio 20 ...