A9708 | Modular Equations
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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<=10^{9}$ ) are given.
输出格式
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 .
输入输出样例
输入 #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 
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted