题意
h,a,H,A,代表你的血量和攻击力以及毛球怪的血量和攻击力。
求你能杀多少只毛球怪,若你能杀无限只,则输出"-1"。(你先手)
思路
计算你需要打一只毛球怪次他才会死,计算你每杀一只毛球怪所消耗的血量
,由于你先手你所扣的血量为你攻击毛球怪的次数
。
若消耗的血量为0,则输出"-1",否则输出,这里-1是代表给你留了一滴血活到最后。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll maxn = 1e6 + 5;
ll h,a,H,A;
void solve(){
cin>>h>>a>>H>>A;
int k=(H+a-1)/a;
int base=(k-1)*A;
if(base>=h){
cout<<0<<'\n';
}else if(base==0){
cout<<-1<<'\n';
}else{
cout<<(h-1)/base<<'\n';
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T; cin>>T;
while(T--){
solve();
}
return 0;
}
京公网安备 11010502036488号