Page 3 of 4

Posted: Mon Aug 06, 2007 6:02 am
by emotional blind
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.

WR Help

Posted: Thu Aug 16, 2007 8:02 am
by sapnil
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;
}

Posted: Thu Aug 16, 2007 6:18 pm
by Mohsin Reza Razib
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

Posted: Thu Aug 16, 2007 8:12 pm
by ayon
correct assumption is (v-v*(x/100))<m-1
using double may give precision error

TLE

Posted: Fri Aug 17, 2007 12:56 am
by chinmoy kanti dhar
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);


}
}



Posted: Fri Aug 17, 2007 6:45 am
by Mohsin Reza Razib
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.

Posted: Fri Aug 17, 2007 7:22 pm
by chinmoy kanti dhar
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);

}
}

Posted: Fri Aug 17, 2007 7:36 pm
by Mohsin Reza Razib
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).

Posted: Fri Aug 24, 2007 9:02 am
by sakhassan
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;
}



Posted: Fri Aug 24, 2007 12:25 pm
by Jan
Check the case.

Input:

Code: Select all

100 1
Output:

Code: Select all

Not found
Hope it helps.

Re: 11247 - Income Tax Hazard

Posted: Mon May 26, 2008 7:00 am
by Obaida
Some one can check out my bug???
Here is my code (getting WA).

Code: Select all

removed after acc....

Re: 11247 - Income Tax Hazard

Posted: Sun Feb 08, 2009 11:53 pm
by lazyboy
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.

Re: 11247 - Income Tax Hazard

Posted: Thu Apr 23, 2009 10:48 am
by setu
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???

Re: 11247 - Income Tax Hazard

Posted: Sat Oct 03, 2009 12:38 am
by lazyboy
Thanks setu for ur help...Got Acc.

Re: 11247 - Income Tax Hazard

Posted: Thu Jun 23, 2011 4:58 pm
by Shafaet_du
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