浙江省赛水题 A题
View Code
1 #include<stdio.h> 2 #include<math.h> 3 #include<stdlib.h> 4 5 int main() 6 { 7 int ncases, d, t; 8 double n1, n2, num1,num2,k; 9 int sum1, sum2; 10 11 scanf("%d",&ncases); 12 while( ncases-- ) 13 { 14 scanf("%d%d",&d,&t); 15 num1 = 0.0; num2 = 0.0; 16 if(d>=0 && d<=3) 17 { 18 num1 += 11; 19 num2 += 11; 20 } 21 else if(d>3 && d<=10) 22 { 23 num1 = 11 + (d-3)*2.0; 24 num2 = 11 + (d-3)*2.5; 25 } 26 else if(d > 10) 27 { 28 num1 = 11 + 7*2.0 + (d-10)*3.0; 29 num2 = 11 + 7*2.5 + (d-10)*3.75; 30 } 31 n1 = (t/5.0)*2; 32 n2 = (t/4.0)*2.5; 33 if((num1+n1)-floor(num1+n1) < 0.500000) 34 sum1 = (int)(num1+n1); 35 else 36 sum1 = (int)(num1+n1)+1; 37 if((num2+n2)-floor(num2+n2) < 0.5000000) 38 sum2 = (int)(num2+n2); 39 else 40 sum2 = (int)(num2+n2)+1; 41 printf("%d\n",sum2-sum1); 42 } 43 return 0; 44 } 45 46