编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#49345 #1261. 数字删除 Compile Error 0 0 ms 0 K C++ 11 / 758 B cgyz 2021-06-28 17:06:48
显示原始代码
#include <bits/stdc++.h>
#define long long ll

using namespace std;
set<int> factor;

const int N = 1e6 + 10;
int n;
int num[N];
int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        scanf("%d", &num[i]);
        bool flag = true;
        for (int j = 2; j * j <= num[i]; j++) {
            if (num[i] % j == 0) {
                //     cout<<j<<endl;
                factor.insert(j);
                flag = false;
            }
        }
        if (flag)
            factor.insert(num[i]);
    }
    //  for(auto i:factor)cout<<i<<endl;
    ll ans = 0;
    for (auto i : factor) {
        if (i == 1)
            continue;
        ll buf = 0;
        for (int j = 0; j < n; j++) {
            if (num[j] % i == 0)
                buf += num[j];
        }
        ans = max(buf, ans);
    }
    cout << ans;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:27:5: error: 'll' was not declared in this scope
     ll ans=0;
     ^~
/sandbox/1/a.cpp:30:11: error: expected ';' before 'buf'
         ll buf=0;
           ^~~~
           ;
/sandbox/1/a.cpp:32:28: error: 'buf' was not declared in this scope
             if(num[j]%i==0)buf+=num[j];
                            ^~~
/sandbox/1/a.cpp:34:9: error: 'ans' was not declared in this scope
         ans=max(buf,ans);
         ^~~
/sandbox/1/a.cpp:34:9: note: suggested alternative: 'abs'
         ans=max(buf,ans);
         ^~~
         abs
/sandbox/1/a.cpp:34:17: error: 'buf' was not declared in this scope
         ans=max(buf,ans);
                 ^~~
/sandbox/1/a.cpp:36:11: error: 'ans' was not declared in this scope
     cout<<ans;
           ^~~
/sandbox/1/a.cpp:36:11: note: suggested alternative: 'abs'
     cout<<ans;
           ^~~
           abs
/sandbox/1/a.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&num[i]);
         ~~~~~^~~~~~~~~~~~~~