ran_by_Dipz's blog

By ran_by_Dipz, 82 minutes ago, In English

Hey everyone,

While solving Problem A (A Number Between Two Others), I noticed a lot of solutions get caught up thinking about prime factors or trying to construct specific test values for $$$z$$$.

Turns out, the entire problem collapses into a single inequality.

The Shortcut

Let $$$y = k \cdot x$$$. Since $$$y$$$ is divisible by $$$x$$$, $$$k \ge 2$$$.

We need a multiple of $$$x$$$, say $$$z = m \cdot x$$$, that lies between $$$x$$$ and $$$y$$$ and does not divide $$$y$$$.

This just means finding an integer $$$m$$$ between $$$1$$$ and $$$k$$$ where $$$k$$$ is not divisible by $$$m$$$:

  • If $$$k = 2$$$: No integer exists strictly between $$$1$$$ and $$$2$$$ $$$\to$$$ NO.

  • If $$$k \ge 3$$$: Always possible $$$\to$$$ YES.

So the answer is YES if and only if $$$k \gt 2$$$, which simply means: b - a > a (or b > 2 * a).

Code

```cpp
   #include <bits/stdc++.h>
   using namespace std;
   #define ll long long

   void solve(){
       ll a,b;
       cin>>a>>b;
       cout<<(b-a>a ? "YES\n" : "NO\n");
   }

   int main() {
       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
       int t;
       cin>>t;
       while (t--) solve();
       return 0;
   }
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
58 minutes ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

k >= 3 works because We can always find a number z = (k-1)*x which is never divisible by y = k*x because k % (k-1) != 0 for k >= 3.

  • »
    »
    20 minutes ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Yaaa