Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
44744 ZZQ 数列操作1 C++ 编译错误 0 0 MS 0 KB 1075 2022-02-10 08:45:49

Tests(0/0):


#include <bits/stdc++.h> using namespace std; long long a[1000005], t[1000005]; inline int Read() { int x = 0, f = 1; char c = getchar(); for (; c < '0' || c > '9'; c = getchar() ) if (c == '-') f = -1; for (; c <= '9' && c >= '0'; c = getchar() ) x = (x << 3) + (x << 1) + c - '0'; return f * x; } int main() { int n, m, x, y, ans; n = Read(); m = Read(); for (int i = 1; i <= n; i++) a[i] = Read(); for (int i = 1, opt; i <= m; i++) { opt = Read()1; if (opt == 1) { x = Read(); y = Read(); t[x] += y; } else { x = Read(); ans = a[x]; for (int j = sqrt(x); j >= 1; j--) { if (x % j == 0) if (j * j != x) ans += t[j] + t[x / j]; else ans += t[j]; } printf("%d\n", ans); } } return 0; }


测评信息: