Comment

avatar username

I changed the degrees, as well as $(1 « i)$ if written like this, it will contain a maximum of $int$. If you write like this $(1ll « i)$ then it will be $long$ $long$ here is the modified code

Code
#include <bits/stdc++.h>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define f(i, m, n) for (int i = m; i < n; i++)
#define int long long  // I changed it here
#define pb push_back

using namespace std;
typedef long long ll;


set<int> generateNumbersByClearingBits(int number) {
    set<int> result;

    for (int i = 0; i < 63; ++i) {
        if (number & (1ll << i)) {  // I changed it here
            int modifiedNumber = number - (1ll << i); // I changed it here
            if(modifiedNumber!=0 && modifiedNumber < number){
            result.insert(modifiedNumber);
            }
        }
    }
    return result;
}

signed main()
{
    int t = 0;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        if (n == 1)
        {
            cout << 1 << endl;
            cout << 1 << endl;
        }
        else
        {
            set<int> ans = generateNumbersByClearingBits(n);
            ans.insert(n);
            cout<<ans.size()<<endl;
            for(auto &it :ans)cout<<it<<" ";
            cout << endl;
        }
    }
}
/*



(.) (.)
 )   (
(  Y  )
*/

The actual rating of this user is 1723.

Original comment.

Statistics