50分求条
查看原帖
50分求条
1128763
Sprunki_Rabbit楼主2024/10/13 13:56

兔求

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

int main() 
{
	long long n,k,q,r;
	int t;
	cin >> t;
	while(t--) 
	{
		long long ans=0;
		cin >> n >> k;
		if(k == 0)
		{
			cout << 1 << endl;
			continue;
		}
		for(q=1;q<=n/k+1;q++) 
		{
			r = n-q*k;
			if(r >= 0 && n/q == k && n%q == r) 
				ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

https://www.luogu.com.cn/problem/P11184

2024/10/13 13:56
加载中...