标签:
import java.util.Scanner; public class Main { static long gcd(long a,long b){ return a%b==0? b:gcd(b,a%b); } static long lcm(long a,long b){ return a*b/gcd(a,b); } public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ long a0=sc.nextLong(); long a1=sc.nextLong(); long b0=sc.nextLong(); long b1=sc.nextLong(); long x=0; int ans=0; for(int i=1;i<1000;i++){ if(gcd(i,a0)==a1){ x=i; break; } } for(long j=x;j<=b1;j+=x){ if(lcm(j,b0)==b1) ans++; } System.out.println(ans); } } }
标签:
原文地址:http://www.cnblogs.com/watchfree/p/5455478.html