• 1000ms
  • 262144K

The Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2×2×22 \times 2 \times 22×2×2 equivalence of a Rubik’s Cube. The cube consists of 888 pieces, all corners.

Each piece is labeled by a three dimensional coordinate (h,k,l)(h, k, l)(h,k,l) where hhh, kkk, l∈0,1l \in {0, 1}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)N(N \le 30)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×22 \times 22×2 face of pieceslabelled by (0,0,1)(0, 0, 1)(0,0,1), (0,1,1)(0, 1, 1)(0,1,1), (1,0,1)(1, 0, 1)(1,0,1), (1,1,1)(1, 1, 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,0,1)(1,0,1), (1,1,1)(1,1,1)(1,1,1), (1,0,0)(1,0,0)(1,0,0), (1,1,0)(1,1,0)(1,1,0). Four integers aregiven corresponding to the above pieces.

The third line describes the bottom face, the common face of (1,0,0)(1, 0, 0)(1,0,0), (1,1,0)(1, 1, 0)(1,1,0), (0,0,0)(0, 0, 0)(0,0,0), (0,1,0)(0, 1, 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,0,0)(0,0,0), (0,1,0)(0,1,0)(0,1,0), (0,0,1)(0,0,1)(0,0,1), (0,1,1)(0,1,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, 0)(0,0,0), (0,0,1)(0, 0, 1)(0,0,1), (1,0,0)(1, 0, 0)(1,0,0), (1,0,1)(1, 0, 1)(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, 1)(0,1,1), (0,1,0)(0, 1, 0)(0,1,0), (1,1,1)(1, 1, 1)(1,1,1), (1,1,0)(1, 1, 0)(1,1,0). Four integers are given corresponding to the above pieces.

In other words, each test case contains 242424 integers aaa, bbb, ccc to xxx. You can flat the surface to get the surface development as follows.

Output

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
思路:直接模拟六种情况。
 #include<bits/stdc++.h>
using namespace std;
int a[][];
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
for(int i=; i<=; i++)
{
for(int j=; j<=; j++)
{
scanf("%d",&a[i][j]);
}
}
int summ=;
int sum=;
for(int i=; i<=; i++)
{
if(a[i][]==a[i][] && a[i][]==a[i][] && a[i][]==a[i][])
{
summ++;
}
}
if((a[][]==a[][] && a[][]==a[][] && a[][]==a[][]) && (a[][]==a[][] && a[][]==a[][] && a[][]==a[][]))
{
sum=;
}
if((a[][]==a[][] && a[][]==a[][] && a[][]==a[][]) && (a[][]==a[][] && a[][]==a[][] && a[][]==a[][]))
{
sum=;
}
if((a[][]==a[][] && a[][]==a[][] && a[][]==a[][]) && (a[][]==a[][] && a[][]==a[][] && a[][]==a[][]))
{
sum=;
}
if(summ==)
{
printf("YES\n");
}
else if(sum==)
{
printf("NO\n");
}
else if(sum==)
{
if(a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][])
printf("YES\n");
else if(a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][])
printf("YES\n");
else
printf("NO\n");
}
else if(sum==)
{
if(a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][])
printf("YES\n");
else if(a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][])
printf("YES\n");
else
printf("NO\n"); }
else if(sum==)
{
if(a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][])
printf("YES\n");
else if(a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][]&&
a[][]==a[][] &&a[][]==a[][] &&a[][]==a[][])
printf("YES\n");
else
printf("NO\n");
}
else
{
printf("NO\n");
}
}
return ;
}
  • 1000ms
  • 262144K
 

Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative stripes in the coating, of length LLL.

While the length of remaining pocky is longer than ddd, 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 ddd, 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 666 decimal places behind the decimal point.

Input

The first line of input contains an integer NNN which is the number of test cases. Each of the NNN lines contains two float-numbers LLL and ddd respectively with at most 555 decimal places behind the decimal point where 1≤d,L≤1501 \le d, L \le 1501≤d,L≤150.

Output

For each test case, output the expected number of times rounded to 666 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 思路:微分。
代码:
 #include<bits/stdc++.h>
using namespace std;
int n;
double l,d;
int main()
{
scanf("%d",&n);
while(n--)
{
scanf("%lf%lf",&l,&d);
if(l<=d)
{
printf("0.000000\n");
}
else
{
printf("%.6f\n",+log(l/d));
}
}
return ;
}
												

青岛 2016ICPC 区域现场赛题目的更多相关文章

  1. HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛

    题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...

  2. HDU 4802 && HDU 4803 贪心,高精 && HDU 4804 轮廓线dp && HDU 4805 计算几何 && HDU 4811 (13南京区域赛现场赛 题目重演A,B,C,D,J)

    A.GPA(HDU4802): 给你一些字符串对应的权重,求加权平均,如果是N,P不计入统计 GPA Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  3. HDU 4811 Ball -2013 ICPC南京区域现场赛

    题目链接 题意:三种颜色的球,现给定三种球的数目,每次取其中一个放到桌子上,排成一条线,每次放的位置任意,问得到的最大得分. 把一个球放在末尾得到的分数是它以前球的颜色种数 把一个球放在中间得到的分数 ...

  4. 2013ACM/ICPC亚洲区南京站现场赛——题目重现

    GPA http://acm.hdu.edu.cn/showproblem.php?pid=4802 签到题,输入两个表,注意细心点就行了. #include<cstdio> #inclu ...

  5. 2013ACM/ICPC亚洲区南京站现场赛---Poor Warehouse Keeper(贪心)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4803 Problem Description Jenny is a warehouse keeper. ...

  6. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  7. 2014ACM/ICPC亚洲区域赛牡丹江现场赛总结

    不知道怎样说起-- 感觉还没那个比赛的感觉呢?如今就结束了. 9号.10号的时候学校还评比国奖.励志奖啥的,由于要来比赛,所以那些事情队友的国奖不能答辩.自己的励志奖班里乱搞要投票,自己又不在,真是无 ...

  8. 2014ACMICPC亚洲区域赛牡丹江现场赛之旅

    下午就要坐卧铺赶回北京了.闲来无事.写个总结,给以后的自己看. 因为孔神要保研面试,所以仅仅有我们队里三个人上路. 我们是周五坐的十二点出发的卧铺,一路上不算无聊.恰巧邻床是北航的神犇.于是下午和北航 ...

  9. 2018ICPC青岛现场赛 重现训练

    先贴代码,以及简要题解. 和一个队友下午双排打了一下,队友光速签到,我签的J被嫌弃写得慢以及演员...然后我秒出了E了思路然而难以置信这么简单的思路当时才过了十几个,于是发现D.F不是太好做.最后交了 ...

随机推荐

  1. laravel5.5源码笔记(三、门面类facade)

    上次说了provider,那么这次来说说facade 首先是启动的源头,从laravel的kernel类中的$bootstrappers 数组,我们可以看到它的一些系统引导方法,其中的Register ...

  2. HBase(3)-安装与Shell操作

    一. 安装 1. 启动Zookeeper集群 2. 启动Hadoop集群 3. 上传并解压HBase -bin.tar.gz -C /opt/module 4. 修改配置文件 #修改habse-env ...

  3. ImageMagick命令执行学习笔记(常见于图片预览处)

    实验版本: ImageMagick版本:6.9.2 push graphic-context viewbox 0 0 640 480 fill 'url(https://"|whoami&q ...

  4. (数据科学学习手札53)Python中tqdm模块的用法

    一.简介 tqdm是Python中专门用于进度条美化的模块,通过在非while的循环体内嵌入tqdm,可以得到一个能更好展现程序运行过程的提示进度条,本文就将针对tqdm的基本用法进行介绍. 二.基本 ...

  5. 课下实践——实现Mypwd

    实现Mypwd 学习pwd命令 想要知道当前所处的目录,可以用pwd命令,该命令显示整个路径名. L 目录连接链接时,输出连接路径 P 输出物理路径 研究pwd实现需要的系统调用(man -k; gr ...

  6. 使用Python进行分布式系统协调 (ZooKeeper/Consul/etcd)

    来源:naughty 链接:my.oschina.net/taogang/blog/410864 笔者之前的博文提到过,随着大数据时代的到来,分布式是解决大数据问题的一个主要手段,随着越来越多的分布式 ...

  7. Block 在 ARC 下的拷贝

    前言 现在有一种说法,是开启arc选项时,已经没有栈上的block了,所以所有的block都不需要copy来拷贝到堆上了.那么这个说法正确与否呢? 结论是这个说法必须是错误的,首先的一点就是arc只是 ...

  8. thinkphp5 开启多语言

    一.配置点击打开链接1.开启语言包功能'lang_switch_on' => true,2.支持的语言列表'lang_list' => ['zh-cn','en-us'],二.语言定义(默 ...

  9. Siki_Unity_2-3_UGUI_Unity4.6 UI Beta版本入门学习(未学)

    Unity 2-3 UGUI Unity4.6 UI Beta版本入门学习(未学)

  10. phpcms v9如何给父级单页栏目添加内容

    对于phpcms单页的调用相信大家都应该没问题,那么如果我们在后台添加的单页有二层甚至更多的时候,这样在管理内容上是没有给父级栏目添加内容这一功能的!那么我们该怎么实现这个功能并调用呢? 首先我们要修 ...