cf 495b Modular Equations

#include<cstdio>

#include<cmath>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

  int a,b,x;

  while(scanf("%d%d",&a,&b)!=EOF)

  {

    if(a<b)

    {

      printf("0\n");

    }

    else if(a==b)

    {

      printf("infinity\n");

    }

    else

    {

      int i,ans=0;

      int cha=a-b;

      for(i=1;i*i<cha;i++)

      {

        if(cha%i==0)

        {

          if(i>b) ans++;

          if(cha/i>b) ans++;

        }

      }

      if(i*i==cha&&i>b) ans++;

      printf("%d\n",ans);

    }



  }

  return 0;

}
View Code

 

你可能感兴趣的:(IO)