您的位置:首页 > 大数据 > 人工智能

2015 Multi-University Training Contest 5

2015-08-04 21:33 363 查看
1002

题意:给出一个长度为n递推数列A,求出所有(Ai+Aj),(1⩽i,j⩽n)相异或的结果。

思路:根据异或可以知道,两个相同的值异或结果为0.所以对于Ai+Aj和Aj+Ai的异或结果就是0,只有当i==j时候,才可能不为0,所以只要考虑i==j的情况即可。

#include<stdio.h>
#include<string.h>
#include<math.h>
#define LL __int64
LL A[500005];
int main()
{
int T,i,j,k;
LL n,m,z,l,ans;
scanf("%d",&T);
while(T--)
{
A[1]=0;
ans=0;
scanf("%I64d%I64d%I64d%I64d",&n,&m,&z,&l);
for(i=2;i<=n;i++)
A[i]=(A[i-1]*m+z)%l;
for(i=1;i<=n;i++)
ans=ans^(2*A[i]);
printf("%I64d\n",ans);
}
return 0;
}


1005

题目大意:元素第一电离能的比较。。。化学全忘光了,打表可以做。

# include<stdio.h>

int Turn(int i){
switch(i){
case 1: return 1312;
case 2: return 2372;
case 3: return 520;
case 4: return 899;
case 5: return 800;
case 6: return 1086;
case 7: return 1402;
case 8: return 1313;
case 9: return 1681;
case 10: return 2080;
case 11: return 495;
case 12: return 737;
case 13: return 577;
case 14: return 786;
case 15: return 1011;
case 16: return 999;
case 17: return 1251;
case 18: return 1520;
case 35: return 1139;
case 36: return 1350;
case 53: return 1008;
case 54: return 1170;
case 85: return 890;
case 86: return 1037;
}
}

int main(){
int i, j;
while (~scanf("%d%d", &i, &j)){
i=Turn(i);
j=Turn(j);
if(i>j) printf("FIRST BIGGER\n");
else printf("SECOND BIGGER\n");
}
return 0;
}


1007

题目大意:三个操作:1、在一个集合里面放入一个数。2、删除集合里面的最小数。如果集合为空,可以跳过这个操作。3、询问集合里最大的数。如果集合为空,则认为是0.

思路:因为他只要最大的数,其实我可以我保留最大数,遇到删除操作就随便删一个数,这里就可以处理为集合的数目减一。

#include<stdio.h>
#include<string.h>
#include<math.h>
#define max(a,b) a>b?a:b
int main()
{
int N,i,j,k,x,y;
int maxi,t;
scanf("%d",&N);
maxi=-2e9;
t=0;
while(N--)
{

scanf("%d",&x);
if(x==1){
scanf("%d",&y);
t++;
maxi=max(y,maxi);
}
if(x==2){
t=max(t-1,0);

if(t==0)
maxi=-2e9;

}
if(x==3){

if(t==0)printf("0\n");
else printf("%d\n",maxi);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: