博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【编码】Font Size-微软实习笔试编程题(一)-2016.04.06
阅读量:7038 次
发布时间:2019-06-28

本文共 1783 字,大约阅读时间需要 5 分钟。

题目1 : Font Size

时间限制:10000ms

单点时限:1000ms
内存限制:256MB

描述

Steven loves reading book on his phone. The book he reads now consists of N paragraphs and the i-th paragraph contains ai characters.
Steven wants to make the characters easier to read, so he decides to increase the font size of characters. But the size of Steven's phone screen is limited. Its width is W and height is H. As a result, if the font size of characters is S then it can only show ⌊W / S⌋ characters in a line and ⌊H / S⌋ lines in a page. (⌊x⌋ is the largest integer no more than x)
So here's the question, if Steven wants to control the number of pages no more than P, what's the maximum font size he can set? Note that paragraphs must start in a new line and there is no empty line between paragraphs.
输入
Input may contain multiple test cases.
The first line is an integer TASKS, representing the number of test cases.
For each test case, the first line contains four integers N, P, W and H, as described above.
The second line contains N integers a1, a2, ... aN, indicating the number of characters in each paragraph.

For all test cases,

1 <= N <= 103,
1 <= W, H, ai <= 103,
1 <= P <= 106,
There is always a way to control the number of pages no more than P.
输出
For each testcase, output a line with an integer Ans, indicating the maximum font size Steven can set.
样例输入
2
1 10 4 3
10
2 10 4 3
10 10
样例输出
3
2

以下是我写的代码:

#include
#include
#include
using namespace std;int main(){ int ta;cin>>ta; for(int i=0;i
>n>>p>>w>>h; int *a=new int[n+1];//new for(int j=0;j
>a[j]; } a[n]='\0'; int s; int wh= w>h ? h:w; //cout<
<<"zuixiaode "<
p) s--; else break; } delete []b; delete []a; cout<
<

转载地址:http://kbfal.baihongyu.com/

你可能感兴趣的文章
Vue3 Proxy DEMO
查看>>
重磅 |“吴恩达deeplearningai”官方微信公众号已经上线!
查看>>
云数据库 Redis 版功能特性
查看>>
动手实现一个AMD模块加载器(二)
查看>>
vue中$attrs你会用吗?
查看>>
3.5 卷积神经网络进阶-Inception-mobile_net 实战
查看>>
生成固定长度不重复的随机字符串
查看>>
源码阅读:Masonry(一)——从使用入手
查看>>
如何使用ABAP Restful API进行代码的全文搜索
查看>>
Java学习笔记5-方法、流(Stream)、文件(File)和IO
查看>>
Linux_《Linux命令行与shell脚本编程大全》第九章学习总结
查看>>
把JavaScript代码改成ES6语法不完全指南
查看>>
关于""创建字符串和new String创建字符串
查看>>
代码之髓读后感——容器&并发
查看>>
【EASYDOM系列教程】之删除节点
查看>>
es6 箭头函数
查看>>
电商购物网站 - 数据库设计
查看>>
Weex iOS端集成Kingfisher实现下载图片的写法
查看>>
利用redis实现多属性快速查询
查看>>
同源策略与JS跨域(JSONP , CORS)
查看>>