C - abc285_brutmhyhiizp
https://atcoder.jp/contests/abc285/tasks/abc285_c
思路
对于长度为L+1的字符序列, A[1], ..., A[L], A[L+1]
首先统计长度为1 到 L 字符序列 总数, 即
A , ... , Z
AA, AB, ..., ZZ
AAA, ..., ZZZ
....
然后统计 A[1], ..., A[L], A[L+1] 的序数
A...A ---- L+1 个A
到
A[1], ..., A[L], A[L+1]
Code
https://atcoder.jp/contests/abc285/submissions/38071836
string s; int main() { cin >> s; int size = s.size(); long long last_order = 0; for(int i=0; i<size; i++){ char a = s[i]; int ai = a - 'A'; last_order *= 26; last_order += ai; } long long last_count = last_order + 1; long long all_count = 0; all_count = last_count; int slen = s.size(); long long level_power = 1; long long prev_count = 0; for(int i=1; i<slen; i++){ level_power *= 26; prev_count += level_power; } all_count += prev_count; cout << all_count << endl; return 0; }
标签:...,brutmhyhiizp,int,long,abc285,size From: https://www.cnblogs.com/lightsong/p/17062692.html