697A:Pineapple Incident

Правка en1, от Aditya_Dave, 2024-12-24 06:55:49

697A - Pineapple Incident ==============: In this question, we are told that the pineapple barks at t, t+s, t+s+1, and so on. One way is to check for each and every multiple of s by applying a for loop, but it will be too lengthy and time consuming. Another way is:

if t+n*s=x or t+n*s+1=x,(where n is any natural number), then it can be clearly seen that (x-t) or (x-t-1) is divisible by s. But here we need to be careful when t>x. This will be our edge case. If t>x, then the pineapple will not bark at the time x. So we can clearly output NO as our answer. If this condition (x-t)%s==0 || ((x-t-1)%s==0 && (x-t-1)/s!=0) satisfies, then we can clearly print YES, else we can print NO. 298127756

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Aditya_Dave 2024-12-24 06:55:49 727 Initial revision (published)