注册 登录
编程论坛 C++教室

如何判断一个变量是不是整形

骑猪闯天下 发布于 2013-04-23 07:40, 2229 次点击
杭电1017题目要求判断变量是不是整形
相关代码if(((b*b+a*a+m)%(a*b))==0其中a,b,m都是整形
为什么表达式为真的时候,就是整形变量?
或者有没有其他的判断方法?
3 回复
#2
peach54602013-04-23 08:22
不是吧,这个是错的吧?
除非有其他的限制条件

给你个反例
这个就是判断a的平方加b的平方加m与a*b的余数
那么,假设现在ab是定数,我的m可以为任意值,不可能每个m与ab的乘积求余都为0
除非有其他的限制条件

[ 本帖最后由 peach5460 于 2013-4-23 08:24 编辑 ]
#3
rjsp2013-04-23 08:25
搞笑,什么叫“……a,b,m都是整形……就是整形变量?”
我Google了一下,原题是:
Given two integers n and m, count the number of pairs of integers (a,b) such that 0 < a < b < n and (a^2+b^2 +m)/(ab) is an integer.
#4
peach54602013-04-23 08:32
以下是引用rjsp在2013-4-23 08:25:42的发言:

搞笑,什么叫“……a,b,m都是整形……就是整形变量?”
我Google了一下,原题是:
Given two integers n and m, count the number of pairs of integers (a,b) such that 0 < a < b < n and (a^2+b^2 +m)/(ab) is an integer.

好吧,我吐血了...
1