Binarize It(训练赛)

题意:输入一个数,输出一个比接近它的比他大的二进制数(通过一直乘2得到的数)。

题解:直接暴力,跑循环得到。

accode:

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int s = 2;
        while (s < n)
        {
            s *= 2;
        }
        cout << "Input value: " << n << endl;
        cout << s << endl << endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/Uiney117/p/14536975.html