思路
直接模拟就行,写一个函数计算 即可。我们可以用一个双重循环来枚举 和 ,之后根据题意进行计算和判断即可。
代码
#include <bits/stdc++.h>
using namespace std;
int m,k;
int f(int a,int b){//计算函数 f(x,y)
int n=a*ceil(sqrt(k)*b);
int m=b*floor(a*sqrt(k));
return n-m;
}
int main(){
while(cin >> m){
int ans=0;
cin >> k;
for(int i=1;i<=10*m;i++){
for(int j=1;j<=10*m;j++){
if(f(i,j)==m and f(i-j,j)!=m and f(i,j-i)!=m)ans++;
}
}cout << ans << endl;
}
return 0;
}