| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Cake Share
Description Updog
prepared to enjoy his delicious supper. At the very time he was ready
to eat, a serious accident occurred—GtDzx appeared!! GtDzx declared his
hadn't eaten anything for 3 days (obviously he was lying) and required
Updog to share the cake with him. Further more, he threatened Updog
that if Updog refused him, he would delete Updog's account in POJ! Thus
Updog had no choice. Updog intended to cut the cake into s (s ≥ 1) pieces evenly, and then gave t(0≤ t ≤ s) pieces to GtDzx. Apparently GtDzx might get different amount of cake for different s and t. Note that s = 12, t = 4 and s = 6, t =
2 will be regarded as the same case since GtDzx will get equal amount
in the two cases. Updog wouldn't separate the cake into more than N pieces. After sorted all available cases according to the amount of cake for GtDzx, in the first case no cake to gave to GtDzx (t = 0) and in the last case GtDzx would get the whole cake (s = t). Updog wondered that how much cake GtDzx would get in the k-th case. Input The first line of the input file contains two integers N (1 ≤ N ≤ 5000) and C(0 ≤ C≤ 3000). The following C lines each contains a positive integer describe C query respectively. The i-th query ki is to ask GtDzx's share of whole cake in the ki-th case . Output Answer each query in a separated line, according to the order in the input. Sample Input Sample Output Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2007 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator