Works Application 2017 笔试题 [Exam1] Magic Cube

[Exam1] Magic Cube

Description

Magic cube is a cube (M*M*M) which contains a integer number (0 <= number < P) in each cell (So you know there are M ^ 3 numbers).

Alice have one big cube and N smaller cubes (each small cube is unique).

The cube is magic since when you put a small cube in bigger one, the number in the same location will add up and mod P.

Your job is to determine the location of each small cube, so that we can make every number in big cube equal 0 after putting all the small cubes.

Notice

We guarantee that there is only one solution.
You cannot rotate cube.
We give the numbers in cubes in order of position [0,0,0], [0,0,1], …, [0,1,0], …,[1,0,0], …

Limits

Memory limit per test: 256 megabytes
Tiem limit per test: The faster the better

Compile & Environment

C++
g++ Main.cc -o Main -fno-asm -Wall -lm –static -std=c++0x -DONLINE_JUDGE

Java J2SE 8
Maximum stack size is 50m

Input

The first line is three integer M (2 <= M <= 7), N (1<= N <= 12), P ( 3 <= P <=5 )
Second line is M*M*M integers, showing the numbers in big cube.

Then is N lines, in which first is a integer L[i] ( 1 <= L[i] < M) shows the length of the small cube, then follows L[i] ^ 3 numbers (0 <= number < P).

Output

Output N lines of triad of integers, shows the location of this small cube.

Sample Test

Input

2 1 3
1 0 0 0 0 0 0 0
1 2

Output
0 0 0

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 13
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值