Блог пользователя Bakry

Автор Bakry, история, 7 лет назад, По-английски

I want to Know what's the answer for this Problem And What's the technique to solve with ? http://codeforces.com/contest/842/problem/A

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Just make a for loop from l to r, i for example. Then you should check if i / k is between x and y and also if i / k is an integer (people who didnt check this were hacked). If this statement will be true at least once then answer is "YES", otherwise "NO".

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll l, r, x, y, k;
    while(cin >> l >> r >> x >> y >> k)
    {
        for(ll i = x; i <= y; i++)
        {
            if(k * i >= l && k * i <= r)
            {
                cout << "YES\n";
                return 0;
            }
        }
        cout << "NO\n";
    }
}

»
7 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

A simple linear search in [x, y] (the given range for the cost)

If, for at least one value , i * k (where k is the efficiency required) lies in the range of the experience ie. [l, r], the answer is "YES" otherwise "NO". Time complexity of this solution is O(y - x)