Advertisement
ahmad_zizo

Remainder

Dec 19th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int counter=0,i;
  7. long int a,b;
  8.  
  9. scanf("%ld %ld",&a,&b);
  10. if(a==b)
  11. printf("infinity");
  12. else if(a-b < b)
  13. printf("0");
  14. else
  15. {
  16. for(i=1; i<= sqrt(a-b) ; i++)
  17. {
  18. if((a-b)%i == 0)
  19. {
  20. if(i<=b && i<sqrt(a-b) && (a-b)/i >b)
  21. counter++;
  22. else if(i<=b && i==sqrt(a-b) && (a-b)/i >b)
  23. continue;
  24. else if(i<=b && (a-b)/i >b)
  25. counter++;
  26. else if(i==sqrt(a-b) && (a-b)/i >b)
  27. counter++;
  28. else if(i>b && (a-b)/i >b)
  29. counter= counter + 2;
  30. }
  31. }
  32. printf("%d",counter);
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement