若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1565: Hanoi Tower Troubles Again!

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,208

题目描述

There are many interesting variations on the Tower of Hanoi problem. This version consists of N pegs and one ball containing each number from 1, 2, 3,…,. Whenever the sum of the numbers on two balls is not a perfect square (i.e., c2 for some integer c), they will repel each other with such force that they can never touch each other.

The player must place balls on the pegs one by one, in order of increasing ball number (i.e., first ball 1, then ball 2, then ball 3…). The game ends where there is no non-repelling move.

The goal is to place as many balls on the pegs as possible. The figure above gives a best possible result for 4 pegs.

输入

The first line of the input contains a single integer T indicating the number of test cases ( 1<=T<=50). Each test case contains a single integer N ( 1<=N<=50) indicating the number of pegs available.

输出

For each test case, print a line containing an integer indicating the maximum number of balls that can be placed. Print “-1'' if an infinite number of balls can be placed.

样例输入

2
4
25


样例输出

11
337

参考代码

暂无

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Dreams孤独患者 Skip 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist