ural 1268. Little Chu

1268. Little Chu

Time limit: 0.25 second
Memory limit: 64 MB
The favorite occupation of Little Chu is to sleep. Strictly speaking, he is busy with nothing but sleeping. Sometimes he wakes up and than the mankind makes some Great Discovery. For the first time Little Chu woke up  K days after his birth. For the second time he woke up  K2 after his birth. For the third time —  K3 days after his birth. This rule still holds true.
Each time whem Little Chu wakes up he looks at the calendar and remembers what day of week is today. They say that if the day of week will be repeated, than Litle Chu will start crying and his tears will flood the world.
Your task is to make the largest number of the Great Discoveries and maximally to delay the doomsday. Determine when should Little Chu be awaken for the first time if it is known that he can’t sleep more than one week after his birth.

Input

The first line contains integer  T (1 ≤  T ≤ 6553) — the number of tests. Each of the next  T lines contains integer  N (2 <  N < 65536) — the number of days in the week.  N is prime.

Output

K for each input test.

Sample

inputoutput
4
3
5
7
11
2
3
5
8
Problem Author: Pavel Atnashev
Problem Source: Ural State University championship, October 25, 2003

转载于:https://www.cnblogs.com/StupidBoy/p/4997997.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值