CodeBus
www.codebus.net
Search
Sign in
Sign up
Hot Search :
Source
embeded
web
remote control
p2p
game
More...
Location :
Home
Search - coin calculation
Main Category
SourceCode
Documents
Books
WEB Code
Develop Tools
Other resource
Sub Category
Compress-Decompress algrithms
STL
Data structs
Algorithm
AI-NN-PR
matlab
Bio-Recognize
Crypt_Decrypt algrithms
mathematica
Maple
DataMining
Big Data
comsol
physical calculation
chemical calculation
simulation modeling
Search - coin calculation - List
[
Mathimatics-Numerical algorithms
]
turnCoin
DL : 1
游戏的规则是,给定一个4×4 的棋盘,每个格子放上一枚硬币, 可能是正面朝上,也可能是反面朝上。如果要翻转其中的一枚硬币,与它相邻的上下左右 的硬币如果存在,也必须同时翻转,合起来称为一次翻转。现在给出棋盘上硬币的初始放 置状态和目标放置状态,请计算,最少需要多少次翻转才能将棋盘上的硬币从初始放置状 态转化为目标放置状态。 Input:输入的第一行含一个正整数k,表示测试例组数。下面紧接着k 组测试例的数据。 每组包含两个4×4 的0﹣1 阵列,用一个空行分隔,分别表示棋盘的初始放置状态和目标放 置状态。同一行的数据之间用一个空格隔开,两组测试例之间用一个空行隔开。 Output:对应每个测试例输出一个整数,表示最少翻转次数,如果无解,则输出-1。一个 整数占一行。-Rules of the game is given a 4 × 4 chessboard, put a coin for each grid, May be right side up, it could be negative up. If you want to flip a coin which, with its adjacent up and down Coins if present, must also flip, collectively referred to as a flip. Now the board is given the initial release of coins Home state and target placement status, calculation, at least how many times can flip a coin on the board-like from the initial placement State into a goal of placing state. Input: Enter the first line containing a positive integer k, the number of said groups of test cases. Then the following set of test cases k data. Each group consists of two 4 × 4 array of 0-1, separated by a blank line, respectively, the board said the initial goal of placing state and put Home state. Data in the same line separated by a space between the two groups of test cases separated by a blank line between. Output: corresponding to each test case output an integer that represents the least n
Date
: 2025-12-19
Size
: 209kb
User
:
小红
CodeBus
is one of the largest source code repositories on the Internet!
Contact us :
1999-2046
CodeBus
All Rights Reserved.