上午小測1「木板」
阿新 • • 發佈:2020-10-28
上午小測1「木板」
題目大意
分析
簡單推論
老數學題了,直接開搞:
\[設 \;BE = x,CE = n - x, CF = y, \angle AEF = 90^{\circ} \]\[\because \Delta ABE \sim \Delta ECF \]\[\therefore \frac{AB}{BE} = \frac{EC}{CF} \]\[\therefore \frac{n}{x} = \frac{n - x}{y} \]\[\therefore y = \frac {nx-x^2}{n} = x - \frac{x^2}{n} \]\[\because x\in \mathbb{Z}\;且\;y\in \mathbb{Z} \]進一步計算
- 如何求 \(x_{min}\) ?
會發現,每個質因子次冪是向上取整的,當次冪是奇數的時候,有一個 \(p_i\) 是必須選取的,剩下的選一半即可。
\[設\; n=2^3\times 3^2\times 5^1 \]\[x_{min} = 2^2\times 3^1\times 5^1 \]\[有\; 2^1\; 和\; 5^1\; 是必選的 \]\[設\; i (i ^ 2\leq n\; 且\; i^2|n), b = 2^1\times 5^1 \]程式碼
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
const int maxn = 1e5 + 50, INF = 0x3f3f3f3f;
inline int read () {
register int x = 0, w = 1;
register char ch = getchar ();
for (; ch < '0' || ch > '9'; ch = getchar ()) if (ch == '-') w = -1;
for (; ch >= '0' && ch <= '9'; ch = getchar ()) x = x * 10 + ch - '0';
return x * w;
}
inline void write (register int x) {
if (x / 10) write (x / 10);
putchar (x % 10 + '0');
}
int n, ans;
signed main () {
freopen ("tri.in", "r", stdin);
freopen ("tri.out", "w", stdout);
while (1) {
n = read();
if (n == 0) break;
for (register int i = 1; i * i <= n; i ++) {
if (n % (i * i) == 0) ans = (i - 1) * 8;
}
printf ("%lld\n", ans);
}
return 0;
}