bzoj 1024 1028
parent
02c932275c
commit
eb75896ed0
@ -0,0 +1,21 @@
|
||||
#include <cstdio>
|
||||
double min(double a, double b) { return a < b ? a : b; };
|
||||
double max(double a, double b) { return a > b ? a : b; };
|
||||
double dfs(double x, double y, int t)
|
||||
{
|
||||
if (t == 1) return max(x / y, y / x);
|
||||
double ans = 1e300;
|
||||
for (int i = 1; i <= t / 2; i++)
|
||||
ans = min(ans, min(
|
||||
max(dfs(x / t * i, y, i), dfs(x / t * (t - i), y, t - i)),
|
||||
max(dfs(x, y / t * i, i), dfs(x, y / t * (t - i), t - i))
|
||||
));
|
||||
return ans;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int n, m, k;
|
||||
scanf("%d%d%d", &n, &m, &k);
|
||||
printf("%.6lf", dfs(n, m, k));
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
#include <cstdio>
|
||||
#include <cctype>
|
||||
inline void readInt(int &x)
|
||||
{
|
||||
int ch = x = 0;
|
||||
while (!isdigit(ch = getchar()));
|
||||
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
|
||||
}
|
||||
int n, m, a[410], b[410], ans[410], sum;
|
||||
bool check()
|
||||
{
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
for (int j = 1; j <= n; j++) b[j] = a[j];
|
||||
int Ans = 0;
|
||||
if (b[i] >= 2)
|
||||
{
|
||||
b[i] -= 2;
|
||||
Ans += 2;
|
||||
for (int j = 1; j <= n; j++)
|
||||
{
|
||||
Ans += 3 * (b[j] / 3);
|
||||
b[j] %= 3;
|
||||
if (b[j] == 0 || b[j + 1] == 0 || b[j + 2] == 0) continue;
|
||||
b[j]--, b[j + 1]--, b[j + 2]--;
|
||||
j--; Ans += 3;
|
||||
}
|
||||
}
|
||||
if (Ans == m * 3 + 2) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
readInt(n), readInt(m);
|
||||
for (int i = 0, x; i <= m * 3; i++)
|
||||
readInt(x), a[x]++;
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
a[i]++;
|
||||
if (check()) ans[sum++] = i;
|
||||
a[i]--;
|
||||
}
|
||||
if (sum == 0) puts("NO");
|
||||
else for (int i = 0; i < sum; i++)
|
||||
printf(i != sum - 1 ? "%d " : "%d", ans[i]);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue