Nathan Coulas

DMOPC '19 Contest 1 P1 - Test Scores

dmopc19c1p1 CPP17 04 May, 2020 0.320s 5 points

Source Code

#include <bits/stdc++.h>
using namespace std;


int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	long N;
	cin >> N;
	
	long n, a, b, t;
	for(int i = 0; i < N; i++){
		
		cin >> n >> a >> b >> t;
		
		double ans = ceil( 1.0 * (t + b * n) / (a + b));
		if(ans > n){
			cout << "-1\n";
		}else{
			cout << (int)round(ans) << "\n";
		}
		
	}

	return 0;
}