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 »

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 »

what happens when m=1?

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

Post by emotional blind »

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 »

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 »

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 »

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 »

The answer of "51 50" is 99 ?

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

Post by emotional blind »

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 »

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
Location: Bangladesh
Contact:

Post by emotional blind »

Yes it is.

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

Post 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.
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
Location: Bangladesh
Contact:

Post by emotional blind »

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! »

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 »

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 »

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

Post Reply

Return to “Volume 112 (11200-11299)”