微软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 ...
随机推荐
- 用SQL语句获得一个存储过程返回的表
1. 定义一个表变量 declare @table table(ReportType nvarchar(30),ReportPath nvarchar(200),ParaCnt int,DataAre ...
- 关于Delphi中多线程传递参数的简单问题
http://bbs.csdn.net/topics/390513469/ unit uThread; interface uses Classes; type Th = class(TThread) ...
- oracle contains
1. 查询住址在北京的学生SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, 'beijing' )remark: ...
- php-fpm 在centos 7下的安装配置
安装php: sudo yum install php php-fpm php-mysql php-mbstring php-mcrypt php-sockets php-curl php-commo ...
- 通过java反射,封装bean
上周有一个封装javabean的流程,成员变量有好多,一路写if(!=null){setXXX} 真的好麻烦,有时候一不小心还会漏掉,很是麻烦,就想到用反射的方法自动进行拼装bean. bean pa ...
- NHibernate系列文章二十八:NHibernate Mapping之Auto Mapping(附程序下载)
摘要 上一篇文章介绍了Fluent NHibernate基础知识.但是,Fluent NHibernate提供了一种更方便的Mapping方法称为Auto Mapping.只需在代码中定义一些Conv ...
- mysql 导出csv
SELECT order_id,product_name,qty FROM ordersINTO OUTFILE '/tmp/orders.csv'FIELDS TERMINATED BY ','EN ...
- Redis3.0.1 Stable版本的集群部署(Mac)
本文档基于如下原始文档(CentOS)创建: http://blog.csdn.net/xu470438000/article/details/42971091 修改了一些路径的错误,补全了一些命令执 ...
- WCF Misconfiguration: Security Not Enabled
Abstract: No transport or message security has been defined. Explanation: Applications that transmit ...
- css小知识之伪元素
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...