Educational Codeforces Round 34 (Rated for Div. 2)

突然沒了方向,數學那塊應該是還有概率的。

開始打cf,不過我都是在白天做的,個人習慣,熬不了夜,可以,兩場下來,掉分很愉快。。。

A:題意:判斷能不能用3和7組成這個數。

暴力測試。

B:題意:遊戲,你的血量h1,攻擊力a1,急救包c1,敵方血量h2,攻擊力a2

問你最少幾回合結束戰鬥,當對方血量爲0或者小於0視爲結束,c1大於a2,所以對方是幹不死你的

思路:模擬即可,當你的血量不足以抵抗對方攻擊並且你一下幹不死對方的時候,就要考慮考慮打急救包了,否則的話就是硬鋼槍了。  超時了n發,到最後發現在判斷的時候寫錯了

C:n個盒子,小盒子可以放進大盒子,問你最少看見幾個盒子

思路:sort一下,可以放進去的全放進去,不能放就暫時放在外面,暴力找找能不能把當前盒子放到後面的盒子裏


A. Hungry Student Problem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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 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
2
6
5
output
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>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define MOD 1000000007
#define N 100005
int main()
{
    int n;
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int flag=0;
        int temp=0;
        if(n%3==0)
        {
            cout<<"YES"<<endl;
            continue;
        }
        while(3*temp<n)
        {
            int gg=n-3*temp;
            if(gg%7==0)
            {
                flag=1;
                break;
            }
            temp++;
        }
        if(flag==1)
            cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

B. The Modcrab
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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 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 c1Vova'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 h1a1c1 (1 ≤ h1, a1 ≤ 1002 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion.

The second line contains two integers h2a2 (1 ≤ h2 ≤ 1001 ≤ 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 100
17 5
output
4
STRIKE
HEAL
STRIKE
STRIKE
input
11 6 100
12 5
output
2
STRIKE
STRIKE
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.

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define MOD 1000000007
#define N 1000005
//char s1[]="HEAL",s2[]="STRIKE";
string map[N];
int h1,a1,c1;
int h2,a2;
int main()
{
    scanf("%d%d%d%d%d",&h1,&a1,&c1,&h2,&a2);
        int num=0;
        while(1)
        {
            if(h2<=0)
                break;
            if(a2>=h1&&h2>a1)
            {
                    map[num++]="HEAL";
                    h1+=c1;
                    h1-=a2;
            }
            else
            {
                map[num++]="STRIKE";
                h2-=a1;
                h1-=a2;
            }

        }
        printf("%d\n",num);
        for(int i=0;i<num;i++)
            cout<<map[i]<<endl;
    return 0;
}

C. Boxes Packing
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 a1a2, ..., 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
3
1 2 3
output
1
input
4
4 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.

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define MOD 1000000007
#define N 10000005
int map[N];
int vis[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&map[i]);
    sort(map,map+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(vis[i])
            continue;
        ans++;
        int temp=map[i];
        vis[i]=1;
        for(int j=i+1;j<n;j++)
        {
            if(vis[j]==0&&temp<map[j])
            {
                vis[j]=1;
                temp=map[j];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章