A、Relic Discovery_hdu5982
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 57 Accepted Submission(s): 49
Problem Description
Recently, paleoanthropologists have found historical remains on an island in the Atlantic Ocean. The most inspiring thing is that they excavated in a magnificent cave and found that it was a huge tomb. Inside the construction,researchers identified a large number of skeletons, and funeral objects including stone axe, livestock bones and murals. Now, all items have been sorted, and they can be divided into N types. After they were checked attentively, you are told that there areAi items of the i-th type. Further more, each item of the i-th type requires Bi million dollars for transportation, analysis, and preservation averagely. As your job, you need to calculate the total expenditure.
Input
The first line of input contains an integer T which is the number of test cases. For each test case, the first line contains an integer N which is the number of types. In the next N lines, the i-th line contains two numbers Ai and Bi as described above. All numbers are positive integers and less than 101.
Output
For each case, output one integer, the total expenditure in million dollars.
Sample Input
1
2
1 2
3 4
2
1 2
3 4
Sample Output
14
Source
Recommend
jiangzijing2015 | We have carefully selected several similar problems for you: 5994 5993 5992 5991 5990
思路:第一题很简单,求费用,把每次的乘积都加起来就行了。
#include <iostream>
#include <cstdio> using namespace std; int main()
{
int n;
int t;
int a,b;
scanf("%d",&t);
for(int i=;i<t;i++){
scanf("%d",&n);
int sum=;
for(int j=;j<n;j++){
scanf("%d %d",&a,&b);
sum+=a*b;
}
printf("%d\n",sum);
} return ;
}
B、Pocket Cube_5983
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 23 Accepted Submission(s): 9
Problem Description
The Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2 × 2 × 2 equivalence of a Rubik’s Cube.
The cube consists of 8 pieces, all corners.
Each piece is labeled by a three dimensional coordinate (h, k, l) where h, k, l ∈ {0, 1}. Each of the six faces owns four small faces filled with a positive integer.
For each step, you can choose a certain face and turn the face ninety degrees clockwise or counterclockwise.
You should judge that if one can restore the pocket cube in one step. We say a pocket cube has been restored if each face owns four same integers.
The cube consists of 8 pieces, all corners.
Each piece is labeled by a three dimensional coordinate (h, k, l) where h, k, l ∈ {0, 1}. Each of the six faces owns four small faces filled with a positive integer.
For each step, you can choose a certain face and turn the face ninety degrees clockwise or counterclockwise.
You should judge that if one can restore the pocket cube in one step. We say a pocket cube has been restored if each face owns four same integers.
Input
The first line of input contains one integer N(N ≤ 30) which is the number of test cases.
For each test case, the first line describes the top face of the pocket cube, which is the common 2 × 2 face of pieces
labelled by (0, 0, 1),(0, 1, 1),(1, 0, 1),(1, 1, 1). Four integers are given corresponding to the above pieces.
The second line describes the front face, the common face of (1, 0, 1),(1, 1, 1),(1, 0, 0),(1, 1, 0). Four integers are
given corresponding to the above pieces.
The third line describes the bottom face, the common face of (1, 0, 0),(1, 1, 0),(0, 0, 0),(0, 1, 0). Four integers are
given corresponding to the above pieces.
The fourth line describes the back face, the common face of (0, 0, 0),(0, 1, 0),(0, 0, 1),(0, 1, 1). Four integers are
given corresponding to the above pieces.
The fifth line describes the left face, the common face of (0, 0, 0),(0, 0, 1),(1, 0, 0),(1, 0, 1). Four integers are given
corresponding to the above pieces.
The six line describes the right face, the common face of (0, 1, 1),(0, 1, 0),(1, 1, 1),(1, 1, 0). Four integers are given
corresponding to the above pieces.
In other words, each test case contains 24 integers a, b, c to x. You can flat the surface to get the surface development
as follows.
For each test case, the first line describes the top face of the pocket cube, which is the common 2 × 2 face of pieces
labelled by (0, 0, 1),(0, 1, 1),(1, 0, 1),(1, 1, 1). Four integers are given corresponding to the above pieces.
The second line describes the front face, the common face of (1, 0, 1),(1, 1, 1),(1, 0, 0),(1, 1, 0). Four integers are
given corresponding to the above pieces.
The third line describes the bottom face, the common face of (1, 0, 0),(1, 1, 0),(0, 0, 0),(0, 1, 0). Four integers are
given corresponding to the above pieces.
The fourth line describes the back face, the common face of (0, 0, 0),(0, 1, 0),(0, 0, 1),(0, 1, 1). Four integers are
given corresponding to the above pieces.
The fifth line describes the left face, the common face of (0, 0, 0),(0, 0, 1),(1, 0, 0),(1, 0, 1). Four integers are given
corresponding to the above pieces.
The six line describes the right face, the common face of (0, 1, 1),(0, 1, 0),(1, 1, 1),(1, 1, 0). Four integers are given
corresponding to the above pieces.
In other words, each test case contains 24 integers a, b, c to x. You can flat the surface to get the surface development
as follows.
+ - + - + - + - + - + - +
| q | r | a | b | u | v |
+ - + - + - + - + - + - +
| s | t | c | d | w | x |
+ - + - + - + - + - + - +
| e | f |
+ - + - +
| g | h |
+ - + - +
| i | j |
+ - + - +
| k | l |
+ - + - +
| m | n |
+ - + - +
| o | p |
+ - + - +
Output
For each test case, output YES if can be restored in one step, otherwise output NO.
Sample Input
4 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 6 6 1 1 1 1 2 2 2 2 3 3 3 3 5 5 5 5 4 4 4 4 1 4 1 4 2 1 2 1 3 2 3 2 4 3 4 3 5 5 5 5 6 6 6 6 1 3 1 3 2 4 2 4 3 1 3 1 4 2 4 2 5 5 5 5 6 6 6 6
Sample Output
YES YES YES NO
Source
Recommend
jiangzijing2015 | We have carefully selected several similar problems for you: 5994 5993 5992 5991 5990
思路:在比赛的时候理解错意思了,以为是判断能不能复原模仿,而没看到只需要一步。
魔方是2*2的,有三种转的方法,上面顺时针转90度,逆时针转,前面顺时针,前面逆时针,左边顺时针(相当于右边顺时针),左边逆时针(相当于左边逆时针)
还有再加上不操作算是一种,总共七种类,模拟出来就行了。
#include <iostream>
#include <cstdio> using namespace std; int a[][];
int b[][]; bool judge(){
int i=;
for(int j=;j<=;j++){
if(a[j][]==a[j][]&&a[j][]==a[j][]&&a[j][]==a[j][]){
i++;
}
}
if(i==){
return true;
}else{
return false;
}
} void opera1(){//前面顺时针
int t1,t2;
t1=a[][];
t2=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=t2;
a[][]=t1;
}
void opera2(){//前面逆时针
int t1,t2;
t1=a[][];
t2=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=t2;
a[][]=t1;
}
void opera3(){//上面顺时针
int t1,t2;
t1=a[][];
t2=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=t1;
a[][]=t2;
}
void opera4(){//上面逆时针
int t1,t2;
t1=a[][];
t2=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=t2;
a[][]=t1;
}
void opera5(){//左边顺指针
int t1,t2;
t1=a[][];
t2=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=t1;
a[][]=t2;
}
void opera6(){//左边逆时针
int t1,t2;
t1=a[][];
t2=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=a[][];
a[][]=a[][]; a[][]=t1;
a[][]=t2;
}
int main()
{
int n;
scanf("%d",&n);
while(n--){
for(int i=;i<=;i++){
for(int j=;j<=;j++){
scanf("%d",&a[i][j]);
b[i][j]=a[i][j];
}
}
if(judge()){
printf("YES\n");
continue;
}
opera1();
if(judge()){
printf("YES\n");
continue;
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
a[i][j]=b[i][j];
}
}
opera2();
if(judge()){
printf("YES\n");
continue;
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
a[i][j]=b[i][j];
}
}
opera3();
if(judge()){
printf("YES\n");
continue;
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
a[i][j]=b[i][j];
}
}
opera4();
if(judge()){
printf("YES\n");
continue;
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
a[i][j]=b[i][j];
}
}
opera5();
if(judge()){
printf("YES\n");
continue;
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
a[i][j]=b[i][j];
}
}
opera6();
if(judge()){
printf("YES\n");
continue;
}
for(int i=;i<=;i++){
for(int j=;j<=;j++){
a[i][j]=b[i][j];
}
}
printf("NO\n");
}
return ;
}
C、Pocky_hdu5984
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 54 Accepted Submission(s): 20
Problem Description
Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative stripes in the coating, of length L.
While the length of remaining pocky is longer than d, we perform the following procedure. We break the pocky at any point on it in an equal possibility and this will divide the remaining pocky into two parts. Take the left part and eat it. When it is not longer than d, we do not repeat this procedure.
Now we want to know the expected number of times we should repeat the procedure above. Round it to 6 decimal places behind the decimal point.
While the length of remaining pocky is longer than d, we perform the following procedure. We break the pocky at any point on it in an equal possibility and this will divide the remaining pocky into two parts. Take the left part and eat it. When it is not longer than d, we do not repeat this procedure.
Now we want to know the expected number of times we should repeat the procedure above. Round it to 6 decimal places behind the decimal point.
Input
The first line of input contains an integer N which is the number of test cases. Each of the N lines contains two float-numbers L and d respectively with at most 5 decimal places behind the decimal point where 1 ≤ d, L ≤ 150.
Output
For each test case, output the expected number of times rounded to 6 decimal places behind the decimal point in a line.
Sample Input
6
1.0 1.0
2.0 1.0
4.0 1.0
8.0 1.0
16.0 1.0
7.00 3.00
1.0 1.0
2.0 1.0
4.0 1.0
8.0 1.0
16.0 1.0
7.00 3.00
Sample Output
0.000000
1.693147
2.386294
3.079442
3.772589
1.847298
1.693147
2.386294
3.079442
3.772589
1.847298
Source
Recommend
jiangzijing2015 | We have carefully selected several similar problems for you: 5994 5993 5992 5991 5990
思路:说实话比赛的时候根本不知道怎么做出来的。
好久之后才队友想起来,输出了一下log2,突然发现了规律。
赛后看别的队,一看0.693147就知道log2了,这就是做题多了有经验了啊。
但当时说的题解好像是求微积分,还是求导呢,把公式推导出来的。。。
#include <iostream>
#include <cstdio>
#include <cmath> using namespace std; int main()
{
int n;
double a,b;
scanf("%d",&n);
while(n--){
scanf("%lf%lf",&a,&b);
if(a<=b){
printf("0.000000\n");
continue;
}
printf("%.6lf\n",log(a)-log(b)+);
}
return ;
}