传说中的谷歌招聘委员会成员之一,从幕后走出来,教你学系统设计!


一亩三分地论坛

 找回密码
 获取更多干活,快来注册
天天打游戏、照样领工资、还办H1B
这份工作你要不要?
把贵司招聘信息放这里
查看: 843|回复: 0
收起左侧

adobe的code challenge

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

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

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

您需要 登录 才可以下载或查看,没有帐号?获取更多干活,快来注册

x
感觉很像nim game可是实在是没懂啊。。。。
Shashank is playing the NIM game with Sara. The NIM game rules are described below:
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.. from: 1point3acres.com/bbs
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

本版积分规则

关闭

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

手机版|小黑屋|一亩三分地论坛声明

custom counter

GMT+8, 2017-9-24 20:31

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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