rt.
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
bool Isprime(int n) {
for(int i = 2; i * i <= n; i++) if(n % i == 0) return true;
return false;
}
int f(int n) {
long long res = 1;
if(n == 0 || n == 1) {
return 1;
}
for(int i = 2; i <= n; i++) {
if(Isprime(i)) continue;
long long cnt = 0;
while(n % i == 0) {
cnt++;
n /= i;
}
res *= (cnt + 1);
}
return res;
}
int main() {
ll ans = 0;
ll n; cin >> n;
for(int i = 1; i <= n; i++) {
ans += f(i);
}
cout << ans;
return 0;
}
能不能帮助优化一下?