1 条题解

  • 0
    @ 2025-11-27 19:16:45
    • 直接按照题意模拟
    • 时间复杂度:O(nm)O(nm),会 TLE
    #include <bits/stdc++.h>
    using namespace std;
    
    using i64 = long long;
    
    int main() {	
        ios::sync_with_stdio(false);
        cin.tie(0); cout.tie(0);
        
        int n, m;
        cin >> n >> m;
        vector<int> a(n + 1);
        for (int i = 1; i <= n; i++) cin >> a[i];
        
        string cmd;
        int x, y;
        while (m--) {
            cin >> cmd >> x >> y;
            if (cmd == "A") {
                i64 ans = 0;
                for (int i = y; i <= n; i += x) ans += a[i];
                cout << ans << '\n';
            } else {
                a[x] = y;
            }
        }
        return 0;
    }
    
    • 1

    信息

    ID
    195
    时间
    1000ms
    内存
    125MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者