Educational Codeforces Round 34 (Rated for Div. 2) ABC

A. Hungry Student Problem

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 xi (1 ≤ xi ≤ 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 xi chunks. Otherwise, print NO.

Example

input

265

output

YESNO

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.

求是否存在3X+7Y=x ,存在就是YES,否则就是NO,由于数字很小就可以通过暴力。当数字很大时就需要用到逆元了。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main() {
 4     int n;
 5     cin >> n;
 6     while(n--) {
 7         int x;
 8         cin >> x;
 9         bool flag = false;
10         for(int i = 0; i < 33; i ++) {
11             for(int j = 0; j < 15; j ++) {
12                 if(3*i + 7*j == x) flag = true;
13             }
14         }
15         if(flag) printf("YES\n");
16         else printf("NO\n");
17     }
18     return 0;
19 }

B. The Modcrab

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 h2 health points and an attack power of a2. Knowing that, Vova has decided to buy a lot of strong healing potions and to prepare for battle.

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

The battle consists of multiple phases. In the beginning of each phase, Vova can either attack the monster (thus reducing its health by a1) or drink a healing potion (it increases Vova‘s health by c1; Vova‘s health can exceed h1). Then, if the battle is not over yet, the Modcrab attacks Vova, reducing his health by a2. 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 h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova‘s health, Vova‘s attack power and the healing power of a potion.

The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 < c1) — 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

input

10 6 10017 5

output

4STRIKEHEALSTRIKESTRIKE

input

11 6 10012 5

output

2STRIKESTRIKE

Note

In the first example Vova‘s character must heal before or after his first attack. Otherwise his health will drop to zero in 2 phases while he needs 3 strikes to win.

In the second example no healing needed, two strikes are enough to get monster to zero health and win with 6 health left.

攻打妖怪,妖怪血量是h2,攻击是a2,  我的血量是h1,攻击是a1,恢复药水是c1

如果当前的攻击力大于妖怪的血量时就可以直接打死,否则就一步一步的模拟下去,

当前的血量大于妖怪的攻击并且被攻击后加的C1要大于妖怪的攻击力就可以攻击妖怪

否则就要加血。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int a[6], b[6];
 4 int main() {
 5     for(int i = 1; i <= 5; i ++) {
 6         cin >> a[i];
 7         b[i] = a[i];
 8     }
 9     int ans = 0;
10     while(a[4] > 0) {
11         if(a[1] > a[5] && (a[1]-a[5]+a[3]) > a[5] || a[2] >= a[4]) a[4] -= a[2];
12         else a[1] += a[3];
13         a[1] -= a[5];
14         ans ++;
15     }
16     printf("%d\n",ans);
17     while(b[4] > 0) {
18         if(b[1] > b[5] && (b[1]-b[5]+b[3]) > b[5] || b[2] >= b[4]) {
19             b[4] -= b[2];
20             printf("STRIKE\n");
21         } else {
22             b[1] += b[3];
23             printf("HEAL\n");
24         }
25         b[1] -= b[5];
26         ans ++;
27     }
28     return 0;
29 }

C. Boxes Packing

Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai.

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 (ai < aj).

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 a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the side length of i-th box.

Output

Print the minimum possible number of visible boxes.

Examples

input

31 2 3

output

1

input

44 2 4 3

output

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.

大箱套小箱,求最少的可见箱子,就是求那个数字出现的次数最多。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 map<int, int> mp;
 4 int main() {
 5     int n, x;
 6     cin >> n;
 7     for(int i = 0; i < n; i ++) {
 8         cin >> x;
 9         mp[x] ++;
10     }
11     int MAX = 0;
12     map<int, int> :: iterator it = mp.begin();
13     for(; it != mp.end(); ++ it) {
14         if(MAX < (*it).second) {
15             MAX = (*it).second;
16         }
17     }
18     cout << MAX << endl;
19     return 0;
20 }

原文地址:https://www.cnblogs.com/xingkongyihao/p/8150153.html

时间: 2024-08-30 17:39:48

Educational Codeforces Round 34 (Rated for Div. 2) ABC的相关文章

Educational Codeforces Round 34 (Rated for Div. 2) D. Almost Difference[数据结构]

题意:求一个数列中所有的绝对值差大于2的数,并用后面的数字减前面的数字的加和. 分析:可以用树状数组每次找前面的差值大于2的数,也可以直接每次加前面所有的数字,再减去差值为1的数字.题目最坑爹的是答案也许会爆long long,可以用long double或者使用unsigned long long手动模拟符号位,或者用python C++代码: 1 #define _CRT_SECURE_NO_DEPRECATE 2 #pragma comment(linker, "/STACK:102400

Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】

B. The Modcrab 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

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers

原文链接:https://www.cnblogs.com/xwl3109377858/p/11404050.html Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburg

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 36 (Rated for Div. 2) 题解

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w

Educational Codeforces Round 55 (Rated for Div. 2)

Educational Codeforces Round 55 (Rated for Div. 2) 链接 A Vasya and Book 傻逼题..注意判边界. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<cm