题目简意
给定 n,求有多少个有序正整数三元组 (x,y,z) 满足 x×y+z=n。2≤n≤106
Code
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int ans = 0;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
if((long long)i * j + 1 <= n)
++ans;
else
break;
cout << ans;
cout.flush();
return 0;
}