10

Kirill And The Game

 1 year ago
source link: https://codeforces.com/blog/entry/54151
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
By Bakry, history, 5 years ago, In English

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

5 years ago, # |

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".

  • 5 years ago, # ^ |

    Okay Thanks

5 years ago, # |

#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";
    }
}
  • 5 years ago, # ^ |

    Thanks :D

5 years ago, # |

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

If, for at least one value 3f61ce5a2325d3601314c3f34c9af0be4c10ebed.png, 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)

  • 5 years ago, # ^ |

    I didn't learn linear search , is it the reason that I can't solve the problem ?

    • 5 years ago, # ^ |

      Rev. 2  

      0

      Linear search is just loop/search which works in linear time, what to learn here? :D

      • 5 years ago, # ^ |

        Okay , I thought it as binary search that need to learn


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK