MINI2- help!(contest is over)

problem link : https://www.codechef.com/problems/MINI2
my solution :
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a=sqrt(n);
        if(n%a==0)
        {
            cout<<2*a<<endl;
        }
        else
        {
            for(int i=a;i<=n;i++)
            {
                a=a+1;
                if(n%a==0)
                {
                    cout<<(a+(n/a))<<endl;
                    break;
                }
                else
                {
                    continue;
                }
            }
        }
        
    
    }
    
    return 0;
}

please help me out the test case is running fine , I can’t find any fault

If n is a perfect square, the answer is not 2*n. Its clearly given in the question that x and y are distinct integers. The simplest solution is to iterate from sqrt(n) to 1 and check whether n%i==0 and i!=n/i . If both these conditions are satisfied, display their sum and break.

1 Like

misread the question