2020年团体程序设计天梯赛 L1-7 前世档案

思路:

水题,略过

Tip:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    ll len = pow(2, n);
    string s;
    for (int i = 1; i <= m; i++) {
        cin >> s;
        int ans = 1;
        ll now = len / 2;
        for (auto j:s) {
            if (j == 'n')
                ans += now;
            now /= 2;
        }
        cout << ans << endl;
    }
    return 0;
}

  

原文地址:https://www.cnblogs.com/Whiteying/p/14056487.html