#include <iostream>
#include <string>
using namespace std;

bool isValidExpression(string X, int Y, string Z, int W) {
    if (X.size() != 1 || Z.size() != 1) {
        return false;
    }
    if (X[0] != Z[0]) {
        return false;
    }
    return true;
}

int calculateEnumeration(string X, int Y, string Z, int W) {
    if (!isValidExpression(X, Y, Z, W)) {
        return -1;
    }
    if (Y <= W) {
        return W - Y + 1;
    } else {
        return Y - W + 1;
    }
}

int main() {
    string X, Z;
    int Y, W;
    cin >> X >> Y >> Z >> W;

    if (isValidExpression(X, Y, Z, W)) {
        cout << "valid" << endl;
        cout << calculateEnumeration(X, Y, Z, W) << endl;
    } else {
        cout << "Invalid" << endl;
        cout << -1 << endl;
    }

    return 0;
}
``
# 枚举结构## 题目描述D-- 是 2077 年的一种新兴语言。在 D-- 语言中引入了一种「枚举结构」。具体的这一种结构可以使用以下表达式表示:plaintextX Y Z W其中$X Z$ 为单个小写字母代表变量名;$Y W$ 为整数代表枚举的起始值和终止值。其代表将变量 $X$ 从 $Y$ 枚举到 $W$。由于 D-- 追求极致的安全性因此为了进行确认如果想要成功对 $X$ 变量进行枚举那

原文地址: https://www.cveoy.top/t/topic/h4nj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录