UCF Local Programming Contest 2015

文章目录

    • A. Find the Twins
    • B. Medal Ranking
    • C. Brownies vs. Candies vs. Cookies
    • D. Lemonade Stand
    • E. Rain Gauge

A. Find the Twins

#include
#include
#include
using namespace std;
const int maxn=2e3;
int n;
int s[maxn][12];
int ok,ok1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
	for(int j=1;j<=10;j++){
		scanf("%d",&s[i][j]);
	}		
    }
	for(int i=1;i<=n;i++){
		for(int j=1;j<=10;j++){
			if(j!=10)
			cout<" ";
			else cout<;
			if(s[i][j]==17)
			ok++;
			if(s[i][j]==18)
			ok1++;
		}
		if(ok==1&&ok1==1){
			cout<<"both"<;
		}
		if(ok==1&&ok1==0){
			cout<<"zack"<;
		}
		if(ok==0&&ok1==1){
			cout<<"mack"<;
		}
		if(ok==0&&ok1==0){
			cout<<"none"<;
		}
		cout<;
		ok=ok1=0;
	}
	return 0;
}

B. Medal Ranking

#include
#include
using namespace std;
const int maxn=1e5+10;
int n;
int ok,ok1;
struct node{
	int x,y,z;
	int sum;
}s[maxn][2];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
	scanf("%d%d%d%d%d%dd",&s[i][1].x,&s[i][1].y,&s[i][1].z,&s[i][2].x,&s[i][2].y,&s[i][2].z);		
	}
	for(int i=1;i<=n;i++){
		ok=ok1=0;
		s[i][1].sum=s[i][1].x+s[i][1].y+s[i][1].z;
		s[i][2].sum=s[i][2].x+s[i][2].y+s[i][2].z;
		if(s[i][1].sum>s[i][2].sum)
		ok=1;
		if(s[i][1].x>s[i][2].x)
		ok1=1;
		if(s[i][1].x==s[i][2].x){
			if(s[i][1].y>s[i][2].y)
			ok1=1;
			if(s[i][1].y==s[i][2].y){
				if(s[i][1].z>s[i][2].z)
				ok1=1;
			}
		}
		cout<" "<" "<" "<" "<" "<;
		if(ok==1&&ok1==1){
			cout<<"both"<;
		}
		if(ok==0&&ok1==0)
		cout<<"none"<;
		if(ok==1&&ok1==0)
		cout<<"count"<;
		if(ok==0&&ok1==1)
		cout<<"color"<;
		cout<;
	}
}

C. Brownies vs. Candies vs. Cookies

#include
#include
using namespace std;
const int maxn=1e5;
int n,m;
int x,y,z[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		scanf("%d",&m);
		for(int j=1;j<=m;j++){
			scanf("%d",&z[j]);
		}
		printf("Practice #%d: %d %d\n",i,x,y);
		int p=y;
		for(int j=1;j<=m;j++){
			while(p<=z[j]){
				p*=2;
			}
			printf("%d %d\n",z[j],p-z[j]);
			p-=z[j];
		}
		cout<;
	}
}

D. Lemonade Stand

#include
#include
#include
using namespace std;
typedef long long ll;
ll n,d,x,s,c,p,q;
ll sum;
ll num1,num2;
ll price1,price2;
int main(){
	scanf("%lld",&n);
	while(n--){
		sum=0;
		num1=num2=0;
		price1=price2=0;
		scanf("%lld%lld%lld",&d,&x,&s);
		while(d--){
			ll cnt=0;
			scanf("%lld%lld%lld",&c,&p,&q);
			if(price1==0){
				price1=p;
			} else price1=min(price1,p);
			if(price2==0){
				price2=q;
			}else price2=min(price2,q);
			if(c*s>num2){
				num1=c*s-num2;
				num2=0;
			}
			else{
				num1=0;
				num2-=c*s;
			}
			if(num1%80!=0)cnt=num1/80+1;
			else cnt=num1/80;
//			cout<" "<" "<;
//			cout<" "<;
			sum+=c*x*price1+cnt*price2;
//			printf("%lld\n",sum);
			num2+=cnt*80-num1;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

E. Rain Gauge

这道题是求圆覆盖正方形的面积
这道题其实不难,关键是使用acos、求出扇形的面积

#include
#include
using namespace std;
const double PI=3.14159265358979;
int d,r,n;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&d,&r);
		double s=r*r*PI;
		int a=d*d;
		if(r*2>=sqrt(2)*d){
			printf("%d.00\n",a);
		}
		else if(d>=2*r){
			printf("%.2f\n",s);
		}
		else{
			double d1=sqrt(r*r-(d/2.0)*(d/2.0));
			double s1=d1*2*(d/2.0)/2*4;
			double p1=acos(d/2.0/r)*2;
			double p2=180*PI/180-2*p1;
			double s2=PI*r*r*p2*2/PI/2;
			printf("%.2f\n",s1+s2);
		}
	}
	return 0;
}

你可能感兴趣的:(--------【训练赛】)