官方题解:2015 Multi-University Training Contest 5 solutions BY 绍兴一中
1002
题意:给出一个长度为\(n\)递推数列\(A\),求出所有\((A_i+A_j),(1\leqslant i,j\leqslant n)\)相异或的结果。
注意\(i,j\)之间没有关系限制,也就是说可以\(i==j\)
因为\((A_i+A_j) xor (A_j+A_i)==0\)
所以就只用计算所有\((A_i+A_i) \)相异或的值
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<string>
using namespace std;
#define MAX(a,b) ((a>b)?(a):(b))
#define MIN(a,b) ((a<b)?(a):(b))
#define LL __int64
#define N 500005
#define INF 1<<30
LL a[N];
int main(){
int T;
scanf("%d",&T);
LL n,m,z,l;
while(T--){
cin>>n>>m>>z>>l;
a[1]=0;
LL ans=0;
for(int i=2;i<=n;++i){
a[i]=(a[i-1]*m+z)%l;
ans^=(a[i]*2);
}
cout<<ans<<endl;
}
return 0;
}
1005
题意:定义\(F(x)\)为原子系数为x的化学元素的第一电离能,给出\(u,v\),比较\(F(u),F(v)\)的大小。
直接打表。
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<string>
using namespace std;
#define MAX(a,b) ((a>b)?(a):(b))
#define MIN(a,b) ((a<b)?(a):(b))
#define LL __int64
#define N 105
#define INF 1<<30
double f[N]={0,1312.0,2372.3,520.2,899.5,800.6,1086.5,1402.3,1313.9,1681.0,2080.7,495.8,737.7,577.5,786.5,1011.8,999.6,1251.2,1520.6};
int main(){
f[35]=1139.9;
f[36]=1350.8;
f[53]=1008.4;
f[54]=1170.4;
f[85]=850.0;
f[86]=1037.0;
int u,v;
while(~scanf("%d%d",&u,&v)){
printf("%s\n",(f[u]>f[v]?"FIRST BIGGER":"SECOND BIGGER"));
}
return 0;
}
1007
HDU 5349:http://acm.hdu.edu.cn/showproblem.php?pid=5349
题意:给出一个multiset和三种操作:
1 x : 将数 \(x\) 加入集合中
2 : 删除一个集合中最小的数 (如果集合为空,忽略此操作)
3 : 询问集合中最大的数是多少 (如果集合为空,最大值为0)
直接用multiset可水过
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define N 100005
#define INF 1<<30
int main()
{
int n;
multiset<int> s;
multiset<int> ::iterator it;
int op,x;
while(scanf("%d",&n)!=EOF){
while(n--){
scanf("%d",&op);
if(op==1){
scanf("%d",&x);
s.insert(x);
}
else if(op==2){
if(!s.empty())
s.erase(s.begin());
}
else{
if(!s.empty()){
it=--s.end();
printf("%d\n",(*it));
}
else{
puts("0");
}
}
}
}
return 0;
}
(待续。。。)