- /****************##### بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم #####******************
- __________________________________________________________________________
- ###################### Ya-Seen Arafat(ACWizard) #########################
- ###################### UAP-CSE-33B #########################
- *************************************************************************/
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int t, P, L, cs = 0;
- scanf("%d", &t);
- while(t--){
- scanf("%d %d", &P, &L);
- int Q = P-L;
- printf("Case %d: ", ++cs);
- if(L >= Q){
- puts("impossible");
- continue;
- }
- int sqr = sqrt(Q);
- vector <int> container;
- for(int i = 1; i <= sqr; i++){
- if(Q%i == 0){
- if(L < i)container.push_back(i);
- int p = Q/i;
- if(p != i && L < p)container.push_back(p);
- }
- }
- sort(container.begin(), container.end());
- int sz = container.size();
- if(sz == 0)puts("impossible");
- else{
- for(int i = 0; i < sz; i++){
- printf("%d", container[i]);
- if(i == sz-1)puts("");
- else printf(" ");
- }
- }
- }
- return 0;
- }
Friday, February 26, 2016
LightOJ - 1014 - Ifter Party
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment