[SP49 HAREFOX - Hares and Foxes]
(https://www.spoj.com/problems/HAREFOX/11)
I encountered some difficulties in solving this problem. My code can pass the example, but I can’t get AC.
This is my code. Who can help me?
Thank you for your reading and help.
#include<bits/stdc++.h>
using namespace std;
long double n,a,b,c,d,h,f,hy,fy;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
scanf("%llf%llf%llf%llf%llf%llf",&a,&b,&c,&d,&h,&f);
hy=h,fy=f;
hy=a*h-b*f,fy=c*f+d*h;
if(hy==fy) cout<<"Ecological balance will develop."<<endl;
else if(hy<0&&fy>0) cout<<"Hares will die out while foxes will overgrow."<<endl;
else if(hy>0&&fy<0) cout<<"Hares will overgrow while foxes will die out."<<endl;
else if(hy<0&&fy<0) cout<<"Both hares and foxes will die out."<<endl;
else if(hy>0&&fy>0) cout<<"Both hares and foxes will overgrow."<<endl;
else cout<<"Chaos will develop."<<endl;
}
return 0;
}
Sample input:
2
2 0.5
0.5 0.6
2 3
0.1 1
2 0.1
1 1
Sample output:
Both hares and foxes will overgrow.
Hares will die out while foxes will overgrow.
created
last reply
- 1
reply
- 529
views
- 2
users
- 1
like
- 1
link