HDOJ 5540 Secrete Master Plan(qwb铜牌题 用%进行环的旋转)
来源:互联网 发布:淘宝客批量申请定向 编辑:程序博客网 时间:2024/05/16 10:28
Secrete Master Plan
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 871 Accepted Submission(s): 523
Problem Description
Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. The plan instructs how to deploy soldiers on the four corners of the city wall. Unfortunately, when Fei opened the pocket he found there are only four numbers written in dots on a piece of sheet. The numbers form 2×2 matrix, but Fei didn't know the correct direction to hold the sheet. What a pity!
Given two secrete master plans. The first one is the master's original plan. The second one is the plan opened by Fei. As KongMing had many pockets to hand out, he might give Fei the wrong pocket. Determine if Fei receives the right pocket.
Given two secrete master plans. The first one is the master's original plan. The second one is the plan opened by Fei. As KongMing had many pockets to hand out, he might give Fei the wrong pocket. Determine if Fei receives the right pocket.
Input
The first line of the input gives the number of test cases,T(1≤T≤104) .T test cases follow. Each test case contains 4 lines. Each line contains two integersai0 and ai1 (1≤ai0,ai1≤100 ). The first two lines stands for the original plan, the 3rd and 4th line stands for the plan Fei opened.
Output
For each test case, output one line containing "Case #x: y", where x is the test case number
(starting from 1) andy is either "POSSIBLE" or "IMPOSSIBLE" (quotes for clarity).
(starting from 1) and
Sample Input
41 23 41 23 41 23 43 14 21 23 43 24 11 23 44 32 1
Sample Output
Case #1: POSSIBLECase #2: POSSIBLECase #3: IMPOSSIBLECase #4: POSSIBLE
Source
The 2015 China Collegiate Programming Contest
思路:
这道题的题意就是给你两个2*2矩阵,看他们能不能经过旋转成为相同的模样。旋转的话,因为这四个数的逆时针顺序是固定不变的,只是他们放的位置从1234变成2341变成3412变成4123,可以发现周期是4,每次数增加后超过4了就减4,所以,这里就用%来表示环进行旋转这个操作。
代码:
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; int a[10], b[10]; bool check() { bool flag=true; for (int i = 0; i < 4; i++) { flag=true; int j; for (j = 0; j < 4; j++) if (a[(i + j) % 4] != b[j]) { flag=false; break; } if (flag==true) return true; } return false; } int main() { int num; while(scanf("%d", &num)!=EOF){ for (int x= 1; x <= num; x++) { for (int i = 0; i <= 1; i++) scanf("%d", &a[i]); for (int i = 3; i >= 2; i--) scanf("%d", &a[i]); for (int i = 0; i <= 1; i++) scanf("%d", &b[i]); for (int i = 3; i >= 2; i--) scanf("%d", &b[i]); printf("Case #%d: ",x); bool flagg=check(); if(flagg==true)printf("%s\n","POSSIBLE"); else printf("%s\n","IMPOSSIBLE"); } } return 0; }
0 0
- HDOJ 5540 Secrete Master Plan(qwb铜牌题 用%进行环的旋转)
- hdoj Secrete Master Plan 5540 (矩阵翻转)
- HDU 5540 Secrete Master Plan(水)
- HDU 5540 Secrete Master Plan
- hdu 5540/Secrete Master Plan
- HDU 5540 Secrete Master Plan
- Secrete Master Plan (模拟)
- hdu5540 Secrete Master Plan--矩阵旋转
- HDOJ 5538 House Building(qwb铜牌水题 几何)
- HDOJ 5546 Ancient Go(qwb铜牌题 DFS搜索)
- HDOJ 5573 Binary Tree(qwb铜牌题 贪心+DFS)
- HDOJ 5551 Huatuo's Medicine(qwb铜牌水题 做过的最水的)
- 杭电5540 Secrete Master Plan
- ccpc Secrete Master Plan(水模拟)
- Secrete Master Plan HDU
- HDU5540-Secrete Master Plan
- UESTC 1215 Secrete Master Plan
- A - Secrete Master Plan【ccpc】
- 登录后跳转到登录前页面
- android中.9图的编辑
- leetcode---Gas Station---动规
- Python学习第五天
- POJ2135 Farm Tour(最小费用最大流裸题)
- HDOJ 5540 Secrete Master Plan(qwb铜牌题 用%进行环的旋转)
- What is Native Client?
- 基于 openssl 生成用于 SSL 和 TLS 的数字证书
- Java + 面向接口interface代码实现(计算三角形、圆形的面积)
- LeetCode: Reverse Integer
- spirgmvc+ajaxfileupload上传文件
- activity的四种启动模式区别_launchmode图文详解
- C语言学习总结(二)
- 杭电 2046 ( 骨牌铺方格 )