Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: ssens3

Problemset: มุมขวาบน

Language: cpp

Time: 0.002 second

Submitted On: 2026-10-05 19:05:24

#include <iostream>
using namespace std;
int main(){
    long long k = 0, n, p = 0; cin >> n;
    if (n == 1){ cout << 1; return 0;}
    while (4*k*k + 2*k + 1 <= n && n != 4*k*k + 2*k - 1) k++;
    if (n == 4*k*k + 2*k - 1) cout << "Cannot find top-right corner.";
    else if (n == 4*k*k + 2*k) cout << 4*k*k + 2*k;
    else if (n < 4*k*k + 2*k + 1){ k--; cout << 4*k*k + 2*k + 1;}
}