Page 1 of 4
11247 - Income Tax
Posted: Sun Jul 29, 2007 7:21 am
by hamedv
What's wrong with my code???
Code: Select all
#include <stdio.h>
long long int m, x;
int main()
{
while (scanf("%lld %lld", &m, &x), x||m)
if (x == 100)
puts("Not found");
else
printf("%lld\n", (m-1)*100/(100-x));
return 0;
}
![:cry:](./images/smilies/icon_cry.gif)
Posted: Sun Jul 29, 2007 7:40 am
by sclo
what happens when m=1?
Posted: Sun Jul 29, 2007 7:42 am
by emotional blind
Think about x=0
and think about the following input
Posted: Sun Jul 29, 2007 7:52 am
by hamedv
i think for x = 0 the answer should be 'Not found'
and for x = 50 && m = 51 the answer should be '100'
and when m = 1 the answer should be 'Not found'
But my code got WA?
Posted: Sun Jul 29, 2007 7:55 am
by hamedv
here's my code
Code: Select all
#include <stdio.h>
long long int m, x;
int main()
{
while (scanf("%lld %lld", &m, &x), x||m)
{
if (x == 100 || x == 0 || m == 1)
puts("Not found");
else
{
if ((m-1)*100/(100-x))
printf("%lld\n", (m-1)*100/(100-x));
else
puts("Not found");
}
}
return 0;
}
Posted: Sun Jul 29, 2007 8:04 am
by sclo
Not quite.
I'll rephrase the question:
Find the maximum integer v such that v>=m and v*(1-x/100)<m-1 if possible
Posted: Sun Jul 29, 2007 8:34 am
by Wei-Ming Chen
The answer of "51 50" is 99 ?
Posted: Sun Jul 29, 2007 8:35 am
by emotional blind
yes it is.
![:lol:](./images/smilies/icon_lol.gif)
Posted: Sun Jul 29, 2007 8:40 am
by Wei-Ming Chen
And now I am wondering why WA..
If the input is "80 20", output is 98?
Posted: Sun Jul 29, 2007 8:43 am
by emotional blind
Yes it is.
Posted: Sun Jul 29, 2007 9:06 am
by hi!man!
I also get WA too...
I checked above test cases but they are correct.
Here is my code.
PS.here n means v in problem statement.
EDIT: code is at next 2 posts.
Posted: Sun Jul 29, 2007 9:09 am
by emotional blind
Using double is not good approach for this problem..
try to avoid double
Posted: Sun Jul 29, 2007 9:16 am
by hi!man!
removed double but still WA
here is my code:
EDIT: ACCEPTED
![:)](./images/smilies/icon_smile.gif)
This is my code
Posted: Sun Jul 29, 2007 9:30 am
by august
this is my code ,but get WA ,i don't know what's more conditions i didn't think about
Code: Select all
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
long double m,x;
long double dal;
long long v;
while (cin>>m>>x)
{
if (m==0&&x==0)
break;
if (x==100||m==1||x==0)
{
printf("Not found\n");
continue;
}
dal = 1 - x/100.0;
v = (int)((m-1)/dal-1E-6);
if (v<m)
{
printf("Not found\n");
}
else
{
cout<<v<<endl;
}
}
return 0;
}
what's wrong in it ??
Posted: Sun Jul 29, 2007 9:37 am
by sclo
even if v==m, the solution v is still valid.