Advertisement
Anwar_Rizk

Untitled

May 22nd, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define cout(st) for(auto& i : st) cout << i << " "; cout << "\n"
  4. #define cin_2d(vec, n, m) for(int i=0; i<n; i++) for(int j=0; j<m && cin >> vec[i][j]; j++);
  5. #define cout_2d(vec, r, c) for(int i=0; i<r; i++, cout << "\n") for(int j=0; j<c && cout << vec[i][j] << ""; j++)
  6. #define cout_map(mp) for(auto& [f, s] : mp) cout << f << " : " << s << "\n"
  7. #define matrix(grid, n, m) vector < vector <int> > grid(n, vector <int> (m));
  8. #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n";
  9. #define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  10. #define fixed(n) cout << fixed << setprecision(n)
  11. #define Num_of_Digits(n) ((int)log10(n)+1)
  12. #define getline(s) getline(cin >> ws, s)
  13. #define to_decimal(bin) stoll(bin, nullptr, 2)
  14. #define rall(s) s.rbegin(), s.rend()
  15. #define all(s) s.begin(), s.end()
  16. #define sz(x) int(x.size())
  17. #define Pair pair <int, int>
  18. #define fi first
  19. #define se second
  20. #define ll long long
  21. #define PI acos(-1)
  22. #define Mod 1'000'000'007
  23. #define INF 2'000'000'000
  24. #define EPS 1e-9
  25. #define endl cout << "\n";
  26.  
  27. template < typename T = int > istream& operator >> (istream &in, vector < T > &v) {
  28. for (auto &x: v) in >> x;
  29. return in;
  30. }
  31.  
  32. template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) {
  33. for (const T &x: v) out << x << ' ';
  34. return out;
  35. }
  36.  
  37. void Anwar_Rizk(){
  38. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  39. // #ifndef ONLINE_JUDGE // Anwar Rizk 🥇🖤
  40. // freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  41. // #endif
  42. }
  43.  
  44. double n, x, y, sum;
  45. vector < int > temp;
  46.  
  47. bool subsets(vector < int > v, int n){
  48. for(int i = 0; i < (1 << n); i++){
  49. temp.clear();
  50. int s = 0;
  51. for(int j = 0; j < n; j++){
  52. if(i & (1 << j)) temp.push_back(v[j]), s += v[j];
  53. }
  54. if(s / (sum - s) == x / y){
  55. cout << "POSSIBLE\n";
  56. cout << sz(temp) << "\n";
  57. cout << temp;
  58. endl
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64.  
  65. void solve(){
  66. cin >> n >> x >> y;
  67. vector < int > v(n);
  68. iota(all(v), 1);
  69. sum = n * (n + 1) / 2;
  70. if(!subsets(v, n)){
  71. cout << "IMPOSSIBLE\n";
  72. }
  73. }
  74.  
  75. int main()
  76. { Anwar_Rizk();
  77.  
  78. int t = 1, tests = 1;
  79. cin >> t;
  80. while(t--){
  81. cout << "Case #" << tests++ << ": ";
  82. solve();
  83. }
  84.  
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement