2 条题解
-
0
模拟即可
题目参考出处 霓虹【算法赛】 - 蓝桥云课 (lanqiao.cn)
双倍经验了算是,将原题的输入读入改为循环枚举当前数和下一个数,将这两数的字符串形式作为题目的输入处理即可
#include <bits/stdc++.h> using namespace std; using i64 [[maybe_unused]] = long long; template<typename T, class comparer = greater<T>> using heap = priority_queue<T, vector<T>, comparer>; const char &ln = '\n'; #define parse static_cast signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int arr[10][10]{ {0, 4, 3, 3, 4, 3, 2, 3, 1, 2}, {4, 0, 5, 3, 2, 5, 6, 1, 5, 4}, {3, 5, 0, 2, 5, 4, 3, 4, 2, 3}, {3, 3, 2, 0, 3, 2, 3, 2, 2, 1}, {4, 2, 5, 3, 0, 3, 4, 3, 3, 2}, {3, 5, 4, 2, 3, 0, 1, 4, 2, 1}, {2, 6, 3, 3, 4, 1, 0, 5, 1, 2}, {3, 1, 4, 2, 3, 4, 5, 0, 4, 3}, {1, 5, 2, 2, 3, 2, 1, 4, 0, 1}, {2, 4, 3, 1, 2, 1, 2, 3, 1, 0} }; string a, b; int ans = 0; for(int i = 1000; i < 2024; ++i) { a = to_string(i), b = to_string(i + 1); for(int i = 0; i < a.length(); ++i) { int x = a[i] ^ '0', y = b[i] ^ '0'; ans += arr[x][y]; } } cout << ans; return 0; }
- 1
信息
- ID
- 996
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 151
- 已通过
- 39
- 上传者