我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: 昨天acm热身赛的a题 显示签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

星坟



性别: 帅哥 状态: 该用户目前不在线
等级: 希望之光
家族: 格格乐心
发贴: 1558
威望: 0
浮云: 310
在线等级:
注册时间: 2006-09-10
最后登陆: 2013-02-21

5come5帮你背单词 [ universal /ju:ni'və:səl/ a. 全世界的,普遍的 ]


昨天acm热身赛的a题

A.  A Simple Game

--------------------------------------------------------------------------------

Time Limit: 1.0 Seconds  Memory Limit: 65536K
Total Runs: 0  Accepted Runs: 0

--------------------------------------------------------------------------------


Alice likes to play games. One day she meets such a game. There are N * N switches arranged in an N * N array. Pressing a switch would change its state, from 'off' to 'on' or from 'on' to 'off'. In addition, if a switch at row r and column c is pressed, then all switches with coordinate (k * r, k * c) will change state, with integer k > 1. Initially all switches are 'off'.



For example, in the picture above, white buttons represent switches turned 'off' and colored ones represent switches turned 'on'. Initially all buttons are white. If the button at (2,2) is pressed, then buttons at (2,2), (4,4) will change state(represented with orange color). And if one presses the button (2,1), buttons at (2,1) and (4,2) will change from 'off' to 'on'(represented with gray color).

The goal of the game is to turn 'on' all the switches (i.e. when you finish the game, all the switches must be at the state of 'on') and the player must do that with as few presses as possible. Now Alice would like your help.


Input
The first line of input file is an integer T, the number of test cases. T lines follow, each contain an integer N, the dimension of the array in one game.

Output
Output consists of T lines. Each line contains an integer, the minimum number of presses for the corresponding test case.
Constraints
1 ≤ T ≤ 100, 1 ≤ N ≤ 10000
Sample Input
2
2
3

Sample Output
3
7

Sample Input/Output Clarification
For test case 1, press (1,1) (1,2) (2,1).
For test case 2, press (1,1) (1,2) (1,3) (2,1) (2,3) (3,1) (3,2).







怎么实现内存啊  不能用10000维的数组啊!!!
顶端 Posted: 2008-05-02 09:46 | [楼 主]
星坟



性别: 帅哥 状态: 该用户目前不在线
等级: 希望之光
家族: 格格乐心
发贴: 1558
威望: 0
浮云: 310
在线等级:
注册时间: 2006-09-10
最后登陆: 2013-02-21

5come5帮你背单词 [ electricity /ilek'trisiti/ n. 电 ]


小于一百维的我弄出来了  但是大于一百维的有点困难  想用位操作  可是有点困难啊    昨天有人做出来了  不知道怎么做的??
顶端 Posted: 2008-05-02 09:50 | [1 楼]
星坟



性别: 帅哥 状态: 该用户目前不在线
等级: 希望之光
家族: 格格乐心
发贴: 1558
威望: 0
浮云: 310
在线等级:
注册时间: 2006-09-10
最后登陆: 2013-02-21

5come5帮你背单词 [ similarity /simi'læriti/ n. 相似,类似 ]


o 个人也这样认为  可是我用位操作还是内存不够  不知道怎么回事 
另外再问个问题  Multiple test files是什么意思啊  不要代码 还是用什么多媒体文件? 解释一下 谢谢
顶端 Posted: 2008-05-02 18:37 | [2 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.009876(s) query 6, Time now is:11-22 00:55, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号