Temperature

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 650    Accepted Submission(s): 208

Problem Description
Many people like summer as summer has a lot of advantages, but on the other hand, sometimes summer is also boring. As a student, Tom has complained with summer for many days. Because when having lunch, Tom has a habit of drinking soup. But the temperature of the soup is too high, so Tom need wait for a long time to drink. One day, Tom bought a bowl of soup again, he measured the temperature of the environment is ua and the temperature of the soup is u0, after t1 minutes, he measured the soup again and the temperature is u1, but he did not want to measure the temperature all the time until he could drink it. Now Tom asks you for help. Could you help Tom calculate what the temperature of the soup is after t2 minutes and how long he need to wait for until the temperature of the soup becomes u2 according to the data which he had measured? You could assume that the temperature of the environment is invariable.
 
Input
The first line of the input contains a single integer T (1 <= T <= 10), the number of test cases. Then T cases follow. 
The first line of each case contains 5 integers, ua(0<ua<100), u0(ua<=u0<=100), u1(ua<=u1<=u0), t1(t1>0), n(1<=n<=10), indicating the temperature of the environment ua, the original temperature of the soup u0 and the later temperature of the soup u1 after t1 minutes, n indicates that there are n options in the following. Each line of the n lines contains two integers, p and s, p is the kind of the option and can only be 0 or 1. If p is 0, you should calculate the time Tom need to wait for until the temperature of the soup becomes s(ua<=s<=u0)(it is guaranteed that temperature s is reachable), or you should calculate the temperature of the soup after s(0<s<=100) minutes from original time t=0.
 
Output
For the x-th test case, first print “Case x:” on a single line.
Then for each option, print a line containing the answer round to two decimal numbers. Print a blank line after each test case. 
 
Sample Input
1
24 100 90 10 2
0 80
1 20
 
Sample Output
Case 1:
21.65
81.32

Hint

According to Newton’s law of cooling, in a certain temperature range, the rate of change of an object’s
temperature is proportional to the temperature difference of the object’s temperature and the environment temperature.

 
 
这么水的积分,竟然不会做,唉。。。。。。。。。
 #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#define eps1 0.000000001
using namespace std;
int main()
{
double ua,u0,u1,t1,c,k,y;
int n,i,t,x,cas=;
scanf("%d",&t);
while(t--)
{
printf("Case %d:\n",cas++);
cin>>ua>>u0>>u1>>t1>>n;
c=log(u0-ua);
k=(log(u1-ua)-c)/t1;
for(i=;i<n;i++)
{
cin>>x>>y;
if(x)
{
if(ua==u0)
printf("%.2lf\n",ua);
else
printf("%.2lf\n",ua+exp(k*y+c));
}
else
{
if(ua==u0)
printf("%.2lf\n",0.0);
else
printf("%.2lf\n",(log(y-ua)-c)/k);
}
}
cout<<endl;
}
}
 

最新文章

  1. Linux添加新盘扩容空间
  2. easyui datagrid高度自适应问题
  3. div滚动到页面顶端后固定住
  4. 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)
  5. angular controller之间通信方式
  6. BZOJ1579 USACO 2009 Feb Gold 3.Revamping Trails Solution
  7. 题目要求:建立一个类Str,将一个正整数转换成相应的字符串,例如整数3456转换为字符串&quot;3456&quot;.
  8. Topself 方便调试的Window服务框架
  9. 字符编码的种类:ASCII、GB2312、GBK、GB18030、Unicode、UTF-8、UTF-16、Base64
  10. hdu 5534(dp)
  11. [蓝桥杯]PREV-27.历届试题_蚂蚁感冒
  12. 我的winows server 2012 突然多了个piress的帐户,后来一查原来是mysql漏洞的问题,郁闷
  13. canvas学习和滤镜实现
  14. A1025. PAT Ranking
  15. http头文件User-Agent详解【转载】
  16. java网页技术
  17. spring task 实现定时执行(补充:解决定时任务执行2次问题)
  18. rqnoj-329-刘翔!加油!-二维背包
  19. CentOS6中OpenMP的运行时间或运行性能分析
  20. c语言输出控制符

热门文章

  1. [2014-08-18]Mac OSX 命令行快捷键
  2. 阿里 java学习之路
  3. Cognos报表调度与作业管理
  4. Android开发——xml知识之xml可绘制对象简介
  5. 慎用kill -9,kill -15的作用
  6. 全平台轻量级 Verilog 编译器 & 仿真环境
  7. Project 1 :创建链表与显示链表
  8. 字符串和转为Data类型前后几天
  9. vSphere笔记01~02
  10. 团队作业8----第二次项目冲刺(beta阶段)5.22