Noip模拟题解题报告

Pro

第一次AK。

题目链接

Sol

站军姿

算是数学题吧,求出两圆的位置关系,然后余弦定理和扇形面积什么的搞搞就行。

#include<iostream>
#include<cstdio>
#include<cmath>
#define rfile(x) freopen("x.in","r",stdin);
#define wfine(x) freopen("x.out","w",stdout);
using namespace std;

const double pi = 3.14159265358979323846264;
int T , flag;
double x1 , Y1 , r1 , x2 , y2 , r2 , len;

inline double mypow(double x , int y) {
	if(!y)
		return 1;
	double t = mypow(x , y>>1);
	if(y&1)
		return t*t*x;
	return t*t;
}

int jud(double x1 , double Y1 , double r1 , double x2 , double y2 , double r2) {
	if(len<r1+r2)
		return 0;//相交
	else
		return 1;
}

void sol(double x1 , double Y1 , double r1 , double x2 , double y2 , double r2) {
	len = sqrt(mypow(x1-x2,2)+mypow(Y1-y2,2));
	double S1=pi*mypow(r1,2) , S2=pi*mypow(r2,2);
	if((r1-r2)>=len) {
		printf("%.3lf\n",S1);
		return ;
	}
	if((r2-r1)>=len) {
		printf("%.3lf\n",S2);
		return ;
	}
	flag = jud(x1,Y1,r1,x2,y2,r2);
	if(flag)
		printf("%.3lf\n",S1+S2);
	if(!flag) {
		double a1 , a2 , s1 , s2;
		a1 = 2*acos((r1*r1+len*len-r2*r2)/(2*r1*len));
		a2 = 2*acos((r2*r2+len*len-r1*r1)/(2*r2*len));
		s1 = r1*r1*a1/2-r1*r1*sin(a1)/2;
		s2 = r2*r2*a2/2-r2*r2*sin(a2)/2;
		printf("%.3lf\n",S1+S2-s1-s2);
	}
}

int main() {
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
	scanf("%d",&T);
	while(T--) {
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&Y1,&r1,&x2,&y2,&r2);
		sol(x1,Y1,r1,x2,y2,r2); 
	}
	return 0;
}

对刚

约瑟夫杀人问题,特别水。

#include<iostream>
#include<cstdio>
using namespace std;

int n , t , vis[200005] , kill , opt , cnt;

int main() {
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
	scanf("%d%d",&n,&t);
	while(kill!=n) {
		if(vis[opt+1]) {
			opt++;
			continue;
		}
		cnt++;
		opt++;
		if(opt>n) opt-=n;
		if(cnt==t) {
			cnt = 0;
			vis[opt] = vis[opt+n] = 1;
			kill++;
		}
	}
	printf("%d",opt);
	return 0;
}

隔壁

做USACO的时候刷到过一道比这个难的题。

这个还是比较简单的,最大值很容易求,就是每一行每一列的最小值。

至于最小值,分两部分求,先做行再做列,能放到同一行的尽量放就会使答案更小。

放过就打上标记,然后再做列的部分。

#include<iostream>
#include<cstdio>
using namespace std;

long long n , m , a[1005] , b[1005] , ans1 , ans2 , visa[1005] , visb[1005];
inline long long mymin(long long x , long long y) { return x<y?x:y; }

int main() {
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
	scanf("%lld%lld",&n,&m);
	for(int i=1; i<=n; i++)
		scanf("%lld",&a[i]);
	for(int i=1; i<=m; i++)
		scanf("%lld",&b[i]);
	for(int i=1; i<=n; i++) {
		visa[i] = 1;
		long long res = 1e9 , pot = 0;
		for(long long j=1; j<=m; j++) {
			if(b[j]>=a[i]) {
				if(b[j]<res&&!visb[j]) {
					res = b[j];
					pot = j;
				}			
			}
			ans2 += mymin(a[i],b[j]);			
		}
		if(res == a[i])
			visb[pot] = 1;
		ans1 += a[i];
	}
	for(int i=1; i<=m; i++) {
		if(visb[i])
			continue;
		ans1 += b[i];
	}
	printf("%lld %lld",ans1,ans2);
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值