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.
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.
1≤n≤100
1≤ai,bi≤1000000000
Process to the end of file.
1≤n≤100
1≤ai,bi≤1000000000
Output
For each case, output "YES" (without quote) if these two files are same, otherwise output "NO" (without quote).
Sample Input
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
143 1 1 2 1 2 2 4 5 3 7 7 7 5 3 3 4 2 5 2 3 2 5 2 5 3 1 2 3 1 2 4
Sample Output
复制代码
1
2
3
4
5
6YES YES NO NO
Source
BestCoder Round #12
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40#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("NOn"); else printf("YESn"); } 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.
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'.
-1000000000 ≤a≤b≤1000000000
Length of string is no more than 100.
The string may contain any characters other than 'n','r'.
-1000000000 ≤a≤b≤1000000000
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
复制代码
1
2
3
4
5
610 -100 100 1a0 -100 100
Sample Output
复制代码
1
2
3
4YES NO
Source
BestCoder Round #12
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73#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("NOn"); } else { if(str[0]=='-'){ if(stra[0]=='-'&&strb[0]=='-'){ if(strcmp(stra+1,str+1)>=0&&strcmp(strb+1,str+1)<=0) printf("YESn"); else printf("NOn"); } else if(stra[0]=='-'&&strb[0]!='-'){ if(strcmp(stra+1,str+1)>=0) printf("YESn"); else printf("NOn"); } else { printf("NOn"); } } else { if(stra[0]=='-'&&strb[0]=='-'){ printf("NOn"); } else if(stra[0]=='-'&&strb[0]!='-'){ if(strcmp(strb,str)>=0) printf("YESn"); else printf("NOn"); } else { if(strcmp(stra,str)<=0&&strcmp(strb,str)>=0) printf("YESn"); else printf("NOn"); } } } } 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
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
[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
2
3
41 1 1 2 1 1
Sample Output
复制代码
1
2
3
40.666667 0.187500
Source
BestCoder Round #12
题意:求圆柱体与球相交的体积和相并的体积的积
解题思路分情况讨论:球冠的体积计算公式V = πh*h(r-h/3) r为原球的半径h为球冠的高
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55#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("%.6lfn",ans); } return 0; }
最后
以上就是辛勤美女最近收集整理的关于BC12haoj5058&&hdoj5059&&hdoj5560 So easy Help him War的全部内容,更多相关BC12haoj5058&&hdoj5059&&hdoj5560内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复