Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d
Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as
the remainder of division of i by j and denote it by .
A Modular Equation, as Hamed's teacher described, is an equation of the form in which a and b are
two non-negative integers and x is a variable. We call a positive integer x for which a solution of
Hamed didn't pay much attention to the class since he was watching a movie. He only managed to understand the definitions of these equations.
Now he wants to write his math exercises but since he has no idea how to do that, he asked you for help. He has told you all he knows about Modular Equations and asked you to write a program which given two numbers a and b determines
how many answers the Modular Equation has.
In the only line of the input two space-separated integers a and b (0 ≤ a, b ≤ 109)
If there is an infinite number of answers to our equation, print "infinity" (without the quotes). Otherwise print the number of solutions of the Modular Equation .
解题思路： t = a - b；如果t%x==0 中的x是一个解，那么t/x就是另外一个解当x>b && t/x>b，如果有一个不满足>b的条件就舍去。 那么就能以sqrt(t) 为一条界限去划分1-t，那么这一条界的左边是上述满足t%x==0的x的话，右边就是t/x，这样使得时间复杂度降低到sqrt(t)。
using namespace std;
t = a-b;
int ans = 0;
int tt = sqrt(t*1.0);
if(t%i==0 && t/i>b)
if((tt*1.0 == sqrt(t*1.0)) && tt>b)