hihocoder 1288
来源:互联网 发布:杜兰特新秀体测数据 编辑:程序博客网 时间:2024/06/04 23:34
微软2016校园招聘4月在线笔试题解(一)
- 字母是方的,即宽高一样。
- 每页至少要显示一个字母,才能有解。即字母大小size = min(W, H)。
- 每行至多可以显示row = W / size个字母,注意下取整。
- 一个段包含p个字母的段,至少需要占用require = (p + row - 1) / row行。
代码:
#include <iostream>#include<vector>using namespace std;int FrontSize(int &N,int &P,int &W,int &H,vector<int>&A){ int size=min(W,H); while(size>=1) { int row=W/size; int col=H/size; int linecnts=0; for(vector<int>::iterator it=A.begin();it<A.end();++it) { linecnts+=(*it+row-1)/row;//每段占多少行 } if(linecnts<=P*col)//P*col总共的行数 return size; else size--; } return 0;} int main(int argc, char *argv[]){ int num; cin>>num; while(num>0) { int N,P,W,H; cin>>N>>P>>W>>H; vector<int> A(N); for(int i=0;i<N;++i) cin>>A[i]; cout<<FrontSize(N,P,W,H,A)<<endl; num--; } return 0;}
参考:http://www.gotit.sinaapp.com/wei-ruan-2016xiao-yuan-zhao-pin-4yue-zai-xian-bi-shi-ti-jie-yi.html
0 0
- hihocoder 1288
- hihoCoder 1288
- Hihocoder 1288
- hihoCoder #1288 : Font Size
- hihocoder:
- hihoCoder
- Hihocoder
- hihocoder
- hihocoder
- hihocoder
- hihocoder
- hihocoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- 【PHP-Laravel框架学习】在ubuntu上配置环境
- 十个随机数求和 1044 郑明雨
- 用闹钟运算
- CAlayer层的属性
- Git版本控制软件结合GitHub从入门到精通常用命令学习手册
- hihocoder 1288
- iOS 语音读文字so easy
- iOS QQ第三方登录的简单实现
- 余数和商 一位数乘一位数
- android抽屉实现
- 项目答辩
- RandomForest随机森林感想
- linux系统安装nginx
- HTML转pdf