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;
}
posted @ 2021-03-15 13:03  Uiney  阅读(42)  评论(0编辑  收藏  举报