1 条题解

  • 0
    @ 2025-10-12 20:05:29

    签到题

    #include <bits/stdc++.h>
    using namespace std;
    
    void solve() {
        int n; cin >> n;
        int ans = 0;
        cin >> ans;     
        for(int i = 1; i < n; i++){  
            int num; cin >> num;
            if(i % 2 == 1){      // 第2、4个数为奇,执行加法
                ans += num;
            } else {             // 第3、5个数为偶,执行减法
                ans -= num;
            }
        }
        cout << ans << '\n';
    }
    
    int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        solve();
        return 0;
    }
    
    • 1

    信息

    ID
    488
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    (无)
    递交数
    210
    已通过
    57
    上传者