302561: CF495B. Modular Equations

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:1 Solved:0

Description

Modular Equations

题意翻译

题目描述 现在zyk给定两个整数a, b,问有多少个x,使得满足等式 a mod x = b 如果存在无限个,就输出”infinity”,否则输出满足条件x的个数 输入 输入a, b 输出 输出个数或”infinity”

题目描述

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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF495B/57aaef9d4f53d75c7150d35a36ceb219c08ecb8d.png). A Modular Equation, as Hamed's teacher described, is an equation of the form ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF495B/bedc8c54f3a5a224f7fdfd3a3301336e4b862b12.png) in which $ a $ and $ b $ are two non-negative integers and $ x $ is a variable. We call a positive integer $ x $ for which ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF495B/bedc8c54f3a5a224f7fdfd3a3301336e4b862b12.png) 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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF495B/bedc8c54f3a5a224f7fdfd3a3301336e4b862b12.png) 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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF495B/bedc8c54f3a5a224f7fdfd3a3301336e4b862b12.png).

输入输出样例

输入样例 #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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF495B/c013274f5a802f50affb5d5736cfe493bd6c937a.png)

Input

题意翻译

题目描述 现在zyk给定两个整数a, b,问有多少个x,使得满足等式 a mod x = b 如果存在无限个,就输出”infinity”,否则输出满足条件x的个数 输入 输入a, b 输出 输出个数或”infinity”

加入题单

上一题 下一题 算法标签: