Ural1881(模拟)
来源:互联网 发布:达内软件测试怎么样 编辑:程序博客网 时间:2024/05/17 22:59
题目链接:点击打开链接
解题思路:
处理起来比较麻烦,把长度用数组存起来,然后按照长度去取,去完之后看能分多少行,最后在取页数即可。精彩点在分行那。
完整代码:
#include <algorithm>#include <iostream>#include <cstring>#include <climits>#include <cstdio>#include <string>#include <cmath>#include <map>#include <queue>using namespace std;typedef long long LL;const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const double EPS = 1e-9;const double PI = acos(-1.0); //M_PI;string s;const int maxn = 10001;int res[maxn];int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif int a , b , c; while(cin >> a >> b >> c) { for(int i = 0 ; i < c ; i ++) { cin >> s; int len = s.length(); res[i] = len; } int cnt = 0; for(int i = 0 ; i < c ; ) { int sum = res[i]; int j = i + 1; while(sum + 1 + res[j] <= b) { sum += 1 + res[j]; j ++; } i = j; cnt ++; } int k = cnt % a == 0 ? cnt / a : cnt / a + 1; cout << k << endl; }}
更多精彩请访问:点击打开链接
0 0
- Ural1881(模拟)
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟:
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- 模拟
- linux-gcc 编译时头文件和库文件搜索路径
- 转自Aufree的一篇 iOS 学习资料整理
- linux常用快捷键和常用命令
- MD5一致性校验
- String, StringBuffer, StringBuilder区别与联系
- Ural1881(模拟)
- iOS开发路线简述
- SQL 函数的用法
- 踏上编程大道,从 Python 开始成为神级 Coder 吧
- nodejs之app.use([path],function)
- 站点服务器的搭建的选择方式
- C#与Java的RSA
- 使用Oracle插入语法来插入多条记录
- 十天学会php