hdu4993(水题)

题意:
      x * a + y * b = c xyab都是正整数,给你a,b,c问有多少对xy组合满足等式。

思路:

      水题,直接枚举其中一个,然后看求出的y是不是正整数就行了,第一眼看了后差点没去写二分。


#include<stdio.h>

int main ()
{
   int t ,a ,b ,c ,Ans ,x ,y;
   scanf("%d" ,&t);
   while(t--)
   {
      scanf("%d %d %d" ,&a ,&b ,&c);
      x = 1 ,Ans = 0;
      while(1)
      {
         if(x * a >= c) break;
         if((c - x * a) % b == 0) Ans ++;
         x ++;
      }
      printf("%d
" ,Ans);
   }
   return 0;
}
         
         

原文地址:https://www.cnblogs.com/csnd/p/12062778.html