Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Apimuk
Problemset: มุมขวาบน
Language: cpp
Time: 0.003 second
Submitted On: 2025-09-24 23:42:37
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <cmath>
using namespace std;
int main() {
int n;
cin >> n;
int k = ceil(sqrt(n));
if (k % 2 == 0) {
k++;
}
int right = k * k - (k - 1);
int cantfind = right - 2;
if (n == cantfind) {
cout << "Cannot find top-right";
}
else if (n < right) {
right = (k - 2) * (k - 2) - (k - 3);
cout << right;
}
else if (n>= right) {
cout << right;
}
}