比赛 暑假综合模拟2 评测结果 AAAAAAAAAA
题目名称 Hankson的趣味题 最终得分 100
用户昵称 wsp 运行时间 0.885 s
代码语言 C++ 内存使用 0.25 MiB
提交时间 2018-08-07 21:02:02
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y)
{
   if(y%x==0)return x;
   else return gcd(y,x%y);
}

int main()
{
	freopen("son.in","r",stdin);
    freopen("son.out","w",stdout);
    int a;cin>>a;
    while(a--)
    {
    	int ans=0,q,w,e,r;cin>>q>>w>>e>>r;
    	for(int j=1;j*j<=r;j++)
    	{	if(r%j==0){
    		if(j%w==0&&gcd(j/w,q/w)==1&&gcd(r/e,r/j)==1)ans++;
    		int c=r/j;
    		if(c%w==0&&c!=j&&gcd(c/w,q/w)==1&&gcd(r/e,r/c)==1)ans++;
    	}	
        }cout<<ans<<endl;
    }
    fclose(stdout);
	return 0;
}