1 solutions

  • 0
    @ 2025-11-5 15:36:13

    C++ :

    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    
    int main()
    {
       long long  n;
        while(cin>>n)
        {
             long long ans;
                if(n<3)
                cout<<n<<endl;
            else   if(n%2==0&&n%6!=0)
            {
                ans=n*(n-1)*(n-3);
                cout<<ans<<endl;
            }
    
            else    if(n%6==0)
            {
            ans=(n-2)*(n-1)*(n-3);
                cout<<ans<<endl;
            }
    
            else if(n%2!=0)
            {
                ans=n*(n-1)*(n-2);
            cout<<ans<<endl;
            }
        }
    
            return 0;
    }
    
    • 1

    Information

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