Submission

Status:

PPPP--PPPPPP---PPPPP

Subtask/Task Score:

75/100

Score: 75

User: sakurajima

Problemset: มุมขวาบน

Language: cpp

Time: 0.002 second

Submitted On: 2026-09-28 17:01:22

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    long long current = 6;
    long long diff = 13;

    while (current <= n) {
        current += diff;
        diff += 9;
    }

    if (current == n) {
        cout << "Cannot find top-right corner.";
        return 0;
    }

    long long i = 1;
    long long latest_i = 1;

    while (i * i <= n) {
        latest_i = i;
        i += 2;
    }

    long long top_right = (latest_i * latest_i) - (latest_i - 1);
    cout << top_right;

}