简洁,快速的bv号转av号 c++实现

加了一部分预处理,变得更高效了
继承自朋友这里

#include <iostream>
#include <string>

using namespace std;

const char map[58] =
    {'f', 'Z', 'o', 'd', 'R', '9', 'X', 'Q', 'D', 'S', 'U', 'm', '2', '1', 'y', 'C', 'k', 'r', '6', 'z', 'B', 'q', 'i', 'v', 'e', 'Y', 'a', 'h', '8', 'b', 't', '4', 'x', 's', 'W', 'p', 'H', 'n', 'J', 'E', '7', 'j', 'L', '5', 'V', 'G', '3', 'g', 'u', 'M', 'T', 'K', 'N', 'P', 'A', 'w', 'c', 'F'};
const int numlist[10] = {6, 2, 4, 8, 5, 9, 3, 7, 1, 0};
unsigned long long power[10] = {1LLU, 58LLU, 3364LLU, 195112LLU, 11316496LLU, 656356768LLU, 38068692544LLU, 2207984167552LLU, 128063081718016LLU, 7427658739644928LLU};

int main()
{
    string bv;
    cout << "请输入:" << endl;
    cin >> bv;
    unsigned long long sum = 0;
    for (register int i = 0; i < 10; i++)
        for (register int j = 0; j < 58; j++)
            if (map[j] == bv[i])
                sum += j * power[numlist[i]];
    sum -= 100618342136696320LLU;
    sum ^= 177451812LLU;
    cout << "结果是" << sum << endl;
}
posted @ 2021-08-11 21:03  Icys  阅读(188)  评论(0编辑  收藏  举报