1 solutions

  • 0
    @ 2025-11-5 16:32:59

    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

    Information

    ID
    17847
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By