zoukankan      html  css  js  c++  java
  • Temperature hdu 3477

    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.
     
     
    这么水的积分,竟然不会做,唉。。。。。。。。。
     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <math.h>
     5 #include <algorithm>
     6 #define eps1 0.000000001
     7 using namespace std;
     8 int main()
     9 {
    10     double ua,u0,u1,t1,c,k,y;
    11     int n,i,t,x,cas=1;
    12     scanf("%d",&t);
    13     while(t--)
    14     {
    15         printf("Case %d:
    ",cas++);
    16         cin>>ua>>u0>>u1>>t1>>n;
    17         c=log(u0-ua);
    18         k=(log(u1-ua)-c)/t1;
    19         for(i=0;i<n;i++)
    20         {
    21             cin>>x>>y;
    22             if(x)
    23             {
    24                 if(ua==u0)
    25                  printf("%.2lf
    ",ua);
    26                 else
    27                 printf("%.2lf
    ",ua+exp(k*y+c));
    28             }
    29             else
    30             {
    31                 if(ua==u0)
    32                  printf("%.2lf
    ",0.0);
    33                 else
    34                 printf("%.2lf
    ",(log(y-ua)-c)/k);
    35             }
    36         }
    37         cout<<endl;
    38     }
    39 }
    View Code
     
  • 相关阅读:
    Apache Commons CLI命令行启动
    《三体1——地球往事》—— 读后总结
    《鬼谷子的局4》 —— 读后总结
    Microsoft Visual C++ 2017 Redistributable
    Navicat Premium 12安装与激活(亲测已成功激活)
    如何从DOS命令窗口进行复制粘贴
    使用java写js中类似setTimeout的代码
    Spring @RestController、@Controller区别
    SpringBoot整合Swagger2
    git clone 报“The project you were looking for could not be found.”
  • 原文地址:https://www.cnblogs.com/ERKE/p/3901611.html
Copyright © 2011-2022 走看看