개발자 톡
연습문제 톡
[21년 재직자 대회 예선] 전광판
C++ 풀이
- 등록일
- 2025-02-05 22:18:44
- 조회수
- 79
- 작성자
- cjh010322
#include <bits/stdc++.h> #define endl '\n' using namespace std; int f(int); int main() { ios::sync_with_stdio(false); cin.tie(NULL); int T, A, B, d1, d2, a, b, res; vector<string> v = { "1011111", "0000101", "1110110", "1110101", "0101101", "1111001", "1111011", "1001101", "1111111", "1111101" }; cin >> T; while (T--) { cin >> A >> B; if (A > B) swap(A, B); d1 = f(A); d2 = f(B); res = 0; for (int i = d2; i >= 1; i /= 10) { a = A / i % 10; b = B / i % 10; if (i <= d1 && i <= d2) { for (int j = 0; j < 7; j++) res += v[a][j] != v[b][j]; } else { for (int j = 0; j < 7; j++) res += v[b][j] == '1'; } } cout << res << endl; } } int f(int n) { int tmp = 1; while (n / (tmp * 10)) tmp *= 10; return tmp; }
#[21년_재직자_대회_예선]_전광판