微软2016校园招聘4月在线笔试 A FontSize
题目链接:http://hihocoder.com/problemset/problem/1288
分析:题目中所求的是最大的FontSize(记为S),其应该满足P*[W/S]*[H/S] >= Sum,其中Sum是字符的总数。但是我们也要注意,段与段之间不能在同一行,所以根据上面公式求出来的S不一定满足条件,还要对其进行检验。下面是我的代码。
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std; int num[];
int N , P, W,H; bool check(int font,int N ,int p){ int page = , line = ; int lc = W/font;
int wc = H/font; for(int i = ; i < N ; i ++){
line += num[i]/lc;
if(num[i]%lc) line ++;
} page = line/wc;
if(line%wc) page ++; return (page<=p);
} int main()
{
int cas,lines;
scanf("%d",&cas);
while(cas --)
{
scanf("%d%d%d%d",&N,&P,&W,&H);
int sum = ; for(int i = ; i < N ; i ++){ scanf("%d",&num[i]);
sum += num[i];
} double cc = (double)/sum * P*W*H;
int font = sqrt(cc) + ; int lc = H/font ;
int wc = W/font ; while(P*lc*wc < sum || !check(font,N,P)){
font --;
lc = H/font ;
wc = W/font ;
}
printf("%d\n",font );
} return ;
}
微软2016校园招聘4月在线笔试 A FontSize的更多相关文章
- hihocoder 1288 : Font Size (微软2016校园招聘4月在线笔试)
hihocoder 1288 笔试第一道..wa了好几次,也是无语..hihocoder错了不会告诉你失败的时候的测试集,这样有时候就很烦.. 遍历所有的字体,从min(w,h)开始逐渐变小开始遍历. ...
- 微软2016校园招聘4月在线笔试 ABC
题目链接:http://hihocoder.com/contest/mstest2016april1/problems 第一题:输入N,P,W,H,代表有N段文字,每段有ai个字,每行有⌊W/S⌋个字 ...
- 微软2016校园招聘4月在线笔试 hihocoder 1289 403 Forbidden
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描写叙述 Little Hi runs a web server. Sometimes he has to deny acces ...
- [Hihocoder 1289] 403 Forbidden (微软2016校园招聘4月在线笔试)
传送门 #1289 : 403 Forbidden 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi runs a web server. Someti ...
- 微软2016校园招聘在线笔试-Professor Q's Software
题目2 : Professor Q's Software 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new softw ...
- 微软2016校园招聘在线笔试第二场 题目1 : Lucky Substrings
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A string s is LUCKY if and only if the number of different ch ...
- 微软2016校园招聘在线笔试 B Professor Q's Software [ 拓扑图dp ]
传送门 题目2 : Professor Q's Software 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new s ...
- 微软2016校园招聘在线笔试 [Recruitment]
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A company plans to recruit some new employees. There are N ca ...
- 题目3 : Spring Outing 微软2016校园招聘在线笔试第二场
题目3 : Spring Outing 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 You class are planning for a spring outin ...
随机推荐
- js中array的join和concat的区别
首先:concat方法定义:concat() 方法用于连接两个或多个数组.该方法不会改变现有的数组,而仅仅会返回被连接数组的一个副本.举例说明:1 /*concat()结果返回的是一个数组*/ 2 3 ...
- ASP.NET MVC4框架揭秘 源代码下载
http://files.cnblogs.com/artech/asp.net.mvc.4.samples.rar
- archlinux配置答疑
Q: chinese can not appear in my firefox and terminal rightly A: pacman -S wqy-microhei Q: install pi ...
- Nginx的安装配置 例子
1.下载 2.解压 3.运行 a.双击nginx.bat b.启动Nginx 会发现进程里面已经开始运行 4.配置 a.双击打开配置文件夹里面的nginx.conf b.修改 upstream tee ...
- 用CMake设置Visual Studio工程中预处理器定义值
构建VS工程时预处理值是不可缺少的,如动态库的导出配置等.在通过CMake构建VS工程时,可以通过CMake命令进行定义,下面讲三种应用. 字符集:默认装填下VS工程是多字节字符集,如果需要使用Uni ...
- etcdctl 命令介绍
通过不同的设置api 版本环境变量,支持的命令行不同. Interacting with etcd: https://coreos.com/etcd/docs/latest/dev-guide/in ...
- 读《JavaScript DOM编程艺术》
国庆假期花了三四天看了这本书,书很薄,因为是入门书,干货也不是很多. 4. childNodes nodeType nodeValue firstChild lastChild childNodes返 ...
- C# Mysql You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ????
有几年没用过MySql数据了,今天在使用C#访问MySql数据库时出现了一个小插曲. 错误提示: You have an error in your SQL syntax; check the man ...
- [vivado系列]Zynq开发常用文档
时间:2016.06.13 目的:阶段性总结学习的策略 ------------------------------------------------------------------------ ...
- vim中 set 用法设置
vi set用法from google search一.常用收集如下:(vi set)set autoindent 在插入模式下,对每行按与上行同样的标准进行缩进,与shiftwidth选项结 ...