Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define IN "a.in"
- #define OUT "a.out"
- //#define fin cin
- //#define fout cout
- using namespace std;
- ifstream fin ( IN ) ;
- ofstream fout ( OUT ) ;
- int main()
- {
- long long a , b , n ;
- fin >> a >> b >> n ;
- for ( register int i = 1 ; i <= n ; ++ i ){
- long long l , t , m ;
- fin >> l >> t >> m ;
- long long st = 1 ;
- long long dr = 2000000 ;
- long long ans = -1 ;
- while ( st <= dr ) {
- long long mij = ( st + dr ) / 2 ;
- long long lb = l ;
- long long ub = mij ;
- if ( a + ( mij - 1 ) * b <= t and ( ub - lb + 1 ) * a + ( ( ( ub - 1 ) * ub ) / 2 - ( ( lb - 1 ) * ( lb - 2 ) ) / 2 ) * b <= m * t ){
- ans = mij ;
- st = mij + 1 ;
- }
- else dr = mij - 1 ;
- }
- fout << ans << '\n' ;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement