2019.03.08晚【NOIP提高组】模拟 B 组 总结

版权声明:~~~感谢支持! https://blog.csdn.net/qq_39897867/article/details/88363654

题目

[jzoj 3054] 祖孙询问 {lca}
[jzoj 3055] 比赛 {期望dp}
[jzoj 3056] 数字 {容斥+dp}


这场比赛在时间控制方面不太好,因为第一道题目的lca中判断’='的这一个错误,损耗了很多时间,第二题也没有坚持想下去(距离正解只有一步之遥


比赛程序

比赛30分 O ( n 2 ) O(n^2)

#include<cstdio>
#include<algorithm>
#include<cstring>
#define rr register 
using namespace std;
int n; double a[50010],b[50010],ans; 
double qw(double x){return x*x;}
double ksm(double x,int y){
	double k=1.0; 
	for (;y;y>>=1,x*=x) if (y&1) k*=x; 
	return k; 
}
int main(){
	scanf("%d",&n); 
	for (int i=1;i<=n;i++) scanf("%lf",&a[i]); 
	for (int i=1;i<=n;i++) scanf("%lf",&b[i]); 
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=n;j++)
	 if (a[i]>b[j]) ans+=qw(a[i]-b[j]); else ans-=qw(a[i]-b[j]); 
	printf("%.1lf",ans/double(n)); 
}

猜你喜欢

转载自blog.csdn.net/qq_39897867/article/details/88363654