acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 竞赛
  • 讨论
  • 团队
登录
注册
题目详情提交记录(0)
  • AC

    #include <bits/stdc++.h> using namespace std; using int64 = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, x, y; long long k; cin >> n >> m >> x >> y >> k; vector<vector<long long>> a(n, vector<long long>(m)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; auto calc = [&](bool east) -> long long { long long total = 0; int curx = x - 1, cury = y - 1; vector<long long> vals; if (east) { for (int j = 0; j < m; j++) vals.push_back(a[curx][j]); } else { for (int i = 0; i < n; i++) vals.push_back(a[i][cury]); } long long cycle_sum = accumulate(vals.begin(), vals.end(), 0LL); long long ans = 0, sum = 0; int pos = (east ? cury : curx); int len = (east ? m : n); if (cycle_sum > 0) { long long full_cycles = max(0LL, (k - 1) / cycle_sum); sum += full_cycles * cycle_sum; ans += full_cycles * len; } while (sum < k) { pos = (pos + 1) % len; sum += vals[pos]; ans++; } return ans; }; cout << calc(true) << " " << calc(false) << "\n"; return 0; }

    userId_undefined

    每题AC!!!

    出道萌新空间掌握者枚举·枚举小能手分支·分支解题者倔强青铜I/O·IO入门者
    1阅读
    0回复
    1点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页