// Accepted
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <sstream>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#define sf scanf
#define pf printf
#define sfint scanf ("%d %d",&a,&b)
#define sfl scanf ("%ld %ld",&a,&b)
#define sfll scanf ("%lld %lld",&a,&b)
#define sfd scanf ("%lf %lf",&a,&b)
#define sff scanf ("%f %f",&a,&b)
#define lp1(i,n) for(i=0;i<n;i++)
#define lp2(i,n) for(i=1;i<=n;i++)
#define LL long long
#define L long
#define mem(c,v) memset(c,v,sizeof(c))
#define ui unsigned int
#define ull unsigned long long int
#define ul unsigned long
#define nl puts("")
#define sq(x) ((x)*(x))
#define MX 1000005
#define N 100
#define MOD 10000000007
#define pb push_back
#define pi acos(-1.0)
#define sz size()
#define gc getchar ()
#define ps push
#define clr clear
#define inf 2147483647
#define bn begin()
#define ed end()
using namespace std;
int main()
{
int t,tc=1;
vector<ull>v;
sf("%d",&t);
while(t-- and tc++)
{
ull p,q,l,modu,divd;
sf("%llu %llu",&p,&l);
if(p<l)
{
p=p^l;
l=l^p;
p=p^l;
}
// if(!l)
// {
// v.push_back(1);
// }
q = p-l;
pf("Case %d:",tc-1);
if(q<=l)
{
pf(" impossible\n");
}
else {
//v.push_back(q);
ull k = sqrt(q),i; //cout << k;
for(i=1;i<=k;i++)
{
modu=q%i;
if(!modu)
{
divd=q/i;
if(divd > l)
{
v.push_back(divd);
}
if(i>l and divd!=i)
{
v.push_back(i);
}
}
}
sort(v.begin(),v.end());
ull vlen=v.size(),sp=vlen;
for(i=0;i<vlen;i++)
{
pf(" %llu",v[i]);
// if(sp>1)
// {
// pf(" ");
// sp--;
// }
}
v.clear();
nl;
}
}
return 0;
}
Comments
Post a Comment