Submission

Status:

PPPP--PPPPPP---PPPPP

Subtask/Task Score:

75/100

Score: 75

User: mik

Problemset: มุมขวาบน

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-11 15:00:28

#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    int n;
    cin >> n;
    int d=1;
    while(d*d<n){
        if ((d+2)*(d+2)>=n) break;
        else d+=2;
    }
    if (n+1==(d+2)*(d+2)-(d+1) || n+1==(d+1)*(d+1)+d+1) cout << "Cannot find top-right corner.";
    else if (n==(d+1)*(d+1)+d+2) cout << n;
    else if (n+d+2>=(d+2)*(d+2)) cout << (d*d)-(d-1);
    else cout <<(d*d)-(d-1);
    return 0;
}