2011浙大研究生机试题
2014-02-27 18:38
344 查看
(1)
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=15;
int a[maxn][maxn];
int m,n;
int main()
{
while(scanf("%d",&m)!=EOF)
{
if(!m) break;
scanf("%d",&n);
memset(a,0,sizeof(a));
int i,j,k=2;
while(k--)
{
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
int temp;
scanf("%d",&temp);
a[i][j]+=temp;
}
}
int sum=0,flag;
for(i=0;i<m;i++)
{
flag=1;
for(j=0;j<n;j++)
if(a[i][j])
{
flag=0;
break;
}
if(flag) sum++;
}
for(j=0;j<n;j++)
{
flag=1;
for(i=0;i<m;i++)
if(a[i][j])
{
flag=0;
break;
}
if(flag) sum++;
}
printf("%d\n",sum);
}
return 0;
}
(2)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int p,t,g1,g2,g3,gj;
int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
while(cin>>p>>t>>g1>>g2>>g3>>gj)
{
if(abs(g1-g2)<=t)
printf("%.1f\n",((float)g1+g2)/2);
else
{
if(abs(g1-g3)<=t||abs(g2-g3)<=t)
{
if(abs(g1-g3)<=t&&abs(g2-g3)<=t)
{
printf("%.1f\n",(float)max(max(g1,g2),g3));
}
else
{
if(abs(g1-g3)<abs(g2-g3))
{
printf("%.1f\n",((float)g1+g3)/2);
}
else
{
printf("%.1f\n",((float)g2+g3)/2);
}
}
}
else printf("%.1f\n",(float)gj);
}
}
return 0;
}
(3)
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=2*1000000+10;
int m,n;
int a[maxn];
int main()
{
while(scanf("%d",&m)!=EOF)
{
int i,j;
for(i=0;i<m;i++)
scanf("%d",&a[i]);
scanf("%d",&n);
for(j=0;j<n;j++)
scanf("%d",&a[m+j]);
sort(a,a+m+n);
printf("%d\n",a[(m+n-1)/2]);
}
return 0;
}
(4)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn=40000+10;
const int maxm=100+10;
const int maxk=5+2;
int n,m,k;
typedef struct
{
int ge,gi,no;
int pre[maxk];
}student;
student stu[maxn];
bool sel[maxn];
int quo[maxm];
int cmp(student a,student b)
{
if((a.ge+a.gi)!=(b.ge+b.gi)) return a.ge+a.gi>b.ge+b.gi;
else return a.ge>b.ge;
}
int main()
{
while(cin>>n>>m>>k)
{
int i,j,s,t;
for(i=0;i<m;i++)
scanf("%d",&quo[i]);
for(i=0;i<n;i++)
{
scanf("%d%d",&stu[i].ge,&stu[i].gi);
stu[i].no=i;
for(j=0;j<k;j++)
scanf("%d",&stu[i].pre[j]);
}
memset(sel,false,sizeof(sel));///一开始都没被录取
sort(stu,stu+n,cmp);
vector<int> res[maxm],result[maxm];
for(t=0;t<n;t++)
{
for(s=0;s<k;s++)
{
if(sel[t]==false)
{
i=stu[t].pre[s];///所选院校
int si=res[i].size(),last;
if(si>0) last=res[i][si-1];///faulty
if(si<quo[i]||(stu[t].ge==stu[last].ge&&stu[t].gi==stu[last].gi))///如果名额还有,或者分数和最后一名录取者相同
{
res[i].push_back(t);///排名第t被i录取
sel[t]=true;
break;
}
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<res[i].size();j++)
{
int t=res[i][j];
result[i].push_back(stu[t].no);
}
sort(result[i].begin(),result[i].end());
for(j=0;j<result[i].size();j++)
{
printf("%d",result[i][j]);
if(j<result[i].size()-1)
printf(" ");
}
printf("\n");
}
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=15;
int a[maxn][maxn];
int m,n;
int main()
{
while(scanf("%d",&m)!=EOF)
{
if(!m) break;
scanf("%d",&n);
memset(a,0,sizeof(a));
int i,j,k=2;
while(k--)
{
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
int temp;
scanf("%d",&temp);
a[i][j]+=temp;
}
}
int sum=0,flag;
for(i=0;i<m;i++)
{
flag=1;
for(j=0;j<n;j++)
if(a[i][j])
{
flag=0;
break;
}
if(flag) sum++;
}
for(j=0;j<n;j++)
{
flag=1;
for(i=0;i<m;i++)
if(a[i][j])
{
flag=0;
break;
}
if(flag) sum++;
}
printf("%d\n",sum);
}
return 0;
}
(2)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int p,t,g1,g2,g3,gj;
int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
while(cin>>p>>t>>g1>>g2>>g3>>gj)
{
if(abs(g1-g2)<=t)
printf("%.1f\n",((float)g1+g2)/2);
else
{
if(abs(g1-g3)<=t||abs(g2-g3)<=t)
{
if(abs(g1-g3)<=t&&abs(g2-g3)<=t)
{
printf("%.1f\n",(float)max(max(g1,g2),g3));
}
else
{
if(abs(g1-g3)<abs(g2-g3))
{
printf("%.1f\n",((float)g1+g3)/2);
}
else
{
printf("%.1f\n",((float)g2+g3)/2);
}
}
}
else printf("%.1f\n",(float)gj);
}
}
return 0;
}
(3)
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=2*1000000+10;
int m,n;
int a[maxn];
int main()
{
while(scanf("%d",&m)!=EOF)
{
int i,j;
for(i=0;i<m;i++)
scanf("%d",&a[i]);
scanf("%d",&n);
for(j=0;j<n;j++)
scanf("%d",&a[m+j]);
sort(a,a+m+n);
printf("%d\n",a[(m+n-1)/2]);
}
return 0;
}
(4)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn=40000+10;
const int maxm=100+10;
const int maxk=5+2;
int n,m,k;
typedef struct
{
int ge,gi,no;
int pre[maxk];
}student;
student stu[maxn];
bool sel[maxn];
int quo[maxm];
int cmp(student a,student b)
{
if((a.ge+a.gi)!=(b.ge+b.gi)) return a.ge+a.gi>b.ge+b.gi;
else return a.ge>b.ge;
}
int main()
{
while(cin>>n>>m>>k)
{
int i,j,s,t;
for(i=0;i<m;i++)
scanf("%d",&quo[i]);
for(i=0;i<n;i++)
{
scanf("%d%d",&stu[i].ge,&stu[i].gi);
stu[i].no=i;
for(j=0;j<k;j++)
scanf("%d",&stu[i].pre[j]);
}
memset(sel,false,sizeof(sel));///一开始都没被录取
sort(stu,stu+n,cmp);
vector<int> res[maxm],result[maxm];
for(t=0;t<n;t++)
{
for(s=0;s<k;s++)
{
if(sel[t]==false)
{
i=stu[t].pre[s];///所选院校
int si=res[i].size(),last;
if(si>0) last=res[i][si-1];///faulty
if(si<quo[i]||(stu[t].ge==stu[last].ge&&stu[t].gi==stu[last].gi))///如果名额还有,或者分数和最后一名录取者相同
{
res[i].push_back(t);///排名第t被i录取
sel[t]=true;
break;
}
}
}
}
for(i=0;i<m;i++)
{
for(j=0;j<res[i].size();j++)
{
int t=res[i][j];
result[i].push_back(stu[t].no);
}
sort(result[i].begin(),result[i].end());
for(j=0;j<result[i].size();j++)
{
printf("%d",result[i][j]);
if(j<result[i].size()-1)
printf(" ");
}
printf("\n");
}
}
return 0;
}
相关文章推荐
- 浙江大学研究生机试题——奥运排序问题
- HotOS 2011年会:对云计算如何进行理论研究
- 华为2012.09.03浙大机试题
- To Fill or Not to Fill<2011浙大复试机试>
- 2011浙大上机题 Median
- 十三、通过浙大上机复试试题学SPFA 算法
- 九度oj 题目1002:Grading 【ZJU2011考研机试题2】
- 2011华为上机试题成都
- 2011分区联赛模拟试题 积木分发(jzoj提高C组)
- 2011 华为机试题
- 浙大2012机试题——Sharing
- 北京理工大学计算机专业研究生复试上机试题(2000-2011)
- android market过滤规则研究 - 第二届 Google 暑期大学生博客分享大赛 - 2011 Android 成长篇
- 九度oj 题目1004:Median 【ZJU2011考研机试题3】
- 九度考研真题 浙大 2011-1浙大1001:A+B for Matrices
- 2011分区联赛模拟试题 积木分发(jzoj提高C组)
- 华为2012.09.03浙大机试题
- 2011大纽约区域赛试题 Decoding EDSAC Data 解题报告
- 2011 google校园招聘试题
- 华为2012.09.03浙大机试题