题目链接: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的更多相关文章

  1. hihocoder 1288 : Font Size (微软2016校园招聘4月在线笔试)

    hihocoder 1288 笔试第一道..wa了好几次,也是无语..hihocoder错了不会告诉你失败的时候的测试集,这样有时候就很烦.. 遍历所有的字体,从min(w,h)开始逐渐变小开始遍历. ...

  2. 微软2016校园招聘4月在线笔试 ABC

    题目链接:http://hihocoder.com/contest/mstest2016april1/problems 第一题:输入N,P,W,H,代表有N段文字,每段有ai个字,每行有⌊W/S⌋个字 ...

  3. 微软2016校园招聘4月在线笔试 hihocoder 1289 403 Forbidden

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描写叙述 Little Hi runs a web server. Sometimes he has to deny acces ...

  4. [Hihocoder 1289] 403 Forbidden (微软2016校园招聘4月在线笔试)

    传送门 #1289 : 403 Forbidden 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi runs a web server. Someti ...

  5. 微软2016校园招聘在线笔试-Professor Q's Software

    题目2 : Professor Q's Software 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new softw ...

  6. 微软2016校园招聘在线笔试第二场 题目1 : Lucky Substrings

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A string s is LUCKY if and only if the number of different ch ...

  7. 微软2016校园招聘在线笔试 B Professor Q's Software [ 拓扑图dp ]

    传送门 题目2 : Professor Q's Software 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new s ...

  8. 微软2016校园招聘在线笔试 [Recruitment]

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A company plans to recruit some new employees. There are N ca ...

  9. 题目3 : Spring Outing 微软2016校园招聘在线笔试第二场

    题目3 : Spring Outing 时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 You class are planning for a spring outin ...

随机推荐

  1. Linux CentOS 7通过yum命令安装Mono4.0.1

    前言 上一篇中提到的快照方式安装Mono,该方式并不稳定,需要做各种配置,各种修改才能与jexus搭配运行. 一.安装源 rpm --import "http://keyserver.ubu ...

  2. 【Python】Celery异步处理

    参考:http://www.cnblogs.com/znicy/p/5626040.html 参考:http://www.weiguda.com/blog/73/ 参考:http://blog.csd ...

  3. Git本地提交到远程指定分支

    git push origin master:ziranmeng2.(本地分支:远程分支)

  4. JAVAC 命令详解(转)

    本文来自:http://www.cnblogs.com/JeffChen/archive/2008/01/16/1041783.html 结构 javac [ options ] [ sourcefi ...

  5. SQL Server 常用函数介绍

    --聚合函数 count( * | 字段名) --统计数据表中的数据总数sum( 表达式 | 字段名) --计算表达式或字段名中数据的和,表达式或字段名的数据类型要求是数值型avg( 表达式 | 字段 ...

  6. HBase预分区

    seq 0 7 | awk '{printf("\\x%02x\\x%02x\n", $1/256, $1%256);}' | sort -R |head -3 create 'm ...

  7. centos服务器全新安装php,apache环境

    留个备份,有空研究一下. 1 yum install php56w-devel.x86_64 yum install httpd-devel.x86_64 vim /etc/php.ini vim / ...

  8. Ogre 1.9 Android移植

    Ogre 1.9 Android移植 分类: 图形渲染2013-02-04 16:47 3860人阅读 评论(14) 收藏 举报 Android Ogre C++linuxLinuxLINUX 上一篇 ...

  9. 犀利点评:csdn某文<第一次创业还是失败了---分享失败的经验>

    今天上午在csdn看了一篇创业文,突然想无节操的做一下点评. 原文详细地址如下:http://blog.csdn.net/android_tutor/article/details/9815801 以 ...

  10. Python数据库备份脚本

    Python数据库备份脚本 #!/usr/bin/env python # author: liudong # -*- coding: utf-8 -*- # filename: db_bak.py ...