#include<iostream>
#include<list>
using namespace std;
int main()
{
int Case;
scanf("%d",&Case);
list<int>font;
for(int i=0;i<Case;i++)
{
int N,P,W,H;
list<int>PChar;
list<int>::iterator itor;
scanf("%d%d%d%d",&N,&P,&W,&H);
for(int i=0;i<N;i++)
{
int Para;
scanf("%d",&Para);
PChar.push_back(Para);
}
int SUM=0;
itor=PChar.begin();
while(itor!=PChar.end())
{
SUM+=*itor++;
}
int Per=SUM/P;
int M;
if(W>=H)
{M=H;}
else M=W;
for(int i=M;i>0;i--)
{
if((W/i)*(H/i)<=Per)
{
int PerLine=W/i;
int TotalLine=(H/i)*P;
int ActualLine=0;
list<int>::iterator Line;
Line=PChar.begin();
while(Line!=PChar.end())
{
int x=(*Line)/PerLine;
if((*Line)*1.0/PerLine>x)x+=1;
Line++;
ActualLine+=x;
}
if(TotalLine>=ActualLine)
{
font.push_back(i);
break;
}
}
}
while(!PChar.empty())
{
PChar.pop_front();
}
}
list<int>::iterator ifont;
ifont=font.begin();
while(ifont!=font.end())
{
printf("%d\n",*ifont++);
}
system("pause");
return 0;
}
以上是今晚参加的微软4月份笔试题目,不仅看到了自己的基础薄弱,方法论也有问题。跌倒在此刻我心服口服,但多少还有些不甘,明明用vs2010编译的是成功的啊。
第一次笔试
最新推荐文章于 2016-08-25 21:54:13 发布