buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <math.h> #include <stdio.h> int main(void) { int n, avec[100], bvec[100], i; double abvalue, dis1 = 0, dis2 = 0, dis3 = 0, dis = 0; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &avec[i]); for (i = 0; i < n; i++) scanf("%d", &bvec[i]); for (i = 0; i < n; i++) { abvalue = fabs(...
#include <math.h> #include <stdio.h> int main(void) { int n, avec[100], bvec[100], i; double abvalue, dis1 = 0, dis2 = 0, dis3 = 0, dis = 0; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &avec[i]); for (i = 0; i < n; i++) scanf("%d", &bvec[i]); for (i = 0; i < n; i++) { abvalue = fabs(...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47]]
0
208
#include <math.h> #include <stdio.h> int main(int argc, char **argv) { int n, i; double x[100], y[100], max = 0, result_p1 = 0, result_p2 = 0, result_p3 = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf", &x[i]); } for (i = 0; i < n; i++) { scanf("%lf", &y[i]); } for (i = 0; i < n;...
#include <math.h> #include <stdio.h> int main(int argc, char **argv) { int n, i; double x[100], y[100], max = 0, result_p1 = 0, result_p2 = 0, result_p3 = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf", &x[i]); } for (i = 0; i < n; i++) { scanf("%lf", &y[i]); } for (i = 0; i < n;...
[["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
0
231
#include <math.h> #include <stdio.h> int main(void) { int n, i, j; scanf("%d", &n); double x[n], y[n], z[3], b = 0, c = 0; for (i = 0; i < n; i++) { scanf("%lf", &x[i]); } for (i = 0; i < n; i++) { scanf("%lf", &y[i]); } for (i = 0; i < 3; i++) { for (j = 0; j < n; j++) { z[i] += fa...
#include <math.h> #include <stdio.h> int main(void) { int n, i, j; scanf("%d", &n); double x[n], y[n], z[3], b = 0, c = 0; for (i = 0; i < n; i++) { scanf("%lf", &x[i]); } for (i = 0; i < n; i++) { scanf("%lf", &y[i]); } for (i = 0; i < 3; i++) { for (j = 0; j < n; j++) { z[i] += fa...
[["-", 3, 4, 0, 2, 3, 4, 0, 69, 71, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 69, 71, 13], ["-", 3, 4, 0, 2, 3, 4, 0, 69, 71, 13]]
0
267
#include <math.h> #include <stdio.h> int abs(int a); int main(void) { int n, i; int x[100], y[100]; double Man, Euc, p3; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &x[i]); for (i = 0; i < n; i++) scanf("%d", &y[i]); // p=1 for (i = 0; i < n; i++) Man += abs(x[i] - y[i]); print...
#include <math.h> #include <stdio.h> int abs(int a); int main(void) { int n, i; int x[100], y[100]; double Man, Euc, p3; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &x[i]); for (i = 0; i < n; i++) scanf("%d", &y[i]); // p=1 for (i = 0; i < n; i++) Man += abs(x[i] - y[i]); print...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
0
335
#include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; int i; int x[1000]; int y[1000]; int z[1000]; double dist1 = 1.0 * 0; double dist2 = 1.0 * 0; double dist2r = 1.0 * 0; double dist3 = 1.0 * 0; double dist3r = 1.0 * 0; double distma...
#include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; int i; int x[1000]; int y[1000]; int z[1000]; double dist1 = 1.0 * 0; double dist2 = 1.0 * 0; double dist2r = 1.0 * 0; double dist3 = 1.0 * 0; double dist3r = 1.0 * 0; double distma...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
0
429
/* * a.c * * Created on: 2017/06/13 * Author: AWV060608 */ #include <math.h> #include <stdio.h> #define MXNMB 1000 + 5 int main(void) { int n; int i; int xi[MXNMB], yi[MXNMB]; double dst, tmp; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &xi[i]); } for (i = 0; i < n; i++) { ...
/* * a.c * * Created on: 2017/06/13 * Author: AWV060608 */ #include <math.h> #include <stdio.h> #define MXNMB 1000 + 5 int main(void) { int n; int i; int xi[MXNMB], yi[MXNMB]; double dst, tmp; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &xi[i]); } for (i = 0; i < n; i++) { ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
0
331
#include <math.h> #include <stdio.h> int main(void) { int i, n; double x[100], y[100], max = 0, d1 = 0, d2 = 0, d3 = 0; scanf("%d", n); for (i = 0; i < n; i++) scanf("%lf", &x[i]); for (i = 0; i < n; i++) scanf("%lf", &y[i]); for (i = 0; i < n; i++) { d1 += fabs(x[i] - y[i]); d2 += pow(fab...
#include <math.h> #include <stdio.h> int main(void) { int i, n; double x[100], y[100], max = 0, d1 = 0, d2 = 0, d3 = 0; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%lf", &x[i]); for (i = 0; i < n; i++) scanf("%lf", &y[i]); for (i = 0; i < n; i++) { d1 += fabs(x[i] - y[i]); d2 += pow(fa...
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
237
#include <math.h> #include <stdio.h> double manhattan(int x[], int y[], int n) { int i, z; double D = 0; for (i = 0; i < n; i++) { z = x[i] - y[i]; if (z < 0) z *= -1; D += z; } return D; } double euclid(int x[], int y[], int n) { int i, z; double D = 0; for (i = 0; i < n; i++) { ...
#include <math.h> #include <stdio.h> double manhattan(int x[], int y[], int n) { int i, z; double D = 0; for (i = 0; i < n; i++) { z = x[i] - y[i]; if (z < 0) z *= -1; D += z; } return D; } double euclid(int x[], int y[], int n) { int i, z; double D = 0; for (i = 0; i < n; i++) { ...
[["-", 8, 9, 0, 37, 0, 2, 3, 4, 0, 13], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 17, 85], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 12, 13]]
0
477
#include <math.h> #include <stdio.h> #include <stdlib.h> int main(void) { int n, i, x[1000], y[1000]; double sum = 0, max = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &x[i]); } for (i = 0; i < n; i++) { scanf("%d", &y[i]); } for (i = 0; i < n; i++) { sum += abs(x[i] - y[i]);...
#include <math.h> #include <stdio.h> #include <stdlib.h> int main(void) { int n, i, x[1000], y[1000]; double sum = 0, max = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &x[i]); } for (i = 0; i < n; i++) { scanf("%d", &y[i]); } for (i = 0; i < n; i++) { sum += abs(x[i] - y[i]);...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 13], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]]
0
340
// // main.c // ITP1_10_D // // Created by k16031kk on 2018/05/29. // Copyright © 2018年 AIT. All rights reserved. // #include <math.h> #include <stdio.h> #include <stdlib.h> int main(int argc, const char *argv[]) { // insert code here... int n; scanf("%d", &n); double x[n], y[n]; for (int i = 0; i < n; ...
// // main.c // ITP1_10_D // // Created by k16031kk on 2018/05/29. // Copyright © 2018年 AIT. All rights reserved. // #include <math.h> #include <stdio.h> #include <stdlib.h> int main(int argc, const char *argv[]) { // insert code here... int n; scanf("%d", &n); double x[n], y[n]; for (int i = 0; i < n; ...
[["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22]]
0
288
import math n = int(input()) x = list(map(float, input().split())) y = list(map(float, input().split())) for p in [1.0, 2.0, 3.0]: a = 0 for i in range(n): a += abs(x[i] - y[i]) ** p D = a ** (1/p) print(D) inf_D = float("inf") for i in range(n): if abs(x[i] - y[i]) < inf_D: inf_D = ...
import math n = int(input()) x = list(map(float, input().split())) y = list(map(float, input().split())) for p in [1.0, 2.0, 3.0]: a = 0 for i in range(n): a += abs(x[i] - y[i]) ** p D = a ** (1/p) print(D) inf_D = float("-inf") for i in range(n): if abs(x[i] - y[i]) > inf_D: inf_D =...
[["-", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 662, 12, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
145
from math import fabs, sqrt n = int(input()) x = list(map(float, input().strip().split())) y = list(map(float, input().strip().split())) sum1 = 0 sum2 = 0 sum3 = 0 pil = [] for i in range(n): sum1 += fabs(x[i] - y[i]) sum2 += fabs(x[i] - y[i]) ** 2 sum3 += fabs(x[i] - y[i]) ** 3 pil.append(fabs(x[i] ...
from math import fabs, sqrt n = int(input()) x = list(map(float, input().strip().split())) y = list(map(float, input().strip().split())) sum1 = 0 sum2 = 0 sum3 = 0 pil = [] for i in range(n): sum1 += fabs(x[i] - y[i]) sum2 += fabs(x[i] - y[i]) ** 2 sum3 += fabs(x[i] - y[i]) ** 3 pil.append(fabs(x[i] ...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
212
#include <bits/stdc++.h> using namespace std; int main() { long x[1000], y[1000]; int n; cin >> n; cout << fixed << setprecision(10); for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } double maxn = 0; for (int p = 1; p < 4; p++) { double sum = 0...
#include <bits/stdc++.h> using namespace std; int main() { long x[1000], y[1000]; int n; cin >> n; cout << fixed << setprecision(10); for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } double maxn = 0; for (int p = 1; p < 4; p++) { double sum = 0...
[["+", 12, 2, 3, 4, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 16, 31, 74, 39, 77, 39, 40], ["+", 12, 2, 3, 4, 0, 16, 31, 74, 0, 25]]
1
189
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { int n; double x[99], y[99], p1 = 0, p1check = 0, p2 = 0, p3 = 0, pinfty = 0; for (int i = 0; n > i; i++) cin >> x[i]; for (int i = 0; n > i; i++) cin >> y[i]; for (int i = 0; n > i; i++) { p1 += abs(x[i] - y...
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { int n; double x[99], y[99], p1 = 0, p1check = 0, p2 = 0, p3 = 0, pinfty = 0; cin >> n; for (int i = 0; n > i; i++) cin >> x[i]; for (int i = 0; n > i; i++) cin >> y[i]; for (int i = 0; n > i; i++) { p1 += ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
268
#include <cmath> #include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { int n; float x[100] = {}, y[100] = {}; float q; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } float tmp = 0; for (int i = 0; i ...
#include <cmath> #include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { int n; double x[100] = {}, y[100] = {}; double q; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } double tmp = 0; for (int i = 0;...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
302
#include <bits/stdc++.h> using namespace std; double dist_Minkowski(const vector<double> &x, const vector<double> &y, int p) { if (p == 0) { double temp = 1e5; for (int i = 0; i < (int)x.size(); i++) { if (abs(x[i] - y[i]) > temp) temp = abs(x[i] - y[i]); } return temp; } double tem...
#include <bits/stdc++.h> using namespace std; double dist_Minkowski(const vector<double> &x, const vector<double> &y, int p) { if (p == 0) { double temp = 0; for (int i = 0; i < (int)x.size(); i++) { if (abs(x[i] - y[i]) > temp) temp = abs(x[i] - y[i]); } return temp; } double temp ...
[["-", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13]]
1
302
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { int n; double a = 0, b = 0, d = 0, e = 0; cin >> n; double x[n] = {}; double y[n] = {}; double c[n] = {}; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } for ...
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { int n; double a = 0, b = 0, d = 0, e = 0; cin >> n; double x[n] = {}; double y[n] = {}; double c[n] = {}; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } for ...
[["-", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70], ["-", 51, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["-", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 73], ["+", 75, 76, 0, 57, 15, 339, ...
1
340
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define vvi vector<vector<int>> #define All(X) X.begin(), X.end() int aabs(double x) { if (x < 0) return x *= -1; else ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define vvi vector<vector<int>> #define All(X) X.begin(), X.end() int aabs(double x) { if (x < 0) return x *= -1; else ...
[["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151]]
1
361
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { double r1, r2, r3, rinf; int a[1000], b[1000], c[1000]; int n; r1 = 0; r2 = 0; r3 = 0; rinf = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } ...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { double r1, r2, r3, rinf; int a[1000], b[1000], c[1000]; int n; r1 = 0; r2 = 0; r3 = 0; rinf = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } ...
[["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
253
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <tuple> #include <typeinfo> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) typedef long long i...
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <tuple> #include <typeinfo> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) typedef long long i...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
301
#include <cmath> #include <iomanip> #include <iostream> using namespace std; int main() { int n, x[100], y[100]; double d1 = 0, d2 = 0, d3 = 0, d8 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } for (int i = 0; i < n; i++) { doub...
#include <cmath> #include <iomanip> #include <iostream> using namespace std; int main() { int n, x[100], y[100]; double d1 = 0, d2 = 0, d3 = 0, d8 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } for (int i = 0; i < n; i++) { doub...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 85], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
226
#include <cmath> #include <cstring> #include <iomanip> #include <iostream> using namespace std; double minkowsky1(int n, int *x, int *y); double minkowsky2(int n, int *x, int *y); double minkowsky3(int n, int *x, int *y); double chebyshev(int n, int *x, int *y); int main() { cout << fixed; cout << setprecision(1...
#include <cmath> #include <cstring> #include <iomanip> #include <iostream> using namespace std; double minkowsky1(int n, int *x, int *y); double minkowsky2(int n, int *x, int *y); double minkowsky3(int n, int *x, int *y); double chebyshev(int n, int *x, int *y); int main() { cout << fixed; cout << setprecision(1...
[["+", 0, 11, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
478
#include <cmath> #include <iostream> using namespace std; int main(void) { u_int n; cin >> n; int x[n], y[n]; for (u_int i = 0; i < n; i++) cin >> x[i]; for (u_int i = 0; i < n; i++) cin >> y[i]; double manh[4] = {0, 0, 0, 0}; for (u_int i = 0; i < n; i++) { double d = abs(x[i] - y[i]); ...
#include <cmath> #include <iostream> using namespace std; int main(void) { u_int n; cin >> n; int x[n], y[n]; for (u_int i = 0; i < n; i++) cin >> x[i]; for (u_int i = 0; i < n; i++) cin >> y[i]; double manh[4] = {0, 0, 0, 0}; for (u_int i = 0; i < n; i++) { double d = abs(x[i] - y[i]); ...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13]]
1
231
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_D #include <cmath> #include <cstdio> #include <iostream> const double inf = 1000; using namespace std; int main() { int n; cin >> n; double x[n], y[n]; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin...
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_D #include <cmath> #include <cstdio> #include <iostream> const double inf = 100; using namespace std; int main() { int n; cin >> n; double x[n], y[n]; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
275
#include <iostream> using namespace std; #include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define SQR(X) ((X) * (X)) long double minkosu(long sa[], long n, long double p) { long i, j; long double tmp = 0; if (p == 100) { for (i = 1; i < n; i++) { if (tmp <...
#include <iostream> using namespace std; #include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define SQR(X) ((X) * (X)) long double minkosu(long sa[], long n, long double p) { long i, j; long double tmp = 0; if (p == 100) { for (i = 0; i < n; i++) { if (tmp <...
[["-", 0, 57, 64, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
305
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int n; double x[1001], y[1001], sum[1001], d = 0.0; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; for (int i = 0; i < n; i++) { sum[i] = fabs(x[i] - y[i]); ...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int n; double x[1001], y[1001], sum[1001], d = 0.0; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; for (int i = 0; i < n; i++) { sum[i] = fabs(x[i] - y[i]); ...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 13]]
1
299
#define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <iostream> #include <list> #include <math.h> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; double *x = ...
#define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <iostream> #include <list> #include <math.h> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; double *x = ...
[["-", 0, 14, 8, 9, 0, 338, 39, 361, 0, 190], ["+", 0, 30, 0, 14, 8, 9, 0, 338, 39, 40], ["-", 0, 14, 8, 9, 0, 338, 12, 83, 0, 13], ["+", 0, 14, 8, 9, 0, 338, 12, 83, 0, 13]]
1
258
#define _USE_MATH_DEFINES // M_PI #include <algorithm> //std::sort #include <cmath> //abs, pow, sqrt, sin, cos, #include <cstdlib> //abs #include <fstream> //std::ifstream #include <iomanip> //std::setprecision #include <iostream> //std::cout, std::cin #include <string> ...
#define _USE_MATH_DEFINES // M_PI #include <algorithm> //std::sort #include <cmath> //abs, pow, sqrt, sin, cos, #include <cstdlib> //abs #include <fstream> //std::ifstream #include <iomanip> //std::setprecision #include <iostream> //std::cout, std::cin #include <string> ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 108]]
1
290
#include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { int n; double D1 = 0, D2 = 0, D3 = 0, Di = 0; cin >> n; int x[n], y[n]; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; for (int i = 0;...
#include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { int n; double D1 = 0, D2 = 0, D3 = 0, Di = 0; cin >> n; int x[n], y[n]; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; for (int i = 0;...
[["-", 75, 76, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 76, 0, 1, 0, 11, 12, 16, 17, 33]]
1
393
#include <iomanip> #include <iostream> #include <math.h> #include <string> #include <vector> int main(int argc, char **argv) { int n = 0; std::vector<int> x; std::vector<int> y; double d = 0; std::cin >> n; x.resize(n, 0); y.resize(n, 0); for (int i = 0; i < n; i++) { std::cin >> x[i]; } for...
#include <iomanip> #include <iostream> #include <math.h> #include <string> #include <vector> int main(int argc, char **argv) { int n = 0; std::vector<int> x; std::vector<int> y; double d = 0; std::cin >> n; x.resize(n, 0); y.resize(n, 0); for (int i = 0; i < n; i++) { std::cin >> x[i]; } for...
[["+", 0, 11, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
374
#include <cmath> #include <cstdlib> #include <iomanip> //setprecision #include <iostream> #include <vector> const int MAX = 100000000; double ans(double x, double y) { double dis; dis = x - y; if (dis < 0) { dis = dis * (-1.0); } return dis; } double calc(std::vector<double> x, std::vector<double> y, in...
#include <cmath> #include <cstdlib> #include <iomanip> //setprecision #include <iostream> #include <vector> const int MAX = 100000000; double ans(double x, double y) { double dis; dis = x - y; if (dis < 0) { dis = dis * (-1.0); } return dis; } double calc(std::vector<double> x, std::vector<double> y, in...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
387
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int n, x[101], y[101]; double d1 = 0, d2 = 0, d3 = 0, dm = 0; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) { cin >> y[i]; d1 += abs(x[i] - y[i]); d2 += pow(x[i] - y[i], 2); ...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int n, x[101], y[101]; double d1 = 0, d2 = 0, d3 = 0, dm = 0; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) { cin >> y[i]; d1 += abs(x[i] - y[i]); d2 += pow(x[i] - y[i], 2); ...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 13]]
1
210
#include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; int manhattan(vector<int> &x, vector<int> &y) { assert(x.size() == y.size()); int sum = 0; for (int i = 0; i < x.size(); i++) { sum += abs(x[i] - y[i]); } return sum; } double euclidean(vect...
#include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; int manhattan(vector<int> &x, vector<int> &y) { assert(x.size() == y.size()); int sum = 0; for (int i = 0; i < x.size(); i++) { sum += abs(x[i] - y[i]); } return sum; } double euclidean(vect...
[["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["-", 0, 14, 8, 9, 0, 37, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 2, 63, 22], ["-", 0, 37, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96]]
1
531
#include <cmath> #include <iomanip> #include <iostream> using namespace std; int main() { int n; double d1, d2, d3, dinf; cin >> n; int x[n] = {}; int y[n] = {}; for (int i = 0; i < n; ++i) { cin >> x[i]; } for (int i = 0; i < n; ++i) { cin >> y[i]; } dinf = 0.0; for (int i = 0; i < n; ...
#include <cmath> #include <iomanip> #include <iostream> using namespace std; int main() { int n; double d1, d2, d3, dinf; cin >> n; int x[n] = {}; int y[n] = {}; for (int i = 0; i < n; ++i) { cin >> x[i]; } for (int i = 0; i < n; ++i) { cin >> y[i]; } dinf = 0.0; for (int i = 0; i < n; ...
[["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
245
#include <cmath> #include <cstdio> #include <iostream> using namespace std; void Minkowski_distance(int n, int p, int X[100], int Y[100]) { double md; if (p == 0) { int max = 0; for (int i = 0; i < n; i++) { max = (max < fabs(X[i] - Y[i]) ? (X[i] - Y[i]) : max); } md = max; } else { do...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; void Minkowski_distance(int n, int p, int X[100], int Y[100]) { double md; if (p == 0) { int max = 0; for (int i = 0; i < n; i++) { max = (max < fabs(X[i] - Y[i]) ? (fabs(X[i] - Y[i])) : max); } md = max; } else { ...
[["+", 12, 23, 0, 41, 64, 23, 0, 2, 63, 22], ["+", 0, 41, 64, 23, 0, 2, 3, 4, 0, 24], ["+", 0, 41, 64, 23, 0, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
285
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> int main() { int n; double pone = 0; double ptwo = 0; double pthree = 0; double pfour = 0; std::cin >> n; int lista[n] = {0}; int listb[n] = {0}; for (int i = 0; i < n; i++) { std::cin >> lista[i]; } for (int j = 0; j <...
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> int main() { int n; double pone = 0; double ptwo = 0; double pthree = 0; double pfour = 0; std::cin >> n; int lista[n] = {0}; int listb[n] = {0}; for (int i = 0; i < n; i++) { std::cin >> lista[i]; } for (int j = 0; j <...
[["+", 0, 57, 64, 1, 0, 11, 12, 2, 63, 22], ["+", 64, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 64, 1, 0, 11, 12, 2, 3, 4, 0, 25], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
301
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int n; int x[1000] = {}, y[1000] = {}; double d1 = 0, d2 = 0, d3 = 0, dinf = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } for (int i = 0; i < n;...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int n; int x[1000] = {}, y[1000] = {}; double d1 = 0, d2 = 0, d3 = 0, dinf = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } for (int i = 0; i < n;...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 85], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
251
#include <bits/stdc++.h> using namespace std; int main() { int n, x[100], y[100]; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; double d[4]; for (int i = 0; i < 4; i++) d[i] = 0.0; for (int p = 1; p <= 3; p++) { for (int i = 0; i < n; i++) {...
#include <bits/stdc++.h> using namespace std; int main() { int n, x[100], y[100]; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; double d[4]; for (int i = 0; i < 4; i++) d[i] = 0.0; for (int p = 1; p <= 3; p++) { for (int i = 0; i < n; i++) {...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32]]
1
284
#include <cstdio> #include <iostream> #include <math.h> using namespace std; int main() { double d1 = 0, d2 = 0, d3 = 0, di = 0; int n, m, i, j; cin >> n; int x[n] = {}, y[n] = {}; for (i = 0; i < n; i++) { cin >> x[i]; } for (i = 0; i < n; i++) { cin >> y[i]; } for (i = 0; i < n; i++) { ...
#include <cstdio> #include <iostream> #include <math.h> using namespace std; int main() { double d1 = 0, d2 = 0, d3 = 0, di = 0; int n, m, i, j; cin >> n; int x[n] = {}, y[n] = {}; for (i = 0; i < n; i++) { cin >> x[i]; } for (i = 0; i < n; i++) { cin >> y[i]; } for (i = 0; i < n; i++) { ...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 13]]
1
231
#include <algorithm> #include <cmath> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <string> #include <time.h> #include <vector> using namespace std; int main() { int n, t; cin >> n; int x[n]; int y[n]; double total = 0, root, max = 0; for (int i = 0; i < n; i++) { ...
#include <algorithm> #include <cmath> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <string> #include <time.h> #include <vector> using namespace std; int main() { int n, t; cin >> n; int x[n]; int y[n]; double total = 0, root, max = 0; for (int i = 0; i < n; i++) { ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
226
#include <iostream> #include <math.h> using namespace std; int main() { double n; cin >> n; double x[100] = {0}; double y[100] = {0}; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } int p1 = 0; for (int i = 0; i < n; i++) { p1 += fabs(x[i] - ...
#include <iostream> #include <math.h> using namespace std; int main() { double n; cin >> n; double x[100] = {0}; double y[100] = {0}; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> y[i]; } double p1 = 0; for (int i = 0; i < n; i++) { p1 += fabs(x[i]...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 13], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 13]]
1
324
#include <iomanip> #include <iostream> #include <math.h> double absolute(double x) { return (x < 0) ? (x * -1) : x; } double chebyshev_distance(double *x, double *y, int size) { double dis = -1, temp; for (int i = 0; i < size; i++) { temp = absolute(x[i] - y[i]); if (temp > dis) dis = temp; } re...
#include <iomanip> #include <iostream> #include <math.h> double absolute(double x) { return (x < 0) ? (x * -1) : x; } double chebyshev_distance(double *x, double *y, int size) { double dis = -1, temp; for (int i = 0; i < size; i++) { temp = absolute(x[i] - y[i]); if (temp > dis) dis = temp; } re...
[["-", 3, 4, 0, 16, 12, 74, 39, 77, 39, 40], ["+", 3, 4, 0, 16, 12, 74, 39, 77, 39, 40]]
1
312
#include <bits/stdc++.h> using namespace std; int n; double x[100], y[100]; double distance(double p) { double sum = 0; for (int i = 0; i < n; i++) { double w = abs(x[i] - y[i]); sum += pow(w, p); } return pow(sum, 1.0 / p); } int main() { cout << fixed << setprecision(12); cin >> n; for (int i...
#include <bits/stdc++.h> using namespace std; int n; double x[100], y[100]; double distance(double p) { double sum = 0; for (int i = 0; i < n; i++) { double w = abs(x[i] - y[i]); sum += pow(w, p); } return pow(sum, 1.0 / p); } int main() { cout << fixed << setprecision(12); cin >> n; for (int i...
[["-", 0, 14, 8, 9, 0, 7, 15, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
226
r=0...gets.to_i x,y=$<.map{|l|l.split.map &:to_i} p c=r.map{|i|(x[i]-y[i]).abs} (1..3).map{|p|puts"%f"%c.map{|v|v**p}.reduce(:+)**(1.0/p)} p "%f"%c.max
r=0...gets.to_i x,y=$<.map{|l|l.split.map &:to_i} c=r.map{|i|(x[i]-y[i]).abs} (1..3).map{|p|puts"%f"%c.map{|v|v**p}.reduce(:+)**(1.0/p)} p c.max
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 0, 652, 3, 4, 0, 738, 31, 557, 0, 62], ["-", 0, 652, 3, 4, 0, 738, 31, 557, 0, 6], ["-", 0, 493, 0, 652, 3, 4, 0, 738, 17, 109]]
4
97
n = gets.to_i x = gets.split.map(&:to_f) y = gets.split.map(&:to_f) p1, p2, p3 = 0, 0, 0; max_array = [] n.times do |i| q = x[i] - y[i] q = q * -1 if q < 0 max_array << q p1 += q p2 += q ** 2 p3 += q ** 3 end puts p1 puts Math.sqrt(p2) puts p3 ** (1 / 3) puts max(max_array)
n = gets.to_i x = gets.split.map(&:to_f) y = gets.split.map(&:to_f) p1, p2, p3 = 0, 0, 0; max_array = [] n.times do |i| q = x[i] - y[i] q = q * -1 if q < 0 max_array << q p1 += q p2 += q ** 2 p3 += q ** 3 end puts p1 puts Math.sqrt(p2) puts p3 ** Rational(1, 3) puts max_array.max
[["+", 0, 652, 3, 4, 0, 738, 12, 652, 735, 743], ["-", 3, 4, 0, 738, 12, 739, 0, 738, 17, 85], ["+", 3, 4, 0, 738, 12, 652, 3, 4, 0, 21], ["-", 0, 493, 0, 652, 3, 4, 0, 652, 735, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 493, 0, 652, 3, 4, 0, 652, 17, 131], ["+", ...
4
110
#!/usr/bin/env ruby def manhattan(n, x_v, y_v) d = 0.0 for i in 0..n.to_i-1 do d += (x_v[i].to_f - y_v[i].to_f).abs end d end def euc_i(n, x_v, y_v, p) d = 0.0 for i in 0..n.to_i-1 do d += (x_v[i].to_f - y_v[i].to_f).abs ** p end d = d ** (1/p.to_f) end def chebshef(n, x_v, y_v) d = 0.0 f...
def manhattan(n, x_v, y_v) d = 0.0 for i in 0..n.to_i-1 do d += (x_v[i].to_f - y_v[i].to_f).abs end d end def euc_i(n, x_v, y_v, p) d = 0.0 for i in 0..n.to_i-1 do d += (x_v[i].to_f - y_v[i].to_f).abs ** p end d = d ** (1/p.to_f) end def chebshef(n, x_v, y_v) d = 0.0 for i in 0..n.to_i-1 d...
[["+", 0, 88, 8, 170, 0, 754, 64, 662, 0, 32], ["+", 0, 88, 8, 170, 0, 754, 64, 662, 12, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
4
266
n = gets.to_i x = gets.split.map(&:to_f) y = gets.split.map(&:to_f) d = [] d1, d2, d3 = 0, 0, 0 n.times{ |i| d[i] - (x[i] - y[i]).abs d1 += d[i] d2 += d[i]**2 d3 += d[i]**3 } puts d1 puts d2**(1/2.0) puts d3**(1/3.0) puts d.max
n = gets.to_i x = gets.split.map(&:to_f) y = gets.split.map(&:to_f) d = [] d1, d2, d3 = 0, 0, 0 n.times{ |i| d[i] = (x[i] - y[i]).abs d1 += d[i] d2 += d[i]**2 d3 += d[i]**3 } puts d1 puts d2**(1/2.0) puts d3**(1/3.0) puts d.max
[["-", 0, 652, 196, 196, 8, 734, 0, 738, 17, 33], ["+", 0, 652, 196, 196, 8, 734, 0, 662, 0, 32]]
4
112
def calc_d1(n, x, y) d1 = 0 n.times{ |i| d1 += (x[i] - y[i]).abs } return d1 end def calc_d2(n, x, y) d2 = 0 n.times{ |j| d2 += ((x[j] - y[j]).abs)**2 } d2 = d2**(1/2.0) return d2 end def calc_d3(n, x, y) d3 = 0 n.times{ |k| d3 += ((x[k] - y[k]).abs)**3 } d3 = d3**(1/3.0) retur...
def calc_d1(n, x, y) d1 = 0 n.times{ |i| d1 += (x[i] - y[i]).abs } return d1 end def calc_d2(n, x, y) d2 = 0 n.times{ |j| d2 += ((x[j] - y[j]).abs)**2 } d2 = d2**(1/2.0) return d2 end def calc_d3(n, x, y) d3 = 0 n.times{ |k| d3 += ((x[k] - y[k]).abs)**3 } d3 = d3**(1/3.0) retur...
[["-", 0, 652, 196, 196, 8, 734, 0, 755, 17, 107], ["+", 0, 652, 196, 196, 8, 734, 0, 662, 0, 32]]
4
247
include Math n = gets.to_i x = gets.split.map(&:to_i) y = gets.split.map(&:to_i) d1 = 0 d2 = 0 d3 = 0 dc = 0 for i in 0..n-1 d = (x[i] - y[i]).abs d1 += d d2 += d ** 2 d3 += d ** 3 dc = d if dc < d end d2 = sqrt(d2) d3 = d3 ** 1.0 / 3.0 printf "%f\n", d1 printf "%f\n", d2 printf "%f\n", d3 printf "%f\n", d4
include Math n = gets.to_i x = gets.split.map(&:to_i) y = gets.split.map(&:to_i) d1 = 0 d2 = 0 d3 = 0 dc = 0 for i in 0..(n-1) d = (x[i] - y[i]).abs d1 += d d2 += d ** 2 d3 += d ** 3 dc = d if dc < d end d2 = sqrt(d2) d3 = d3 ** (1.0/3.0) printf "%f\n", d1 printf "%f\n", d2 printf "%f\n", d3 printf "%f\n", d...
[["+", 0, 88, 51, 267, 0, 475, 444, 739, 0, 24], ["+", 0, 88, 51, 267, 0, 475, 444, 739, 0, 25], ["+", 0, 493, 0, 662, 12, 738, 12, 739, 0, 24], ["+", 0, 493, 0, 662, 12, 738, 12, 739, 0, 25], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22], ["+", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]]
4
126
import decimal d = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) D_1 = 0 for i in range(d): L_i = abs(x[i] - y[i]) D_1 += L_i D_2 = 0 for i in range(d): L_i = (x[i]-y[i])**2 D_2 += L_i D_2 = (D_2) **(1/2) D_3 = 0 for i in range(d): L_i = (x[i]-y[i])**3 ...
import decimal d = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) D_1 = 0 for i in range(d): L_i = abs(x[i] - y[i]) D_1 += L_i D_2 = 0 for i in range(d): L_i = abs(x[i]-y[i])**2 D_2 += L_i D_2 = (D_2) **(1/2) D_3 = 0 for i in range(d): L_i = abs(x[i]-y[i])**...
[["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22]]
5
231
n=int(input()) s_str=[] for i in range(2): s_str.append(input().split()) s_int=[] for i in s_str: s_int.append([int(s) for s in i]) manh=0 yu=0 p_3=0 che=[] for i in range(n): manh+=abs(s_int[0][i]-s_int[1][i]) yu+=(s_int[0][i]-s_int[1][i])**2 p_3+=(s_int[0][i]-s_int[1][i])**3 che.append(abs(s_i...
n=int(input()) s_str=[] for i in range(2): s_str.append(input().split()) s_int=[] for i in s_str: s_int.append([int(s) for s in i]) manh=0 yu=0 p_3=0 che=[] for i in range(n): manh+=abs(s_int[0][i]-s_int[1][i]) yu+=(s_int[0][i]-s_int[1][i])**2 p_3+=(abs(s_int[0][i]-s_int[1][i]))**3 che.append(ab...
[["+", 0, 677, 12, 657, 31, 23, 0, 652, 63, 22], ["+", 12, 657, 31, 23, 0, 652, 3, 4, 0, 24], ["+", 12, 657, 31, 23, 0, 652, 3, 4, 0, 25]]
5
193
import math input() vx = [int(i) for i in input().split()] vy = [int(i) for i in input().split()] Dxy = [] for p in range(1, 4): Dxy.append(sum([abs(xv[i] - vy[i]) ** p for i in range(len(vx))]) ** (1 / p)) Dxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))])) for res in Dxy: print('{0:5f}'.format(...
import math input() vx = [int(i) for i in input().split()] vy = [int(i) for i in input().split()] Dxy = [] for p in range(1, 4): Dxy.append(sum([abs(vx[i] - vy[i]) ** p for i in range(len(vx))]) ** (1 / p)) Dxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))])) for res in Dxy: print('{0:5f}'.format(...
[["-", 31, 652, 3, 4, 0, 657, 31, 206, 51, 22], ["+", 31, 652, 3, 4, 0, 657, 31, 206, 51, 22]]
5
143
def dist(X, Y, p): sum(abs(x - y) ** p for x, y in zip(X,Y)) ** (1.0 / p) n = eval(input()) X = list(map(int, input().split())) Y = list(map(int, input().split())) for i in [1, 2, 3]: print(dist(X, Y, i)) print(max([abs(xy[0] - xy[1]) for xy in zip(X, Y)]))
def dist(X, Y, p): return sum(abs(x - y) ** p for x, y in zip(X,Y)) ** (1.0 / p) n = eval(input()) X = list(map(int, input().split())) Y = list(map(int, input().split())) for i in [1, 2, 3]: print(dist(X, Y, i)) print(max([abs(xy[0] - xy[1]) for xy in zip(X, Y)]))
[["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 38]]
5
131
import math def manhattan(xs, ys): return sum([abs(x-y) for x, y in zip(xs, ys)]) def euclid(xs, ys): return math.sqrt(sum([(x-y)**2 for x, y in zip(xs, ys)])) def l3(xs, ys): return sum([(x-y)**3 for x, y in zip(xs, ys)])**(1/3) def chev(xs, ys): return max([abs(x-y) for x, y in zip(xs, ys)]) def ...
import math def manhattan(xs, ys): return sum([abs(x-y) for x, y in zip(xs, ys)]) def euclid(xs, ys): return math.sqrt(sum([(x-y)**2 for x, y in zip(xs, ys)])) def l3(xs, ys): return sum([abs(x-y)**3 for x, y in zip(xs, ys)])**(1/3) def chev(xs, ys): return max([abs(x-y) for x, y in zip(xs, ys)]) d...
[["+", 3, 4, 0, 658, 8, 657, 31, 652, 63, 22]]
5
225
n=int(input()) vector1=[int(x) for x in input().split()] vector2=[int(x) for x in input().split()] for i in range(1,4): print("{0:.8f}".format(sum([abs(a-b)**p for a,b in zip(vector1,vector2)])**(1/i))) print("{0:.8f}".format(max([abs(a-b) for a,b in zip(vector1,vector2)])))
n=int(input()) vector1=[int(x) for x in input().split()] vector2=[int(x) for x in input().split()] for i in range(1,4): print("{0:.8f}".format(sum([abs(a-b)**i for a,b in zip(vector1,vector2)])**(1/i))) print("{0:.8f}".format(max([abs(a-b) for a,b in zip(vector1,vector2)])))
[["-", 31, 652, 3, 4, 0, 658, 8, 657, 12, 22], ["+", 31, 652, 3, 4, 0, 658, 8, 657, 12, 22]]
5
126
import math n = int(input()) x = list(map(int, raw_input().split())) y = list(map(int, raw_input().split())) t1 = t2 = t3 = ti = 0.0 for a, b in zip(x, y): d1 = abs(a - b) ti = max(ti, d1) t1 += d1 t2 += d1**2 t3 += d1**3 print(t1) print(math.sqrt(t2)) print(t3 ** (1.0/3)) print(ti)
import math n = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) t1 = t2 = t3 = ti = 0.0 for a, b in zip(x, y): d1 = abs(a - b) ti = max(ti, d1) t1 += d1 t2 += d1**2 t3 += d1**3 print(t1) print(math.sqrt(t2)) print(t3 ** (1.0/3)) print(ti)
[["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22]]
5
121
n = eval(input()) x = list(map(int,input().split())) y = list(map(int,input().split())) gap = [] gap1 = 0.0 gap2 = 0.0 gap3 = 0.0 a = 0.0 for i in range(n): gap.append(abs(x[i]-y[i])) for i in range(n): gap1 += gap[i] print(gap1) for i in range(n): gap2 += gap[i] ** 2 print(pow(gap2,0.5)) for i in ra...
n = eval(input()) x = list(map(int,input().split())) y = list(map(int,input().split())) gap = [] gap1 = 0.0 gap2 = 0.0 gap3 = 0.0 a = 0.0 for i in range(n): gap.append(abs(x[i]-y[i])) for i in range(n): gap1 += gap[i] print(gap1) for i in range(n): gap2 += gap[i] ** 2 print(pow(gap2,0.5)) for i in ra...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 531], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 531]]
5
158
import math n = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) for p in range(1, 4): sum = 0 for i in range(n): sum += math.fabs(x[i]-y[i])**p print(sum**(1/p)) a = [] for i in range(n): a.append(math.fabs(x[i]-y[i])) a = a.sort() print(a[n-1])
import math n = int(input()) x = list(map(int, input().split())) y = list(map(int, input().split())) for p in range(1, 4): sum = 0 for i in range(n): sum += math.fabs(x[i]-y[i])**p print(sum**(1/p)) a = [] for i in range(n): a.append(math.fabs(x[i]-y[i])) a.sort() print(a[n-1])
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22]]
5
140
#ITP1_10-D Distance2 n = int(input()) x = [float(x) for x in input().split(" ")] y = [float(x) for x in input().split(" ")] d1=0.0 for i in range(n): d1 += abs(x[i]-y[i]) print(d1) d2=0.0 for i in range(n): d2 += (x[i]-y[i])**2 print(d2**(1/2)) d3=0.0 for i in range(n): d3 += (x[i]-y[i])**3 print(d3**(1/...
#ITP1_10-D Distance2 n = int(input()) x = [float(x) for x in input().split(" ")] y = [float(x) for x in input().split(" ")] d1=0.0 for i in range(n): d1 += abs(x[i]-y[i]) print(d1) d2=0.0 for i in range(n): d2 += (x[i]-y[i])**2 print(d2**(1/2)) d3=0.0 for i in range(n): d3 += abs((x[i]-y[i])**3) print(d3...
[["+", 8, 196, 0, 1, 0, 677, 12, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 0, 1, 0, 677, 12, 652, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
194
import math n=int(input()) xli=list(map(int,input().split())) yli=list(map(int,input().split())) a=0 b=0 c=0 d=0 for x,y in zip(xli,yli): base = math.fabs(x,y) a += base b += base**2 c += base**3 if d < base : d = base print(a) print(b**(1/2)) print(c**(1/3)) print(d)
import math n=int(input()) xli=list(map(float,input().split())) yli=list(map(float,input().split())) a=0 b=0 c=0 d=0 for x,y in zip(xli,yli): base = math.fabs(x-y) a += base b += base**2 c += base**3 if d < base : d = base print(a) print(b**(1/2)) print(c**(1/3)) print(d)
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 33]]
5
127
#include <stdio.h> int main() { int dice[6]; int swap; //????????¨ char c; int i; for (i = 0; i < 6; i++) { scanf(" %D", &dice[i]); } while (scanf("%c", &c) != EOF) { if (c == 'E') { swap = dice[0]; dice[0] = dice[3]; dice[3] = dice[5]; dice[5] = dice[2]; dice[2...
// ITP1_11_A #include <stdio.h> int main() { int dice[6]; int swap; //????????¨ char c; int i; for (i = 0; i < 6; i++) { scanf("%d", &dice[i]); } while (scanf("%c", &c) != EOF) { if (c == 'E') { swap = dice[0]; dice[0] = dice[3]; dice[3] = dice[5]; dice[5] = dice[2];...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
299
#include <stdio.h> #include <string.h> struct Dice { int dice_1; int dice_2; int dice_3; int dice_4; int dice_5; int dice_6; }; void direct(char c, struct Dice *d) { int tmp; switch (c) { case 'N': tmp = d->dice_1; d->dice_1 = d->dice_2; d->dice_2 = d->dice_6; d->dice_6 = d->dice_5;...
#include <stdio.h> #include <string.h> struct Dice { int dice_1; int dice_2; int dice_3; int dice_4; int dice_5; int dice_6; }; void direct(char c, struct Dice *d) { int tmp; switch (c) { case 'N': tmp = d->dice_1; d->dice_1 = d->dice_2; d->dice_2 = d->dice_6; d->dice_6 = d->dice_5;...
[["-", 0, 100, 0, 1, 0, 11, 31, 118, 119, 120], ["+", 0, 100, 0, 1, 0, 11, 31, 118, 119, 120]]
0
355
#include <stdio.h> #include <string.h> void North(int *a, int *b, int *e, int *f) { int x; x = *a; *a = *b; *b = *f; *f = *e; *e = x; } void East(int *a, int *c, int *d, int *f) { int x; x = *a; *a = *d; *d = *f; *f = *c; *c = x; } void West(int *a, int *c, int *d, int *f) { int x; x = *a;...
#include <stdio.h> #include <string.h> void North(int *a, int *b, int *e, int *f) { int x; x = *a; *a = *b; *b = *f; *f = *e; *e = x; } void East(int *a, int *c, int *d, int *f) { int x; x = *a; *a = *d; *d = *f; *f = *c; *c = x; } void West(int *a, int *c, int *d, int *f) { int x; x = *a;...
[["-", 0, 57, 15, 23, 0, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 23, 0, 16, 12, 103, 0, 125]]
0
463
#include <stdio.h> typedef struct { int iti; int suuti; } SAIKORO; int main(void) { int kaisuu1, kaisuu2, kaisuu3; char hougaku[64] = {0}; char kari1; SAIKORO date[6]; SAIKORO kari2; kaisuu2 = 0; for (kaisuu1 = 0; kaisuu1 < 6; kaisuu1++) { date[kaisuu1].iti = kaisuu1 + 1; // printf("%d ", ...
#include <stdio.h> typedef struct { int iti; int suuti; } SAIKORO; int main(void) { int kaisuu1, kaisuu2, kaisuu3; char hougaku[128] = {0}; char kari1; SAIKORO date[6]; SAIKORO kari2; kaisuu2 = 0; for (kaisuu1 = 0; kaisuu1 < 6; kaisuu1++) { date[kaisuu1].iti = kaisuu1 + 1; // printf("%d ",...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["-", 64, 9, 0, 1, 0, 11, 12, 69, 71, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 71, 13], ["-", 64, 9, 0, 1, 0, 11, 31, 69, 71, 13], ["+", 64, 9, 0, ...
0
438
#include <stdio.h> typedef struct { int iti; int suuti; } SAIKORO; int main(void) { int kaisuu1, kaisuu2, kaisuu3; char hougaku[64] = {0}; char kari1; SAIKORO date[6]; SAIKORO kari2; kaisuu2 = 0; for (kaisuu1 = 0; kaisuu1 < 6; kaisuu1++) { date[kaisuu1].iti = kaisuu1 + 1; // printf("%d ", ...
#include <stdio.h> //ヘッダファイルの宣言 typedef struct { int iti; //面の位置 int suuti; //サイコロに代入される数 } SAIKORO; //構造体の宣言 int main(void) { int kaisuu1, kaisuu2, kaisuu3; //処理に利用するローカル変数 char hougaku[128] = {0}; //方角の値を代入するローカル関数 char kari1; //仮で使うローカル関数 SAIKORO date[6]; //サイコロのデータを格納する構造体...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["-", 64, 9, 0, 1, 0, 11, 12, 69, 71, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 71, 13], ["-", 64, 9, 0, 1, 0, 11, 31, 69, 71, 13], ["+", 64, 9, 0, ...
0
438
#include <stdio.h> #include <string.h> int main(int argc, const char *argv[]) { int d[6], temp = 0; int i; char c[101]; for (i = 0; i < 6; i++) { scanf("%d", &d[i]); } scanf("%s", c); for (i = 0; i < strlen(c); i++) { if (c[i] == 'E') { temp = d[2]; d[2] = d[0]; d[0] = d[3]; ...
#include <stdio.h> #include <string.h> int main(int argc, const char *argv[]) { int d[6], temp = 0; int i; char c[101]; for (i = 0; i < 6; i++) { scanf("%d", &d[i]); } scanf("%s", c); for (i = 0; i < strlen(c); i++) { if (c[i] == 'E') { temp = d[2]; d[2] = d[0]; d[0] = d[3]; ...
[["-", 64, 9, 0, 1, 0, 11, 12, 69, 71, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 71, 13], ["-", 64, 9, 0, 1, 0, 11, 31, 69, 71, 13], ["+", 64, 9, 0, 1, 0, 11, 31, 69, 71, 13]]
0
337
#include <stdio.h> int rot[5][7] = {{0, 1, 2, 3, 4, 5, 6}, {0, 2, 6, 3, 4, 1, 5}, {0, 4, 2, 1, 6, 5, 3}, {0, 3, 2, 6, 1, 5, 4}, {0, 5, 1, 3, 4, 6, 2}}; int assign[7]; int tr['Z']; void dice_init(int *a) { int i; int t[5] = {0, 'N', 'E', 'W', 'S'}; ...
#include <stdio.h> int rot[5][7] = {{0, 1, 2, 3, 4, 5, 6}, {0, 2, 6, 3, 4, 1, 5}, {0, 4, 2, 1, 6, 5, 3}, {0, 3, 2, 6, 1, 5, 4}, {0, 5, 1, 3, 4, 6, 2}}; int assign[7]; int tr['Z']; void dice_init(int *a) { int i; int t[5] = {0, 'N', 'E', 'W', 'S'}; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
385
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a, b) for (int i = a; i < b; i++) //'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122 struct dice { int s[6]; void roll(char c) { int tmp; if (c == 'E') { tmp = s[0]; s[0] = s[3]; s[3] = s[5]; s[5] = s[2]; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a, b) for (int i = a; i < b; i++) //'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122 struct dice { int s[6]; void roll(char c) { int tmp; if (c == 'E') { tmp = s[0]; s[0] = s[3]; s[3] = s[5]; s[5] = s[2]; ...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
344
#include <cassert> #include <ccomplex> #include <cctype> #include <cerrno> #include <cfenv> #include <cfloat> #include <cinttypes> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstdbool> #include <cstddef> #include <cstdint>...
#include <cassert> #include <ccomplex> #include <cctype> #include <cerrno> #include <cfenv> #include <cfloat> #include <cinttypes> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstdbool> #include <cstddef> #include <cstdint>...
[["-", 49, 50, 51, 83, 0, 69, 341, 342, 0, 13], ["+", 49, 50, 51, 83, 0, 69, 341, 342, 0, 13]]
1
533
#include <iostream> #include <string> class Dice { public: int a[7]; // up,flont,right,left,back,down void roll(char d); }; void Dice::roll(char d) { int tmp; if (d == 'N') { tmp = a[1]; a[1] = a[2]; a[2] = a[6]; a[6] = a[5]; a[5] = tmp; } else if (d == 'S') { tmp = a[1]; a[1] = ...
#include <iostream> #include <string> class Dice { public: int a[7]; // up,flont,right,left,back,down void roll(char d); }; void Dice::roll(char d) { int tmp; if (d == 'N') { tmp = a[1]; a[1] = a[2]; a[2] = a[6]; a[6] = a[5]; a[5] = tmp; } else if (d == 'S') { tmp = a[1]; a[1] = ...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
356
#include <iostream> #include <string> using namespace std; class Cube { public: int f[6]; Cube() {} void roll_z() { roll(1, 2, 4, 3); } void roll_y() { roll(0, 2, 5, 3); } void roll_x() { roll(0, 1, 5, 4); } void roll(int i, int j, int k, int l) { int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k...
#include <iostream> #include <string> using namespace std; class Cube { public: int f[6]; Cube() {} void roll_z() { roll(1, 2, 4, 3); } void roll_y() { roll(0, 2, 5, 3); } void roll_x() { roll(0, 1, 5, 4); } void roll(int i, int j, int k, int l) { int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k...
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
308
#include <iostream> using namespace std; int main() { int dice[6]; for (int i = 0; i < 6; ++i) { cin >> dice[i]; } string s; cin >> s; int tmp; for (const auto &c : s) { switch (c) { case ('S'): tmp = dice[5]; dice[5] = dice[1]; dice[2] = dice[0]; dice[0] = dice[4]; ...
#include <iostream> using namespace std; int main() { int dice[6]; for (int i = 0; i < 6; ++i) { cin >> dice[i]; } string s; cin >> s; int tmp; for (const auto &c : s) { switch (c) { case ('S'): tmp = dice[5]; dice[5] = dice[1]; dice[1] = dice[0]; dice[0] = dice[4]; ...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13]]
1
292
#include <iostream> #include <string> using namespace std; class Dice { public: int top, face[6]; void East() { top = face[0]; face[0] = face[3]; face[3] = face[5]; face[5] = face[2]; face[2] = top; } void West() { top = face[0]; face[0] = face[2]; face[2] = face[5]; face[5...
#include <iostream> #include <string> using namespace std; class Dice { public: int top, face[6]; void East() { top = face[0]; face[0] = face[3]; face[3] = face[5]; face[5] = face[2]; face[2] = top; } void West() { top = face[0]; face[0] = face[2]; face[2] = face[5]; face[5...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13]]
1
355
#include <cmath> #include <cstring> #include <iomanip> #include <iostream> using namespace std; class dice { public: dice() {} int n[6]; void set(int n0, int n1, int n2, int n3, int n4, int n5) { n[0] = n0; n[1] = n1; n[2] = n2; n[3] = n3; n[4] = n4; n[5] = n5; } int get(int i) { retur...
#include <cmath> #include <cstring> #include <iomanip> #include <iostream> using namespace std; class dice { public: dice() {} int n[6]; void set(int n0, int n1, int n2, int n3, int n4, int n5) { n[0] = n0; n[1] = n1; n[2] = n2; n[3] = n3; n[4] = n4; n[5] = n5; } int get(int i) { retur...
[["-", 0, 99, 8, 9, 0, 100, 0, 93, 0, 94], ["-", 0, 99, 8, 9, 0, 100, 0, 93, 0, 35], ["+", 0, 99, 8, 9, 0, 100, 0, 1, 0, 35], ["+", 0, 99, 8, 9, 0, 100, 0, 93, 0, 94]]
1
476
#include <iostream> #include <string> using namespace std; class DICE { public: int top; int bottom; int right; int left; int front; int back; void South(); void North(); void East(); void West(); }; void DICE::South() { int kari = front; front = top; top = back; back = bottom; bottom =...
#include <iostream> #include <string> using namespace std; class DICE { public: int top; int bottom; int right; int left; int front; int back; void South(); void North(); void East(); void West(); }; void DICE::South() { int kari = front; front = top; top = back; back = bottom; bottom =...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]]
1
310
#include <iostream> #include <string> using namespace std; class Dice { public: int dice[6]; int buff1, buff2, buff3; void north() { buff1 = dice[0]; buff2 = dice[1]; buff3 = dice[5]; dice[0] = dice[4]; dice[4] = buff3; dice[5] = buff2; dice[1] = buff1; } void south() { buff1 ...
#include <iostream> #include <string> using namespace std; class Dice { public: int dice[6]; int buff1, buff2, buff3; void south() { buff1 = dice[0]; buff2 = dice[1]; buff3 = dice[5]; dice[0] = dice[4]; dice[4] = buff3; dice[5] = buff2; dice[1] = buff1; } void north() { buff1 ...
[["-", 0, 353, 8, 123, 0, 14, 49, 53, 49, 120], ["+", 0, 353, 8, 123, 0, 14, 49, 53, 49, 120]]
1
402
#include <iostream> #include <string> using namespace std; int D[6]; void spin(char c) { if (c == 'E') { swap(D[0], D[3]); swap(D[3], D[5]); swap(D[5], D[2]); } else if (c == 'W') { swap(D[0], D[2]); swap(D[2], D[5]); swap(D[5], D[3]); } else if (c == 'S') { swap(D[0], D[1]); swap...
#include <iostream> #include <string> using namespace std; int D[6]; void spin(char c) { if (c == 'E') { swap(D[0], D[3]); swap(D[3], D[5]); swap(D[5], D[2]); } else if (c == 'W') { swap(D[0], D[2]); swap(D[2], D[5]); swap(D[5], D[3]); } else if (c == 'S') { swap(D[0], D[1]); swap...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
278
#include <iostream> #include <string> #include <vector> class dice { private: std::vector<int> faces; public: dice(int *surface) { for (int i = 0; i < 6; i++) { faces.push_back(surface[i]); } }; int getSurface() { return faces[0]; }; dice roll(char d) { int *s = new int[6]; switch (d) {...
#include <iostream> #include <string> #include <vector> class dice { private: std::vector<int> faces; public: dice(int *surface) { for (int i = 0; i < 6; i++) { faces.push_back(surface[i]); } }; int getSurface() { return faces[0]; }; dice roll(char d) { int *s = new int[6]; switch (d) {...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13]]
1
485
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> #define PI 3.14159265359 using namespace std; int main() { int tmp; vector<int> d(6); for (int i = 0; i < 6; i++) cin >> d[i]; string s; cin >> s; for (int i = 0; i < s.size(); i++) { i...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> #define PI 3.14159265359 using namespace std; int main() { int tmp; vector<int> d(6); for (int i = 0; i < 6; i++) cin >> d[i]; string s; cin >> s; for (int i = 0; i < s.size(); i++) { i...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
314
#include <array> #include <iostream> #include <sstream> class Dice { private: std::array<int, 6> inner_; public: Dice(std::string str) { std::istringstream stream(str); for (int i = 0; i != 6; ++i) { stream >> inner_[i]; } } void roll(char dir) { std::array<int, 6> new_dice; switch ...
#include <array> #include <iostream> #include <sstream> class Dice { private: std::array<int, 6> inner_; public: Dice(std::string str) { std::istringstream stream(str); for (int i = 0; i != 6; ++i) { stream >> inner_[i]; } } void roll(char dir) { std::array<int, 6> new_dice; switch ...
[["+", 8, 123, 0, 14, 8, 9, 0, 37, 0, 38]]
1
522
#include <cmath> #include <iostream> using std::cin; using std::cout; using std::endl; using std::string; int Dice(int n[6], string str) { int east; int west; int sou; int nor; int g; g = 1; int t = 0; sou = 2; east = 3; west = 4; nor = 5; for (int i = 0; i < str.length(); i++) { if (str[i...
#include <cmath> #include <iostream> using std::cin; using std::cout; using std::endl; using std::string; int Dice(int n[6], string str) { int east; int west; int sou; int nor; int g; g = 1; int t = 0; sou = 2; east = 3; west = 4; nor = 5; for (int i = 0; i < str.length(); i++) { if (str[i...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]]
1
260
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <string> #include <vector> int main() { std::vector<int> v(6); for (int i = 0; i < 6; i++) { std::cin >> v[i]; } std::string s; std::cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] ==...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <string> #include <vector> int main() { std::vector<int> v(6); for (int i = 0; i < 6; i++) { std::cin >> v[i]; } std::string s; std::cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] ==...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13]]
1
327
#include <iomanip> #include <iostream> struct dice { int top, bottom, west, east, north, south; // no need naming these... just for clarity void roll_east() { int t = top; top = west; west = bottom; bottom = east; east = t; }; void roll_west() { int t = top; top = east; east ...
#include <iomanip> #include <iostream> struct dice { int top, bottom, west, east, north, south; // no need naming these... just for clarity void roll_east() { int t = top; top = west; west = bottom; bottom = east; east = t; }; void roll_west() { int t = top; top = east; east ...
[["-", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["+", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["-", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["+", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["-", 8, 9, 0, 1, 0, 16, 12, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 16, 12, 118, 119, 120]]
1
319
#include <bits/stdc++.h> using namespace std; int main() { int D[6], C; string S; for (int i = 0; i < 6; i++) { cin >> D[i]; } cin >> S; for (int i = 0; i < S.length(); i++) { if (S[i] == 'S') { C = D[1], D[1] = D[5], D[5] = D[6], D[6] = D[2], D[2] = C; } else if (S[i] == 'W') { C =...
#include <bits/stdc++.h> using namespace std; int main() { int D[7], C; string S; for (int i = 1; i <= 6; i++) { cin >> D[i]; } cin >> S; for (int i = 0; i < S.length(); i++) { if (S[i] == 'S') { C = D[1], D[1] = D[5], D[5] = D[6], D[6] = D[2], D[2] = C; } else if (S[i] == 'W') { C ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
310
#include <iostream> #include <string> using namespace std; class Dice { public: enum DICE_FACE { eTop, eFront, eRight, eLeft, eBack, eBottom }; Dice(int t, int f, int r, int l, int ba, int bo) { this->mTopValue = t; this->mFrontValue = f; this->mRightValue = r; this->mLeftValue = l; this->mBa...
#include <iostream> #include <string> using namespace std; class Dice { public: enum DICE_FACE { eTop, eFront, eRight, eLeft, eBack, eBottom }; Dice(int t, int f, int r, int l, int ba, int bo) { this->mTopValue = t; this->mFrontValue = f; this->mRightValue = r; this->mLeftValue = l; this->mBa...
[["-", 0, 353, 8, 123, 0, 14, 49, 53, 49, 120], ["+", 0, 353, 8, 123, 0, 14, 49, 53, 49, 120]]
1
1,333
#include <iostream> #include <math.h> #include <string> #define MEN 6 #include <iomanip> using namespace std; struct DICE { int num; }; int main() { DICE A[MEN]; string meirei; int i = 0; for (int i = 0; i < MEN; i++) { cin >> A[i].num; } cin >> meirei; while (1) { if (meirei[i] == '\0') { ...
#include <iostream> #include <math.h> #include <string> #define MEN 6 #include <iomanip> using namespace std; struct DICE { int num; }; int main() { DICE A[MEN]; string meirei; int i = 0; for (int i = 0; i < MEN; i++) { cin >> A[i].num; } cin >> meirei; while (1) { if (meirei[i] == '\0') { ...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
409
#include <stdio.h> enum ROTETYPE { W, E, S, N }; class cDICE { public: cDICE() { Init(); }; ~cDICE(){}; void Init() { int Me[6] = {1, 2, 4, 8, 16, 32}; int Dice[6] = {0, 1, 2, 3, 4, 5}; int Rote[2][4] = {{0, 1, 5, 4}, {2, 5, 3, 0}}; InputData(Dice, mDice); InputData(Me, mMe); for (int i = ...
#include <stdio.h> enum ROTETYPE { W, E, S, N }; class cDICE { public: cDICE() { Init(); }; ~cDICE(){}; void Init() { int Me[6] = {1, 2, 4, 8, 16, 32}; int Dice[6] = {0, 1, 2, 3, 4, 5}; int Rote[2][4] = {{0, 1, 5, 4}, {2, 5, 3, 0}}; InputData(Dice, mDice); InputData(Me, mMe); for (int i = ...
[["-", 0, 100, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 100, 0, 1, 0, 2, 3, 4, 0, 13]]
1
839
#include <iostream> #include <string> #include <vector> using namespace std; struct Dice { vector<int> faces; Dice(vector<int> &f) : faces(f) {} int top() { return faces.front(); } void roll(char direction) { int tmp; switch (direction) { case 'E': // 1,4,5,3 -> 4,5,3,1 tmp = faces[0]; ...
#include <iostream> #include <string> #include <vector> using namespace std; struct Dice { vector<int> faces; Dice(vector<int> &f) : faces(f) {} int top() { return faces.front(); } void roll(char direction) { int tmp; switch (direction) { case 'E': // 1,4,6,3 -> 4,6,3,1 tmp = faces[0]; ...
[["-", 0, 100, 0, 1, 0, 11, 12, 69, 28, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 100, 0, 1, 0, 11, 12, 22]]
1
382
#include <iostream> #include <string> using namespace std; int main() { int n = 6, d[n + 1]; for (int i = 1; i <= n; i++) { cin >> d[i]; } string cmd; cin >> cmd; for (int i = 0; i <= cmd.size(); i++) { if (true) { cout << " " << "," << d[1] << endl; cout << d[4] << "," << ...
#include <iostream> #include <string> using namespace std; int main() { int n = 6, d[n + 1]; for (int i = 1; i <= n; i++) { cin >> d[i]; } string cmd; cin >> cmd; for (int i = 0; i <= cmd.size(); i++) { if (false) { cout << " " << "," << d[1] << endl; cout << d[4] << "," <<...
[["-", 0, 7, 8, 9, 0, 57, 15, 339, 51, 146], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 51, 147], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 13], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 13]]
1
395
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <math.h> #include <unordered_map> #define min(a, b) (a) > (b) ? (b) : (a) #define max(a, b) (a) > (b) ? (a) : (b) using namespace st...
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <math.h> #include <unordered_map> #define min(a, b) (a) > (b) ? (b) : (a) #define max(a, b) (a) > (b) ? (a) : (b) using namespace st...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13]]
1
323
#include <cmath> #include <iomanip> #include <iostream> #include <string> using namespace std; int main() { int i, j, d[7], d_next[7]; string dire; cin >> d[1] >> d[2] >> d[3] >> d[4] >> d[5] >> d[6]; cin >> dire; for (i = 0; i < dire.size(); i++) { if (dire[i] == 'E') { d_next[1] = d[4]; d_...
#include <cmath> #include <iomanip> #include <iostream> #include <string> using namespace std; int main() { int i, j, d[7], d_next[7]; string dire; cin >> d[1] >> d[2] >> d[3] >> d[4] >> d[5] >> d[6]; cin >> dire; for (i = 0; i < dire.size(); i++) { if (dire[i] == 'E') { d_next[1] = d[4]; d_...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]]
1
412
#include <algorithm> #include <cmath> #include <complex> #include <iomanip> #include <iostream> using namespace std; int main(void) { int a[6]; string str; for (int i = 0; i < 6; ++i) cin >> a[i]; cin >> str; for (auto itr = str.begin(); itr != str.end(); ++itr) { int tmp; switch (*itr) { cas...
#include <algorithm> #include <cmath> #include <complex> #include <iomanip> #include <iostream> using namespace std; int main(void) { int a[6]; string str; for (int i = 0; i < 6; ++i) cin >> a[i]; cin >> str; for (auto itr = str.begin(); itr != str.end(); ++itr) { int tmp; switch (*itr) { cas...
[["-", 0, 99, 8, 9, 0, 100, 51, 103, 0, 125], ["+", 0, 99, 8, 9, 0, 100, 51, 103, 0, 125]]
1
305
#include <cstdio> #include <cstring> #include <iostream> using namespace std; class Dice { public: Dice() { num = new int[7]; } ~Dice() { delete[] num; } int setLabel(int i, int label) { num[i] = label; } int top() { return num[1]; } int roll(char dir) { int tmp[7]; memcpy(tmp, num, 7 * sizeof(...
#include <cstdio> #include <cstring> #include <iostream> using namespace std; class Dice { public: Dice() { num = new int[7]; } ~Dice() { delete[] num; } int setLabel(int i, int label) { num[i] = label; } int top() { return num[1]; } int roll(char dir) { int tmp[7]; memcpy(tmp, num, 7 * sizeof(...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
390
#include <iostream> void do_command(int *dice, char command) { int targets[4] = {0, -1, 5, -1}; int temp; switch (command) { case 'E': targets[1] = 3; targets[3] = 2; break; case 'W': targets[1] = 2; targets[3] = 3; break; case 'N': targets[1] = 4; targets[3] = 1; break...
#include <iostream> void do_command(int *dice, char command) { int targets[4] = {0, -1, 5, -1}; int temp; switch (command) { case 'E': targets[1] = 3; targets[3] = 2; break; case 'W': targets[1] = 2; targets[3] = 3; break; case 'S': targets[1] = 4; targets[3] = 1; break...
[["-", 0, 99, 8, 9, 0, 100, 51, 103, 0, 125], ["+", 0, 99, 8, 9, 0, 100, 51, 103, 0, 125]]
1
246
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { int a[6]; for (int i = 0; i < 6; i++) { cin >> a[i]; } string str; cin >> str; int b, c, d, e; b = c = d = e = 0; for (int i = 0; i < str.size(); i++) { if (str[i] ==...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { int a[6]; for (int i = 0; i < 6; i++) { cin >> a[i]; } string str; cin >> str; int b, c, d, e; b = c = d = e = 0; for (int i = 0; i < str.size(); i++) { if (str[i] ==...
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
380
#include <cstdio> #include <string.h> int main() { int s[6]; int t[6]; char h[101]; for (int i = 0; i < 6; i++) { scanf("%d", &s[i]); } scanf("%s", h); for (int i = 0; h[i] != '\n'; i++) { if (h[i] == 'N') { t[4] = s[0]; t[0] = s[1]; t[1] = s[5]; t[5] = s[4]; t[2] = ...
#include <cstdio> #include <string.h> int main() { int s[6]; int t[6]; char h[101]; for (int i = 0; i < 6; i++) { scanf("%d", &s[i]); } scanf("%s", h); for (int i = 0; h[i] != 0; i++) { if (h[i] == 'N') { t[4] = s[0]; t[0] = s[1]; t[1] = s[5]; t[5] = s[4]; t[2] = s[2...
[["-", 8, 9, 0, 7, 15, 16, 12, 103, 0, 104], ["-", 8, 9, 0, 7, 15, 16, 12, 103, 0, 44], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
418
<?php class Dice { private $label; public function __construct( $labels ) { $this->labels = $labels; } public function roll( $cmds ) { $len = strlen( $cmds ); for( $i=0; $i<$len; $i++ ) { if( 'E' == $cmds[$i] ) { $this->labels = [ $this->labels[3], $this->labels[1], $this->labels[0], $this->...
<?php class Dice { private $labels; public function __construct( $labels ) { $this->labels = $labels; } public function roll( $cmds ) { $len = strlen( $cmds ); for( $i=0; $i<$len; $i++ ) { if( 'E' == $cmds[$i] ) { $this->labels = [ $this->labels[3], $this->labels[1], $this->labels[0], $this-...
[["-", 8, 201, 0, 277, 0, 622, 0, 606, 0, 141], ["+", 8, 201, 0, 277, 0, 622, 0, 606, 0, 141], ["-", 0, 11, 12, 227, 0, 618, 0, 69, 0, 612], ["+", 0, 11, 12, 227, 0, 618, 0, 69, 0, 612]]
6
423
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // Here your code ! BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String str = br.readLine(); Dic...
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // Here your code ! BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String str = br.readLine(); Dic...
[["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 526, 8, 527, 0, 46]]
3
366
public class Main { public void run(java.io.InputStream in, java.io.PrintStream out) { java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int[] dice; int i, n; String str; char[] ch; dice = new int[6]; for (i = 0; i < 6; i++) { dice[i] = sc.nextInt(); } str = s...
public class Main { public void run(java.io.InputStream in, java.io.PrintStream out) { java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int[] dice; int i, n; String str; char[] ch; dice = new int[6]; for (i = 0; i < 6; i++) { dice[i] = sc.nextInt(); } str = s...
[["-", 8, 196, 0, 1, 0, 11, 12, 504, 71, 499], ["+", 8, 196, 0, 1, 0, 11, 12, 504, 71, 499], ["-", 8, 196, 0, 1, 0, 11, 31, 504, 71, 499], ["+", 8, 196, 0, 1, 0, 11, 31, 504, 71, 499]]
3
411
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String[] inputs = scan.nextLine().split(" "); int[] face = new int[6]; int SOUTH = 2; int NORTH = 5; int WEST = 4; int EAST = 3; int TOP = 1; int BOTTOM = 6...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String[] inputs = scan.nextLine().split(" "); int[] face = new int[6]; int SOUTH = 2; int NORTH = 5; int WEST = 4; int EAST = 3; int TOP = 1; int BOTTOM = 6...
[["-", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
3
317