周赛题

UESTC - 1034

AC Milan VS Juventus

Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu

SubmitStatus

Description

Kennethsnow and Hlwt both love football.

One day, Kennethsnow wants to review the match in
2003
between AC Milan and Juventus for the Championship Cup. But before the penalty shootout. he fell asleep.

The next day, he asked Hlwt for the result. Hlwt said that it scoreda:b
in the penalty shootout.

Kennethsnow had some doubt about what Hlwt said becauseHlwt is a fan of Juventus but
Kennethsnow loves AC Milan.

So he wanted to know whether the result can be a legal result of a penalty shootout. If it can be, outputYes, otherwise output
No.

The rule of penalty shootout is as follows:

  • There will be 5
    turns, in each turn, 2
    teams each should take a penalty shoot. If goal, the team get
    1
    point. After each shoot, if the winner can be confirmed(i.e: no matter what happened after this shoot, the winner will not change), the match end immediately.
  • If after 5
    turns the 2
    teams score the same point. A new turn will be added, until that one team get a point and the other not in a turn.

Before the penalty shootout begins, the chief referee will decide which team will take the shoot first, and afterwards, two teams will take shoot one after the other. Since Kennethsnow fell asleep last night, he had no idea whether AC Milan or Juventus took
the first shoot.

Input

The only line contains
2
integers a,b.
Means the result that Hlwt said.

0≤a,b≤10

Output

Output a string Yes or No, means whether the result is legal.

Sample Input

3 2


2 5

Sample Output

Yes


No

Hint

The Sample 1 is the actual result of the match in
2003.

The Sample 2, when it is
2:4
after 4 turns, AC Milan can score at most
1 point in the next turn. So Juventus has win when it is
2:4.
So the result cannot be
2:5.

This story happened in a parallel universe. In this world where we live,
kennethsnow
is a fan of Real Madrid.

Source

The 13th UESTC Programming Contest Preliminary

//题意:输入a,b;

表示两个人在点球,a,b表示两个人的得分数

现在要求:

进行五局的比赛,没进一个球的一分,没进不得分,如果比赛已经分出胜负了,那么比赛就结束,后面的几轮就不用比了,现在问给定的a,b是否是正确。

//思路:

因为是问是否确定所以要逐个球比较。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool work(int a, int b)
{
	if(a == b)
		return false;
	if(a > 5 || b > 5)
	{
		if(abs(a - b) == 1)
			return true;
		else
			return false;
	}
	if(a == 5 || b == 5)
	{
		if(b < 3 || a < 3)
			return false;
		else
			return true;
	}
	if(a == 4 || b == 4)
	{
		if(a == 0 || b == 0)
			return false;
		else
			return true;
	}
	if(a == 3 || b == 3)
	{
		return true;
	}
	return true;
}
int main()
{
	int a, b;
	while(~scanf("%d%d", &a, &b))
	{
		if(work(a, b))
			puts("Yes");
		else
			puts("No");
	}
	return 0;
}

UESTC - 1039

Fabricate equation

Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu

SubmitStatus

Description

Given an integer Y,
you need to find the minimal integer
K
so that there exists a
X
satisfying X?Y=Z(Z≥0)
and the number of different digit between
X
and Z
is K
under decimal system.

For example: Y=1,
you can find a X=100
so that Z=99
and K
is 3
due to 1≠0
and 0≠9.
But for minimization, we should let
X=1
so that Z=0
and K
can just be 1.

Input

Only one integer Y(0≤Y≤1018).

Output

The minimal K.

Sample Input

1


191

Sample Output

1


2

Hint

Source

The 13th UESTC Programming Contest Preliminary

//题意:

给你一个Y,问通过X-Y=Z这个公式可以确定出来的X,Z每个位上的数字进行比较,最少有几个位上的数是不相等的。

//思路:

通过模拟可以发现规律,只有给定的Y中有0(取它本身),9(通过下一位进位)可以使得X和Z在对应位上获得相等的数字,所以每个位上模拟。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
int a[25];
int ans;
void dfs(int cur, int cnt, int tp, int kg)
{
	if(cur >= tp)
	{
		ans = max(ans, cnt);
		return;
	}
	if(a[cur] == 0)
	{
		if(kg != 9 && !(cur == tp - 2 && a[tp - 1] == 9))
			dfs(cur + 1, cnt + 1, tp, 0);
		else
			dfs(cur + 1, cnt, tp, 1);
	}
	else if(a[cur] == 9)
	{
		if((kg == 1 || kg == 9) && cur != tp - 1 && cur != 0)
			dfs(cur + 1, cnt + 1, tp, 9);
		else
			dfs(cur + 1, cnt, tp, 1);
	}
	else
		dfs(cur + 1, cnt, tp, 1);
}
int main()
{
	LL Y;
	while(~scanf("%lld", &Y))
	{
		int tp = 0;
		while(Y)
		{
			a[tp++] = Y % 10;
			Y /= 10;
		}
		ans = 0;
		dfs(0, 0, tp, 1);
		printf("%d\n", tp - ans);
	}
	return 0;
}
 //这是自己写的模拟的代码,一直WA4。。。,还不懂
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define ll long long
using namespace std;
char a[20],b[20],s[20],ss[20];
int main()
{
	int i,j;
	while(scanf("%s",ss)!=EOF)
	{
		memset(a,'\0',sizeof(a));
		memset(b,'\0',sizeof(b));
		memset(s,'\0',sizeof(s));
		int len=strlen(ss),k=0;
		for(i=len-1;i>=0;i--)
			s[k++]=ss[i];
		if(s[0]!='0')
			a[0]=s[0]-1;
		else
			a[0]='0';

		int l,r;
		for(i=1;i<k-1;)
		{
			if(s[i]!='0')
			{
				a[i]=s[i]-1;
				i++;
			}
			else
			{
				l=i;
				while(s[i]=='0') i++;
				r=i;
				if(r-l<=1)
					a[l]='0';
				else
				{
					a[l]='1';
					for(j=l+1;j<r;j++)
						a[j]='0';
				}
			}
		}
		a[k-1]=s[k-1]+1;
		ll n=0,m=0,nm;
		for(i=k-1;i>=0;i--)
			n=n*10+(a[i]-'0');
		for(i=0;i<len;i++)
			m=m*10+(ss[i]-'0');
		nm=n-m;
		k=0;
		while(nm)
		{
			b[k++]=nm%10+'0';
			nm/=10;
		}
		for(i=k;i<len;i++)
			b[i]='0';
		int cnt=0;
		for(i=0;i<len;i++)
			if(b[i]!=a[i])
				cnt++;
		if(ss[0]=='9')
			cnt++;
		printf("%d\n",cnt);
	}
	return 0;
}

UESTC - 1041

Hug the princess

Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu

SubmitStatus

Description

There is a sequence with
n elements. Assuming they are
a1,a2,?,an.

Please calculate the following expession.

∑1≤i<j≤n(ai∧aj)+(ai|aj)+(ai&aj)

In the expression above, ^|& is bit operation. If you don’t know bit operation, you can visit

http://en.wikipedia.org/wiki/Bitwise_operation

to get some useful information.

Input

The first line contains a single integer
n, which is the size of the sequence.

The second line contains
n integers, the
ith
integer ai
is the ith
element of the sequence.

1≤n≤100000,0≤ai≤100000000

Output

Print the answer in one line.

Sample Input

2

1 2

Sample Output

6

Hint

Because the answer is so large, please use long long instead of int. Correspondingly, please use%lld instead of
%d to scanf and printf.

Large input. You may get Time Limit Exceeded if you use “cin” to get the input. So “scanf” is suggested.

Likewise, you are supposed to use “printf” instead of “cout”.

Source

The 13th UESTC Programming Contest Preliminary

//题意:

给你n个数,让求∑1≤i<j≤n(ai∧aj)+(ai|aj)+(ai&aj);

//思路:

队友的想法太机智了,先用个二维数组存放每个位上的值的和,然后在每个位进行计算。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 1e5 + 100;
int num[MAXN][35];
int a[35];
int p[MAXN];
typedef long long LL;
int main()
{
	int n;
	while(~scanf("%d", &n))
	{
		int x;
		memset(num, 0, sizeof(num));
		for(int i = 1; i <= n; i++)
		{
			scanf("%d", &x);
			for(int j = 0; j < 33; j++)
			{
				num[i][j] = num[i - 1][j] + x % 2;
				x = x / 2;
			}
		}
		LL ans = 0;
		for(int i = 1; i <= n; i++)
		{
			for(int j = 0; j < 33; j++)
			{
				a[j] = num[i][j] - num[i - 1][j];
			}
			for(int j = 0; j < 33; j++)
			{
				int cnt = 0;
				if(a[j])
				{
					cnt += (i - 1 - num[i - 1][j]);//异或值
					cnt += i - 1;				   //或值
					cnt += num[i - 1][j];		   //非值
				}
				else
				{
					cnt += num[i - 1][j];
					cnt += num[i - 1][j];
				}
				ans += (LL)cnt * (1 << j);//得到对应位上的值后再向右移动对应的位数
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

UESTC - 1045

Lovely princess

Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu

SubmitStatus

Description

There are n jobs you need to complete. However, complete the
ith
job you capability must be no less than
vi.
If you have completed the ith
job, your capability will increase
ai.

Then the question is coming, what is the minimum initial capability value if you are required to complete all of then
jobs.

Note that there is no restriction on the order you complete them. That is to say, you can decide the order by your own.

Input

The first line contains a single integer
n, which is the number of jobs you need to complete.

Then each of the following
n lines contains2
integers vi
and ai,
which are described above.

1≤n≤1000,0≤vi≤1000000,0≤ai≤1000

Output

Print the answer in one line.

Sample Input

1

2 1

Sample Output

2

Hint

Source

The 13th UESTC Programming Contest Preliminary

//题意:输入n个数,再输入n个a[i],w[i];

给你n个任务,每完成一个一个任务你的能力值会加上对应任务的权值,完成某个任务的要求是,你的能力值要大于这个任务的a[i],问初始的能力值最小是多大?

//思路:

直接模拟。

#include<stdio.h>
#include<string.h>
#include<algorithm>
#define N 1010
using namespace std;
struct zz
{
	int v;
	int w;
}p[N];
bool cmp(zz a,zz b)
{
	if(a.v==b.v)
		return a.w<b.w;
	return a.v<b.v;
}
int main()
{
	int n,m,i,j,k;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
			scanf("%d%d",&p[i].v,&p[i].w);
		sort(p,p+n,cmp);
		int k=p[0].v,kk=0;
		m=k;
		for(i=1;i<n;i++)
		{
			m+=p[i-1].w;
			if(m<p[i].v)
			{
				kk=p[i].v-m;
				k+=kk;m+=kk;
			}
		}
		printf("%d\n",k);
	}
	return 0;
}

时间: 2024-10-29 19:10:17

周赛题的相关文章

HDU周赛题

Description Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph. There are n toy cars. Each pair collides. The resul

soj 4390 电梯问题

背景:周赛题,当时未读.就算读了也只能想到暴力,不可ac. 学习:1.在暴力搜索超时的情况下,必须找到优秀的算法,这个题就是用类似变化趋势的角度来审视最优解而不是算出每层楼对应的值,找最大值.思路:假设当前楼层以下有n1人,当前楼层有n2人,当前楼层以上有n3人.每向上走一层就有n1+n2人要多走一楼,来 人要少走一楼,若从第0楼开始考虑,这时n1+n2是0,n3为总人数,然后依次上楼,n1+n2单增,n3单减,显然n1+n2>=n3停止上楼即取最大值. 代码: #include <stdio

CSDN 轻松周赛赛题:能否被8整除

轻松周赛赛题:能否被8整除 题目详情 给定一个非负整数,问能否重排它的全部数字,使得重排后的数能被8整除. 输入格式: 多组数据,每组数据是一个非负整数.非负整数的位数不超过10000位. 输出格式 每组数据输出一行,YES或者NO,表示能否重排它的全部数字得到能被8整除的数.注意: 重排可以让0开头. 答题说明 输入样例   610 122 输出样例   YES NO 解释   第一个数可以变为016 , 160 解题:很水的一道题...思路很简单,1000是能被8整除的,所以一千的倍数都能被

2020-3-14 acm训练联盟周赛Preliminaries for Benelux Algorithm Programming Contest 2019 解题报告+补题报告

2020-3-15比赛解题报告+2020-3-8—2020-3-15的补题报告 2020-3-15比赛题解 训练联盟周赛Preliminaries for Benelux Algorithm Programming Contest 2019  A建筑(模拟) 耗时:3ms 244KB 建筑 你哥哥在最近的建筑问题突破大会上获得了一个奖项 并获得了千载难逢的重新设计城市中心的机会 他最喜欢的城市奈梅根.由于城市布局中最引人注目的部分是天际线, 你的兄弟已经开始为他想要北方和东方的天际线画一些想法

SWPU-ACM集训队周赛之组队赛(3-11)G题题解

点这里去做题 水水水水水,不难发现如下表 t 1 2 3 4 v 1 3 5 7 s 1 4 9 16 明显s=t*t 题目中对10000取模即取后四位,即对1000取余 #include<stdio.h> int main() { long long v,T,t,s; scanf("%lld",&T); while(T--) { scanf("%lld",&t); s=t*t; s=s%10000; printf("%lld\

SWPU-ACM集训队周赛之组队赛(3-11) C题题解

点这里去看题 模拟,注意细节 #include<stdio.h> #include<string.h> int main() { int T,n,i,j,ct,q[1010]; //q[]储存正负信息 scanf("%d",&T); while(T--) { char a[1010],b[1010]; memset(q,0,sizeof(q)); scanf("%d",&n); getchar(); //读掉回车(换行符) f

CSDN轻松周赛赛题:能否被8整除

题目意思: 给定一个非负整数,问能否重排它的全部数字,使得重排后的数能被8整除.输入格式:多组数据,每组数据是一个非负整数.非负整数的位数不超过10000位.输出格式每组数据输出一行,YES或者NO,表示能否重排它的全部数字得到能被8整除的数.注意: 重排可以让0开头. 题目分析: 判断一个数是否能够被8整除,只需要判断这个数的后三位是否能够整除8即可,对于此题需要模拟判断所有的后三位数重排的六个数是够被8整除,只是注意一位数和两位数的时候需要自己判断. AC代码: #include<cstdi

SWPU-ACM集训队周赛之组队赛(3-11) E题题解

点这里去做题 %*c  读入时跳过一位,本题中即跳过"-"; #include<stdio.h> int run(int x) //判断闰年 { int f=0; if(x%4==0&&x%100!=0) f=1; if(x%400==0) f=1; return f; } int main() { int y,m,d,sum=0,i,j,k,day=0; int a[12]={31,28,31,30,31,30,31,31,30,31,30,31}; sc

周赛2(星期三之前补题完)

本厂做了3个水体,被略哭 水题1  暴力乱搞 题目: 回文数猜想 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4433    Accepted Submission(s): 2638 Problem Description 一个正整数,如果从左向右读(称之为正序数)和从右向左读(称之为倒序数)是一样的,这样的数就叫回文数.任取一个正