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 ...
随机推荐
- 直接在注册DB服务的时候,做beforeQuery事件监听
- 单文件组件(single-file components)
介绍 我们可以使用预处理器来构建简洁和功能更丰富的组件,比如 Pug,Babel (with ES2015 modules),和 Stylus.
- git学习笔记三
1.每个分支的历史版本维护信息位置是.git/logs/refs/heads/master,这个位置的信息是文本文件,不是引用. harvey@harvey-Virtual-Machine:~/dem ...
- django开发项目实例1--建立一个项目并初步运行
1:进入目标目录新建一个项目 D:\>django-admin.py startproject qiweijie 新建完成后,进入项目文件夹查看目录 D:\>cd qiweijie D:\ ...
- pom报错解决方法大全
1.Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom 解决方法: Windows: CMD --> c ...
- linux命令(26):ls命令
例一:列出/home/peidachang文件夹下的所有文件和目录的详细资料 ls -l -R /home/test 例二:列出当前目录中所有以“t”开头的目录的详细内容,可以使用如下命令: ls - ...
- [PAT] 1144 The Missing Number(20 分)
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
- %和format的区别
在python中字符串的格式化分为两种:%和format.那么我们在什么时候来使用它们呢?它们有什么区别呢? 举个例子:我们根据一个坐标来表示一个动作 #定义一个坐标 point = (250,250 ...
- Excel Sheet Column Title&&Excel Sheet Column Number
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...
- WebDriver自动化测试工具(3)---PhantomJS的使用
PhantomJS是一个基于webkit的javascript API.它使用QtWebKit作为它核心浏览器的功能,使用webkit来编译解释执行JavaScript代码.任何你可以在基于webki ...