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

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

星坟



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

5come5帮你背单词 [ reign /rein/ n. (君主)统治时期,统治,支配;vi. 统治,称王 ]


昨天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帮你背单词 [ golden /'gəuldən/ a. 金色的,发亮的,金的,金制的,高尔夫球 ]


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



性别: 帅哥 状态: 该用户目前不在线
等级: 人见人爱
家族: 考研俱乐部
发贴: 3812
威望: 0
浮云: 1815
在线等级:
注册时间: 2006-11-15
最后登陆: 2009-06-10

5come5帮你背单词 [ northwest /'no:θ'west/ n. 西北;a. 西北的,在西北的;ad. 向西北 ]


欧拉函数。。。
顶端 Posted: 2008-05-02 11:13 | [2 楼]
magian



性别: 帅哥 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 958
威望: 0
浮云: 1947
在线等级:
注册时间: 2006-11-05
最后登陆: 2008-06-29

5come5帮你背单词 [ satellite /'sætəlait/ n. 沙丁鱼 ]


你定义2维数组是不行的,我也试过了,定义10000,元素就有100000000个,大小已经超过默认栈的大小了,如果想用,就把数组定义成全局,可以运行,但是内存使用和运行时间都超标

我觉得这个题目有递推关系
顶端 Posted: 2008-05-02 12:01 | [3 楼]
星坟



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

5come5帮你背单词 [ pump /pΛmp/ n. 泵,抽水机,打气机;v. 用抽水机抽,打气 ]


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





性别: 帅哥 状态: 该用户目前不在线
等级: 初出茅庐
发贴: 21
威望: 0
浮云: 1136
在线等级:
注册时间: 2008-01-17
最后登陆: 2016-04-13

5come5帮你背单词 [ diligent /'dilid3ənt/ a. 勤奋的,用功的 ]


I am not sure whether this is a problem of binary match!
顶端 Posted: 2009-12-27 22:22 | [5 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.013558(s) query 5, Time now is:04-19 18:47, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号