답안 #20636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20636 2017-02-13T05:05:50 Z ??(#78, jjwdi0) 채점 시스템 (OJUZ11_judge) C++11
100 / 100
223 ms 2020 KB
#include <bits/stdc++.h>
using namespace std;

int T, A, B;
string ar[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};

int main() {
    scanf("%d", &T);
    for(int i=0; i<T; i++) {
        scanf("%d %d", &A, &B);
        string s, t;
        if(A == 0) s = "0";
        while(A) s = ar[A % 10] + s, A /= 10;
        while(B) t = ar[B % 10] + t, B /= 10;
        int ans = 0;
        for(int i=0;; i++) {
            string u = s;
            for(int j=0; j<i; j++) u = "0" + u;
            if(u.length() >= t.length()) {ans = i; break;}
            u = "1" + u;
            if(u.length() == t.length() && u > t) {ans = i; break;}
        }
        printf("%d\n", ans);
    }
}

Compilation message

judge.cpp: In function 'int main()':
judge.cpp:8:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &T);
                    ^
judge.cpp:10:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &A, &B);
                               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 2020 KB Output is correct
2 Correct 66 ms 2020 KB Output is correct
3 Correct 59 ms 2020 KB Output is correct
4 Correct 56 ms 2020 KB Output is correct
5 Correct 63 ms 2020 KB Output is correct
6 Correct 69 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 2020 KB Output is correct
2 Correct 66 ms 2020 KB Output is correct
3 Correct 59 ms 2020 KB Output is correct
4 Correct 56 ms 2020 KB Output is correct
5 Correct 63 ms 2020 KB Output is correct
6 Correct 69 ms 2020 KB Output is correct
7 Correct 89 ms 2020 KB Output is correct
8 Correct 79 ms 2020 KB Output is correct
9 Correct 89 ms 2020 KB Output is correct
10 Correct 79 ms 2020 KB Output is correct
11 Correct 223 ms 2020 KB Output is correct