编程介的小学生 2017-05-04 12:39 采纳率: 20.5%
浏览 754
已采纳

Parity Modulo P

A Mersenne prime is a prime number of the form Mn = 2n − 1.This is to say that it is a prime number which is one less than a power of two. They are named after Marin Mersenne, a French Minim friar, who studied them in the early 17th century. The first four Mersenne primes (sequence A000668 in OEIS) are 3, 7, 31, and 127.

The 37th Mersenne prime is 23021377-1, which has 909526 decimal digits. You task is to give the parity of (x mod (23021377-1)). That is to say, try to find (x mod (23021377-1)) mod 2.

Input

There are multiple test cases. The input is very huge, nearly 5 MiB. Please use the fast IO methods. The first line of input contains an integer T(T≤ 50) indicating the number of test cases. For each test case:

There is an integer x in one line. (0≤ x< 101300000)

Output

For each test case, if the result is even, then output 0, otherwise output 1.

Sample Input

5
1
2
10
1000000007
12345478431674673261786478321654125365674123451276564712356471253674517132876760
Sample Output

1
0
0
1
0

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-05-05 15:48
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?