text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
double sqr(double x) { return x * x; }
int n, x[5010], y[5010], z[5010];
double dis(int a, int b) {
return sqrt(sqr(x[a] - x[b]) + sqr(y[a] - y[b]) + sqr(z[a] - z[b]));
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d%d%d", x + i, y + i, z + i);
double ans = 1e100;
for (int i = 1; i < n; i++)
for (int j = i + 1; j < n; j++)
ans = min(ans, (dis(0, i) + dis(0, j) + dis(i, j)) / 2);
printf("%.9f\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double INF = 1e20;
int dcmp(double x) { return (x > 1e-10) - (x < -1e-10); }
struct Point {
double x;
double y;
double z;
} p[5000 + 20];
double calDist(int i, int j) {
return sqrt((p[i].x - p[j].x) * (p[i].x - p[j].x) +
(p[i].y - p[j].y) * (p[i].y - p[j].y) +
(p[i].z - p[j].z) * (p[i].z - p[j].z));
}
int n;
double dist[5000 + 20];
int main() {
while (cin >> n) {
for (int i = 1; i <= n; i++) {
scanf("%lf%lf%lf", &p[i].x, &p[i].y, &p[i].z);
}
for (int i = 2; i <= n; i++) {
dist[i] = calDist(1, i);
}
double ans = INF;
double dij;
for (int i = 2; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
dij = calDist(i, j);
if (dcmp((dist[i] + dist[j] + dij) / 2 - ans) < 0) {
ans = (dist[i] + dist[j] + dij) / 2;
}
}
}
printf("%.10lf\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int mod0 = 1e9 + 7;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 9;
const long long mod3 = 2147483647;
const int sz = 2 * 1024 * 1024;
const long long inf = 2 * 1024 * 1024 * 1023 - 1;
const long long INF = inf * inf;
const double eps = 1e-6;
void init() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout.precision(16);
}
const int N = 4e4 + 4;
void solve() {
int n;
cin >> n;
vector<vector<double> > a(n, vector<double>(3));
vector<vector<double> > d(n, vector<double>(n));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 3; ++j) cin >> a[i][j];
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
double dx = a[i][0] - a[j][0], dy = a[i][1] - a[j][1],
dz = a[i][2] - a[j][2];
d[i][j] = sqrt(dx * dx + dy * dy + dz * dz);
}
}
double ans = 1e12;
for (int i = 1; i < n; ++i) {
for (int j = 1; j < n; ++j) {
if (i == j) continue;
ans = min(ans, (d[0][i] + d[0][j] + d[i][j]) / 2);
}
}
cout << ans << '\n';
}
bool multitest = false;
int main() {
init();
int t = 1;
if (multitest) cin >> t;
for (int i = 0; i < t; ++i) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double dist[5001][5001];
double x[5001], y[5001], z[5001];
int n;
double sqr(double x) { return x * x; }
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i];
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
dist[i][j] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]) + sqr(z[i] - z[j]));
dist[j][i] = dist[i][j];
}
}
double distance = 100000;
for (int i = 2; i <= n; i++) {
double minn = 100000;
for (int j = 2; j <= n; j++) {
if (i != j) {
if (dist[1][j] + dist[j][i] < minn) minn = dist[1][j] + dist[j][i];
}
}
if (dist[1][i] + (minn - dist[1][i]) / 2 < distance)
distance = dist[1][i] + (minn - dist[1][i]) / 2;
}
cout.precision(20);
cout << distance;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<int, int> > > v;
long long sq(long long x) { return x * x; }
void print(pair<int, pair<int, int> > p) {
cout << p.first << " , " << p.second.first << ", " << p.second.second << "\n";
}
double getDist(int i, int j) {
int x1 = v[i].first;
int x2 = v[j].first;
int y1 = v[i].second.first;
int y2 = v[j].second.first;
int z1 = v[i].second.second;
int z2 = v[j].second.second;
double ans = sqrt(sq(x1 - x2) + sq(y1 - y2) + sq(z1 - z2));
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
v.push_back({x, {y, z}});
}
double ans = 1e9;
for (int i = 1; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
ans = min(ans, getDist(i, 0) + getDist(j, 0) + getDist(i, j));
}
}
cout << setprecision(12);
cout << ans / 2 << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct point {
int x, y, z;
};
double DPP(point a, point b) {
return sqrt(0.0 + ((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y)) +
((a.z - b.z) * (a.z - b.z)));
}
point p[5010];
double d[5010], ans = 1000 * 1000 * 1000;
int n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> p[i].x >> p[i].y >> p[i].z;
for (int i = 1; i < n; i++) d[i] = DPP(p[0], p[i]);
for (int i = 1; i < n; i++)
for (int j = i + 1; j < n; j++) {
double x = DPP(p[i], p[j]);
x = (x + d[j] - d[i]) / 2;
ans = min(ans, x + d[i]);
}
printf("%.7lf\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
double a, b, c;
};
double max(double a, double b) { return a < b ? b : a; }
double min(double a, double b) { return a > b ? b : a; }
node tm[5005];
double one_2[5005];
const double inf = 2147483647.0;
int main() {
double a, b, c;
int n;
int i, j;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%lf%lf%lf", &tm[i].a, &tm[i].b, &tm[i].c);
}
double a1 = tm[1].a;
double b1 = tm[1].b;
double c1 = tm[1].c;
double dis_pow2;
for (j = 2; j <= n; j++) {
double a2 = tm[j].a;
double b2 = tm[j].b;
double c2 = tm[j].c;
dis_pow2 = sqrt((a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2) +
(c1 - c2) * (c1 - c2));
one_2[j] = dis_pow2;
}
double ans = inf;
int id;
double dis2;
for (id = 2; id <= n; id++) {
double dis1 = one_2[id];
a1 = tm[id].a;
b1 = tm[id].b;
c1 = tm[id].c;
for (j = 2; j <= n; j++) {
if (j == id) continue;
double a2 = tm[j].a;
double b2 = tm[j].b;
double c2 = tm[j].c;
dis2 = sqrt((a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2) +
(c1 - c2) * (c1 - c2));
double cha = fabs(dis1 - one_2[j]);
ans = min(ans, dis1 + (cha + dis2) / 2);
}
}
printf("%.7lf\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5010;
double x[maxn], y[maxn], z[maxn];
double dis(int i, int j) {
return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
(z[i] - z[j]) * (z[i] - z[j]));
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) scanf("%lf%lf%lf", &x[i], &y[i], &z[i]);
double ans = 1e12;
for (int i = 1; i < n; i++)
for (int j = i + 1; j < n; j++) {
double tmp = dis(0, i) + dis(0, j) + dis(i, j);
ans = min(ans, tmp);
}
printf("%.8f\n", ans / 2);
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int N = 5010;
int n;
double x[N], y[N], z[N];
double f[N];
double sq(double r) { return r * r; }
double dist(int u, int v) {
return sqrt(sq(x[u] - x[v]) + sq(y[u] - y[v]) + sq(z[u] - z[v]));
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
double ans = 1e18;
for (int i = 1; i < n; i++) f[i] = dist(0, i);
for (int i = 1; i < n; i++)
for (int j = i + 1; j < n; j++) ans = min(ans, f[i] + f[j] + dist(i, j));
ans /= 2.0;
cout << fixed << setprecision(15);
cout << ans << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int oo = ~0u >> 2, mo = (int)1e9 + 7;
const int mn = 5100;
struct po {
int x, y, z;
} p[mn];
int n;
double Ans(1e100);
double dis(const po &a, const po &b) {
return sqrt(((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y)) +
((a.z - b.z) * (a.z - b.z)));
}
double len(const po &a, const po &b, const po &c) {
return dis(a, b) + dis(a, c) + dis(b, c);
}
int main() {
cin >> n;
for (int i = (1); i <= (n); ++i) cin >> p[i].x >> p[i].y >> p[i].z;
for (int i = (2); i <= (n); ++i)
for (int j = (i + 1); j <= (n); ++j)
(Ans = min(Ans, len(p[1], p[i], p[j])));
cout << fixed << setprecision(10) << Ans / 2 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Pt {
int x, y, z;
} t[50010];
int n;
double get(int i, int j) {
return sqrt((double)((t[i].x - t[j].x) * (t[i].x - t[j].x) +
(t[i].y - t[j].y) * (t[i].y - t[j].y) +
(t[i].z - t[j].z) * (t[i].z - t[j].z)));
}
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) cin >> t[i].x >> t[i].y >> t[i].z;
double ans = (1 << 30) * 1ll;
for (int i = 2; i < n; ++i)
for (int j = i + 1; j <= n; ++j) {
double t2 = get(1, i);
double t1 = get(1, j);
double s = get(i, j);
if (t2 > t1) swap(t1, t2);
double T = (s - abs(t2 - t1)) * 0.5;
ans = min(ans, T * 1.0 + max(t2, t1));
}
printf("%.10lf", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double INF = 1e20;
int dcmp(double x) { return (x > 1e-10) - (x < -1e-10); }
struct Point {
double x;
double y;
double z;
} p[5000 + 20];
double calDist(int i, int j) {
return sqrt((p[i].x - p[j].x) * (p[i].x - p[j].x) +
(p[i].y - p[j].y) * (p[i].y - p[j].y) +
(p[i].z - p[j].z) * (p[i].z - p[j].z));
}
int n;
double dist[5000 + 20];
int main() {
while (cin >> n) {
for (int i = 1; i <= n; i++) {
scanf("%lf%lf%lf", &p[i].x, &p[i].y, &p[i].z);
}
for (int i = 2; i <= n; i++) {
dist[i] = calDist(1, i);
}
double ans = INF;
double dij;
for (int i = 2; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
dij = calDist(i, j);
if (dcmp((dist[i] + dist[j] + dij) / 2 - ans) < 0) {
ans = (dist[i] + dist[j] + dij) / 2;
}
}
}
printf("%.10lf\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int x[N], y[N], z[N];
double sqr(double x) { return x * x; }
double dist(int i, int j) {
return sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]) + sqr(z[i] - z[j]));
}
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d%d%d", x + i, y + i, z + i);
}
double ans = 1e20;
for (int i = 1; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
ans = min(ans, dist(0, i) + dist(0, j) + dist(i, j));
}
}
printf("%.12f\n", ans / 2);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct point {
double x, y, z;
} p[5050];
double getdis(point p1, point p2) {
return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y) +
(p1.z - p2.z) * (p1.z - p2.z));
}
int main() {
int n;
while (cin >> n) {
double mint = 0x3f3f3f3f;
for (int i = 0; i < n; i++) {
cin >> p[i].x >> p[i].y >> p[i].z;
}
for (int i = 1; i < n; i++) {
for (int j = i + 1; j < n; j++) {
double t1 = getdis(p[0], p[i]);
double t2 = getdis(p[0], p[j]);
double t3 = getdis(p[i], p[j]);
mint = min(mint, (t1 + t2 + t3) / 2.0);
}
}
printf("%.10lf\n", mint);
}
}
|
#include <bits/stdc++.h>
const int M = 5500;
const double esp = 1e-6;
const double PI = 3.14159265359;
const int INF = 0x3f3f3f3f;
using namespace std;
struct node {
double x, y, z;
} arr[M];
double judge(node x, node y) {
return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y) +
(x.z - y.z) * (x.z - y.z));
}
int main() {
int n;
while (~scanf("%d", &n)) {
for (int i = 1; i <= n; i++) {
scanf("%lf %lf %lf", &arr[i].x, &arr[i].y, &arr[i].z);
}
double qmin = (double)INF;
for (int i = 2; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
qmin = min(qmin, judge(arr[1], arr[i]) + judge(arr[1], arr[j]) +
judge(arr[i], arr[j]));
}
}
printf("%lf\n", qmin / 2);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
int x, y, z;
double dis;
} a[5010];
double dis[5001][5002];
double cadis(int i, int j) {
return sqrt((a[i].x - a[j].x) * (a[i].x - a[j].x) +
(a[i].y - a[j].y) * (a[i].y - a[j].y) +
(a[i].z - a[j].z) * (a[i].z - a[j].z));
}
double adis[5000];
int main() {
int n;
while (scanf("%d", &n) != EOF) {
int x, y, z;
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &x, &y, &z);
a[i].x = x, a[i].y = y;
a[i].z = z;
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
dis[i][j] = dis[j][i] = cadis(i, j);
}
}
double ans = 9999999;
for (int i = 1; i < n; i++) {
adis[i] = 99999999;
for (int j = i + 1; j < n; j++) {
adis[i] = min(adis[i], dis[0][i] + dis[0][j] + dis[i][j]);
}
if (adis[i] < ans) ans = adis[i];
}
printf("%.10lf\n", ans / 2);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5001;
double x[MAXN], y[MAXN], z[MAXN];
double dis[MAXN];
inline double calc(double x1, double y1, double z1, double x2, double y2,
double z2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
(z1 - z2) * (z1 - z2));
}
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lf%lf%lf", &x[i], &y[i], &z[i]);
for (int i = 1; i < n; i++) dis[i] = calc(x[0], y[0], z[0], x[i], y[i], z[i]);
double ans = 2147483647.0;
for (int i = 1; i < n; i++)
for (int j = 1; j < n; j++)
if (i != j) {
double d = calc(x[i], y[i], z[i], x[j], y[j], z[j]);
double t = (dis[i] + dis[j] + d) / 2.0;
ans = min(t, ans);
}
printf("%.10f\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct p {
int x, y, z;
};
double dist(p a, p b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) +
(a.z - b.z) * (a.z - b.z));
}
int main() {
int n;
cin >> n;
vector<p> a(n);
double ans = INT_MAX;
for (int i = 0; i < n; ++i) cin >> a[i].x >> a[i].y >> a[i].z;
for (int i = 1; i < n; ++i) {
for (int j = 1; j < n; ++j) {
if (i == j) continue;
double d = (dist(a[i], a[0]) + dist(a[j], a[0]) + dist(a[i], a[j])) / 2;
if (ans - d > 1e-8) ans = d;
}
}
cout << setprecision(20) << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
const int SZ = 5100;
int x[SZ], y[SZ], z[SZ];
double dist(int i, int j) {
return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
(z[i] - z[j]) * (z[i] - z[j]) + 0.0);
}
int n;
double d[SZ];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d%d%d", &x[i], &y[i], &z[i]);
d[i] = dist(i, 0);
}
double p = 1e100;
for (int i = 1; i < n; ++i)
for (int j = i + 1; j < n; ++j) p = min(p, d[i] + d[j] + dist(i, j));
printf("%.10lf\n", p / 2);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int x[N], y[N], z[N];
double dist(int i, int j) {
double s = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
(z[i] - z[j]) * (z[i] - z[j]);
return sqrt(s);
}
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d%d", &x[i], &y[i], &z[i]);
}
double ans = 1000000000.0;
for (int i = 2; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
double ret = dist(1, i) + dist(i, j) + dist(j, 1);
ans = min(ans, ret);
}
}
printf("%.8f\n", ans / 2);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
struct point {
int x, y, z;
void read() { scanf("%d%d%d", &x, &y, &z); }
} a[N];
double dist(point p, point q) {
return sqrt(0.0 + (p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y) +
(p.z - q.z) * (p.z - q.z));
}
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) a[i].read();
double ans = 1e20;
for (int i = 2; i <= n; i++)
for (int j = i + 1; j <= n; j++) {
ans = min(ans, dist(a[1], a[i]) + dist(a[1], a[j]) + dist(a[i], a[j]));
}
printf("%.20lf\n", ans / 2);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double x[5555], y[5555], z[5555];
int n;
int main() {
cin >> n;
for (int(i) = 0; (i) < (n); ++(i)) cin >> x[i] >> y[i] >> z[i];
double ans = (double)1000000000 * 1000000000;
for (int i = 1; i < n; ++i)
for (int j = 1; j < i; ++j) {
double d1 =
sqrt((x[i] - x[0]) * (x[i] - x[0]) + (y[i] - y[0]) * (y[i] - y[0]) +
(z[i] - z[0]) * (z[i] - z[0]));
double d2 =
sqrt((x[j] - x[0]) * (x[j] - x[0]) + (y[j] - y[0]) * (y[j] - y[0]) +
(z[j] - z[0]) * (z[j] - z[0]));
double d3 =
sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
(z[i] - z[j]) * (z[i] - z[j]));
ans = min(ans, (d1 + d2 + d3) / 2.0);
}
printf("%0.9f\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 99999;
double m = inf;
int n, i, j, a[5001], b[5001], c[5001];
double d;
int main() {
cin >> n;
for (i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
for (i = 2; i <= n - 1; i++)
for (j = i + 1; j <= n; j++) {
d = sqrt((a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]) +
(c[i] - c[j]) * (c[i] - c[j]));
d += sqrt((a[i] - a[1]) * (a[i] - a[1]) + (b[i] - b[1]) * (b[i] - b[1]) +
(c[i] - c[1]) * (c[i] - c[1]));
d += sqrt((a[1] - a[j]) * (a[1] - a[j]) + (b[1] - b[j]) * (b[1] - b[j]) +
(c[1] - c[j]) * (c[1] - c[j]));
if (m > d) m = d;
}
printf("%6f", m / 2);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, i, j, k;
int a[5100], b[5100], c[5100];
double sol;
int dist(int x, int y) {
return (a[x] - a[y]) * (a[x] - a[y]) + (b[x] - b[y]) * (b[x] - b[y]) +
(c[x] - c[y]) * (c[x] - c[y]);
}
int main() {
scanf("%d", &n);
sol = (double)2000000000;
for (int i = 1; i <= n; ++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);
for (int i = 2; i <= n; ++i)
for (int j = i + 1; j <= n; ++j)
sol = min(sol, sqrt(dist(1, i)) + sqrt(dist(i, j)) + sqrt(dist(1, j)));
sol = sol / 2;
printf("%.6lf\n", sol);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int x[N], y[N], z[N];
inline long double dist(int i, int j) {
return sqrt(((x[i] - x[j]) * (x[i] - x[j])) +
((y[i] - y[j]) * (y[i] - y[j])) +
((z[i] - z[j]) * (z[i] - z[j])));
}
int main() {
int n;
scanf("%d", &n);
long double ans = 1e20;
for (int i = 0; i < (int)n; ++i) scanf("%d%d%d", &x[i], &y[i], &z[i]);
for (int i = 0; i < (int)n; ++i)
for (int j = 1; j < i; ++j)
ans = min(ans, (dist(0, i) + dist(0, j) + dist(i, j)) / 2.);
printf("%.20lf\n", (double)ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
void _R(T &x) {
cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
_R(head);
R(tail...);
}
template <class T>
void _W(const T &x) {
cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
_W(x.first);
putchar(' ');
_W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
for (auto i = x.begin(); i != x.end(); _W(*i++))
if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
_W(head);
putchar(sizeof...(tail) ? ' ' : '\n');
W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
x = (x + v) % MOD;
if (x < 0) x += MOD;
}
const int SIZE = 1e6 + 10;
const double EPS = 1e-12;
const double PI = acos(-1);
struct Point {
long long x, y, z;
Point(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
Point operator-(const Point &b) const {
return Point(x - b.x, y - b.y, z - b.z);
}
Point operator+(const Point &b) const {
return Point(x + b.x, y + b.y, z - b.z);
}
long double dis() const { return sqrt((long double)(x * x + y * y + z * z)); }
void scan() { R(x, y, z); }
void print() { W(x, y); }
} p[SIZE];
int main() {
int n;
R(n);
for (int i = 0; i < (n); ++i) p[i].scan();
long double an = 2e12;
for (int i = (1); i < (n); ++i)
for (int j = (1); j < (i); ++j) {
an = min(an, ((p[i] - p[0]).dis() + (p[j] - p[0]).dis() +
(p[i] - p[j]).dis()) /
2);
}
W((double)an);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Point {
int x, y, z;
} a[5001];
inline int sqr(int x) { return x * x; }
double dist(Point &a, Point &b) {
return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y) + sqr(a.z - b.z));
}
int main() {
int n, i, j;
scanf("%d", &n);
for (i = 1; i <= n; ++i) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
double ans = 1e20;
for (i = 2; i < n; ++i)
for (j = i + 1; j <= n; ++j)
ans = min(ans, dist(a[1], a[i]) + dist(a[1], a[j]) + dist(a[i], a[j]));
printf("%.7lf\n", ans * 0.5);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(T a, int n) {
for (int i = 0; i < n; ++i) cout << a[i] << ' ';
cout << endl;
}
template <class T>
void show(T a, int r, int l) {
for (int i = 0; i < r; ++i) show(a[i], l);
cout << endl;
}
const int N = 5100;
const int M = 5000;
const int oo = 10000 * 10000 * 10;
int n;
struct Node {
int x, y, z;
} p[N];
double idis[N][N];
inline double dis(Node a, Node b) {
long long x = a.x - b.x;
long long y = a.y - b.y;
long long z = a.z - b.z;
double ans = x * x + y * y + z * z;
return sqrt(ans);
}
void solve() {
int i, j, k;
double ans = 1e50;
for (i = 0; i < n; ++i) {
for (j = i + 1; j < n; ++j) idis[i][j] = idis[j][i] = dis(p[i], p[j]);
}
for (i = 1; i < n; ++i) {
for (j = i + 1; j < n; ++j) {
ans = (ans < idis[0][i] + idis[0][j] + idis[i][j]
? ans
: idis[0][i] + idis[0][j] + idis[i][j]);
}
}
printf("%0.10f\n", ans * 0.5);
}
int main() {
int i, j, cas = 0;
scanf("%d", &n);
for (i = 0; i < n; ++i) scanf("%d %d %d", &p[i].x, &p[i].y, &p[i].z);
solve();
return 0;
}
|
#include <bits/stdc++.h>
const int MAXN = 5000 + 10;
double ans = 1e99;
double x[MAXN], y[MAXN], z[MAXN];
int n;
double D(int i, int j) {
return sqrt(((x[i] - x[j]) * (x[i] - x[j])) +
((y[i] - y[j]) * (y[i] - y[j])) +
((z[i] - z[j]) * (z[i] - z[j])));
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lf%lf%lf", &x[i], &y[i], &z[i]);
for (int j = 2; j <= n; j++)
for (int k = j + 1; k <= n; k++) {
double cur = D(1, j) + D(j, k) + D(k, 1);
if (cur < ans) ans = cur;
}
printf("%0.8lf\n", ans / 2);
}
|
#include <bits/stdc++.h>
using namespace std;
double dist(int x1, int y1, int z1, int x2, int y2, int z2) {
x1 -= x2;
y1 -= y2;
z1 -= z2;
return sqrt(x1 * x1 + y1 * y1 + z1 * z1);
}
int n;
int x[5001], y[5001], z[5001];
int main(void) {
scanf("%d", &n);
double MinDist = 100000;
for (int i = 0; i < n; i++) scanf("%d%d%d", &x[i], &y[i], &z[i]);
for (int i = 1; i < n - 1; i++)
for (int j = i + 1; j < n; j++) {
double di = dist(x[i], y[i], z[i], x[0], y[0], z[0]);
double dj = dist(x[j], y[j], z[j], x[0], y[0], z[0]);
double dij = dist(x[j], y[j], z[j], x[i], y[i], z[i]);
double diff = fabs(di - dj);
MinDist = min(MinDist, fabs(max(di, dj) + (dij - diff) / 2));
}
printf("%.7lf", MinDist);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef struct {
double x, y, z;
} tetik;
tetik tik[5002];
int n;
double a, b, x, r, mi;
double pyt(tetik aa, tetik bb) {
double dx, dy, dz;
dx = aa.x - bb.x;
dy = aa.y - bb.y;
dz = aa.z - bb.z;
return dx * dx + dy * dy + dz * dz;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf%lf%lf", &tik[i].x, &tik[i].y, &tik[i].z);
}
mi = 1e+300;
for (int i = 1; i <= n - 1; i++) {
for (int j = i + 1; j <= n - 1; j++) {
a = sqrt(pyt(tik[i], tik[0]));
b = sqrt(pyt(tik[j], tik[0]));
x = sqrt(pyt(tik[i], tik[j]));
r = (b + x - a) / (2 * x);
if ((0 <= r) && (r <= 1)) {
mi = min(mi, a + r * x);
}
}
}
printf("%.10lf\n", mi);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5006;
const int mod = 1000000009;
double x[maxn], y[maxn], z[maxn];
double d[maxn][maxn];
int n;
double dis(double x1, double y1, double z1, double x2, double y2, double z2) {
double dx = x1 - x2;
double dy = y1 - y2;
double dz = z1 - z2;
return sqrt(dx * dx + dy * dy + dz * dz);
}
double getans() {
double ret = 100000000000.0;
for (int i = 1; i < n; ++i)
for (int j = i + 1; j < n; ++j) {
double dd = d[i][j] + d[0][i] + d[0][j];
ret = min(ret, dd);
}
return ret;
}
void init() {
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
d[i][j] = dis(x[i], y[i], z[i], x[j], y[j], z[j]);
}
int main() {
while (~scanf("%d", &n)) {
for (int i = 0; i < n; ++i) {
scanf("%lf%lf%lf", x + i, y + i, z + i);
}
init();
double ans = getans();
ans /= 2;
printf("%.9lf\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
double t[5001];
int n;
double ans;
struct P {
double x, y, z;
};
P a[5001];
double dis(P a, P b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) +
(a.z - b.z) * (a.z - b.z));
}
double min(double x, double y) {
if (x < y) {
return x;
} else {
return y;
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].z);
}
for (int i = 2; i <= n; i++) {
t[i] = dis(a[1], a[i]);
}
ans = 100000000.0;
for (int i = 2; i < n; i++)
for (int j = i + 1; j <= n; j++) {
ans = min(ans, min(t[i], t[j]) + fabs(t[i] - t[j]) +
(dis(a[i], a[j]) - fabs(t[i] - t[j])) / 2.0);
}
printf("%.6f\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9,
inf = 1e9 + 7;
const long long infll = 1e18 + 7;
long double ans = inf;
int n;
int a[N], b[N], c[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
for (int i = 2; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (ans >
sqrtl((a[1] - a[i]) * (a[1] - a[i]) + (b[1] - b[i]) * (b[1] - b[i]) +
(c[1] - c[i]) * (c[1] - c[i])) +
sqrtl((a[i] - a[j]) * (a[i] - a[j]) +
(b[i] - b[j]) * (b[i] - b[j]) +
(c[i] - c[j]) * (c[i] - c[j])) +
sqrtl((a[j] - a[1]) * (a[j] - a[1]) +
(b[j] - b[1]) * (b[j] - b[1]) +
(c[j] - c[1]) * (c[j] - c[1]))) {
ans = sqrtl((a[1] - a[i]) * (a[1] - a[i]) +
(b[1] - b[i]) * (b[1] - b[i]) +
(c[1] - c[i]) * (c[1] - c[i])) +
sqrtl((a[i] - a[j]) * (a[i] - a[j]) +
(b[i] - b[j]) * (b[i] - b[j]) +
(c[i] - c[j]) * (c[i] - c[j])) +
sqrtl((a[j] - a[1]) * (a[j] - a[1]) +
(b[j] - b[1]) * (b[j] - b[1]) +
(c[j] - c[1]) * (c[j] - c[1]));
}
}
}
cout << fixed << setprecision(6) << ans / 2.0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct point {
double x, y, z;
};
inline double sqr(double x) { return x * x; }
double dist(const point& p1, const point& p2) {
return sqrt(sqr(p1.x - p2.x) + sqr(p1.y - p2.y) + sqr(p1.z - p2.z));
}
point pts[5000 + 10];
double D[5000 + 10];
int n;
int main() {
double ans = 1e80;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf%lf%lf", &pts[i].x, &pts[i].y, &pts[i].z);
if (i) D[i] = dist(pts[i], pts[0]);
}
for (int i = 1; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
ans = min(ans, (D[i] + D[j] + dist(pts[i], pts[j])) * 0.5);
printf("%.10lf\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[5010], b[5010], c[5010], i, j, k;
double ans = 0, mini = 99999, maxi, d;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
for (i = 1; i < n - 1; i++)
for (j = i + 1; j < n; j++) {
d = sqrt((a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]) +
(c[i] - c[j]) * (c[i] - c[j]));
d += sqrt((a[i] - a[0]) * (a[i] - a[0]) + (b[i] - b[0]) * (b[i] - b[0]) +
(c[i] - c[0]) * (c[i] - c[0]));
d += sqrt((a[j] - a[0]) * (a[j] - a[0]) + (b[j] - b[0]) * (b[j] - b[0]) +
(c[j] - c[0]) * (c[j] - c[0]));
if (mini > d) {
mini = d;
}
}
ans = (ans + (mini / 2));
printf("%f", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double inf = 1e10;
int n;
struct P {
int x, y, z;
P() {}
void Scan() { scanf("%d%d%d", &x, &y, &z); }
};
vector<P> Pt;
vector<vector<double> > R;
double Range(int x, int y) {
if (R[x][y] != -1.0) return R[x][y];
double xt = Pt[x].x - Pt[y].x;
double yt = Pt[x].y - Pt[y].y;
double zt = Pt[x].z - Pt[y].z;
return R[x][y] = sqrt(xt * xt + yt * yt + zt * zt);
}
int main() {
scanf("%d", &n);
Pt.resize(n);
for (int i = 0; i < n; ++i) Pt[i].Scan();
vector<double> Rt(n, 1e10);
R.resize(n, vector<double>(n, -1.0));
Rt[0] = 0;
vector<int> P(n, -1);
vector<int> U(n, 0);
for (int i = 0; i < n; ++i) {
double x = 1e10;
int t = -1;
for (int j = 0; j < n; ++j) {
if (!U[j] && Rt[j] < x) {
t = j;
x = Rt[j];
}
}
if (t == -1 || x >= inf) break;
for (int j = 0; j < n; ++j) {
double tt = Range(t, j);
if (Rt[t] + tt < Rt[j]) {
Rt[j] = Rt[t] + tt;
P[j] = t;
}
}
U[t] = 1;
}
double res = inf;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (i != j && P[i] != j && P[j] != i) {
double tt = Range(i, j);
if (Rt[i] <= Rt[j] && Rt[j] <= Rt[i] + tt) {
res = min(res, Rt[j] + (tt - Rt[j] + Rt[i]) / 2);
}
}
}
}
printf("%.8lf", res);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double finf = 1e18;
int n;
double x[5005], y[5005], z[5005], out;
double dis(int i, int j) {
return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
(z[i] - z[j]) * (z[i] - z[j]));
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lf%lf%lf", &x[i], &y[i], &z[i]);
out = finf;
for (int i = 1; i < n; i++)
for (int j = i + 1; j < n; j++)
out = min(out, (dis(0, i) + dis(0, j) + dis(i, j)) / 2);
printf("%f\n", out);
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T, class S>
ostream &operator<<(ostream &o, const pair<T, S> &p) {
return o << '(' << p.first << ", " << p.second << ')';
}
template <template <class, class...> class T, class... A>
typename enable_if<!is_same<T<A...>, string>(), ostream &>::type operator<<(
ostream &o, T<A...> V) {
o << '[';
for (auto a : V) o << a << ", ";
return o << ']';
}
long double x[5010], y[5010], z[5010];
long double dst(long long int i, long long int j) {
return sqrt(((x[i] - x[j]) * (x[i] - x[j])) +
((y[i] - y[j]) * (y[i] - y[j])) +
((z[i] - z[j]) * (z[i] - z[j])));
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long int n;
cin >> n;
for (long long int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
long double ans = 1000000007.;
for (long long int i = 1; i < n; i++)
for (long long int j = 1; j < n; j++)
if (i - j) {
ans = min(ans, (dst(0, i) + dst(0, j) + dst(i, j)) / (long double)2);
}
cout << fixed << setprecision(10) << ans << '\n';
}
|
/* 2013-08-11 10:01:16.979212 */#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#define sqr(x) ((x)*(x))
using namespace std;
struct data{
int x,y,z;
long double dis;
}A[5005];
long double ans;
inline bool operator < (data a,data b){
return a.dis<b.dis;
}
int main(){
int n,m,i,j,k,l;
scanf("%d",&n);
ans=1000000000000000.00;
for(i=1;i<=n;i++)scanf("%d%d%d",&A[i].x,&A[i].y,&A[i].z);
for(i=2;i<=n;i++){
A[i].dis=sqrt((long double)sqr(A[i].x-A[1].x)+sqr(A[i].y-A[1].y)+sqr(A[i].z-A[1].z));
}
sort(A+2,A+1+n);
for(i=2;i<=n;i++)
for(j=i+1;j<=n;j++){
long double d1=sqrt((long double)sqr(A[i].x-A[j].x)+sqr(A[i].y-A[j].y)+sqr(A[i].z-A[j].z));
ans=min(ans,d1+A[i].dis+A[j].dis);
/* if(A[i].dis+d1+eps<A[j].dis){
}*/
}
printf("%.7f\n",(double)ans/2);
// cout<<fixed()<<setprecision(7)<<ans<<endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
int x, y, z;
} a[5001];
int main() {
int n;
cin >> n;
for (int x = 1; x <= n; x++) cin >> a[x].x >> a[x].y >> a[x].z;
double ans = 1e18;
for (int x = 2; x <= n; x++)
for (int y = 2; y < x; y++)
ans = min(ans, (double)(sqrt((a[1].x - a[x].x) * (a[1].x - a[x].x) +
(a[1].y - a[x].y) * (a[1].y - a[x].y) +
(a[1].z - a[x].z) * (a[1].z - a[x].z))) +
(double)(sqrt((a[1].x - a[y].x) * (a[1].x - a[y].x) +
(a[1].y - a[y].y) * (a[1].y - a[y].y) +
(a[1].z - a[y].z) * (a[1].z - a[y].z))) +
(double)(sqrt((a[x].x - a[y].x) * (a[x].x - a[y].x) +
(a[x].y - a[y].y) * (a[x].y - a[y].y) +
(a[x].z - a[y].z) * (a[x].z - a[y].z))));
printf("%.10lf\n", ans / 2);
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
struct point {
double x, y, z;
point(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {}
};
double dist(const point& a, const point& b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) +
(a.z - b.z) * (a.z - b.z));
}
struct edge {
int p;
double t;
edge(int p, double t) : p(p), t(t) {}
bool operator<(const edge& e) const { return t > e.t; }
};
int n, size;
point p[N];
set<double, greater<double> > frame[N];
double dijkstra() {
priority_queue<edge> pq;
pq.push(edge(0, 0));
double mn = HUGE_VAL;
while (!pq.empty()) {
edge e = pq.top();
pq.pop();
if (e.t > mn) break;
for (int i = 0; i < n; ++i) {
if (e.p == i) continue;
double d = dist(p[i], p[e.p]);
double nt = e.t + d;
set<double, greater<double> >::iterator it =
frame[i].lower_bound(e.t + d);
if (it == frame[i].end()) {
frame[i].insert(nt);
pq.push(edge(i, nt));
} else {
double f = *it;
if (!(nt - d <= f + 1e-7 && f - 1e-7 <= nt)) {
frame[i].insert(nt);
pq.push(edge(i, nt));
} else {
double x = (nt + f) / 2;
mn = min(mn, x);
}
}
}
}
return mn;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(12);
cout << fixed;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> p[i].x >> p[i].y >> p[i].z;
}
size = n;
cout << dijkstra() << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
double dist(int x1, int y1, int z1, int x2, int y2, int z2) {
return sqrt(double(x2 - x1) * (x2 - x1) + double(y2 - y1) * (y2 - y1) +
double(z2 - z1) * (z2 - z1));
}
int main() {
int n;
cin >> n;
int x[n], y[n], z[n];
for (int _n(n), i(0); i < _n; i++) cin >> x[i] >> y[i] >> z[i];
double ans = 1.e40;
double D[n];
for (int _n(n), i(1); i < _n; i++)
D[i] = dist(x[i], y[i], z[i], x[0], y[0], z[0]);
for (int _n(n), i(1); i < _n; i++)
for (int _n(n), j(i + 1); j < _n; j++) {
double d = dist(x[i], y[i], z[i], x[j], y[j], z[j]) + D[i] + D[j];
ans = min(ans, d / 2);
}
printf("%6f\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5023;
int N, X[MAXN], Y[MAXN], Z[MAXN];
inline double dist(int i, int j) {
long long a = X[i] - X[j];
a = a * a;
long long b = Y[i] - Y[j];
b = b * b;
long long c = Z[i] - Z[j];
c = c * c;
return sqrt(a + b + c);
}
int main() {
scanf("%d", &N);
for (int i(1); i <= (N); ++i) {
scanf("%d %d %d", X + i, Y + i, Z + i);
}
double ans = 1e100;
for (int i(2); i <= (N); ++i)
for (int j(i + 1); j <= (N); ++j) {
ans = min(ans, dist(i, j) + dist(1, i) + dist(1, j));
}
printf("%.8f\n", ans * 0.5);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
double ans = 1e10;
struct point {
int a, b, c;
void get() { scanf("%d%d%d", &a, &b, &c); }
};
point p[5001];
double di(int i, int j) {
return sqrt((p[i].a - p[j].a) * (p[i].a - p[j].a) +
(p[i].b - p[j].b) * (p[i].b - p[j].b) +
(p[i].c - p[j].c) * (p[i].c - p[j].c));
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) p[i].get();
for (int i = 1; i < n; i++)
for (int j = i + 1; j < n; j++)
ans = min(ans, di(i, j) + di(0, i) + di(0, j));
printf("%.12lf\n", ans / 2);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
double dis[5005][5005];
double ans(double a, double b, double c) { return (b + c - a) / 2. + a; }
int main() {
int n, i, j;
double x[maxn], y[maxn], z[maxn], mn = 1e+10, tmp;
cin >> n;
for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
dis[i][j] =
sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]) +
(z[j] - z[i]) * (z[j] - z[i]));
for (i = 1; i < n; i++)
for (j = i + 1; j < n; j++) {
tmp = ans(dis[0][i], dis[0][j], dis[i][j]);
mn = min(mn, tmp);
}
printf("%.12lf", mn);
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod1 = static_cast<long long>(1073741824);
const long long mod2 = static_cast<long long>(1000000007);
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long double ldOne = 1.0;
long long gcd(long long a, long long b) {
if (!b) return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long power(long long x, long long y, long long p) {
long long res = 1;
x %= p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
long long exp(long long x, long long n) {
if (n == 0)
return 1;
else if (n & 1)
return x * exp(x * x, (n - 1) / 2);
else
return exp(x * x, n / 2);
}
bool isPrime(long long n) {
for (long long i = 0; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
vector<long long> SieveOfEratosthenes(long long n) {
vector<bool> prime(n + 1, true);
for (long long p = 2; p * p <= n; p++) {
if (prime[p]) {
for (long long i = p * p; i <= n; i += p) prime[i] = false;
}
}
vector<long long> v;
for (long long i = 2; i <= n; i++) {
if (prime[i]) v.push_back(i);
}
return v;
}
map<long long, long long> PrimeFactorization(long long n) {
vector<long long> v = SieveOfEratosthenes(static_cast<long long>(sqrt(n)));
map<long long, long long> m;
for (unsigned long long i = 0; i < v.size(); i++) {
if (n % v[i] == 0) {
n /= v[i];
m[v[i]]++;
i--;
}
}
return m;
}
long long nCr(long long n, long long r) {
vector<long long> c(r + 1, 0);
c[0] = 1;
for (long long i = 0; i < n + 1; i++) {
for (long long j = min(i, r); j > 0; j--) c[j] = c[j - 1] + c[j];
}
return c[r];
}
long long num(char a) {
switch (a) {
case '0':
return 2;
case '1':
return 7;
case '2':
return 2;
case '3':
return 3;
case '4':
return 3;
case '5':
return 4;
case '6':
return 2;
case '7':
return 5;
case '8':
return 1;
case '9':
return 2;
}
return 0;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
cin >> s;
long long multi = 1;
for (long long i = 0; i < static_cast<long long>(s.length()); i++) {
multi *= num(s[i]);
}
cout << multi;
cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
<< "ms\n";
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int visited[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int n;
string s;
while (cin >> s) {
int a = s[0] - '0';
int b = s[1] - '0';
int sum = visited[a] * visited[b];
cout << sum << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int func(int n) {
if (n == 0)
return 2;
else if (n == 1)
return 7;
else if (n == 2)
return 2;
else if (n == 3)
return 3;
else if (n == 4)
return 3;
else if (n == 5)
return 4;
else if (n == 6)
return 2;
else if (n == 7)
return 5;
else if (n == 8)
return 1;
else if (n == 9)
return 2;
}
int main() {
int i, j, k, l, t, m, n;
cin >> n;
if (n < 10) {
m = 0;
n = n;
} else {
m = n / 10;
n = n % 10;
}
int p = func(m);
int q = func(n);
cout << p * q << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double maxdouble = numeric_limits<double>::max();
const double eps = 1e-10;
const int INF = 0x7FFFFFFF;
int len[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
char s[3];
int main() {
while (cin >> s) {
cout << len[s[1] - '0'] * len[s[0] - '0'] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
std::vector<int> digits;
digits.push_back(2);
digits.push_back(7);
digits.push_back(2);
digits.push_back(3);
digits.push_back(3);
digits.push_back(4);
digits.push_back(2);
digits.push_back(5);
digits.push_back(1);
digits.push_back(2);
int input;
scanf("%d\n", &input);
int output = digits[input / 10] * digits[input % 10];
printf("%d\n", output);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int mint(long long int a, long long int b) {
if (a < b)
return a;
else
return b;
}
int main() {
int arr[10];
arr[0] = 2;
arr[1] = 7;
arr[2] = 2;
arr[3] = 3;
arr[4] = 3;
arr[5] = 4;
arr[6] = 2;
arr[7] = 5;
arr[8] = 1;
arr[9] = 2;
int n;
cin >> n;
int x = n % 10;
n = n / 10;
cout << arr[x] * arr[n];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long n;
vector<long> prec;
int main() {
ios_base::sync_with_stdio(0);
prec.push_back(2);
prec.push_back(7);
prec.push_back(2);
prec.push_back(3);
prec.push_back(3);
prec.push_back(4);
prec.push_back(2);
prec.push_back(5);
prec.push_back(1);
prec.push_back(2);
cin >> n;
cout << prec[n / 10] * prec[n % 10] << endl;
cin.get();
cin.get();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[111];
cin >> n;
a[0] = 2;
a[1] = 7;
a[2] = 2;
a[3] = 3;
a[4] = 3;
a[5] = 4;
a[6] = 2;
a[7] = 5;
a[8] = 1;
a[9] = 2;
int x = n / 10;
int y = n % 10;
cout << a[x] * a[y];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[11];
string s;
int main() {
arr[0] = 1 + 1;
arr[1] = 6 + 1;
arr[2] = 1 + 1;
arr[3] = 2 + 1;
arr[4] = 2 + 1;
arr[5] = 3 + 1;
arr[6] = 1 + 1;
arr[7] = 4 + 1;
arr[8] = 0 + 1;
arr[9] = 1 + 1;
cin >> s;
int ans = 0;
ans = arr[s[0] - '0'] * arr[s[1] - '0'];
cout << ans << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int func(int a) {
if (a == 0)
return 2;
else if (a == 1)
return 7;
else if (a == 2)
return 2;
else if (a == 3)
return 3;
else if (a == 4)
return 3;
else if (a == 5)
return 4;
else if (a == 6)
return 2;
else if (a == 7)
return 5;
else if (a == 8)
return 1;
else
return 2;
}
int main() {
int n, f, f1;
cin >> n;
f = n % 10;
f1 = n / 10;
int ans1 = func(f);
int ans2 = func(f1);
cout << ans1 * ans2 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline int gn(char x) { return x - '0'; }
int main() {
int ans = 1;
char s[10];
scanf("%s", s);
int n = strlen(s);
int cnt[10];
cnt[0] = 2;
cnt[1] = 7;
cnt[2] = 2;
cnt[3] = 3;
cnt[4] = 3;
cnt[5] = 4;
cnt[6] = 2;
cnt[7] = 5;
cnt[8] = 1;
cnt[9] = 2;
for (int i = 0; i < n; i++) {
ans *= cnt[gn(s[i])];
}
printf("%d", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a, c;
int main() {
cin >> n;
a = n % 10;
if (a == 0 || a == 6 || a == 9 || a == 2)
c = 2;
else if (a == 8)
c = 1;
else if (a == 4 || a == 3)
c = 3;
else if (a == 5)
c = 4;
else if (a == 7)
c = 5;
else if (a == 1)
c = 7;
n = n / 10;
a = n;
if (a == 0 || a == 6 || a == 9 || a == 2)
c = c * 2;
else if (a == 8)
c = c * 1;
else if (a == 4 || a == 3)
c = c * 3;
else if (a == 5)
c = c * 4;
else if (a == 7)
c = c * 5;
else if (a == 1)
c = c * 7;
cout << c;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char twoDigt[2];
int x = 0, y = 0;
for (int i = 0; i < 2; i++) cin >> twoDigt[i];
if (twoDigt[0] == '0' || twoDigt[0] == '9')
x = 2;
else if (twoDigt[0] == '1')
x = 7;
else if (twoDigt[0] == '7')
x = 5;
else if (twoDigt[0] == '3' || twoDigt[0] == '4')
x = 3;
else if (twoDigt[0] == '5')
x = 4;
else if (twoDigt[0] == '8')
x = 1;
else if (twoDigt[1] == '2')
x = 2;
else
x = 2;
if (twoDigt[1] == '0' || twoDigt[1] == '9')
y = 2;
else if (twoDigt[1] == '1')
y = 7;
else if (twoDigt[1] == '2' || twoDigt[1] == '6')
y = 2;
else if (twoDigt[1] == '7')
y = 5;
else if (twoDigt[1] == '3' || twoDigt[1] == '4')
y = 3;
else if (twoDigt[1] == '5')
y = 4;
else if (twoDigt[1] == '8')
y = 1;
cout << x * y;
return 0;
}
|
#include <bits/stdc++.h>
int d[] = {
0x1011111, 0x0000101, 0x1110110, 0x1110101, 0x0101101,
0x1111001, 0x1111011, 0x1000101, 0x1111111, 0x1111101,
};
using namespace std;
int main() {
int n, res = 0;
cin >> n;
int n1 = d[n / 10];
int n2 = d[n % 10];
for (int i = 0; i <= 99; ++i) {
int i1 = d[i / 10];
int i2 = d[i % 10];
if ((n1 & i1) == n1 && (n2 & i2) == n2) res++;
}
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int calc(int num) {
switch (num) {
case '0':
return 2;
break;
case '1':
return 7;
break;
case '2':
return 2;
break;
case '3':
return 3;
break;
case '4':
return 3;
break;
case '5':
return 4;
break;
case '6':
return 2;
break;
case '7':
return 5;
break;
case '8':
return 1;
break;
case '9':
return 2;
break;
default:
break;
}
return 0;
}
int main() {
string s;
while (cin >> s) {
int ans = calc(s[0]);
ans *= calc(s[1]);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int c[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int main() {
int n;
while (~scanf("%d", &n)) {
int a = n % 10, b = n / 10 % 10;
printf("%d\n", c[a] * c[b]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
vector<int> A(10);
A[0] = 2, A[1] = 7, A[2] = 2, A[3] = 3, A[4] = 3, A[5] = 4, A[6] = 2,
A[7] = 5, A[8] = 1, A[9] = 2;
int n;
cin >> n;
cout << A[n % 10] * A[(n / 10) % 10];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int f(char a) {
if (a == '0') return 1;
if (a == '1') return 6;
if (a == '2') return 1;
if (a == '3') return 2;
if (a == '4') return 2;
if (a == '5') return 3;
if (a == '6') return 1;
if (a == '7') return 4;
if (a == '8') return 0;
if (a == '9') return 1;
}
int main() {
string s;
cin >> s;
long long out = 1;
for (int i = 0; i < s.size(); i++) {
out *= f(s[i]) + 1;
}
cout << out << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n) {
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) {
return false;
}
}
return true;
}
inline long long getPow(long long a, long long b) {
long long res = 1, tp = a;
while (b) {
if (b & 1ll) {
res *= tp;
res %= 1000000007;
}
tp *= tp;
tp %= 1000000007;
b >>= 1ll;
}
return res;
}
inline long long to_ll(string s) {
long long cur = 0;
for (int i = 0; i < s.size(); i++) {
cur = cur * 10 + s[i] - '0';
}
return cur;
}
inline string to_str(long long x) {
string s = "";
while (x) {
s += char(x % 10 + '0');
x /= 10;
}
reverse(s.begin(), s.end());
return s;
}
inline long long nxt() {
long long x;
scanf("%lld", &x);
return x;
}
void ok() {
puts("YES");
exit(0);
}
void panic() {
puts("NO");
exit(0);
}
const long long N = 1e6 + 5;
long long value(long long d) {
if (d == 0) {
return 2;
}
if (d == 1) {
return 7;
}
if (d == 2) {
return 2;
}
if (d == 3) {
return 3;
}
if (d == 4) {
return 3;
}
if (d == 5) {
return 4;
}
if (d == 6) {
return 2;
}
if (d == 7) {
return 5;
}
if (d == 8) {
return 1;
}
if (d == 9) {
return 2;
}
}
int main() {
long long n = nxt();
cout << value(n % 10) * value(n / 10);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char ch;
cin >> ch;
int ans = 1;
switch (ch) {
case '9':
ans *= 2;
break;
case '8':
ans *= 1;
break;
case '7':
ans *= 5;
break;
case '6':
ans *= 2;
break;
case '5':
ans *= 4;
break;
case '4':
ans *= 3;
break;
case '3':
ans *= 3;
break;
case '2':
ans *= 2;
break;
case '1':
ans *= 7;
break;
case '0':
ans *= 2;
break;
}
cin >> ch;
switch (ch) {
case '9':
ans *= 2;
break;
case '8':
ans *= 1;
break;
case '7':
ans *= 5;
break;
case '6':
ans *= 2;
break;
case '5':
ans *= 4;
break;
case '4':
ans *= 3;
break;
case '3':
ans *= 3;
break;
case '2':
ans *= 2;
break;
case '1':
ans *= 7;
break;
case '0':
ans *= 2;
break;
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
int main() {
int have[10];
have[0] = 2;
have[1] = 7;
have[2] = 2;
have[3] = 3;
have[4] = 3;
have[5] = 4;
have[6] = 2;
have[7] = 5;
have[8] = 1;
have[9] = 2;
int ans = 1, tmp;
string n;
cin >> n;
cout << have[n[0] - '0'] * have[n[1] - '0'] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[13][10] = {{0, 1, 2, 4, 5, 6, 10}, {2, 6, 10, 10, 10, 10, 10},
{0, 2, 3, 4, 5, 10, 10}, {0, 2, 3, 5, 6, 10, 10},
{1, 2, 3, 6, 10, 10, 10}, {0, 1, 3, 5, 6, 10, 10},
{0, 1, 3, 4, 5, 6, 10}, {0, 2, 6, 10, 10, 10, 10},
{0, 1, 2, 3, 4, 5, 6}, {0, 1, 2, 3, 5, 6, 10}};
bool ok(int a, int b) {
int k;
for (int i = (0); i < (7); i++) {
k = arr[a][i];
if (k == 10) continue;
if (!binary_search(arr[b], arr[b] + 7, k)) {
return 0;
}
}
return 1;
}
int main(int argc, char const* argv[]) {
int a, b, c;
scanf("%d", &c);
a = c / 10;
b = c % 10;
set<pair<int, int> > res;
for (int i = (0); i < (10); i++) {
if (!ok(a, i)) {
continue;
}
for (int j = (0); j < (10); j++) {
if (!ok(b, j)) {
continue;
}
res.insert(make_pair(i, j));
}
}
a = res.size();
printf("%d\n", a);
return 0;
}
|
#include <bits/stdc++.h>
int A[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int main() {
char a, b;
scanf("%c%c", &a, &b);
printf("%d\n", A[a - '0'] * A[b - '0']);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, x, y, num[10], i, j, vis[10];
int check(int a, int b) {
int i, d, tmp;
for (i = 0; i <= 9; i++) {
vis[i] = 0;
}
tmp = num[a];
while (tmp != 0) {
d = tmp % 10;
if (!vis[d]) {
vis[d] = 1;
}
tmp /= 10;
}
tmp = num[b];
while (tmp != 0) {
d = tmp % 10;
if (!vis[d]) {
break;
}
tmp /= 10;
}
return (!tmp);
}
int ans = 0;
int main() {
cin >> n;
num[0] = 123456;
num[1] = 34;
num[2] = 23567;
num[3] = 23457;
num[4] = 1347;
num[5] = 12457;
num[6] = 124567;
num[7] = 234;
num[8] = 1234567;
num[9] = 123457;
if (n < 10) {
x = 0;
y = n;
} else {
x = n / 10;
y = n % 10;
}
for (i = 0; i <= 9; i++) {
for (j = 0; j <= 9; j++) {
if (check(i, x) && check(j, y)) {
ans++;
}
}
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int xemxet(int r) {
int s[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
return (s[r]);
}
int main() {
int s;
cin >> s;
cout << xemxet(s / 10) * xemxet(s % 10);
}
|
#include <bits/stdc++.h>
using namespace std;
int cnt[10];
int main() {
cnt[0] = 2, cnt[1] = 7, cnt[2] = 2, cnt[3] = 3, cnt[4] = 3;
cnt[5] = 4, cnt[6] = 2, cnt[7] = 5, cnt[8] = 1, cnt[9] = 2;
int a = getchar() - '0';
int b = getchar() - '0';
printf("%d", cnt[a] * cnt[b]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
template <typename T>
string to_str(T str) {
stringstream stream;
stream << str;
return stream.str();
}
template <typename T>
int to_int(T num) {
int val;
stringstream stream;
stream << num;
stream >> val;
return val;
}
vector<string> split(const string& s, char delim) {
vector<string> elems;
stringstream ss(s);
string item;
while (getline(ss, item, delim)) elems.push_back(item);
return elems;
}
const int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};
int main() {
char s[3];
char t[11] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
cin >> s;
cout << t[s[0] - '0'] * t[s[1] - '0'] << endl;
return 0;
}
|
#include <bits/stdc++.h>
int main(void) {
int mul[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int n;
int ans;
scanf("%d", &n);
ans = mul[n / 10] * mul[n % 10];
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
int a, b;
if (str[0] == '0') {
a = 2;
}
if (str[0] == '1') {
a = 7;
}
if (str[0] == '2') {
a = 2;
}
if (str[0] == '3') {
a = 3;
}
if (str[0] == '4') {
a = 3;
}
if (str[0] == '5') {
a = 4;
}
if (str[0] == '6') {
a = 2;
}
if (str[0] == '7') {
a = 5;
}
if (str[0] == '8') {
a = 1;
}
if (str[0] == '9') {
a = 2;
}
if (str[1] == '0') {
b = 2;
}
if (str[1] == '1') {
b = 7;
}
if (str[1] == '2') {
b = 2;
}
if (str[1] == '3') {
b = 3;
}
if (str[1] == '4') {
b = 3;
}
if (str[1] == '5') {
b = 4;
}
if (str[1] == '6') {
b = 2;
}
if (str[1] == '7') {
b = 5;
}
if (str[1] == '8') {
b = 1;
}
if (str[1] == '9') {
b = 2;
}
cout << a * b;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
char s[5];
while (~scanf("%s", s)) {
int ans = 1;
for (int i = 0; s[i]; i++) {
switch (s[i]) {
case '0':
ans *= 2;
break;
case '1':
ans *= 7;
break;
case '2':
ans *= 2;
break;
case '3':
ans *= 3;
break;
case '4':
ans *= 3;
break;
case '5':
ans *= 4;
break;
case '6':
ans *= 2;
break;
case '7':
ans *= 5;
break;
case '8':
ans *= 1;
break;
case '9':
ans *= 2;
break;
}
}
printf("%d\n", ans);
}
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> v[10];
vector<int> w[10];
int main() {
int(n);
scanf("%d", &(n));
;
v[0].push_back(1);
v[3].push_back(1);
v[3].push_back(7);
v[4].push_back(1);
v[6].push_back(5);
v[6].push_back(7);
v[7].push_back(1);
for (int i = (0); i < (10); ++i)
if (i != 8) v[8].push_back(i);
int u[] = {1, 3, 4, 5, 7};
for (int j = (0); j < (5); ++j) v[9].push_back(u[j]);
for (int i = (0); i < (10); ++i) v[i].push_back(i);
for (int j = (0); j < (10); ++j)
for (int k = (0); k < (v[j].size()); ++k) w[v[j][k]].push_back(j);
int a1 = n % 10, a2 = n / 10;
printf("%d\n", w[a1].size() * w[a2].size());
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[11][11];
int main() {
for (int a = 0; a < 10; ++a) arr[a][a] = arr[8][a] = 1;
arr[0][1] = 1;
arr[0][7] = 1;
arr[3][1] = 1;
arr[3][7] = 1;
arr[4][1] = 1;
arr[6][5] = 1;
arr[7][1] = 1;
arr[9][1] = 1;
arr[9][3] = 1;
arr[9][4] = 1;
arr[9][5] = 1;
arr[9][7] = 1;
int n;
scanf("%d", &n);
int X = n % 10;
int Y = n / 10;
int res = 0;
for (int a = 0; a < 100; ++a) {
int x = a % 10;
int y = a / 10;
res += arr[x][X] && arr[y][Y];
}
printf("%d\n", res);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int need[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
string s;
cin >> s;
cout << need[s[0] - '0'] * need[s[1] - '0'] << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int num[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
char str[5];
int ans = 0, nl, nr;
while (scanf("%s", str) != EOF) {
ans = 0;
if (strlen(str) == 1) {
nl = str[0] - '0';
ans += num[nl];
} else if (strlen(str) == 2) {
nl = str[0] - '0';
nr = str[1] - '0';
ans += (num[nl] * num[nr]);
}
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int tp = 1, z = 1;
char ch[2];
cin >> ch[0] >> ch[1];
{
if (ch[0] == '0' || ch[0] == '2' || ch[0] == '6' || ch[0] == '9')
tp *= 2;
else if (ch[0] == '1')
tp *= 7;
else if (ch[0] == '3' || ch[0] == '4')
tp *= 3;
else if (ch[0] == '5')
tp *= 4;
else if (ch[0] == '7')
tp *= 5;
else if (ch[0] == '8')
tp *= 1;
}
{
if (ch[1] == '0' || ch[1] == '2' || ch[1] == '6' || ch[1] == '9')
z *= 2;
else if (ch[1] == '1')
tp *= 7;
else if (ch[1] == '3' || ch[1] == '4')
z *= 3;
else if (ch[1] == '5')
z *= 4;
else if (ch[1] == '7')
z *= 5;
else if (ch[1] == '8')
z *= 1;
}
cout << tp * z;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int a[10];
inline void init() {
a[0] = 2;
a[1] = 7;
a[2] = 2;
a[3] = 3;
a[4] = 3;
a[5] = 4;
a[6] = 2;
a[7] = 5;
a[8] = 1;
a[9] = 2;
}
char s[2];
int main() {
scanf("%s", s);
init();
int ans = a[s[0] - '0'] * a[s[1] - '0'];
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int n;
cin >> n;
int kind[20] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int sum = 0;
sum = kind[n % 10] * kind[n / 10];
cout << sum;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int i, j, n, v[10001];
int nr[10] = {1, 6, 1, 2, 2, 3, 1, 4, 0, 1};
bool ok;
string s;
int main() {
cin >> n;
cout << (nr[n / 10] + 1) * (nr[n % 10] + 1);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int main() {
string str;
cin >> str;
int a = arr[str[0] - '0'];
int b = arr[str[1] - '0'];
cout << (a * b) << endl;
return 0;
}
|
#include <bits/stdc++.h>
int poss(char ch) {
if (ch == '3' || ch == '4') return 3;
if (ch == '0' || ch == '6' || ch == '9' || ch == '2') return 2;
if (ch == '1') return 7;
if (ch == '5') return 4;
if (ch == '8') return 1;
if (ch == '7') return 5;
}
int main() {
char str[3];
gets(str);
printf("%d\n", poss(str[0]) * poss(str[1]));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long ans = 1;
vector<long long> ways = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
char ch;
while (cin >> ch) ans *= ways[ch - '0'];
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, ans = 0;
scanf("%d", &n);
x = n % 10;
n /= 10;
y = n % 10;
if (x == 0)
ans = 2;
else if (x == 1)
ans = 7;
else if (x == 2)
ans = 2;
else if (x == 3)
ans = 3;
else if (x == 4)
ans = 3;
else if (x == 5)
ans = 4;
else if (x == 6)
ans = 2;
else if (x == 7)
ans = 5;
else if (x == 8)
ans = 1;
else
ans = 2;
x = y;
if (x == 0)
ans *= 2;
else if (x == 1)
ans *= 7;
else if (x == 2)
ans *= 2;
else if (x == 3)
ans *= 3;
else if (x == 4)
ans *= 3;
else if (x == 5)
ans *= 4;
else if (x == 6)
ans *= 2;
else if (x == 7)
ans *= 5;
else if (x == 8)
ans *= 1;
else
ans *= 2;
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string n;
int v[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
while (cin >> n) {
int x = n[0] - '0', y = n[1] - '0';
cout << v[x] * v[y] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int con[10][10] = {1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1};
int main() {
ios::sync_with_stdio(false);
int n, ans = 0;
cin >> n;
for (int i = 0; i < 100; i++) {
if (con[i % 10][n % 10] == 1 && con[i / 10][n / 10] == 1) ans++;
}
cout << ans;
}
|
#include <bits/stdc++.h>
int cc(int y) {
switch (y) {
case 0:
return 2;
case 1:
return 7;
case 2:
return 2;
case 3:
return 3;
case 4:
return 3;
case 5:
return 4;
case 6:
return 2;
case 7:
return 5;
case 8:
return 1;
case 9:
return 2;
}
}
int main() {
int i, x;
x = 1;
scanf("%d", &i);
x = cc(i % 10) * cc(i / 10);
printf("%d", x);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int d[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int main() {
string s;
cin >> s;
cout << d[s[0] - '0'] * d[s[1] - '0'] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
int x = a % 10;
int y = a / 10;
int k, s;
if (y == 8)
k = 1;
else if (y == 0 || y == 2 || y == 6 || y == 9)
k = 2;
else if (y == 3 || y == 4)
k = 3;
else if (y == 5)
k = 4;
else if (y == 1)
k = 7;
else if (y == 7)
k = 5;
if (x == 8)
s = 1;
else if (x == 0 || x == 2 || x == 6 || x == 9)
s = 2;
else if (x == 3 || x == 4)
s = 3;
else if (x == 5)
s = 4;
else if (x == 1)
s = 7;
else if (x == 7)
s = 5;
cout << s * k << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int ans(int n) {
if (n == 1) {
return 7;
}
if (n == 2) {
return 2;
}
if (n == 3) {
return 3;
}
if (n == 4) {
return 3;
}
if (n == 5) {
return 4;
}
if (n == 6) {
return 2;
}
if (n == 7) {
return 5;
}
if (n == 8) {
return 1;
}
if (n == 9) {
return 2;
}
if (n == 0) {
return 2;
}
}
int main() {
string s;
cin >> s;
cout << ans(s[0] - 48) * ans(s[1] - 48) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int ans = 1;
void input() { cin >> n; }
void output() {
int t = n % 10, i = 0;
while (i < 2) {
if (t == 0) ans *= 2;
if (t == 1) ans *= 7;
if (t == 2) ans *= 2;
if (t == 3) ans *= 3;
if (t == 4) ans *= 3;
if (t == 5) ans *= 4;
if (t == 6) ans *= 2;
if (t == 7) ans *= 5;
if (t == 9) ans *= 2;
n /= 10;
t = n;
i++;
}
cout << ans << endl;
}
int main() {
input();
output();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
map<int, int> m{{0, 2}, {1, 7}, {2, 2}, {3, 3}, {4, 3},
{5, 4}, {6, 2}, {7, 5}, {8, 1}, {9, 2}};
string s;
cin >> s;
cout << m[s[0] - '0'] * m[s[1] - '0'] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
char a, b;
int num[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
int main() {
cin >> a >> b;
cout << num[a - '0'] * num[b - '0'] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int b[10][10] = {1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1,
0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1,
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1};
int len, ans, ans2, o;
char s[10];
int main() {
scanf("%s", s + 1);
len = strlen(s + 1);
if (len == 1) {
o = s[1] - '0';
for (int i = 0; i < 10; i++)
if (b[o][i]) ans++;
printf("%d", ans);
} else {
o = s[1] - '0';
for (int i = 0; i < 10; i++)
if (b[o][i]) ans++;
o = s[2] - '0';
for (int i = 0; i < 10; i++)
if (b[o][i]) ans2++;
printf("%d", ans * ans2);
}
}
|
#include <bits/stdc++.h>
using namespace std;
void mego() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main() {
mego();
int x, arr[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
cin >> x;
cout << (arr[x / 10] * arr[x % 10]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int ans = 1;
int a[2][10] = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
{2, 7, 2, 3, 3, 4, 2, 5, 1, 2}};
int n;
cin >> n;
int d = n % 10;
if (n <= 9)
ans = 2 * a[1][d];
else {
int x = n / 10;
ans = ans * (a[1][d]) * (a[1][x]);
}
cout << ans << endl;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.