zoj 3176 Rounding or Truncation

本文探讨了Kaspersky Anti-Virus(KAV)在文件扫描过程中如何计算已处理文件的百分比,通过分析一系列记录的数据点来判断是采用四舍五入还是截断的方式进行计算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C - Rounding or Truncation
Time Limit:1000MS    Memory Limit:32768KB    64bit IO Format:%lld & %llu

Description

Kaspersky Anti-Virus (often referred to as KAV) is an antivirus program developed by Kaspersky Lab. One of its operations is scan. When running scan, there are two kinds of information in the window: the number of files scanned and the percentage of files been processed, which are demonstrated in the figure below. As we can see, the percentage presented is always an integer in [0, 100]. What's more, we have no idea the number of files in total, which is a positive integer. If a list of (number, percent) pairs has been recorded, can we decide whether truncation or rounding KAV may use to calculate the percentage? Both truncation and rounding first discard the digits after the decimal point. Then, rounding increases the percentage by 1 if the digit immediately after the decimal point is 5 or more.

Input

The first line of the input contains an integer T (T <= 200), indicating the number of cases.

Each case starts with the number of records n (1 <= n <= 1000) in a line, followed byn lines in the format m p% (1 <= m <= 10000, 0 <= p <= 100), where m is the number of files scanned and p is the corresponding percentage. Bothm and p are integers.

Cases are separated by one blank line.

Output

For each case, if it can only be produced by rounding, print "Rounding" in a single line. If it canonly be produced by truncation, print "Truncation" in a single line.If it can be produced by either rounding or truncation, print "Either". If neither mechanism can produce the records (due to mistakes made in recording), print "Neither" instead.

Sample Input

4
2
1 1%
2 1%

2
1 1%
3 5%

1
1 1%

2
1 2%
2 1%

Sample Output

Rounding
Truncation
Either
Neither



代码:

计算不等式组,精度啊

#include<iostream>
#include<stdio.h>
using namespace std;
#define inf 0x7fffffff
int main()
{
    int T;
    int n;
    int m,per;
    int roul,rour,tral,trar;
    bool flagr,flagt;
    scanf("%d",&T);
    while(T--)
    {
        flagr=true;
        flagt=true;
        scanf("%d",&n);
        scanf("%d%d%%",&m,&per);
        if(per==100) roul=m;
        else
        //roul=int((m*1.0)/(per/100.0+0.005))+1;
        roul=int((m*100)/(per+0.5))+1;
        if(per==0)
            rour=inf;
        else
        //rour=int((m*1.0)/(per/100.0-0.01+0.005));
        rour=int((m*100)/(per-1+0.5));

        if(per==100) tral=m;
        else
        //tral=int((m*1.0)/(per/100.0+0.01))+1;
        tral=int((m*100)/(per+1))+1;
        //printf("%d %d %d %d %d\n",m,per,tral,int((m*1.0)/(per/100.0+0.01)),int((m*100)/(per+1)));
        if(per==0)
            trar=inf;
        else
        //trar=int((m*1.0)/(per/100.0));
        trar=int((m*100)/(per));
        //trar=int((m*100)/per);
       // printf("%d %d\n",tral,trar);
        for(int i=1; i<n; i++)
        {
            scanf("%d%d%%",&m,&per);
            int tmprl,tmprr,tmptl,tmptr;
            if(per==100)
                tmprl=m;
            else
            //tmprl=int((m*1.0)/(per/100.0+0.005))+1;
            tmprl=int((m*100)/(per+0.5))+1;

            if(per==0)
                tmprr=inf;
            else
            //tmprr=int((m*1.0)/(per/100.0-0.01+0.005));
            tmprr=int((m*100)/(per-1+0.5));

            if(per==100)
                tmptl=m;
            else
            //tmptl=int((m*1.0)/(per/100.0+0.01))+1;
            tmptl=int((m*100)/(per+1)+1);

            if(per==0)
                tmptr=inf;
            else
            //tmptr=int((m*1.0)/(per/100.0));
            tmptr=int((m*100)/(per));

            roul=max(roul,tmprl);
            rour=min(rour,tmprr);
            if(rour<roul)
            flagr=false;

            tral=max(tral,tmptl);
            trar=min(trar,tmptr);
            if(trar<tral)
            flagt=false;
            //printf("%d %d %d %d\n",tmprr,roul,tmprl,rour);
            //printf("%d %d %d %d\n",tmptr,tral,tmptl,trar);
//            if(tmprr<roul||tmprl>rour)
//                flagr=false;
//            if(tmptr<tral||tmptl>trar)
//                flagt=false;
        }
        if(flagr&&flagt)
            printf("Either\n");
        else if(flagr)
            printf("Rounding\n");
        else if(flagt)
            printf("Truncation\n");
        else
            printf("Neither\n");
    }
    return 0;
}



智慧城管,作为现代城市管理的新模式,正以其独特的魅力引领着城市管理方式的深刻变革。这一解决方案融合了物联网、云计算、大数据等前沿技术,为城市打造了一套高效、智能、全面的管理体系。 想象一下,城市的每一个角落都被智能感知设备所覆盖,从街道的监控摄像头到井盖下的传感器,它们就像城市的神经末梢,实时收集着城市运行的点点滴滴。这些数据通过高速网络汇聚到智慧城管平台,经过大数据分析处理,为管理者提供了精准的决策支持。无论是违规停车的自动抓拍,还是公共设施损坏的及时预警,智慧城管都能迅速响应,让城市管理变得更加主动、高效。 更令人兴奋的是,智慧城管不仅提升了管理效率,还极大地丰富了服务手段。市民可以通过手机APP一键上报问题,从路灯不亮到井盖丢失,各种问题都能得到快速处理。同时,智慧城管平台还整合了城市服务资源,如网上办事大厅、公共信息查询等,让市民享受到了更加便捷、高效的城市服务。此外,智慧城管还通过大数据分析,为城市规划、交通管理、环境保护等领域提供了科学依据,助力城市可持续发展。 总之,智慧城管综合解决方案以其先进的技术、丰富的功能和卓越的性能,为城市管理注入了新的活力。它不仅让城市管理变得更加智能、高效,还极大地提升了市民的幸福感和满意度。对于致力于提升城市管理水平的城市管理者来说,智慧城管无疑是一个值得深入研究和推广的解决方案。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值