11247 - Income Tax

All about problems in Volume 112. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

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

11247 - Income Tax

Post by hamedv » Sun Jul 29, 2007 7:21 am

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:

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo » Sun Jul 29, 2007 7:40 am

what happens when m=1?

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

Post by emotional blind » Sun Jul 29, 2007 7:42 am

Think about x=0

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

Post by hamedv » Sun Jul 29, 2007 7:52 am

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?

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

Post by hamedv » Sun Jul 29, 2007 7:55 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)
			puts("Not found");
		else
		{
			if ((m-1)*100/(100-x))
				printf("%lld\n", (m-1)*100/(100-x));
			else
				puts("Not found");
		}
	}
	return 0;
}

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo » Sun Jul 29, 2007 8:04 am

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

Post by Wei-Ming Chen » Sun Jul 29, 2007 8:34 am

The answer of "51 50" is 99 ?

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

Post by emotional blind » Sun Jul 29, 2007 8:35 am

yes it is. :lol:

Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Post by Wei-Ming Chen » Sun Jul 29, 2007 8:40 am

And now I am wondering why WA.. :-?

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

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

Post by emotional blind » Sun Jul 29, 2007 8:43 am

Yes it is.

hi!man!
New poster
Posts: 48
Joined: Fri Dec 29, 2006 1:26 pm

Post by hi!man! » Sun Jul 29, 2007 9:06 am

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.

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

Post by emotional blind » Sun Jul 29, 2007 9:09 am

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

Post by hi!man! » Sun Jul 29, 2007 9:16 am

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

Post by august » Sun Jul 29, 2007 9:30 am

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 ??

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo » Sun Jul 29, 2007 9:37 am

even if v==m, the solution v is still valid.

Post Reply

Return to “Volume 112 (11200-11299)”