#include <iostream> #include <cmath> #define int long long using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; int ans = 0; for (int i = s.size() - 3, j = 2; i >= 0; i--, j++) { if (s[j] >= '0' && s[j] <= '9') ans += (int)pow(16, i) * (int)(s[j] - '0'); else { ans += (int)pow(16, i) * (int)(s[j] - 'A' + 10); } } cout << ans << endl; return 0; } // 64 位输出请用 printf("%lld")
就是一个简单的按照描述写出程序,当然要注意不能把减减写成加加,很rz的错误。简单的签到题,嗯,字数应该差不多了吧。#牛客春招刷题训练营#