Codeforces Round #232 (Div. 2), problem: (B) On Corruption and Numbers editorial:
Div2-B
First of all, calculate how many L's we can bring so that the result will not exceed N. It's .
Now, if R·K ≥ N we may increase any of K numbers by 1. At some moment sum will be equal to N becase sum of K R's is greater thanN. So answer in this case is YES.
If R·K < N, we can't get K or less numbers because their sum is less than N. But we can't get more than K numbers too, because their sum is more than N. So answer is NO.
Complexity: O(1) for every query.
Overall complexity: O(t).
Overall complexity: O(t).
Codeforces Round #232 (Div. 2), problem: (B) On Corruption and Numbers solution: http://ideone.com/r2fZHe
#include <iostream> #include <cstdio> using namespace std; int main() { int t, n, l, r; scanf("%d", &t); while(t--) { scanf("%d%d%d", &n, &l, &r); if(n%l==0 || n%r==0 || (n%l)%r==0 || (n%r)%l==0) { printf("Yes\n"); continue; } if(r*(n/r+1)>n && l*(n/r+1)<n) { printf("Yes\n"); continue; } printf("No\n"); } return 0; }
No comments:
Post a Comment