Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Poon

Problemset: มุมขวาบน

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-09 09:10:57

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin>>n;
    bool l=0;
    int a,b;
    for(int k=0;(2*k-2)*(2*k-1)-1<=n;k++)
    {
        if((2*k-2)*(2*k-1)-1==n)
        {
            l=1;
        }
    }
    if(l==1)
    {
        cout<<"Cannot find top-right corner.";
        return 0;
    }
    for(int k=0;(2*k-2)*(2*k-1)<=n;k++)
    {
        a=(2*k-2)*(2*k-1);
    }
    for(int k=0;(2*k-2)*(2*k-1)+1<=n;k++)
    {
        b=(2*k-2)*(2*k-1)+1;
    }
    cout<<max(a,b);
}