牛客国庆集训派对Day_7

A.Relic Discovery

题目描述

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 are A i items of the i-th type. Further more, each item of the i-th type requires B i million dollars for transportation, analysis, and preservation averagely. As your job, you need to calculate the total expenditure. 

输入描述:

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 A_i and B_i as described above. All numbers are positive integers and less than 101.

输出描述:

For each case, output one integer, the total expenditure in million dollars.
示例1

输入

1
2
1 2
3 4

输出

14
解题思路:简单水过!
AC代码:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 int t,n,a,b,sum;
 5 int main(){
 6     while(cin>>t){
 7         while(t--){
 8             cin>>n;sum=0;
 9             while(n--){
10                 cin>>a>>b;
11                 sum+=a*b;
12             }
13             cout<<sum<<endl;
14         }
15     }
16     return 0;
17 }

B.Pocket Cube

题目描述

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 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, output YES if can be restored in one step, otherwise output NO.
示例1

输入

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

输出

YES
YES
YES
NO
解题思路:简单模拟,看转一步是否到位,即每一面的数字相同即可。
AC代码:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 int n,o[25],t[25];bool flag;
 5 bool judge(){
 6     for(int i=1;i<=24;i+=4)
 7         for(int j=i+1;j<i+4;++j)
 8             if(t[j]!=t[j-1])return false;
 9     return true;
10 }
11 void restore(){
12     for(int i=1;i<=24;++i)t[i]=o[i];
13 }
14 int main(){
15     while(cin>>n){
16         while(n--){
17             for(int i=1;i<=24;++i)cin>>o[i],t[i]=o[i];
18             flag=judge();
19             if(!flag){//左上旋
20                 t[1]=t[5],t[3]=t[7],t[5]=t[9],t[7]=t[11];
21                 t[9]=t[13],t[11]=t[15],t[13]=o[1],t[15]=o[3];
22                 flag=judge();
23                 if(!flag){//左下旋
24                     restore();
25                     t[5]=t[1],t[7]=t[3],t[1]=t[13],t[3]=t[15];
26                     t[13]=t[9],t[15]=t[11],t[9]=o[5],t[11]=o[7];
27                     flag=judge();
28                 }
29             }
30             if(!flag){//上左旋
31                 restore();
32                 t[5]=t[23],t[6]=t[21],t[23]=t[16],t[21]=t[15];
33                 t[16]=t[18],t[15]=t[20],t[18]=o[5],t[20]=o[6];
34                 flag=judge();
35                 if(!flag){//上右旋
36                     restore();
37                     t[5]=t[18],t[6]=t[20],t[18]=t[16],t[20]=t[15];
38                     t[16]=t[23],t[15]=t[21],t[23]=o[5],t[21]=o[6];
39                     flag=judge();
40                 }
41             }
42             if(!flag){//正左旋
43                 restore();
44                 t[3]=t[23],t[4]=t[24],t[23]=t[10],t[24]=t[9];
45                 t[10]=t[19],t[9]=t[20],t[19]=o[3],t[20]=o[4];
46                 flag=judge();
47                 if(!flag){//正右旋
48                     restore();
49                     t[3]=t[19],t[4]=t[20],t[19]=t[10],t[20]=t[9];
50                     t[10]=t[24],t[9]=t[23],t[24]=o[4],t[23]=o[3];
51                     flag=judge();
52                 }
53             }
54             if(flag)cout<<"YES"<<endl;
55             else cout<<"NO"<<endl;
56         }
57     }
58     return 0;
59 }

C.Pocky

题目描述

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. 

输入描述:

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.

输出描述:

For each test case, output the expected number of times rounded to 6 decimal places behind the decimal point in a line.
示例1

输入

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

输出

0.000000
1.693147
2.386294
3.079442
3.772589
1.847298
解题思路:因为ln(2)≈0.693147,因此大胆验证一下数据,发现当l>d时,f=ln(l/d)+1,否则f=0。
AC代码:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 int t;double l,d;
 5 int main(){
 6     while(cin>>t){
 7         while(t--){
 8             cin>>l>>d;
 9             if(l<=d)cout<<"0.000000"<<endl;
10             else cout<<setiosflags(ios::fixed)<<setprecision(6)<<(1.0+log(l/d))<<endl;
11         }
12     }
13     return 0;
14 }

猜你喜欢

转载自www.cnblogs.com/acgoto/p/9751015.html