2 条题解

  • 1
    @ 2026-5-23 16:10:04

    #include<bits/stdc++.h> using namespace std;

    long long sum(long long n) { long long sum = 0;

    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (i == n / i)
            {
                sum += i;
            }
            else
            {
                sum += i + n / i;
            }
        }
    }
    return sum;
    

    }

    int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--){
        long long n;
        cin >> n;
        cout << sum(n) << endl;
    }
    
    return 0;
    

    }

    信息

    ID
    5994
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    11
    已通过
    5
    上传者