Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <math.h>
- #include <string>
- #include <deque>
- #include <utility>
- #include <sstream>
- #include <set>
- #include <algorithm>
- #include <numeric>
- #include <list>
- #define FIO ios::sync_with_stdio(0);
- # define NEW(type, count) ((type *)calloc(count, sizeof(type)))
- using namespace std;
- struct sett{int n,m,x,y;};
- int main(){
- //freopen("mosalah.in" , stdin, "r");
- int n;
- cin>>n;
- vector <sett> z(n);
- for (int i=0;i<n;i++){
- cin>>z[i].n>>z[i].m>>z[i].x>>z[i].y;
- }
- for (int i=0;i<n;i++){
- int ans = ((z[i].x+z[i].y)*z[i].n)-z[i].m,curravg,avg;
- if (z[i].m == 0){
- curravg=0;
- }else{
- curravg = z[i].x/z[i].m;
- }
- if (z[i].n == 0){
- avg=0;
- }else{
- avg = (z[i].x+z[i].y)/z[i].n;
- }
- if (z[i].y == 0){
- cout<< -1<<endl;
- }else if (curravg>avg||curravg==avg||ans<=0){
- cout << 0<<endl;
- }
- else{
- cout<<ans<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement