1 条题解

  • 0
    @ 2024-12-24 9:54:32

    C++ :

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    const int maxn=2000001;
    long long a,b,d;
    long long f[maxn];
    int main()
    {
    	//freopen("parents.in","r",stdin);
    	//freopen("parents.out","w",stdout);
    	cin>>a>>b>>d;
    	//a=a/d;b=b/d;
    	if(a>b)
    	{
    		long long c;
    		c=a;a=b;b=c;
    	}
    	for(int k=a;k>0;k--)//f[k]表示以k位公约数的最大数对 
    	{
    		f[k]=(a/k)*(b/k);//此时求得是以k位约数的对数 
    		for(int i=2;i<=a/k;i++) f[k]=f[k]-f[k*i];
    	}
    	cout<<f[d]<<endl;
    }
    
    • 1

    信息

    ID
    1221
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者