HDU 4493 Tutor(精度处理)

题目

#include<stdio.h>
int main()
{
    int t;
    double a,s;
    scanf("%d",&t);
    while(t--)
    {
        s=0;
        for(int i=0;i<12;i++)
        {
            scanf("%lf",&a);
            s+=a;
        }
        //1.注意案例的输出格式
        //2.rounded to the nearest penny

        int ss=s/12.0+0.005;
        printf("$%d",ss);
        int yi,er,shu;
        shu=(s/12.0+0.005)*100;
        yi=shu%100/10;er=shu%10;
        if(yi!=0||er!=0)
        {
            printf(".");
            if(yi!=0&&er==0)
                printf("%d",yi);
            else
                printf("%d%d",yi,er);
        }
        puts("");
    }
    return 0;
}

HDU 4493 Tutor(精度处理)

时间: 2024-10-09 22:35:16

HDU 4493 Tutor(精度处理)的相关文章

hdu 4493 Tutor

Tutor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 1981    Accepted Submission(s): 552 Problem Description Lilin was a student of Tonghua Normal University. She is studying at University of

hdu 4493 Tutor(简单处理题)

http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意是输入12个数据,让你求平均值,但是要去除尾零,就像100.00只要输出100 其实这题有点不严密,像这组数据 2 100.995 100.995 100.995 100.995 100.995 100.995 100.995 100.995 100.995 100.995 100.995 100.995 输出100,其他可以过的输出100.10以及101都可以 用自己的方法死活不可以过,上网搜了一

hdu 4493 Tutor (水 精度)

题意: 思路: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int fa[150]; int fin(int x) { return fa[x]==x?x:fin(fa[x]); } void unionn(int x,int y) { int fx=fin(x); int fy=fin(y); if(fx

HDU 4493 Tutor(数学啊 )

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4493 Problem Description Lilin was a student of Tonghua Normal University. She is studying at University of Chicago now. Besides studying, she worked as a tutor teaching Chinese to Americans. So, she can

hdu 4493 Tutor 水题

Tutor Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 Description Lilin was a student of Tonghua Normal University. She is studying at University of Chicago now. Besides studying, she worked as a tutor tea

HDU 4493 Tutor (控制精度)

题意:给定12个数,求平均数. 析:这个题就是精度控制问题,如果控制精度,最好的办法就是用整型了. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #include

Hdu 5073 Galaxy 精度问题

思路: 其实求解很简单直接说解法,移动K个后 上下的角动量最小,能肯定是相连的(n-k)个,至于为什么 你自己好好想想(easy): 对于一些等质量的质点中心在 所在位置和除以点的个数 average=sum[l,l+(n-k)-1]/(n-k); 一个点的值: (pi-average)* (pi-average)  也就是 pi^2+avery^2 - 2*pi*average  多个点相加也就是 ∑pi^2+(n-k)*sum*sum/(n-k)/(n-k)   -  2*∑pi*sum/(

Hdu 4493

题目链接 注意四舍五入,保留到小数点后两位(如果存在的话). 附上代码: 1 /************************************************************************* 2 > File Name: 4493.cpp 3 > Author: Stomach_ache 4 > Mail: [email protected] 5 > Created Time: 2014年05月19日 星期一 22时39分19秒 6 > P

HDU 5170 GTY&#39;s math problem 精度判断问题

传送门 GTY's math problem Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 568    Accepted Submission(s): 263 Problem Description GTY is a GodBull who will get an Au in NOI . To have more time to l