hihocoder 1288 : Font Size (微软2016校园招聘4月在线笔试)
笔试第一道。。wa了好几次,也是无语。。hihocoder错了不会告诉你失败的时候的测试集,这样有时候就很烦。。
遍历所有的字体,从min(w,h)开始逐渐变小开始遍历。。计算行数,和all行数比较,只要比他小就可以。。
我太瓜皮了。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std; int main()
{
int testn,n,p,w,h;
cin>>testn;
while(testn--)
{
cin>>n>>p>>w>>h;
int a[n];
for(int i=; i<n; i++)
cin>>a[i];
int up=min(w,h);
bool flag=false; for(int i=up; i>=; i--)
{
int temph=;
int allh=(h/i)*p;
for(int j=; j<n; j++)
{
temph+=a[j]/(w/i);
//这里表示开始分段了
if(a[j]%(w/i)) temph++;
}
if(temph<=allh) {cout<<i<<endl; flag=true; break;}
} if(!flag) cout<<<<endl; }
return ;
}
hihocoder 1288 : Font Size (微软2016校园招聘4月在线笔试)的更多相关文章
- [Hihocoder 1289] 403 Forbidden (微软2016校园招聘4月在线笔试)
传送门 #1289 : 403 Forbidden 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi runs a web server. Someti ...
- 微软2016校园招聘4月在线笔试 hihocoder 1289 403 Forbidden
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描写叙述 Little Hi runs a web server. Sometimes he has to deny acces ...
- 微软2016校园招聘4月在线笔试 A FontSize
题目链接:http://hihocoder.com/problemset/problem/1288 分析:题目中所求的是最大的FontSize(记为S),其应该满足P*[W/S]*[H/S] > ...
- 微软2016校园招聘4月在线笔试 ABC
题目链接:http://hihocoder.com/contest/mstest2016april1/problems 第一题:输入N,P,W,H,代表有N段文字,每段有ai个字,每行有⌊W/S⌋个字 ...
- ACM学习历程—Hihocoder 1288 Font Size(暴力 || 二分)
http://hihocoder.com/problemset/problem/1288 这题是这次微软笔试的第一题,关键的是s的上限是min(w, h),这样s的范围只有到1000,这样就可以直接暴 ...
- 微软2016校园招聘在线笔试之Magic Box
题目1 : Magic Box 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. When ...
- 微软2016校园招聘在线笔试-Professor Q's Software
题目2 : Professor Q's Software 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Professor Q develops a new softw ...
- 微软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 ...
随机推荐
- 【Matlab】绘制饼状统计图
a=tabulate(b); % b为需要绘制饼图的原始数据列,生成新的一个矩阵a label={'1','2','3'} % 设定饼图每块扇形代表的内容 percent=num2str(a(:,3) ...
- Linux 入门记录:二、Linux 文件系统基本结构
一.树状目录结构 Linux 文件系统是一个倒置的单根树状结构.文件系统的根为"/":文件名严格区分大小写:路径使用"/"分割(Windows 中使用" ...
- 在LINUX平台上手动创建多个实例(oracle11g)
在LINUX平台上手动创建多个实例(oracle11g) http://blog.csdn.net/sunchenglu7/article/details/39676659 ORACLE linux ...
- python之operator操作符函数
operator函数主要分为以下几类:对象比较.逻辑比较.算术运算和序列操作. 举例: #python 3.4 >>> operator.eq(1,2)False >>& ...
- C基础入门 - 第一章 - C语言绪言
第1章 C语言绪言 1.1 C语言概述 1.1.1 C语言世界 1.1.2 C语言学习, 能当饭吃吗 1.2 开发环境构建 1.2.1 visual studio安装使用 1.2.2 visual s ...
- Leetcode 之Regular Expression Matching(31)
正则表达式的匹配,还是挺难的.可根据下一个字符是不是*分为两种情况处理,需要考虑多种情况. bool isMatch(const char *s, const char *p) { if (*p == ...
- IntelliJ IDEA 启动方法
IntelliJ IDEA cd idea-IU-145.1617.8/bin && ./idea.sh
- mac下安装golang
1.安装homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/in ...
- yum 安装 jdk
https://www.cnblogs.com/kevingrace/p/5870814.html yum -y list java* 以yum库中java-1.7.0为例注:“*”表示将java-1 ...
- C# Merge into的使用详解
Merge是一个非常有用的功能,类似于Mysql里的insert into on duplicate key. Oracle在9i引入了merge命令, 通过这个merge你能够在一个SQL语句中对一 ...