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

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

Post by emotional blind » Mon Aug 06, 2007 6:02 am

change this line:

Code: Select all

int t = 100*(m-1); 
to

Code: Select all

long long t = (long long)100*(m-1); 
and remove your code after getting accepted.

sapnil
Experienced poster
Posts: 106
Joined: Thu Apr 26, 2007 2:40 pm
Location: CSE-SUST
Contact:

WR Help

Post by sapnil » Thu Aug 16, 2007 8:02 am

I get too many WR.
plz help.........
Here my code

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main()
{
long long num,Per,tnum,limit;
long long tax,after_tax,Diff,Add,res;

while(scanf("%lld %lld",&num,&Per)==2)
{
if(num==0 && Per==0)
{
break;
}

if(Per==0 || Per==100 || num==1)
{
printf("Not found\n");
continue;
}

tnum=num;

limit=num-1;
limit=limit*100;
limit=limit-1;

num=num*100;

tax=(Per*num)/100;
after_tax=num-tax;

Diff=limit-after_tax;

Add=Diff/(100-Per);

res=tnum+Add;

if(res>=tnum)
{
printf("%lld\n",res);
}
else
{
printf("Not found\n");
}
}

return 0;
}

Mohsin Reza Razib
New poster
Posts: 12
Joined: Fri Dec 15, 2006 12:57 pm
Location: Dhaka, Bangladesh
Contact:

Post by Mohsin Reza Razib » Thu Aug 16, 2007 6:18 pm

As far as i understand from the problem statement v is as,
(v-v*(x/100))<m and in my algorithm i used the maximum value for v as
v<m/(1-(x/100)) and here is my code. It gives output for 51 50 as 98, 100 67 as 299, 51 2 as 51, 2 99 as 99 and for (x==0||x==100||m==1) as 'Not found'. Some pls help me to understand why i am getting WA.
javascript:emoticon('')

I changed double and
used long long and got accepted.
__javascript:emoticon(':lol:')_______________

Someone plz tell me the range of long int and long long int. What is the difference? What is the output of 1000000001 99? Is n't it 99999999999? How can i get this output using long long int for this problem. If i couldn't then how i got accepted? I am confused.javascript:emoticon(':o')

How can i use 64 bit int. (__intd4,scanf("%I64d",&x)) is getting compile error? If i can't use 64 bit int then how can i solve problem that require data like 1234567890123. Is there any data type?
Mohsin
Last edited by Mohsin Reza Razib on Thu Aug 16, 2007 8:21 pm, edited 1 time in total.
Mohsin Reza
"The tragedy of life does not lie in not reaching your goal. The tragedy lies in having no goal to reach".- Benajamin Mays

ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
Location: buet, dhaka, bangladesh

Post by ayon » Thu Aug 16, 2007 8:12 pm

correct assumption is (v-v*(x/100))<m-1
using double may give precision error
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program

chinmoy kanti dhar
New poster
Posts: 19
Joined: Fri Jun 22, 2007 6:17 pm
Location: bangladesh

TLE

Post by chinmoy kanti dhar » Fri Aug 17, 2007 12:56 am

help me plz.how can i solve it within the time limit....

Code: Select all

#include<stdio.h>
#include<string.h>
#include<math.h>

void main()
{
long i,j,p,a,sum;
double n,b,m,k;
while(scanf("%ld %lf",&a,&b)==2)
{
if(a==0&&b==0)break;
if(b==0||b==1||b==100){printf("Not found\n");continue;}

p=0;
for(i=a;;i++)
{
m=double(i);
n=i*b/100;k=m-((i-1)*b/100);
if((m-n)>=a-1)break;
if(k<m-n){p=1;break;}
//printf("%ld  = %lf\n",i,m-n);
}
		if(p==1){printf("Not found\n");continue;}
printf("%ld\n",i-1);


}
}



Mohsin Reza Razib
New poster
Posts: 12
Joined: Fri Dec 15, 2006 12:57 pm
Location: Dhaka, Bangladesh
Contact:

Post by Mohsin Reza Razib » Fri Aug 17, 2007 6:45 am

chinmoy. you dont,t have a upper limit for v, it is (v-v*(x/100))<m-1, and
check if v<m/(1-(x/100)). And don't use double, use long long int. Try to use a specific upperlimit.
Mohsin Reza
"The tragedy of life does not lie in not reaching your goal. The tragedy lies in having no goal to reach".- Benajamin Mays

chinmoy kanti dhar
New poster
Posts: 19
Joined: Fri Jun 22, 2007 6:17 pm
Location: bangladesh

Post by chinmoy kanti dhar » Fri Aug 17, 2007 7:22 pm

Thanks mohsin for reply. I have modified my code but still I am getting tle.help plz

Code: Select all

#include<stdio.h>
#include<string.h>
#include<math.h>

void main()
{
long i,j,p,a,sm;
double n,b,m,k;
while(scanf("%ld %lf",&a,&b)==2)
{
if(a==0&&b==0)break;
if(b==0||b==1||b==100){printf("Not found\n");continue;}

p=1;
k=(a-1)*100/(100-b);
sm=ceil(k);
for(i=sm;i>=a;i--)
{
m=double(i);
n=i*b/100;
if((m-n)>=a-1){p=0;break;}
}
			
if(p==1){printf("Not found\n");continue;}
printf("%ld\n",i-1);

}
}

Mohsin Reza Razib
New poster
Posts: 12
Joined: Fri Dec 15, 2006 12:57 pm
Location: Dhaka, Bangladesh
Contact:

Post by Mohsin Reza Razib » Fri Aug 17, 2007 7:36 pm

read the problem again. b in your code is always integer. Just avoid double completely and use long long int. Using double in this problem may result in prcesion error. change while(scanf("%ld %lf",&a,&b)==2) to while(1).
Mohsin Reza
"The tragedy of life does not lie in not reaching your goal. The tragedy lies in having no goal to reach".- Benajamin Mays

sakhassan
Experienced poster
Posts: 105
Joined: Sat Mar 11, 2006 9:42 am
Location: cse,DU

Post by sakhassan » Fri Aug 24, 2007 9:02 am

WA WA AND WA :(

Code: Select all


#include<stdio.h>

int main()
{

	long long int m,v,n;
       double x;

	while(1)
		{
				scanf("%lld %lf",&m,&x);
				if(m==0 && x ==0)
					break;
				if (x == 100 || x == 0 || m == 1) 
				{
					printf("Not found\n"); 
					continue;
				}


				//v = (long int)(m-1)/(1.0-x/100.0);
				v = (m-1)*100/(100-x);
				//printf("%lld\n",v);
				if(v >= m)
				{
				       //	if(v*100%(100-x)==0)
					 //  v--;
					n = v-v*(x/100);
					if(n==(m-1))
					 v--;
					n = v-v*(x/100);
					if(n<m-1)
					printf("%lld\n",v);
					else
					 printf("Not found\n");

				}
				/*else if( v==m)
				{
					v--;
					printf("%lld\n",v);
				}*/
				else
					printf("Not found\n");
		}
	return 0;
}


Time that gone is gone forever ...

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Fri Aug 24, 2007 12:25 pm

Check the case.

Input:

Code: Select all

100 1
Output:

Code: Select all

Not found
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11247 - Income Tax Hazard

Post by Obaida » Mon May 26, 2008 7:00 am

Some one can check out my bug???
Here is my code (getting WA).

Code: Select all

removed after acc....
Last edited by Obaida on Sun Apr 26, 2009 8:45 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

lazyboy
New poster
Posts: 17
Joined: Tue Jul 08, 2008 3:19 am

Re: 11247 - Income Tax Hazard

Post by lazyboy » Sun Feb 08, 2009 11:53 pm

Hi... my code passes for all the test cases given in this thread. but i got WA for many time. please give me some more test case for this problem. i post my code below..

Code: Select all

Code removed after ACC...
Thanks in advance.
Last edited by lazyboy on Sat Oct 03, 2009 12:39 am, edited 1 time in total.

setu
New poster
Posts: 4
Joined: Fri Mar 06, 2009 11:33 pm

Re: 11247 - Income Tax Hazard

Post by setu » Thu Apr 23, 2009 10:48 am

lazyboy wrote:Hi... my code passes for all the test cases given in this thread. but i got WA for many time. please give me some more test case for this problem. i post my code below.
Hlw bro..just remove all the complex thinking about the problem..
If u think some input and output there is a relation u can find.
V = 100(m -1) / (100 - x);
F = 100(m -1) % (100 - x);
If F is zero then the ans will be V -1 otherwise floor(V).
Got it???

lazyboy
New poster
Posts: 17
Joined: Tue Jul 08, 2008 3:19 am

Re: 11247 - Income Tax Hazard

Post by lazyboy » Sat Oct 03, 2009 12:38 am

Thanks setu for ur help...Got Acc.

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh
Contact:

Re: 11247 - Income Tax Hazard

Post by Shafaet_du » Thu Jun 23, 2011 4:58 pm

Ac after lots of wa. try to avoid double whenever possible. try this random cases:

Code: Select all

2345235 34
1243214 34
213123 45
21313 5
12432 65
456456 54
3452342 23
36213 21
324234 4
35645555 4
344 3
23325 100
234 0
12312 56
234234 4
0 0
out:

Code: Select all

3553384
1883656
387494
22433
35517
992293
4483559
45837
337742
37130785
353
Not found
Not found
27979
243992

Post Reply

Return to “Volume 112 (11200-11299)”