求助时间复杂度分析
查看原帖
求助时间复杂度分析
617314
TigerTanWQY楼主2024/8/26 22:05

题目简意

给定 nn,求有多少个有序正整数三元组 (x,y,z)(x,y,z) 满足 x×y+z=nx\times y+z=n。2≤n≤1062\le n\le 10^6

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;
}
2024/8/26 22:05
加载中...