编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#49206 | #1261. 数字删除 | Compile Error | 0 | 0 ms | 0 K | C++ / 432 B | 力学71-颛孙宇翔 | 2021-05-26 12:11:41 |
#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> m;
void get_factor(int x) {
int x0 = x;
for (int i = 2; i <= x / i; i++) {
if (x % i == 0) {
m[i] += x0;
while (x % i == 0) {
x /= i;
}
}
}
if (x > 1)
m[x] += x0;
}
int main() {
int n, x;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
get_factor(x);
}
int ans = 0;
for (auto p : m) {
ans = max(ans, p.second);
}
cout << ans;
return 0;
}
编译信息
/sandbox/1/a.cpp:5:1: error: 'unordered_map' does not name a type
unordered_map <int,int> m;
^~~~~~~~~~~~~
/sandbox/1/a.cpp: In function 'void get_factor(int)':
/sandbox/1/a.cpp:12:4: error: 'm' was not declared in this scope
m[i]+=x0;
^
/sandbox/1/a.cpp:18:10: error: 'm' was not declared in this scope
if(x>1) m[x]+=x0;
^
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:30:11: error: 'p' does not name a type
for(auto p:m){
^
/sandbox/1/a.cpp:32:3: error: expected ';' before 'cout'
}
^
;
cout<<ans;
~~~~
/sandbox/1/a.cpp:34:5: error: expected primary-expression before 'return'
return 0;
^~~~~~
/sandbox/1/a.cpp:33:12: error: expected ')' before 'return'
cout<<ans;
^
)
return 0;
~~~~~~
/sandbox/1/a.cpp:30:5: note: to match this '('
for(auto p:m){
^