View Code of Problem 448

#include<stdio.h>
int con(double a)
{
	int b=a;
	if(a-b>=0.5)
		return b+1;
	else
		return b;
}
int main()
{
	int c,i,j,k,d,t;
	double a,b;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d%d",&d,&t);
		if(d<=3)
		{
			a=0.4*t;
			b=0.625*t;
		}
		else if(d>3&&d<=10)
		{
			a=2*(d-3)+0.4*t;
			b=2.5*(d-3)+0.625*t;
		}
		else
		{
			a=14+(d-10)*3+0.4*t;
			b=2.5*7+(d-10)*3.75+0.625*t;
		}
		c=con(b)-con(a);
		printf("%d\n",c);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 448