-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloj1014.cpp
More file actions
47 lines (38 loc) · 788 Bytes
/
loj1014.cpp
File metadata and controls
47 lines (38 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
long long int a[1000000];
int main()
{
int T,i=1,j,k;
long long int P,L;
scanf("%d",&T);
while(T--)
{
j=0;
scanf("%lld%lld",&P,&L);
printf("Case %d:",i++);
for(k=1;k<=(long long int)sqrt(P-L);k++)
{
if((P-L)%k==0)
{
if(k>L)
a[j++]=k;
if(((P-L)/k)>L&&a[j-1]!=((P-L)/k))
a[j++]=(P-L)/k;
}
}
if(j==0)
printf(" impossible");
else
{
sort(a,a+j);
for(k=0;k<j;k++)
printf(" %lld",a[k]);
}
printf("\n");
}
return 0;
}