题目链接http://bailian.openjudge.cn/practice/2814/
思路:逐步枚举,暴力。。。
题目本来是这样:
移动 影响的时钟
1 ABDE
2 ABC
3 BCEF
4 ADG
5 BDEFH
6 CFI
7 DEGH
8 GHI
9 EFHI
这样不好理解,可以转换为时钟会被哪些移动影响
A 124
B 1235
C 236
D 1457
E 13579
F 3569
G 478
H 5789
I 689
这样就只需用九个for循环,找到使每个钟初始状态加最后移动的对4取模等于0时即可。
代码在此
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a[11];\\初始钟
int moves[11]={
0};\\存移动次数
for(int i = 1;i<=9;++i)
{
scanf("%d",&a[i]);
}
int sum = 0;
for(moves[1] = 0;moves[1]<4;moves[1]++)
for(moves[2] = 0;moves[2]<4;moves[2]++