一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

扫码关注一亩三分地公众号
查看: 393|回复: 0
收起左侧

adobe的code challenge

[复制链接] |试试Instant~ |关注本帖
pinkdatura 发表于 2016-8-6 13:26:54 | 显示全部楼层 |阅读模式

2016(1-3月) 码农类 硕士 全职@adobe - 网上海投 - 在线笔试 |Fail在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

x
感觉很像nim game可是实在是没懂啊。。。。
Shashank is playing the NIM game with Sara. The NIM game rules are described below: . visit 1point3acres.com for more.
There are  buckets. Each bucket contains  or more ball(s). During each turn, a player selects a bucket and takes out  or more ball(s). The last player to take out the last ball(s) wins the game.
Shashank makes a modification to the game because he is bored. For the first 50 moves, the game is played in the following manner:
  • Shashank adds a bucket containing a non-zero number of balls.
  • Sara adds a bucket containing a non-zero number of balls.
  • Shashank selects a bucket and takes out  or more balls.
  • Sara selects a bucket and takes out  or more balls.
After the first 50 moves, the usual rules of the NIM game are followed, and the addition of buckets does not take place. Shashank plays first. Shashank wants to know the minimum number of balls the first additional bucket should contain (which he is adding in the first turn of the game). If no such bucket exists, print −1.
Your task: Find the minimum number of balls Shashank should add to win the game.
Input Format
The first line contains an integer , denoting the number of test cases.
The first line of each test case contains an integer , denoting the number of buckets.
The next line contains  integers. The  integer denotes the number of balls in the  bucket.
Output Format
Print the answer corresponding to each test case on separate lines.
Constraints


, where  is the  integer.
Sample Input
1110
Sample Output
10

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2016-12-4 16:46

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表