some programs!!

This commit is contained in:
rogerwang2008 committed 2026-09-28 14:05:06 +08:00
1 parent ed054247d5
commit 71f1022dea
38 files changed
+1037 -281

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
/*
* 本来想打表的,打着打着发现了一些数学规律。具体怎么证明嘛……🤷‍
*/
#include <iostream>
#include <cmath>
constexpr size_t MAX_N = 10001;
int get_ans(int n) {
const int k = ceil(-0.5 + 0.5 * sqrt(4 * n + 1));
const bool extra = k * k < n;
const int ans = k * (k - 1) + 1 + k * extra;
return ans;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::cout << get_ans(n) << std::endl;
return 0;
}