牛客国庆集训派对Day_7
A.Relic Discovery
题目描述
输入描述:
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
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
题目描述
输入描述:
输出描述:
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
-->
输入
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
题目描述
输入描述:
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
-->
输入
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 ;
}
牛客国庆集训派对Day_7的更多相关文章
- 牛客国庆集训派对Day6 A Birthday 费用流
牛客国庆集训派对Day6 A Birthday:https://www.nowcoder.com/acm/contest/206/A 题意: 恬恬的生日临近了.宇扬给她准备了一个蛋糕. 正如往常一样, ...
- 2019牛客国庆集训派对day5
2019牛客国庆集训派对day5 I.Strange Prime 题意 \(P=1e10+19\),求\(\sum x[i] mod P = 0\)的方案数,其中\(0 \leq x[i] < ...
- 牛客国庆集训派对Day1 L-New Game!(最短路)
链接:https://www.nowcoder.com/acm/contest/201/L 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
- 牛客国庆集训派对Day4 J-寻找复读机
链接:https://www.nowcoder.com/acm/contest/204/J 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
- 牛客国庆集训派对Day4 I-连通块计数(思维,组合数学)
链接:https://www.nowcoder.com/acm/contest/204/I 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
- 牛客国庆集训派对Day1-C:Utawarerumono(数学)
链接:https://www.nowcoder.com/acm/contest/201/C 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
- 牛客国庆集训派对Day2 Solution
A 矩阵乘法 思路: 1° 牛客机器太快了,暴力能过. #include <bits/stdc++.h> using namespace std; #define N 5000 in ...
- 2019 牛客国庆集训派对day1-C Distinct Substrings(exkmp+概率)
链接:https://ac.nowcoder.com/acm/contest/1099/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...
- 2018 牛客国庆集训派对Day4 - H 树链博弈
链接:https://ac.nowcoder.com/acm/contest/204/H来源:牛客网 题目描述 给定一棵 n 个点的树,其中 1 号结点是根,每个结点要么是黑色要么是白色 现在小 Bo ...
随机推荐
- 多媒体开发之---h264快速运动估计算法
#include "stdio.h"#include "stdlib.h"#include "malloc.h"#include " ...
- WPF代码注意事项,开发常见问题,知识总结
代码注意事项: 1.代码实现的样式赋值 XXX.Style = TryFindResource("StyleName") as Style; 2.WPF中FindName方法的使用 ...
- LeetCode(38)题解: Count and Say
https://leetcode.com/problems/count-and-say/ 题目: The count-and-say sequence is the sequence of integ ...
- block-循环引用
在ARC机制下,app的内存管理由操作系统进行管理,不须要程序猿手动的管理内存,方便了开发.虽然,自己主动释放内存非常方便.可是并不是绝对安全,绝对不会产生内存泄露. 大部分导致iOS对象无法按预期释 ...
- Spring Base
1.在java开发领域,Spring相对于EJB来说是一种轻量级的,非侵入性的Java开发框架,曾经有两本很畅销的书<Expert one-on-one J2EE Design and Deve ...
- inherited在消息中的作用(编译器根据inherited所在的函数,直接转换成对祖先类同名动态函数的调用,或者转换成对DefaultHandler的调用)
好奇一下.看来Object Pascal确实与Windows深入结合了. unit Unit1; interface uses Windows, Messages, SysUtils, Variant ...
- 蓝牙协议(bluetooth spec)
1.概述: 蓝牙协议规范遵循开放系统互连参考模型(OSI/RM),从低到高地定义了蓝牙协议堆栈的各个层次. SIG(Session Initiation Protocol)所定义的蓝牙技术规范的目 ...
- p1694猴子 并查集
有n只猴子,第一只尾巴挂在树上,剩下的n-1只,要么被其他的猴子抓住,要么抓住了其他的猴子,要么两者均有. 当然一只猴子最多抓两只另外的猴子,因为只有两只猴爪子嘛.现在给出这n只猴子抓与被抓的信息,并 ...
- BZOJ_2017_[Usaco2009 Nov]硬币游戏_博弈论+DP
BZOJ_2017_[Usaco2009 Nov]硬币游戏_博弈论+DP Description 农夫约翰的奶牛喜欢玩硬币游戏,因此他发明了一种称为“Xoinc”的两人硬币游戏. 初始时,一个有N(5 ...
- 【Codeforces 947B】 Producting Snow
[题目链接] 点击打开链接 [算法] 前缀和 + 堆 [代码] #include<bits/stdc++.h> using namespace std; typedef long long ...