1633C - Kill the Monster - CodeForces Solution


brute force math *1100

Please click on ads to support us..

Python Code:

I = lambda: map(int, input().split())
for _ in range(int(input())):
    hc,dc=I()
    hm,dm=I()
    k,w,a=I()
    ff=0
    for i in range(k+1):
        minmod=(dc+(k-i)*w+hm-1)//(dc+(k-i)*w)
        maxhc=(hc+i*a+dm-1)//dm
        if maxhc>=minmod:
            ff=1
            break
    print('yneos'[int(ff==0)::2])

C++ Code:

#include <bits/stdc++.h>
using namespace std;
#define easy_love ios::sync_with_stdio(0), cin.tie(nullptr)
#define endl '\n'
#define int long long
#define ar array<int, 2>
#define arr array<int, 3>
int T, n, m, k, inf = 1e18;
int mod = 998244353; //1e9+7;
const int N = 201314;

signed main()
{
    easy_love;
#ifdef DEBUG
    freopen("../1.in", "r", stdin);
#endif
    // 挺费劲的。。
    // 就是 每次升级。。可以用加攻击力 w 或者加护甲a。。。
    // 升级k次。。
    // 问 能否打死怪兽。。。轮流
    // 增加护甲相当于减少怪兽的攻击力。。
    // k是可以枚举的。。
    // 我们可以枚举 k不同分配下的情况。。。
    cin >> T;
    while (T--)
    {
        ar a, b;
        cin >> a[0] >> a[1];
        cin >> b[0] >> b[1];
        cin >> k >> n >> m;
        bool f = 0;
        for (int i = 0; i <= k; ++i)
        {
            int x = a[1] + i * n, y = a[0] + m * (k - i);
            if ((b[0] + x - 1) / x <= (y + b[1] - 1) / b[1])
            {
                f = 1;
                break;
            }
        }
        cout << (f ? "YES" : "NO") << endl;
    }
};


Comments

Submit
0 Comments
More Questions

Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches
HRDSEQ Hard Sequence
DRCHEF Doctor Chef
559. Maximum Depth of N-ary Tree
821. Shortest Distance to a Character
1441. Build an Array With Stack Operations