Educational Codeforces Round 34 (Rated for Div. 2)日常训练

A. Hungry Student Problem

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Ivan’s classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.

CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken.

Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks.

Help Ivan to answer this question for several values of x!

Input
The first line contains one integer n (1 ≤ n ≤ 100) — the number of testcases.

The i-th of the following n lines contains one integer x i (1 ≤ x i ≤ 100) — the number of chicken chunks Ivan wants to eat.

Output
Print n lines, in i-th line output YES if Ivan can buy exactly x i chunks. Otherwise, print NO.

Example
inputCopy
2
6
5
outputCopy
YES
NO
Note
In the first example Ivan can buy two small portions.

In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much

#include<iostream>
using namespace std;
int a,b,m,n,i,j,k,t;
bool f;
int main(){
	cin>>t;
	while(t--){
		cin>>n;
		f=false;
		for(i=0;i<=n/7;i++){
			if((n-i*7)%3==0) f=true;
		}
		if (f) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
} 

思路

水题,数据量也不大,随便搞搞就好。

B. The Modcrab

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Vova is again playing some computer game, now an RPG. In the game Vova’s character received a quest: to slay the fearsome monster called Modcrab.

After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h 2 health points and an attack power of a 2. Knowing that, Vova has decided to buy a lot of strong healing potions and to prepare for battle.

Vova’s character has h 1 health points and an attack power of a 1. Also he has a large supply of healing potions, each of which increases his current amount of health points by c 1 when Vova drinks a potion. All potions are identical to each other. It is guaranteed that c 1 > a 2.

The battle consists of multiple phases. In the beginning of each phase, Vova can either attack the monster (thus reducing its health by a 1) or drink a healing potion (it increases Vova’s health by c 1; Vova’s health can exceed h 1). Then, if the battle is not over yet, the Modcrab attacks Vova, reducing his health by a 2. The battle ends when Vova’s (or Modcrab’s) health drops to 0 or lower. It is possible that the battle ends in a middle of a phase after Vova’s attack.

Of course, Vova wants to win the fight. But also he wants to do it as fast as possible. So he wants to make up a strategy that will allow him to win the fight after the minimum possible number of phases.

Help Vova to make up a strategy! You may assume that Vova never runs out of healing potions, and that he can always win.

Input
The first line contains three integers h 1, a 1, c 1 (1 ≤ h 1, a 1 ≤ 100, 2 ≤ c 1 ≤ 100) — Vova’s health, Vova’s attack power and the healing power of a potion.

The second line contains two integers h 2, a 2 (1 ≤ h 2 ≤ 100, 1 ≤ a 2 < c 1) — the Modcrab’s health and his attack power.

Output
In the first line print one integer n denoting the minimum number of phases required to win the battle.

Then print n lines. i-th line must be equal to HEAL if Vova drinks a potion in i-th phase, or STRIKE if he attacks the Modcrab.

The strategy must be valid: Vova’s character must not be defeated before slaying the Modcrab, and the monster’s health must be 0 or lower after Vova’s last action.

If there are multiple optimal solutions, print any of them.

Examples
inputCopy
10 6 100
17 5
outputCopy
4
STRIKE
HEAL
STRIKE
STRIKE
inputCopy
11 6 100
12 5
outputCopy
2
STRIKE
STRIKE

#include<iostream>
using namespace std;
int h1,a1,c1,h2,a2,hp,hm,i,j,k,t,n,m;
int a[100000];
int main(){
	cin>>h1>>a1>>c1;
	cin>>h2>>a2;
	k=0;
	hp=h1;hm=h2;
	while(hm>0){
		k=k+1;
		if(hp<=a2&&a1<hm){
			a[k]=2;
			hp=hp+c1-a2;
		}
		else{
			a[k]=1;
			hm=hm-a1;
			if(hm<=0) break;
			hp=hp-a2;
		}
	}
	cout<<k<<endl;
	for(i=1;i<=k;i++){
		if (a[i]==1) cout<<"STRIKE"<<endl;
		if (a[i]==2) cout<<"HEAL"<<endl;
	}
	return 0;
}

思路

贪心,能打就打。一开始判断条件漏了血不够但是可以先一拳打死,查了好久。。。

C. Boxes Packing

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length a i.

Mishka can put a box i into another box j if the following conditions are met:

i-th box is not put into another box;
j-th box doesn’t contain any other boxes;
box i is smaller than box j ( a i < a j).
Mishka can put boxes into each other an arbitrary number of times. He wants to minimize the number of visible boxes. A box is called visible iff it is not put into some another box.

Help Mishka to determine the minimum possible number of visible boxes!

Input
The first line contains one integer n (1 ≤ n ≤ 5000) — the number of boxes Mishka has got.

The second line contains n integers a 1, a 2, …, a n (1 ≤ a i ≤ 109), where a i is the side length of i-th box.

Output
Print the minimum possible number of visible boxes.

Examples
inputCopy
3
1 2 3
outputCopy
1
inputCopy
4
4 2 4 3
outputCopy
2
Note
In the first example it is possible to put box 1 into box 2, and 2 into 3.

In the second example Mishka can put box 2 into box 3, and box 4 into box 1.

#include<iostream>
#include<algorithm>
using namespace std;
int t,a,i,j,m,n,ans;
int b[100000];
int main(){
	cin>>n;
	ans=0;
	for(i=1;i<=n;i++){
		cin>>b[i];
    }
    sort(b+1, b+1+n);
    i = 1;
    while(i<=n) {
        int num=1;
        while(i<n&&b[i]==b[i+1]) {
            i++;
            num++;
        }
        ans=max(ans,num);
        i++;
    }
	cout<<ans<<endl;
}

思路

只有一样大的不可以合并,其他情况都可以套娃。

后记

开的clone,没写出四题要反思。(最后半小时才开始看D,还没啥思路)

下周很忙,咕咕咕。
博主要一周速成微机了。加油。
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值