# CodeForces 495B Modular Equations

Modular Equations
Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

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.

Input

In the only line of the input two space-separated integers a and b (0 ≤ a, b ≤ 109) are given.

Output

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 .

Sample Input

Input
21 5

Output
2

Input
9435152 272

Output
282

Input
10 10

Output
infinity

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

int main()
{
int i,j,k,t,m,n;

int a,b;
scanf("%d%d",&a,&b);
if(a==b)
printf("infinity\n");

else if(b>a/2)
printf("0\n");

else{
t =  a-b;
int ans = 0;
int tt = sqrt(t*1.0);
for(i=1;i<=b;i++)
{
if(t%i==0 && t/i>b)
ans++;
}
for(i=b+1;i<=tt;i++){
if(t%i==0 )
ans+=2;
}
if((tt*1.0 == sqrt(t*1.0)) && tt>b)
ans--;
printf("%d\n",ans);
}
return 0;
}

• 本文已收录于以下专栏：

## codeforces 495B - Modular Equations

codeforces 495B - Modular Equations time limit per test 1 second memory limit per test 256 megab...
• ping1632743560
• 2016年07月26日 14:41
• 127

## 495B - Modular Equations

B. Modular Equations time limit per test 1 second memory limit per test 256 megabytes ...
• u010395983
• 2014年12月16日 11:27
• 1295

## CodeForce 495B Modular Equations 【数学】

B. Modular Equations time limit per test 1 second memory limit per test 256 megabytes ...
• shengweisong
• 2014年12月17日 09:53
• 1295

## Codeforces 495 A. Digital Counterr && Codeforces Round #282 (Div. 2)

• piaocoder
• 2014年12月14日 10:48
• 398

## Codeforces Hello 2018 - A - Modular Exponentiation

• 2018年01月09日 00:56
• 32

## Modular Equations

http://codeforces.com/contest/495/problem/B a mod x = b等价于(a-b)%x=0那么就容易思考解决，不过我没想到这个也做出来了! AC...
• Unin88
• 2014年12月17日 16:10
• 245

## Codeforces Round #214 (Div. 2)（背包变形）

A. Dima and Guards 只需要比较一下，守卫的最小要求的和与给定值的大小即可 #include #include using namespace std; int n,x1,y1,x2,...
• u010660276
• 2014年01月14日 17:01
• 461

## Codeforces 913A Modular Exponentiation

• Leo_Nasir
• 2018年01月10日 20:24
• 61

## codeforces 214A

• AcToy
• 2012年12月31日 20:33
• 167

## codeforces 913A Modular Exponentiation

http://www.elijahqi.win/2018/01/09/codeforces-913a-modular-exponentiation/ The following problem is...
• elijahqi
• 2018年01月09日 08:12
• 91

举报原因： 您举报文章：CodeForces 495B Modular Equations 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)