## 11247 - Income Tax

Moderator: Board moderators

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am

### 11247 - Income Tax

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)
else
printf("%lld\n", (m-1)*100/(100-x));
return 0;
}
``````

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Contact:
what happens when m=1?

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:

and think about the following input

Code: Select all

``````51 50
0 0``````

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am
and for x = 50 && m = 51 the answer should be '100'
But my code got WA?

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am
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)
else
{
if ((m-1)*100/(100-x))
printf("%lld\n", (m-1)*100/(100-x));
else
}
}
return 0;
}
``````

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Contact:
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

Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan
The answer of "51 50" is 99 ?

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:
yes it is.

Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan
And now I am wondering why WA..

If the input is "80 20", output is 98?

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:
Yes it is.

hi!man!
New poster
Posts: 48
Joined: Fri Dec 29, 2006 1:26 pm
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.
Last edited by hi!man! on Sun Jul 29, 2007 9:34 am, edited 1 time in total.

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:
Using double is not good approach for this problem..
try to avoid double

hi!man!
New poster
Posts: 48
Joined: Fri Dec 29, 2006 1:26 pm
removed double but still WA

here is my code:
EDIT: ACCEPTED
Last edited by hi!man! on Sun Jul 29, 2007 10:25 am, edited 1 time in total.

august
New poster
Posts: 1
Joined: Sun Jul 29, 2007 9:17 am
Location: China

### This is my code

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)
{
continue;
}
dal = 1 - x/100.0;
v = (int)((m-1)/dal-1E-6);
if (v<m)
{
}
else
{
cout<<v<<endl;
}
}
return 0;
}

``````
what's wrong in it ??

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm