Educational Codeforces Round 100 (Rated for Div. 2)

22 篇文章 0 订阅

好久没有打比赛了,,,,,gggggggg

A. Dungeon

time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are playing a new computer game in which you have to fight monsters. In a dungeon you are trying to clear, you met three monsters; the first of them has a health points, the second has b health points, and the third has c.

To kill the monsters, you can use a cannon that, when fired, deals 1 damage to the selected monster. Every 7-th (i. e. shots with numbers 7, 14, 21 etc.) cannon shot is enhanced and deals 1 damage to all monsters, not just one of them. If some monster’s current amount of health points is 0, it can’t be targeted by a regular shot and does not receive damage from an enhanced shot.

You want to pass the dungeon beautifully, i. e., kill all the monsters with the same enhanced shot (i. e. after some enhanced shot, the health points of each of the monsters should become equal to 0 for the first time). Each shot must hit a monster, i. e. each shot deals damage to at least one monster.

Input
The first line contains a single integer t (1≤t≤104) — the number of test cases.

Each test case consists of a single line that contains three integers a, b and c (1≤a,b,c≤108) — the number of health points each monster has.

Output
For each test case, print YES if you can kill all the monsters with the same enhanced shot. Otherwise, print NO. You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answer).

Example
inputCopy
3
3 2 4
1 1 1
10 1 7
outputCopy
YES
NO
NO
Note
In the first test case, you can do as follows: 1-th shot to the first monster, 2-th shot to the second monster, 3-th shot to the third monster, 4-th shot to the first monster, 5-th shot to the third monster, 6-th shot to the third monster, and 7-th enhanced shot will kill all the monsters.

In the second test case, you can’t kill monsters with the same enhanced shot, because the total number of health points of monsters is 3, and you will kill them in the first 3 shots.

题目大意:
三只怪物,每只怪物分别由a、b、c的血量,每次对某一只怪物造成一点伤害,第7、14、21等等可以对三只怪物同时造成一点伤害,问能否在某一次7、14这样的打击中击败全部怪物

#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

/*
前六轮造成六点伤害  第七次造成三点伤害
一个完整的7-th 造成九点伤害 
*/

int main(int argc,char* argv[])  {
	int T,a,b,c;
	cin >> T;
	while(T--) {
		cin >> a >> b >> c;
		if((a + b + c) % 9 == 00 && min(a,min(b,c)) >= (a + b + c) / 9) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	// 注意严格大于等于	
	return 0;
}

B. Find The Array

time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are given an array [a1,a2,…,an] such that 1≤ai≤109. Let S be the sum of all elements of the array a.

Let’s call an array b of n integers beautiful if:

1≤bi≤109 for each i from 1 to n;
for every pair of adjacent integers from the array (bi,bi+1), either bi divides bi+1, or bi+1 divides bi (or both);
2∑i=1n|ai−bi|≤S.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.

Input
The first line contains one integer t (1≤t≤1000) — the number of test cases.

Each test case consists of two lines. The first line contains one integer n (2≤n≤50).

The second line contains n integers a1,a2,…,an (1≤ai≤109).

Output
For each test case, print the beautiful array b1,b2,…,bn (1≤bi≤109) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.

Example
inputCopy
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
outputCopy
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3

#include<iostream>
#include<cstring>
#include<cstdio>
//不开 long long 居然会挂掉
using namespace std;
int a[100],b[100];
int main(int argc,char* argv[])  {
	int T,n;
	long long sum,s;
	cin >> T;
	while(T--) {
		cin >> n;
		sum = 0,s = 0;
		for(int i=1; i<=n; i++){
			cin >> a[i],sum += a[i];
			if(i & 1) b[i] = 1;
			else b[i] = a[i];
		}
		for(int i=1; i<=n; i++) s += abs(b[i] - a[i]);
		if(s * 2 <= sum) {
			for(int i=1; i<=n; i++) cout << b[i] << ' ';
			cout << endl;
		}
		else {
			for(int i=1; i<=n; i++)
				if(i & 1) cout << a[i] << ' ';
				else cout << 1 << ' ';
			cout << endl;
		}
	}
	
	
	
	return 0;
}

C. Busy Robot

time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
You have a robot that can move along a number line. At time moment 0 it stands at point 0.

You give n commands to the robot: at time ti seconds you command the robot to go to point xi. Whenever the robot receives a command, it starts moving towards the point xi with the speed of 1 unit per second, and he stops when he reaches that point. However, while the robot is moving, it ignores all the other commands that you give him.

For example, suppose you give three commands to the robot: at time 1 move to point 5, at time 3 move to point 0 and at time 6 move to point 4. Then the robot stands at 0 until time 1, then starts moving towards 5, ignores the second command, reaches 5 at time 6 and immediately starts moving to 4 to execute the third command. At time 7 it reaches 4 and stops there.

You call the command i successful, if there is a time moment in the range [ti,ti+1] (i. e. after you give this command and before you give another one, both bounds inclusive; we consider tn+1=+∞) when the robot is at point xi. Count the number of successful commands. Note that it is possible that an ignored command is successful.

Input
The first line contains a single integer t (1≤t≤1000) — the number of test cases. The next lines describe the test cases.

The first line of a test case contains a single integer n (1≤n≤105) — the number of commands.

The next n lines describe the commands. The i-th of these lines contains two integers ti and xi (1≤ti≤109, −109≤xi≤109) — the time and the point of the i-th command.

The commands are ordered by time, that is, ti<ti+1 for all possible i.

The sum of n over test cases does not exceed 105.

Output
For each testcase output a single integer — the number of successful commands.

Example
inputCopy
8
3
1 5
3 0
6 4
3
1 5
2 4
10 -5
5
2 -5
3 1
4 1
5 1
6 1
4
3 3
5 -3
9 2
12 0
8
1 1
2 -6
7 2
8 3
12 -9
14 2
18 -1
23 9
5
1 -4
4 -7
6 -1
7 -3
8 -7
2
1 2
2 -2
6
3 10
5 5
8 0
12 -4
14 -7
19 -5
outputCopy
1
2
0
2
1
1
0
2

题目大意:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七情六欲·

学生党不容易~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值