BC12haoj5058&&hdoj5059&&hdoj5560

来源:互联网 发布:本西蒙斯夏季联赛数据 编辑:程序博客网 时间:2024/06/17 12:19

So easy

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 755    Accepted Submission(s): 402


Problem Description
Small W gets two files. There are n integers in each file. Small W wants to know whether these two files are same. So he invites you to write a program to check whether these two files are same. Small W thinks that two files are same when they have the same integer set.
For example file A contains (5,3,7,7),and file B contains (7,5,3,3). They have the same integer set (3,5,7), so they are same.
Another sample file C contains(2,5,2,5), and file D contains (2,5,2,3).
The integer set of C is (2,5),but the integer set of D is (2,3,5),so they are not same.
Now you are expected to write a program to compare two files with size of n.
 

Input
Multi test cases (about 100). Each case contain three lines. The first line contains one integer n represents the size of file. The second line contains n integers a1,a2,a3,,an - represents the content of the first file. The third line contains n integers b1,b2,b3,,bn - represents the content of the second file.
Process to the end of file.
1n100
1ai,bi1000000000
 

Output
For each case, output "YES" (without quote) if these two files are same, otherwise output "NO" (without quote).
 

Sample Input
31 1 21 2 245 3 7 77 5 3 342 5 2 32 5 2 531 2 31 2 4
 

Sample Output
YESYESNONO
 

Source
BestCoder Round #12
 

#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<list>#include<vector>#include<map>using namespace std;const int maxn=110;map<int,int>visa,visb;int numa[maxn];int numb[maxn];int main(){    int t,i,j,k,n,m;    while(scanf("%d",&n)!=EOF){        visa.clear();        visb.clear();        int a,b;        for(i=0;i<n;++i){            scanf("%d",&numa[i]);            visa[numa[i]]++;        }        for(i=0;i<n;++i){            scanf("%d",&numb[i]);            visb[numb[i]]++;        }        for(i=0;i<n;++i){            if(!visa.count(numb[i])||!visb.count(numa[i]))break;        }        if(i<n)            printf("NO\n");        else             printf("YES\n");    }    return 0;}

Help him

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2194    Accepted Submission(s): 445


Problem Description
As you know, when you want to hack someone's program, you must submit your test data. However sometimes you will submit invalid data, so we need a data checker to check your data. Now small W has prepared a problem for BC, but he is too busy to write the data checker. Please help him to write a data check which judges whether the input is an integer ranged from a to b (inclusive).
Note: a string represents a valid integer when it follows below rules.
1. When it represents a non-negative integer, it contains only digits without leading zeros.
2. When it represents a negative integer, it contains exact one negative sign ('-') followed by digits without leading zeros and there are no characters before '-'.
3. Otherwise it is not a valid integer.
 

Input
Multi test cases (about 100), every case occupies two lines, the first line contain a string which represents the input string, then second line contains a and b separated by space. Process to the end of file.

Length of string is no more than 100.
The string may contain any characters other than '\n','\r'.
-1000000000ab1000000000
 

Output
For each case output "YES" (without quote) when the string is an integer ranged from a to b, otherwise output "NO" (without quote).
 

Sample Input
10-100 1001a0-100 100
 

Sample Output
YESNO
 

Source
BestCoder Round #12
 

#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<list>#include<vector>using namespace std;char str[110];char stra[110];char strb[110]; int main(){    int i,j,k;    while(gets(str)){        scanf("%s%s",stra,strb);        getchar();        int len=strlen(str);        bool sign=true;        for(i=0;i<len;++i){            if(str[i]=='-'&&i==0)continue;            if(sign&&str[i]=='0')break;            if(str[i]>='0'&&str[i]<='9');            else break;                        sign=false;        }        if((len==1&&str[0]=='0')){            i=len+1;sign=false;        }        if(i<len||sign){            printf("NO\n");        }        else {            if(str[0]=='-'){                                if(stra[0]=='-'&&strb[0]=='-'){                    if(strcmp(stra+1,str+1)>=0&&strcmp(strb+1,str+1)<=0)                        printf("YES\n");                    else                         printf("NO\n");                }                else if(stra[0]=='-'&&strb[0]!='-'){                    if(strcmp(stra+1,str+1)>=0)                        printf("YES\n");                    else                         printf("NO\n");                }                else {                    printf("NO\n");                }            }            else {                if(stra[0]=='-'&&strb[0]=='-'){                    printf("NO\n");                }                else if(stra[0]=='-'&&strb[0]!='-'){                    if(strcmp(strb,str)>=0)                        printf("YES\n");                    else                         printf("NO\n");                }                else {                    if(strcmp(stra,str)<=0&&strcmp(strb,str)>=0)                        printf("YES\n");                    else                         printf("NO\n");                }            }        }    }    return 0;}

War

Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 233    Accepted Submission(s): 76
Special Judge


Problem Description
Long long ago there are two countrys in the universe. Each country haves its own manor in 3-dimension space. Country A's manor occupys x^2+y^2+z^2<=R^2. Country B's manor occupys x^2+y^2<=HR^2 && |z|<=HZ. There may be a war between them. The occurrence of a war have a certain probability. 
We calculate the probability as follow steps.
1. VC=volume of insection manor of A and B.
2. VU=volume of union manor of A and B.
3. probability=VC/VU
 

Input
Multi test cases(about 1000000). Each case contain one line. The first line contains three integers R,HR,HZ. Process to end of file.

[Technical Specification]
0< R,HR,HZ<=100
 

Output
For each case,output the probability of the war which happens between A and B. The answer should accurate to six decimal places.
 

Sample Input
1 1 12 1 1
 

Sample Output
0.6666670.187500
 

Source
BestCoder Round #12
 


题意:求圆柱体与球相交的体积和相并的体积的积

解题思路分情况讨论:球冠的体积计算公式V = πh*h(r-h/3) r为原球的半径h为球冠的高

#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<list>#include<vector>#define PI acos(-1.0)using namespace std;const int maxn=10010;int main(){double r,hr,hz;while(scanf("%lf%lf%lf",&r,&hr,&hz)!=EOF){double ans;if(hr>r){if(hz>r){double hc=4.0/3.0*PI*r*r*r;double hu=PI*hr*hr*hz*2.0;ans=hc/hu;}else {double v=PI*(r-hz)*(r-hz)*(r-(r-hz)/3.0)*2.0;double hc=4.0/3.0*PI*r*r*r-v;double hu=PI*hr*hr*hz*2.0+4.0/3.0*PI*r*r*r-hc;ans=hc/hu;}}else {if(hz<=sqrt(r*r-hr*hr)){double hc=PI*hr*hr*hz*2.0;double hu=4.0/3.0*PI*r*r*r;ans=hc/hu;}else if(hz>r){double hh=sqrt(r*r-hr*hr);double hc=PI*hr*hr*hh*2.0+PI*(r-hh)*(r-hh)*(r-(r-hh)/3.0)*2.0;double hu=4.0/3.0*PI*r*r*r+PI*hr*hr*hz*2.0-hc;ans=hc/hu;}else {double hh=sqrt(r*r-hr*hr);double v1=PI*(r-hh)*(r-hh)*(r-(r-hh)/3.0);double v2=PI*(r-hz)*(r-hz)*(r-(r-hz)/3.0);double hc=PI*hr*hr*hh*2.0+(v1-v2)*2.0;double hu=4.0/3.0*PI*r*r*r+PI*hr*hr*hz*2.0-hc;ans=hc/hu;}}printf("%.6lf\n",ans);}return 0;}


0 0