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.
![](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=rounding%20or%20truncation_1.jpg)
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;
}