/ Randle /

记录详情

Runtime Error

/in/foo.cc: In function 'long long int read()':
/in/foo.cc:10:6: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
      if(c=='-')
      ^~
/in/foo.cc:12:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   c=getchar();
   ^
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 372.0 KiB
#2 Wrong Answer 3ms 372.0 KiB
#3 Wrong Answer 3ms 364.0 KiB
#4 Runtime Error 8ms 356.0 KiB
#5 Wrong Answer 14ms 360.0 KiB
#6 Runtime Error 21ms 344.0 KiB
#7 Runtime Error 14ms 368.0 KiB
#8 Runtime Error 11ms 368.0 KiB
#9 Runtime Error 13ms 384.0 KiB
#10 Runtime Error 4ms 364.0 KiB

代码

#include<cstdio>
#include<cmath>

inline long long read()
{
    long long f=1;
    long long k=0;
    char c=getchar();
    while(c>'9'||c<'0') {
    	if(c=='-')
    		f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		k=k*10+c-'0';
		c=getchar();
	}
	return k*f;
}

inline void print(long long a)
{
	if(a==0) {
	    putchar('0');
	    putchar('\n');
	    return ;
	}
	char c[100];
	int q=0;
	while(a) {
	    c[++q]=a%10+'0';
	    a/=10;
	}
	for(int i=q;i>=1;--i)
	    putchar(c[i]);
	putchar('\n');
}

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

inline long long solve()
{
	long long a=a0/a1;
	long long b=b1/b0;
	
	long long ans=0;
	register long long total=sqrt(b1);
	for(register int i=1;i<=total;++i) {
		if(b1%i==0) {
    		if(i%a1==0&&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()
{
//	freopen("1.out","w",stdout);
	long long n=read();
	for(register int i=0;i<n;++i) {
		a0=read();
		a1=read();
		b0=read();
		b1=read();
		print(solve());
	}
	return 0;
}

信息

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