• 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. dtree的自定义select动作

    项目中用到了dtree,别问我为什么用这么古老的插件,因为简单啊orz,文件树的条目不多,detree加载卡顿的问题也不用解决,开森. 在使用过程中在选择节点后需要自定义一些onclick的动作,本来 ...

  2. Java基础——JVM内存结构

    推荐阅读:https://www.cnblogs.com/wangjzh/p/5258254.html 一.内存结构图 先导知识: 一个 Java 源程序文件,会被编译为字节码文件(以 class 为 ...

  3. 20155313 2016-2017-2 《Java程序设计》第一周学习总结

    20155313 2016-2017-2 <Java程序设计>第一周学习总结 教材学习内容总结 本周的Java学习进入了一个全新的阶段,对于我这样的并没有每天花费时间钻研的同学来说,最后几 ...

  4. 洛谷 P1876 开灯

    传送门 这道题凭什么是! 就因为它代码短?! 还是我太菜了... 第$i$盏灯的开关与否只由其约数个数决定,又有约数公式: 当$n=p_1^{a_1}p_2^{a_2}...p_n^{a_n}$时,约 ...

  5. angular 缓存模板 ng-template $templateCache

    由于浏览器加载html模板是异步加载的,如果加载大量的模板会拖慢网站的速度,这里有一个技巧,就是先缓存模板. 使用angular缓存模板主要有三种方法: 方法一:通过script标签引入 <sc ...

  6. hive bug

    SHELL$ hive -S -e “set” | grep warehouse hive.metastore.warehouse.dir=/user/hive/warehouse hive.ware ...

  7. Oracle dba权限下修改用户密码 授予用户权限 解锁用户

    1.修改用户密码 alter user scott identified by 123 2.授予用户权限 grant connect,resource to scott 3.解锁用户 alter us ...

  8. 一次性搞定Session

    相信很多人遇到过同一个浏览器会出现Session覆盖问题.今天主要针对Session覆盖问题来看看Session是如何工作的.那么先看一张简单的图说明一下 上面的图大致的说明Session工作简单创建 ...

  9. zigbee路由(报文实例)

    4855 广播  routeRequestId = 6, pathCost = 0 radius=1E 62BB 继续广播 routeRequestId = 6, pathCost = 1 radiu ...

  10. Throwable、Error、Exception、RuntimeException的区别与联系

    Throwable类是Java语言中所有错误和异常的超类.只有作为此类(或其子类之一)的实例的对象才被Java虚拟机抛出,或者可以被Java throw语句抛出.类似地,只有这个类或其子类之一可以是c ...