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 Ai 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. 

输入描述:

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
2
1 2
3 4
输出例子:
14

-->

示例1

输入

1
2
1 2
3 4

输出

14
解题思路:简单水过!
AC代码:
 #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int t,n,a,b,sum;
int main(){
while(cin>>t){
while(t--){
cin>>n;sum=;
while(n--){
cin>>a>>b;
sum+=a*b;
}
cout<<sum<<endl;
}
}
return ;
}

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.

输入例子:
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

-->

示例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代码:
 #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,o[],t[];bool flag;
bool judge(){
for(int i=;i<=;i+=)
for(int j=i+;j<i+;++j)
if(t[j]!=t[j-])return false;
return true;
}
void restore(){
for(int i=;i<=;++i)t[i]=o[i];
}
int main(){
while(cin>>n){
while(n--){
for(int i=;i<=;++i)cin>>o[i],t[i]=o[i];
flag=judge();
if(!flag){//左上旋
t[]=t[],t[]=t[],t[]=t[],t[]=t[];
t[]=t[],t[]=t[],t[]=o[],t[]=o[];
flag=judge();
if(!flag){//左下旋
restore();
t[]=t[],t[]=t[],t[]=t[],t[]=t[];
t[]=t[],t[]=t[],t[]=o[],t[]=o[];
flag=judge();
}
}
if(!flag){//上左旋
restore();
t[]=t[],t[]=t[],t[]=t[],t[]=t[];
t[]=t[],t[]=t[],t[]=o[],t[]=o[];
flag=judge();
if(!flag){//上右旋
restore();
t[]=t[],t[]=t[],t[]=t[],t[]=t[];
t[]=t[],t[]=t[],t[]=o[],t[]=o[];
flag=judge();
}
}
if(!flag){//正左旋
restore();
t[]=t[],t[]=t[],t[]=t[],t[]=t[];
t[]=t[],t[]=t[],t[]=o[],t[]=o[];
flag=judge();
if(!flag){//正右旋
restore();
t[]=t[],t[]=t[],t[]=t[],t[]=t[];
t[]=t[],t[]=t[],t[]=o[],t[]=o[];
flag=judge();
}
}
if(flag)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return ;
}

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.

输入例子:
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

-->

示例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代码:
 #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int t;double l,d;
int main(){
while(cin>>t){
while(t--){
cin>>l>>d;
if(l<=d)cout<<"0.000000"<<endl;
else cout<<setiosflags(ios::fixed)<<setprecision()<<(1.0+log(l/d))<<endl;
}
}
return ;
}

最新文章

  1. Referenced file contains errors (http://www.springframework.org/schema...错误
  2. zoj 3261 Connections in Galaxy War
  3. pthread_create如何传递两个参数以上的参数
  4. Express实现http和https服务
  5. 问自己----也是自己该怎么走的路(phper)
  6. [JavaScript] js 复制到剪切板
  7. C#中问号的使用
  8. fafu 1100 线段树
  9. 前端angularjs+requirejs+dhtmlx 后端asp.net webapi
  10. linux安装bind with DLZ &lt;NIOT&gt;
  11. HTML转义字符串
  12. ELF 动态链接 - so 的 .dynamic 段
  13. rabbitmq之基本原理及搭建单机环境
  14. [ Python ] unittest demo
  15. go module 命令
  16. NDT(Normal Distributions Transform)算法原理与公式推导
  17. Java乱码解决之道
  18. python爬虫从入门到放弃(一)——试用bs4, request爬百度股票
  19. ASP.NET Core 中的应用程序启动 Startup
  20. 简易四则运算生成程序——添加GUI支持

热门文章

  1. HDU 6086 Rikka with String AC自动机 + DP
  2. Latex 5: LaTeX资料下载
  3. linux kfifo移植
  4. sublime text2 相关插件及其应用
  5. SDUT oj 选拔赛1 迷之好奇
  6. oracle 转移表空间
  7. Objective-C基础知识
  8. 区间DP中的环形DP
  9. 【ZJOI 2008】树的统计
  10. 【POJ 1151】 Altlantis