Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Buktep

Problemset: มุมขวาบน

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-02 13:03:39

#include<bits/stdc++.h>
using namespace std;

#define int long long

int check(int k)
{
    if (k < 0) return 0;
    return 4 * k * k + 2 * k + 1;
}

int32_t main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n; cin>>n;
    int s = ceil(sqrt((double)n));
    if(s%2==0) s++;
    int k = (s - 1) / 2;

    int tr_k = check(k);

    if (n == tr_k - 1) cout << "Cannot find top-right corner.";
    else if (n >= tr_k) cout << tr_k;
    else cout<<check(k-1);

    return 0;
}