Find the number of integer solutions satisfying the inequality:
A < B*x + C ≤ D (0 ≤ A, B, C, D ≤ 10¹⁸, B ≠ 0) Find the number of integer solutions satisfying the inequality:
A < B*x + C ≤ D (0 ≤ A, B, C, D ≤ 10¹⁸, B ≠ 0) Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
A < B*x + C ≤ D => (A - C) < B*x ≤ (D - C) => (A - C)/B < x ≤ (D - C)/B => [x - целое] => ⌈(A - C)/B⌉ ≤ x ≤ ⌊(D - C)/B⌋ => #x = max (⌊(D - C)/B⌋ - ⌈(A - C)/B⌉ + 1, 0). @pavel has already described the algorithm for you. If you are interested in java , then I give the option.
//Исходные данные double A = 10.5; double B = 10; double C = 5; double D = 1000; double xleft = Math.ceil((AC)/B); double xright = Math.floor((DC)/B); int xcount = (int)(xright - xleft + 1); if (xcount < 0) xcount = 0; The variant is primitive, but I think should help.
Source: https://ru.stackoverflow.com/questions/577950/
All Articles