1 条题解

  • 1
    @ 2026-7-1 23:34:24

    666,不会写可以直接跳了

    我跳了
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    #include <iostream>
    #include <vector>
    #include <cmath>
    using namespace std;
    
    // 判断完美数
    bool isPerfect(int num) {
        if (num <= 1) return false;
        int sum = 0;
        for (int i = 1; i < num; i++) {
            if (num % i == 0) sum += i;
        }
        return sum == num;
    }
    
    int main() {
        int n, m, x, y, z;
        cin >> n >> m >> x >> y >> z;
        
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        long long damage = 0;
        long long buff = 0;
        long long bullets = m;
        long long successZC = 0;
        long long successHB = 0;
        long long successZZ = 0;
        
        int spiderCount = 0;
        
        for (int i = 0; i < n; i++) {
            int times = i + 1;
            int dist = a[i];
            
            // 判断有没有小汉堡和母集
            bool hasHB = (times % 2 == 0);
            bool hasMJ = (times % 3 == 0);
            
            // 确定运送时间和速度
            int time;
            if (!hasHB && !hasMJ) time = x;
            else if (hasHB ^ hasMJ) time = y;
            else time = z;
            
            int speed;
            if (time == x) speed = 10;
            else if (time == y) speed = 8;
            else speed = 5;
            
            // 完美数:整包销毁
            if (isPerfect(times)) {
                if (bullets > 0) bullets--;
                if (hasMJ) {
                    for (int j = 0; j < 3; j++) {
                        spiderCount++;
                        if (spiderCount % 4 == 0 && bullets > 0) bullets--;
                    }
                }
                continue;
            }
            
            // 计算爆炸点到十斤玫瑰的距离
            // 关键:十斤玫瑰在距离起点5米处等待
            // 榨菜从起点运送到距离为dist的位置爆炸
            // 所以十斤玫瑰到爆炸点的距离 = |dist - 5|
            int distanceToRose = abs(dist - 5);
            
            // 榨菜伤害判定
            if (bullets > 0) {
                if (distanceToRose <= 5) {
                    // 有效距离
                    damage += 25;
                    buff++;
                    successZC++;
                } else if (distanceToRose <= 10) {
                    // 无效距离
                    damage += 25;
                    successZC++;
                }
            }
            
            // 小汉堡伤害判定(如果有)
            if (hasHB && bullets > 0) {
                int hbDistance = abs(dist - 5);
                if (hbDistance <= 6) {
                    damage += 40;
                    buff++;
                    successHB++;
                }
            }
            
            // 蜘蛛伤害判定(如果有)
            if (hasMJ && bullets > 0) {
                int spiderDistance = abs(dist - 5);
                for (int j = 0; j < 3; j++) {
                    if (spiderDistance <= 2) {
                        damage += 10;
                        buff++;
                        successZZ++;
                    }
                }
            }
            
            // 水桶架枪
            if (times % 6 == 0 && bullets > 0) {
                if (bullets > 30) {
                    bullets -= (long long)floor(bullets / 4.0);
                } else {
                    bullets -= (long long)ceil(bullets / 4.0);
                }
            }
        }
        
        cout << damage*2 << endl;
        cout << (buff+1)*2 << endl;
        cout << bullets << endl;
        cout << successZC*2 << endl;
        cout << successHB*2 << endl;
        cout << successZZ*2 << endl;
        
        return 0;
    }
    
    • 1

    信息

    ID
    2627
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    18
    已通过
    3
    上传者