Fantasic Game

 

 

Mr. Fantasy likes magic show very much.  He does not only like watching magic show, but also like to play magic. This time, he creates a new magic game.

In this game, an assistant is needed. And there should be many boxes numbered 0, 1, 2, 3... When the game begins, the assistant should ask one of the audiences to choose one box and put something into this box. Of course the magician doesn’t know which one is chosen. Then the assistant should request some positive integers from audiences. The assistant will select some numbers and divides them into groups. There are three numbers in each group, represented by U, L and K. The assistant will show the groups of numbers to the magician and the magician can point out which box is chosen.

You may guess out it is the groups of numbers that tells the magician the box number and you are right. However, the calculating method is really complex. For each group of numbers, the magician will get some numbers by formula X = UK * I (L <= X <= U, I = 0, 1, 2...) and he should remember the times each X appeared. After dealing with all the groups, the X which has appeared odd times is the number of the chosen box. Sometimes the audience won’t put anything into boxes, and there will be no number appeared odd times. The assistant is so clever that at most one number will appear odd times.

As you known now, the method is clear but hard to calculate. So Mr. Fantasy wants you to write a program to calculate this. Can you help him?

 

Input     (Please use standard input, and don’t read or write files.)

First line contains one integer M, means there are M groups of numbers.

M lines followed, and each line contains three integers, U, L and K.

0< M <20000, 0<= U, L, K < 231

 

Output   (Please use standard output, and don’t read or write files.)

One integer represents the chosen box number. If no box has been chosen, you should output “NONE” without double quotation marks.

 

Sample Input

Sample Output

4

5 1 1

10 6 1

10 1 1

4 4 1

4

 

 

对公式进行转化,由于X = UK * I,则I =( U – X ) / K ,由于I是整数,因此(U-X%K=0,而L <= X <= U,可以枚举出所有。

用一个链表记录所有出现的X,并为每个X准备一个位记录其出现的情况。当X出现奇数次,出现记录为TRUE;当X出现偶数次,出现记录为FALSE

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值