编程介的小学生 2017-12-01 09:27 采纳率: 20.5%
浏览 657
已采纳

Bicycle Puzzle

Problem Description
Per and Gunnar has found a wonderful online bicycle picture puzzle fiash solitaire game, and since they are very competitive, they want to find out who is best.

The purpose of the game is to descramble a picture of a bicycle. At the start of each game, the picture of the bicycle is cut into W times H equally sized rectangles and scrambled randomly.

Then the player repeatedly chooses two arbitrary rectangles and swaps them. He continues to swap rectangles until the picture is complete again. The game keeps track of the number of swaps, which is the score for that particular playthrough.

After Gunnar has played a game, he sends his score (along with W and H) to Per, and challenges Per to beat this score. Per soon realizes that if he is unlucky with the scrambling, it is impossible to beat Gunnar's score.

Per quickly writes a program to find out the probability that he can beat Gunnar's score (assuming that all scrambled pictures are equally probable) if he plays optimally.

But he is not sure whether his program is correct and wants to verify its correctness by challenging you to write the same program.

Input
The first line of the input consists of a single number T, the number of scenarios. Each scenario is given by a line with three integers W, H and S, where S is Gunnar's last score.

Output
For each scenario, output a line with the probability that Per beats Gunnar's score. Format the probability as an irreducible fraction where the numerator and the denominator are separated by /. Output only the numerator if the answer is an integer.

Notes and Constraints
0 < T <= 150
0 < W <= 5
0 < H <= 4
0 <= S <= W * H
When comparing two scores, the lowest one is best.

Sample Input
3
1 1 1
1 2 1
3 1 2

Sample Output
1
1/2
2/3

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-12-02 15:23
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?