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<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<int>V;
int main()
{
//double start_time = clock();
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int t;
cin >> t;
for(int cs = 1; cs <= t; cs++){
int p,l;
cin >> p >> l;
int ext = p - l;
int sz = sqrt(ext);
// cout << ext << " "<<sz<<endl;
if(l < 1)V.insert(1);
if(ext > l)V.insert(ext);
for(int i = 2; i <= sz; i++){
if(ext%i == 0){
if(i*i == ext){
if(i > l)V.insert(i);
}
else{
if(i > l)V.insert(i);
if(ext/i > l)V.insert(ext/i);
}
}
}
cout << "Case "<<cs<<":";
int tt = V.size();
if(tt == 0)cout << " impossible\n";
else{
for(auto it = V.begin(); it != V.end(); it++)cout << " "<<*it;
cout << endl;
}
V.clear();
}
return 0;
}
|
No comments:
Post a Comment