hdu 4627 The Unsolvable Problem

#include<stdio.h>
int gcd(int x,int y)
{
    if(y==0)return x;
    return gcd(y,x%y);
}
int main()
{
    int _case,n,i,j,k;
    scanf("%d",&_case);
    while(_case--)
    {
        scanf("%d",&n);
        for(i=n/2; i<n; i++)
        {
            k=gcd(i,n-i);
            if(k==1)
                break;
        }
        if(i>=n)printf("%d\n",n-1);
        else
        {
            long long mul=1;
            mul=mul*i/k*(n-i);
            printf("%I64d\n",mul);
        }
    }
    return 0;
}

 

你可能感兴趣的:(HDU)