while doing a question i am getting my answer wrong while the sample input and ouput are satisfied .
the link to the problem is :
and the link to the slotuion is i basically want to know the bug in my code:-
https://www.codechef.com/viewsolution/30591924
You put a 100% income tax after 1500000.
Look at your last if statement.
i have corrected my last if even then i am not getting correct answer
here is my code
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–)
{
long long int n,total;
cin>>n;
if(n>=0&&n<=250000)
total=n;
else
if(n>=250001&&n<=500000)
total=n-((250001-n)*0.05);
else
if(n>=500001&&n<=750000)
total=n-((n-500000)*0.1)-12500;
else
if(n>=750001&&n<=1000000)
total=n-((n-750000)*0.15)-37500;
else
if(n>=1000001&&n<=1250000)
total=n-((n-1000000)*0.2)-75000;
else
if(n>=1250001&&n<=1500000)
total=n-((n-1250000)*0.25)-125000;
else
if(n>1500000)
total=n-((n-1500000)*0.3)-187500;
cout<<total<<endl;
}
}
Format your code using
``` above and below your code
"
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–)
{
long long int n,total;
cin>>n;
if(n>=0&&n<=250000)
total=n;
else
if(n>=250001&&n<=500000)
total=n-((250001-n)*0.05);
else
if(n>=500001&&n<=750000)
total=n-((n-500000)*0.1)-12500;
else
if(n>=750001&&n<=1000000)
total=n-((n-750000)*0.15)-37500;
else
if(n>=1000001&&n<=1250000)
total=n-((n-1000000)*0.2)-75000;
else
if(n>=1250001&&n<=1500000)
total=n-((n-1250000)*0.25)-125000;
else
if(n>1500000)
total=n-((n-1500000)*0.3)-187500;
cout<<total<<endl;
}
}
"
I AM NOT GETTING WHAT U WANT TO SAY ???
@everule1 PLZ SEND ME THE BUG IN MY CODE