题解 | #Math Practice#

Math Practice

https://ac.nowcoder.com/acm/problem/24744

思路:直接照着题意模拟就可以了,但要注意一件事。

十年OI一场空

不开longlong见祖宗

其实题目给了提示,不会有人眼瞎看不见吧

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

long long a, b;

int fj (long long x) {//求x的最高位
    int y;
    while (x != 0) {
        y = x % 10;
        x /= 10;
    }
    return y;
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cin >> a >> b;
    for (int e = 0; e <= 62; e ++) {
        long long tmp = pow(2, e);
        if (e > a && fj (tmp) == b) {
            cout << e;
            return 0;
        }
    }
    cout << 0;
    return 0;
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 11:47
点赞 评论 收藏
分享
05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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