浙江省11届省赛部分题解

ZOJ 3776A题:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define N 1005
int n, m;
int main(){
	int T;scanf("%d",&T);
	int i, j;
	while(T--){
		scanf("%d%d",&n,&m);
		int sum1= 0, sum2= 0;
		while(n--){scanf("%d",&i);sum1+=i;}
		while(m--){scanf("%d",&i);sum2+=i;}
		if(sum1>sum2)puts("Calem");
		if(sum1<sum2)puts("Serena");
		if(sum1==sum2)puts("Draw");
	}
	return 0;
}

ZOJ 3777 B题:

题解

ZOJ 3778C题:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define N 1005
#define ll long long
ll n, m;
int main(){
	int T;scanf("%d",&T);
	ll i, j;
	while(T--){
		scanf("%lld%lld",&n,&m);
		ll sum1= 0, sum2= 0;
		while(n--){scanf("%d",&i);sum1+=i;sum2=max(sum2,i);}
		sum2 = max(sum1/m+((sum1%m)?1:0), sum2);
		printf("%lld\n",sum2);
	}
	return 0;
}

ZOJ 3780  E题:

题解


ZOJ 3781 F题:

题解


ZOJ 3782 G题:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
using namespace std;
#define N 10000
#define ll long long
ll n, m;
ll a,b,c;
char s[2][2];
ll work(ll x, ll y, ll cur){
	if(s[cur][0]=='*')return x*y;
	if(s[cur][0]=='/')return x/y;
	if(s[cur][0]=='+')return x+y;
	if(s[cur][0]=='-')return x-y;
	if(s[cur][0]=='%')return x%y;
}
bool pri(ll cur){
	if(s[cur][0]=='%')return 1;
	if(s[cur][0]=='*')return 1;
	if(s[cur][0]=='/')return 1;
return 0;
}
int main(){		
	ll T, ans;scanf("%lld",&T);
	while(T--){
		scanf("%lld %s %lld %s %lld",&a,s[0],&b,s[1],&c);
		if(pri(1) && !pri(0) )
			ans = work(a,work(b,c,1),0);
		else 
			ans = work(work(a,b,0),c,1);
		printf("%lld\n",ans);
	}
	return 0;
}

ZOJ 3785 J题:

题解

ZOJ 3787 L题:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
using namespace std;
#define N 20005
struct node{
	int s,f,m, num;
}p[N], now;
void add(int se){
	now.m += se;
	if(now.m >= 60){now.f += now.m/60; now.m %= 60;}
	if(now.f >= 60){now.s += now.f/60; now.f %= 60;}
}
bool same(node a,node b){return a.m==b.m && a.f==b.f && a.s==b.s;}
bool cmp(node a,node b){
	if(a.s==b.s){
		if(a.f==b.f)
		{
			if(a.m==b.m)return a.num<b.num;
			return a.m<b.m;
		}
		return a.f<b.f;
	}
	return a.s<b.s;
}
int Stack[N];
int n, m;
int main(){
	int T, i, j;scanf("%d",&T);
	while(T--){
		scanf("%d %d",&n,&m);
		for(i = 0; i < n; i++)scanf("%d:%d:%d",&p[i].s,&p[i].f,&p[i].m), p[i].num = i+1;
		sort(p, p+n, cmp);
		int Top = 0;
		Stack[Top++] = p[0].num; 
		now = p[0];
		add(m);
		for(i = 1; i < n; i++){
			if(same(p[i],now))
			{
				Stack[Top++] = p[i].num;
				now = p[i];
				add(m);
			}
			if(!cmp(p[i],now))
			{
				Stack[Top++] = p[i].num;
				now = p[i];
				add(m);
			}
		}
		printf("%d\n", Top);
		sort(Stack, Stack+Top);
		for(i = 0; i < Top; i++){
			printf("%d",Stack[i]);
			i<Top-1?printf(" "):puts("");
		}
	}
	return 0;
}


你可能感兴趣的:(浙江省11届省赛部分题解)