Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define cout(st) for(auto& i : st) cout << i << " "; cout << "\n"
- #define cin_2d(vec, n, m) for(int i=0; i<n; i++) for(int j=0; j<m && cin >> vec[i][j]; j++);
- #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++)
- #define cout_map(mp) for(auto& [f, s] : mp) cout << f << " : " << s << "\n"
- #define matrix(grid, n, m) vector < vector <int> > grid(n, vector <int> (m));
- #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n";
- #define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
- #define fixed(n) cout << fixed << setprecision(n)
- #define Num_of_Digits(n) ((int)log10(n)+1)
- #define getline(s) getline(cin >> ws, s)
- #define to_decimal(bin) stoll(bin, nullptr, 2)
- #define rall(s) s.rbegin(), s.rend()
- #define all(s) s.begin(), s.end()
- #define sz(x) int(x.size())
- #define Pair pair <int, int>
- #define fi first
- #define se second
- #define ll long long
- #define PI acos(-1)
- #define Mod 1'000'000'007
- #define INF 2'000'000'000
- #define EPS 1e-9
- #define endl cout << "\n";
- template < typename T = int > istream& operator >> (istream &in, vector < T > &v) {
- for (auto &x: v) in >> x;
- return in;
- }
- template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) {
- for (const T &x: v) out << x << ' ';
- return out;
- }
- void Anwar_Rizk(){
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- // #ifndef ONLINE_JUDGE // Anwar Rizk 🥇🖤
- // freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- // #endif
- }
- double n, x, y, sum;
- vector < int > temp;
- bool subsets(vector < int > v, int n){
- for(int i = 0; i < (1 << n); i++){
- temp.clear();
- int s = 0;
- for(int j = 0; j < n; j++){
- if(i & (1 << j)) temp.push_back(v[j]), s += v[j];
- }
- if(s / (sum - s) == x / y){
- cout << "POSSIBLE\n";
- cout << sz(temp) << "\n";
- cout << temp;
- endl
- return true;
- }
- }
- return false;
- }
- void solve(){
- cin >> n >> x >> y;
- vector < int > v(n);
- iota(all(v), 1);
- sum = n * (n + 1) / 2;
- if(!subsets(v, n)){
- cout << "IMPOSSIBLE\n";
- }
- }
- int main()
- { Anwar_Rizk();
- int t = 1, tests = 1;
- cin >> t;
- while(t--){
- cout << "Case #" << tests++ << ": ";
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement