1 条题解
-
0
#include <bits/stdc++.h> using namespace std; int n, m, x, sum; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x; // 找到 >=x 的最小的 m 的倍数 for (int j = x;; j++) { if (j % m == 0) { sum += j; break; } } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, x, sum; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x; int num = x / m; // x 里面有几个 m if (x % m == 0) sum += x; else sum += (num + 1) * m; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, x, sum; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x; sum += (x + (m - 1)) / m * m; } cout << sum; return 0; }
- 1
信息
- ID
- 1557
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 4
- 已通过
- 4
- 上传者