This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
/**
* 功能:计算约数之和
* @param n
* @return
*/
LL getSumOfDivisors(LL x) {
//拆出所有质数因子及质数因子个数
unordered_map<int, int> primes;
for (int i = 2; i <= x / i; i++)
while (x % i == 0) {
x /= i;
primes[i]++;
}
if (x > 1) primes[x]++;
//计算约数个数
LL res = 1;
for (auto p : primes) {
LL a = p.first, b = p.second;
LL t = 1;
while (b--) t = (t * a + 1);
res = res * t;
return res;
LL res;
int main() {
//测试用例:180
//参考答案:546
int n;
cin >> n;
cout<<getSumOfDivisors(n) << endl;
return 0;