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

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

星坟



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

5come5帮你背单词 [ schedule /'edju:l/ n. 计划,进度表,时刻表,时间表,一览表;vt. 预定,排定,制作…表,记入…表 ]


昨天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 | [楼 主]
stephenwang



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

5come5帮你背单词 [ immigration /imi'greiən/ n. 移居,外来的移民,移民总称 ]


欧拉函数。。。
顶端 Posted: 2008-05-02 11:13 | [1 楼]
我来我网·5come5 Forum » 程序员之家

Total 0.012566(s) query 6, Time now is:05-02 10:10, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号