编程介的小学生 2019-02-18 22:14 采纳率: 20.5%
浏览 314

拨动时钟转盘的可行性的问题,如何利用C语言的办法实现的呢?

Problem Description
There are N clocks in the room. The clock is so weird that it has only four states: 3 o'clock, 6 o'clock, 9 o'clock, 12 o'clock, represented by 1,2,3,0.(i.e, state 1 means 3 o'clock, and so on). Now giving you the initial state of N clocks, and N operations you can use to make all the clocks into the state 12 o'clock. Each operation Mi represents by a vector size of N, M[i][j] is 0 or 1. When you use operation M[i] on the N clocks, M[i][j] = 0 means the j-th clock will not make any change, M[i][j] = 1 means the j-th clock will turn into the next state (i.e, 3 o'clock --> 6 o'clock, 6 o'clock --> 9 o'clock, 9 o'clock -->12 o'clock, 12 o'clock -->3 o'clock). You should note that you can use each operation at most 3 times.

Input
Each test case contains a single integer N (1<=N<=50), indicating the number of clocks. The next following line contains N integers (each integer is in the range [0, 3]), meaning the initial state of N clocks. The next coming N lines each line contains N integers 0 or 1, each line describes an operation. The input is terminated by a set starting with N = 0.

Output
For each test case, If you can turn all the clocks into the state 12 o'clock, output "Yes", otherwise output "No".

Sample Input
3
3 3 3
1 0 0
0 1 0
0 0 1
3
3 3 3
1 1 0
1 0 0
0 1 0
3
3 3 3
1 1 1
0 1 0
0 0 1
0

Sample Output
Yes
No
Yes

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?