Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///http://codeforces.com/contest/1066/problem/A
- #include <iostream>
- using namespace std;
- int main()
- {
- int L, V, a, b;
- int Q;
- cin>>Q;
- for (int i=0; i<Q; i++)
- {
- cin>>L>>V>>a>>b;
- int x = L/V;
- int T = (b-a+1);
- int Tx = 0;
- if ( T >= V ) ///si es mas chico
- {
- Tx = T/V;
- int sobra = T%V; ///me sobran...
- int LPR = b - sobra; ///me paro en la ultima pos del rango de tam multiplo de V
- int falta = V - LPR%V; ///a esa ultima pos le faltan...
- if (sobra >= falta)
- Tx++;
- }
- else
- {
- if ( a <= b-(b%V) )
- Tx++;
- }
- cout<< x-Tx <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment