[原创]Light OJ 1014 Ifter Party [因子分解]【数论】

2016-06-29 15:13:15 Tabris_ 阅读数：415

https://blog.csdn.net/qq_33184171/article/details/51783218

Ifter Party
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Submit

Status
Description
I have an Ifter party at the 5th day of Ramadan for the contestants. For this reason I have invited C contestants and arranged P piaju’s (some kind of food, specially made for Ifter). Each contestant ate Q piaju’s and L piaju’s were left (L < Q).

Now you have to find the number of piaju’s each contestant ate.

Input
Input starts with an integer T (≤ 325), denoting the number of test cases.

Each case contains two non-negative integers P and L (0 ≤ L < P < 231).

Output
For each case, print the case number and the number of possible integers in ascending order. If no such integer is found print ‘impossible’.

Sample Input
4
10 0
13 2
300 98
1000 997
Sample Output
Case 1: 1 2 5 10
Case 2: 11
Case 3: 101 202
Case 4: impossible

T只有325个 所以暴力求解即可

for(LL i=1;i*i<=n;i++)
{
if(p%i==0)
{
if(i>l)
a[num++]=i;
if(p/i>l&&p/i!=i) //注意这里 能被开平方的话数就重了 在这wrong 5发 汗！
a[num++]=p/i;
}
}