CF495B.Modular Equations
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 our equation.
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.
上周,哈米德在数学课上学习了一类新型方程,称为模方程(Modular Equations)。我们定义 i 对 j 取模为 i 除以 j 的余数,并记作
。正如哈米德的老师所描述的那样,一个模方程是形如
的方程,其中 a 和 b 是两个非负整数,x 是未知变量。我们称满足
的正整数 x 为该方程的一个解。
由于哈米德上课时正在看电影,因此没有太注意听讲,他仅记住了这类方程的定义。
现在他想完成数学作业,但因完全不知如何下手,便向你求助。他把他所知道的关于模方程的一切都告诉了你,并请你编写一个程序:给定两个数 a 和 b,确定模方程
共有多少个解。
输入格式
In the only line of the input two space-separated integers a and b (0 ≤ a, b ≤ 109) are given.
输入仅有一行,包含两个由空格分隔的整数 a 和 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
.
如果该方程有无穷多个解,则输出 “infinity”(不带引号)。否则,输出同余方程
的解的个数。
输入输出样例
输入#1
21 5
输出#1
2
输入#2
9435152 272
输出#2
282
输入#3
10 10
输出#3
infinity
说明/提示
In the first sample the answers of the Modular Equation are 8 and 16 since 
在第一个样例中,模方程的解为 8 和 16,因为 
输入解题思路,AI测评打分。不知道怎么写?