본문 바로가기

USACO/Bronze

백준 5940 Math Practice (USACO November 2010 Bronze 3번)

문제 링크: https://www.acmicpc.net/problem/5940

 

5940번: Math Practice

One lovely afternoon, Bessie's friend Heidi was helping Bessie review for her upcoming math exam. Heidi presents two integers A (0 <= A <= 45) and B (1 <= B <= 9) to Bessie who must respond with an integer E in the range 1..62. E is the smallest integer in

www.acmicpc.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int A, B;
    cin >> A >> B;
    for(int i = A + 1; i <= 62; i++) {
        long long n = 1;
        int power = i;
        while(power--) n *= 2;
        while(n > 9) n /= 10;
        if(n == B) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << 0 << '\n';
    return 0;
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter