题解 | #切蛋糕#

我爱城科软协!

https://ac.nowcoder.com/acm/contest/72285/A

#include<iostream>
#include<string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n & (n-1) == 0) cout << n << " " << 0 << endl;
    else{
        int limit = (n&(n-1)) ^ n;
        int ans = 0;
        while(limit < n){
            limit <<= 1;
            ans++;
        }
        cout << limit << " " << ans << endl;
    }
    return 0;
}
全部评论

相关推荐

测试糕手手:社会第一课,随便吹牛逼,直接说四个月,别老实。老实人只会被欺负
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务