/ Randle /

记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Wrong Answer 4ms 384.0 KiB
#2 Wrong Answer 3ms 348.0 KiB
#3 Wrong Answer 3ms 384.0 KiB
#4 Wrong Answer 6ms 376.0 KiB
#5 Wrong Answer 6ms 356.0 KiB
#6 Wrong Answer 6ms 372.0 KiB
#7 Time Exceeded ≥2004ms ≥368.0 KiB
#8 Time Exceeded ≥2007ms ≥384.0 KiB
#9 Time Exceeded ≥2007ms ≥380.0 KiB
#10 Time Exceeded ≥2007ms ≥376.0 KiB

代码

#include<cstdio>
#include<cmath>

long long a0,a1,b0,b1;
long long gcd(long long a,long long b) {
	long long r;
	while(b) {
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}

long long solve()
{
	long long a=a0/a1;
	long long b=b1/b0;
	long long ans=0;
	long long total=sqrt(b1);
	for(int i=1;i<=total;++i) {
		if(i%a1==0&&b1%i==0) {
    		if(gcd(b,b1/i)==1&&gcd(a,i/a1)==1)
	    	    ++ans;
	    	int x=b1/i;
	    	if(x%a1==0&&x!=i&&gcd(b,b1/x)==1&&gcd(a,x/a1)==1)
	    	    ++ans;
	    }
	}
	return ans;
}

int main()
{
	long long n;
	scanf("%lld",&n);
	for(int i=0;i<n;++i) {
		scanf("%lld %lld %lld %lld",&a0,&a1,&b0,&b1);
		printf("%lld\n",solve());
	}
	return 0;
}

信息

递交者
类型
递交
题目
改编小学数学题(第一个AC奖励5元)
题目数据
下载
语言
C++
递交时间
2017-10-13 11:35:52
评测时间
2017-10-13 11:35:52
评测机
分数
0
总耗时
≥8057ms
峰值内存
≥384.0 KiB