Friday, February 26, 2016

LightOJ - 1014 - Ifter Party

  1. /****************#####    بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم   #####******************
  2. __________________________________________________________________________
  3. ######################  Ya-Seen Arafat(ACWizard) #########################
  4. ######################        UAP-CSE-33B        #########################
  5. *************************************************************************/
  6. #include <bits/stdc++.h>
  7. using namespace std;
  8.  
  9. int main(){
  10.     int t, P, L, cs = 0;
  11.     scanf("%d"&t);
  12.     while(t--){
  13.         scanf("%d %d"&P, &L);
  14.         int Q = P-L;
  15.         printf("Case %d: "++cs);
  16.         if(>= Q){
  17.             puts("impossible");
  18.             continue;
  19.         }
  20.         int sqr = sqrt(Q);
  21.         vector <int> container;
  22.         for(int i = 1; i <= sqr; i++){
  23.             if(Q%== 0){
  24.                 if(< i)container.push_back(i);
  25.                 int p = Q/i;
  26.                 if(!= i && L < p)container.push_back(p);
  27.             }
  28.         }
  29.         sort(container.begin(), container.end());
  30.         int sz = container.size();
  31.         if(sz == 0)puts("impossible");
  32.         else{
  33.             for(int i = 0; i < sz; i++){
  34.                 printf("%d", container[i]);
  35.                 if(== sz-1)puts("");
  36.                 else printf(" ");
  37.             }
  38.         }
  39.     }
  40.     return 0;
  41. }

No comments:

Post a Comment