Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Kei

Problemset: มุมขวาบน

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-08 16:57:12

#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;


void solve(){

    ll n;
    cin >> n;
    ll corner=1,k=0; //k=starter
    ll d=7;
    while(d<=n){
        corner=d;
        k++;
        d=corner+8*k+6;
    }
    if(n==d-2) cout << "Cannot find top-right corner.";
    else if(n==d-1) cout <<n;
    else cout << corner;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}