Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: peilin
Problemset: มุมขวาบน
Language: c
Time: 0.002 second
Submitted On: 2025-10-12 18:01:04
#include <stdio.h>
#include <math.h>
int main() {
long long n;
scanf("%lld", &n);
if (n == 1) {
printf("1\n");
return 0;
}
long long k;
long long k_base = (long long)ceil(sqrt((double)n));
if (k_base % 2 == 0) {
k = k_base + 1;
} else {
k = k_base;
}
if (k > 1) {
long long corner_value = (k - 2) * (k - 2) + 3 * (k - 2) + 1;
if (n <= corner_value) {
k -= 2;
}
}
long long top_right = k * k - (k - 1);
printf("%lld\n", top_right);
return 0;
}