解題心得
AAA3 = AAA(col) * 3(row)
AAA = A * 26^2 + A * 26^1 + A
程式碼
#include<iostream> #include<cmath> using namespace std; int main() { string s; int col = 0, row = 0, base = 1; cin >> s; while (isdigit(s.back())) { row += base * (s.back() - '0'); s.pop_back(); base *= 10; } base = 0; for (int i = s.size() - 1; i >= 0; i--) { col += (s[i] - 'A' + 1) * pow(26, base); base++; } cout << col * row; return 0; }
沒有留言:
張貼留言