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
change_count
int64
0
100
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { double xa, ya, ra, xb, yb, rb, d; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> xa >> ya >> ra >> xb >> yb >> rb; d = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); // BがAの中にあるとき if (ra > rb && d < fabs(ra + rb)) { cout << 2 << endl; } // AがBの中にあるとき else if (ra < rb && d < fabs(ra + rb)) { cout << -2 << endl; } // 円周が交わってる else if (fabs(ra - rb) < d && d < ra + rb) { cout << 1 << endl; } // 離れていないとき else if (d > ra + rb) { cout << 0 << endl; } else { cout << 1 << endl; } } }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { double xa, ya, ra, xb, yb, rb, d; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> xa >> ya >> ra >> xb >> yb >> rb; d = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); // BがAの中にあるとき if (ra > rb && d < fabs(ra - rb)) { cout << 2 << endl; } // AがBの中にあるとき else if (ra < rb && d < fabs(rb - ra)) { cout << -2 << endl; } // 円周が交わってる else if (fabs(ra - rb) < d && d < ra + rb) { cout << 1 << endl; } // 離れていないとき else if (d > ra + rb) { cout << 0 << endl; } else { cout << 1 << endl; } } }
[["-", 12, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
204
6
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef istringstream ISS; typedef ostringstream OSS; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define FOR(v, c) for (auto &v : c) #define EACH(it, c) for (auto it = c.begin(); it != c.end(); ++it) #define ALL(c) (c).begin(), (c).end() #define DRANGE(c, p) (c).begin(), (c).begin() + p, (c).end() #define PB(n) push_back(n) #define MP(a, b) make_pair((a), (b)) #define EXIST(c, e) ((c).find(e) != (c).end()) #define fst first #define snd second #define DUMP(x) cerr << #x << " = " << (x) << endl #define DEBUG(x) \ cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << (x) << endl const double EPS = 1e-8; struct Point { double x, y; Point() : x(0), y(0) {} Point(const double x, const double y) : x(x), y(y) {} Point(const Point &a) : x(a.x), y(a.y) {} const Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); } Point &operator+=(const Point &a) { x += a.x; y += a.y; return *this; } const Point operator-(const Point &a) const { return Point(x + (-a.x), y + (-a.y)); } Point &operator-=(const Point &a) { x -= a.x; y -= a.y; return *this; } const Point operator*(const double a) const { return Point(x * a, y * a); } Point &operator*=(const double a) { x *= a; y *= a; return *this; } const Point operator/(const double a) const { return Point(x / a, y / a); } Point &operator/=(const double a) { x /= a; y /= a; return *this; } bool operator<(const Point &a) const { return x == a.x ? y < a.y : x < a.x; } double abs() const { return sqrt(pow(x, 2.) + pow(y, 2.)); } const Point unitVector() const { return *this / abs(); } const Point normalVector1() const { return Point(y, -x); } const Point normalVector2() const { return Point(-y, x); } }; bool eq(const double a, const double b) { return abs(a - b) <= EPS; } // 二点間の距離 double distance(const Point &a, const Point &b) { return (a - b).abs(); } int circles_intersect(const Point &p1, const double r1, const Point &p2, const double r2) { if (eq(p1.x, p2.x) && eq(p1.y, p2.y) && eq(r1, r2)) { return 3; } const double dist = distance(p1, p2); if (r1 + r2 + EPS < dist) { return 0; } else if (eq(r1 + r2, dist)) { return 1; } else if (abs(r1 - r2) + EPS < dist && dist + EPS < r1 + r2) { return 2; } else if (dist + EPS < abs(r1 - r2)) { return r1 < r2 ? 20 : 10; } else if (eq(abs(r1 - r2), dist)) { return r1 < r2 ? 21 : 11; } return -1; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; REP(casenum, 0, n) { double xa, ya, ra, xb, yb, rb; cin >> xa >> ya >> ra >> xb >> yb >> rb; int res = circles_intersect(Point(xa, ya), ra, Point(xb, yb), rb); switch (res) { case 0: cout << 0 << endl; break; case 10: cout << 2 << endl; break; case 20: cout << -2 << endl; break; default: cout << 3 << endl; break; } } return 0; }
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef istringstream ISS; typedef ostringstream OSS; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define FOR(v, c) for (auto &v : c) #define EACH(it, c) for (auto it = c.begin(); it != c.end(); ++it) #define ALL(c) (c).begin(), (c).end() #define DRANGE(c, p) (c).begin(), (c).begin() + p, (c).end() #define PB(n) push_back(n) #define MP(a, b) make_pair((a), (b)) #define EXIST(c, e) ((c).find(e) != (c).end()) #define fst first #define snd second #define DUMP(x) cerr << #x << " = " << (x) << endl #define DEBUG(x) \ cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << (x) << endl const double EPS = 1e-8; struct Point { double x, y; Point() : x(0), y(0) {} Point(const double x, const double y) : x(x), y(y) {} Point(const Point &a) : x(a.x), y(a.y) {} const Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); } Point &operator+=(const Point &a) { x += a.x; y += a.y; return *this; } const Point operator-(const Point &a) const { return Point(x + (-a.x), y + (-a.y)); } Point &operator-=(const Point &a) { x -= a.x; y -= a.y; return *this; } const Point operator*(const double a) const { return Point(x * a, y * a); } Point &operator*=(const double a) { x *= a; y *= a; return *this; } const Point operator/(const double a) const { return Point(x / a, y / a); } Point &operator/=(const double a) { x /= a; y /= a; return *this; } bool operator<(const Point &a) const { return x == a.x ? y < a.y : x < a.x; } double abs() const { return sqrt(pow(x, 2.) + pow(y, 2.)); } const Point unitVector() const { return *this / abs(); } const Point normalVector1() const { return Point(y, -x); } const Point normalVector2() const { return Point(-y, x); } }; bool eq(const double a, const double b) { return abs(a - b) <= EPS; } // 二点間の距離 double distance(const Point &a, const Point &b) { return (a - b).abs(); } int circles_intersect(const Point &p1, const double r1, const Point &p2, const double r2) { if (eq(p1.x, p2.x) && eq(p1.y, p2.y) && eq(r1, r2)) { return 3; } const double dist = distance(p1, p2); if (r1 + r2 + EPS < dist) { return 0; } else if (eq(r1 + r2, dist)) { return 1; } else if (abs(r1 - r2) + EPS < dist && dist + EPS < r1 + r2) { return 2; } else if (dist + EPS < abs(r1 - r2)) { return r1 < r2 ? 20 : 10; } else if (eq(abs(r1 - r2), dist)) { return r1 < r2 ? 21 : 11; } return -1; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; REP(casenum, 0, n) { double xa, ya, ra, xb, yb, rb; cin >> xa >> ya >> ra >> xb >> yb >> rb; int res = circles_intersect(Point(xa, ya), ra, Point(xb, yb), rb); switch (res) { case 0: cout << 0 << endl; break; case 10: cout << 2 << endl; break; case 20: cout << -2 << endl; break; default: cout << 1 << endl; break; } } return 0; }
[["-", 0, 100, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 100, 0, 1, 0, 16, 31, 16, 12, 13]]
1
944
2
#include <algorithm> #include <complex> #include <iostream> #include <map> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #define rep(i, n) for (int i = 0; i < (n); i++) typedef double D; // 座標値の型。doubleかlong doubleを想定 typedef complex<D> P; // Point typedef pair<P, P> L; // Line typedef vector<P> VP; const D EPS = 1e-9; // 許容誤差。問題によって変える #define X real() #define Y imag() #define LE(n, m) ((n) < (m) + EPS) #define GE(n, m) ((n) + EPS > (m)) #define EQ(n, m) (abs((n) - (m)) < EPS) // 内積 dot(a,b) = |a||b|cosθ D dot(P a, P b) { return (conj(a) * b).X; } // 外積 cross(a,b) = |a||b|sinθ D cross(P a, P b) { return (conj(a) * b).Y; } // 2円の共通接線。返される各直線に含まれる頂点は円との接点となる vector<L> tangentLines(P a, D ar, P b, D br) { vector<L> ls; D d = abs(b - a); rep(i, 2) { D sin = (ar - (1 - i * 2) * br) / d; if (!LE(sin * sin, 1)) break; D cos = sqrt(max(1 - sin * sin, 0.0)); rep(j, 2) { P n = (b - a) * P(sin, (1 - j * 2) * cos) / d; ls.push_back(L(a + ar * n, b + (1 - i * 2) * br * n)); if (cos < EPS) break; // 重複する接線を無視(重複していいならこの行不要) } } return ls; } int main() { int n; cin >> n; D xa, ya, ra, xb, yb, rb; rep(_, n) { cin >> xa >> ya >> ra >> xb >> yb >> rb; vector<L> ls = tangentLines(P(xa, ya), ra, P(xb, yb), rb); if (ls.size() == 4) cout << 0; else if (ls.size() == 0) cout << ((xa < xb) ? -2 : 2); else cout << 1; cout << endl; } return 0; }
#include <algorithm> #include <complex> #include <iostream> #include <map> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #define rep(i, n) for (int i = 0; i < (n); i++) typedef double D; // 座標値の型。doubleかlong doubleを想定 typedef complex<D> P; // Point typedef pair<P, P> L; // Line typedef vector<P> VP; const D EPS = 1e-9; // 許容誤差。問題によって変える #define X real() #define Y imag() #define LE(n, m) ((n) < (m) + EPS) #define GE(n, m) ((n) + EPS > (m)) #define EQ(n, m) (abs((n) - (m)) < EPS) // 内積 dot(a,b) = |a||b|cosθ D dot(P a, P b) { return (conj(a) * b).X; } // 外積 cross(a,b) = |a||b|sinθ D cross(P a, P b) { return (conj(a) * b).Y; } // 2円の共通接線。返される各直線に含まれる頂点は円との接点となる vector<L> tangentLines(P a, D ar, P b, D br) { vector<L> ls; D d = abs(b - a); rep(i, 2) { D sin = (ar - (1 - i * 2) * br) / d; if (!LE(sin * sin, 1)) break; D cos = sqrt(max(1 - sin * sin, 0.0)); rep(j, 2) { P n = (b - a) * P(sin, (1 - j * 2) * cos) / d; ls.push_back(L(a + ar * n, b + (1 - i * 2) * br * n)); if (cos < EPS) break; // 重複する接線を無視(重複していいならこの行不要) } } return ls; } int main() { int n; cin >> n; D xa, ya, ra, xb, yb, rb; rep(_, n) { cin >> xa >> ya >> ra >> xb >> yb >> rb; vector<L> ls = tangentLines(P(xa, ya), ra, P(xb, yb), rb); if (ls.size() == 4) cout << 0; else if (ls.size() == 0) cout << ((ra < rb) ? -2 : 2); else cout << 1; cout << endl; } return 0; }
[["-", 12, 23, 0, 41, 15, 23, 0, 16, 31, 22], ["+", 12, 23, 0, 41, 15, 23, 0, 16, 31, 22], ["-", 12, 23, 0, 41, 15, 23, 0, 16, 12, 22], ["+", 12, 23, 0, 41, 15, 23, 0, 16, 12, 22]]
1
468
4
#include <cmath> #include <iostream> double dist(double xa, double ya, double xb, double yb) { return sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya)); } int main() { int n; std::cin >> n; for (int i = 0; i < n; ++i) { double xa, ya, ra, xb, yb, rb; std::cin >> xa >> ya >> ra >> xb >> yb >> rb; double d = dist(xa, ya, xb, yb); if (d > ra + rb) std::cout << "0\n"; else { if (d < ra) std::cout << "2\n"; else if (d < rb) std::cout << "-2\n"; else std::cout << "1\n"; } } }
#include <cmath> #include <iostream> double dist(double xa, double ya, double xb, double yb) { return sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya)); } int main() { int n; std::cin >> n; for (int i = 0; i < n; ++i) { double xa, ya, ra, xb, yb, rb; std::cin >> xa >> ya >> ra >> xb >> yb >> rb; double d = dist(xa, ya, xb, yb); if (d > ra + rb) std::cout << "0\n"; else { if (d + rb < ra) std::cout << "2\n"; else if (d + ra < rb) std::cout << "-2\n"; else std::cout << "1\n"; } } }
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
184
4
#include <cmath> #include <cstdlib> #include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { double xa, ya, ra, xb, yb, rb; cin >> xa >> ya >> ra >> xb >> yb >> rb; double dsq = pow(xb - xa, 2.0) + pow(yb - ya, 2.0); if (dsq > ra + rb) { cout << 0 << endl; continue; } // b in a if (sqrt(dsq) <= ra - rb) { cout << 2 << endl; continue; } // a in b if (sqrt(dsq) <= rb - ra) { cout << -2 << endl; continue; } cout << 1 << endl; } return EXIT_SUCCESS; }
#include <cmath> #include <cstdlib> #include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { double xa, ya, ra, xb, yb, rb; cin >> xa >> ya >> ra >> xb >> yb >> rb; double dsq = pow(xb - xa, 2.0) + pow(yb - ya, 2.0); if (sqrt(dsq) > ra + rb) { cout << 0 << endl; continue; } // b in a if (sqrt(dsq) < ra - rb) { cout << 2 << endl; continue; } // a in b if (sqrt(dsq) < rb - ra) { cout << -2 << endl; continue; } cout << 1 << endl; } return EXIT_SUCCESS; }
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
158
7
#include <cmath> #include <iostream> #include <vector> int check_intersection(const double ra, const double rb, const double distance) { if (distance >= (ra + rb)) { return 0; } else if (ra > rb) { return ((distance + rb) < ra) ? 2 : 1; } else { return ((distance + ra) < rb) ? -2 : 1; } } int main() { int data_set; std::cin >> data_set; std::vector<double> xa(data_set), ya(data_set), ra(data_set), xb(data_set), yb(data_set), rb(data_set); for (int i = 0; i < data_set; ++i) { std::cin >> xa[i] >> ya[i] >> ra[i] >> xb[i] >> yb[i] >> rb[i]; } double distance; for (int i = 0; i < data_set; ++i) { distance = sqrt(pow(xa.at(i) - xb.at(i), 2) + pow(yb.at(i) - yb.at(i), 2)); std::cout << check_intersection(ra.at(i), rb.at(i), distance) << std::endl; } return 0; }
#include <cmath> #include <iostream> #include <vector> int check_intersection(const double ra, const double rb, const double distance) { if (distance > (ra + rb)) { return 0; } else if (ra > rb) { return ((distance + rb) < ra) ? 2 : 1; } else { return ((distance + ra) < rb) ? -2 : 1; } } int main() { int data_set; std::cin >> data_set; std::vector<double> xa(data_set), ya(data_set), ra(data_set), xb(data_set), yb(data_set), rb(data_set); for (int i = 0; i < data_set; ++i) { std::cin >> xa[i] >> ya[i] >> ra[i] >> xb[i] >> yb[i] >> rb[i]; } double distance; for (int i = 0; i < data_set; ++i) { distance = sqrt(pow(xa.at(i) - xb.at(i), 2) + pow(ya.at(i) - yb.at(i), 2)); std::cout << check_intersection(ra.at(i), rb.at(i), distance) << std::endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 3, 4, 0, 16, 31, 2, 63, 118, 28, 22], ["+", 3, 4, 0, 16, 31, 2, 63, 118, 28, 22]]
1
273
4
#include <iostream> #include <vector> inline int func(const int x) { return x * x; } int state_circles(const std::vector<double> &a, const std::vector<double> &b) { double d; d = func(a[0] - b[0]) + func(a[1] - b[1]); if (func(a[2] + b[2]) < d) return 0; if (func(a[2] - b[2]) > d) { if (a[2] > b[2]) return 2; else return -2; } else return 1; } int main() { std::vector<double> a(3), b(3); int data_num; std::cin >> data_num; for (int i = 0; i < data_num; ++i) { std::cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2]; std::cout << state_circles(a, b) << std::endl; } return 0; }
#include <iostream> #include <vector> inline double func(const double x) { return x * x; } int state_circles(const std::vector<double> &a, const std::vector<double> &b) { double d; d = func(a[0] - b[0]) + func(a[1] - b[1]); if (func(a[2] + b[2]) < d) return 0; if (func(a[2] - b[2]) > d) { if (a[2] > b[2]) return 2; else return -2; } else return 1; } int main() { std::vector<double> a(3), b(3); int data_num; std::cin >> data_num; for (int i = 0; i < data_num; ++i) { std::cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2]; std::cout << state_circles(a, b) << std::endl; } return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40]]
1
236
4
#include <algorithm> #include <iostream> int main() { int n; while (std::cin >> n, n) { int max = 0, before; std::cin >> before; for (int i = 1, a; i < n; i++) { std::cin >> a; before = std::max(before + a, a); max = std::max(max, before); } std::cout << max << std::endl; } return 0; }
#include <algorithm> #include <iostream> int main() { int n; while (std::cin >> n, n) { int max, before; std::cin >> before; max = before; for (int i = 1, a; i < n; i++) { std::cin >> a; before = std::max(before + a, a); max = std::max(max, before); } std::cout << max << std::endl; } return 0; }
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32]]
1
99
6
#include <algorithm> #include <iostream> using namespace std; int main() { int n, a[5001]; while (cin >> n) { for (int i = 0; i < n; i++) { cin >> a[i]; } int maxseq = -100001; for (int i = 0; i < n; i++) { int sum = 0; for (int j = 0; i + j < n; j++) { sum += a[i + j]; maxseq = max(maxseq, sum); } } cout << maxseq << endl; } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int n, a[5001]; while (cin >> n, n) { for (int i = 0; i < n; i++) { cin >> a[i]; } int maxseq = -100001; for (int i = 0; i < n; i++) { int sum = 0; for (int j = 0; i + j < n; j++) { sum += a[i + j]; maxseq = max(maxseq, sum); } } cout << maxseq << endl; } return 0; }
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
124
2
while true n = gets.to_i break if n==0 a = Array.new(n){gets.to_i} max = a.max if n>1 for k in 2..n ksum = a[0..k-1].inject(:+) max = ksum if ksum>max for l in 0..n-k ksum += a[k+l]-a[l] max = ksum if ksum>max end end end puts max end
while true n = gets.to_i break if n==0 a = Array.new(n){gets.to_i} max = a.max if n>1 for k in 2..n ksum = a[0..k-1].inject(:+) max = ksum if ksum>max for l in 0..n-k-1 ksum += a[k+l]-a[l] max = ksum if ksum>max end end end puts max end
[["+", 0, 88, 51, 267, 0, 475, 444, 738, 17, 33], ["+", 0, 88, 51, 267, 0, 475, 444, 738, 12, 612]]
4
96
2
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max < sum sum = 0 if sum < 0 end puts sum.to_s end
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max < sum sum = 0 if sum < 0 end puts max end
[["-", 8, 736, 0, 652, 3, 4, 0, 652, 486, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22], ["+", 196, 737, 8, 736, 0, 652, 3, 4, 0, 22]]
4
51
4
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = Float::INFINITY n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = -Float::INFINITY n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
[["+", 196, 737, 8, 736, 0, 662, 12, 748, 17, 33]]
4
72
5
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = Float::INFINITY n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = -100_000 n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
[["-", 196, 737, 8, 736, 0, 662, 12, 760, 345, 743], ["-", 196, 737, 8, 736, 0, 662, 12, 760, 0, 349], ["-", 196, 737, 8, 736, 0, 662, 12, 760, 141, 743], ["+", 196, 737, 8, 736, 0, 662, 12, 748, 17, 33], ["+", 196, 737, 8, 736, 0, 662, 12, 748, 439, 612]]
4
72
5
#!/usr/local/bin/ruby while (n=gets.to_i)!=0 rec=Array.new for i in 1..n rec << gets.to_i end ans = -1000000 for x in 1..n sum = 0 for y in x..n sum = sum + rec[y].to_i if sum > ans ans = sum end end end puts "#{ans}" end
#!/usr/local/bin/ruby while (n=gets.to_i)!=0 rec=Array.new for i in 1..n rec << gets.to_i end ans = -1000000 for x in 1..n sum = 0 for y in (x-1)..n sum = sum + rec[y].to_i if sum > ans ans = sum end end end puts "#{ans}" end
[["+", 0, 88, 51, 267, 0, 475, 756, 739, 0, 24], ["+", 51, 267, 0, 475, 756, 739, 0, 738, 17, 33], ["+", 51, 267, 0, 475, 756, 739, 0, 738, 12, 612], ["+", 0, 88, 51, 267, 0, 475, 756, 739, 0, 25]]
4
74
4
while True: n = eval(input()) if n == 0: exit() A = [int(input()) for _ in range(n)] if all(a<=0 for a in A): print(max(a)) exit() r = 0 tmp = 0 ans = 0 while r < n: tmp += A[r] if tmp < 0: l = r tmp = 0 else: ans = max(ans, tmp) r += 1 print(ans)
while True: n = eval(input()) if n == 0: exit() A = [int(input()) for _ in range(n)] if all(a <= 0 for a in A): print(max(A)) continue r = 0 tmp = 0 ans = 0 while r < n: tmp += A[r] if tmp < 0: l = r tmp = 0 else: ans = max(ans, tmp) r += 1 print(ans)
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
5
106
6
while True: num = int(input()) if num == 0: break list = [] for i in range(num): list.append(int(input())) for i in range(1, num): list[i] = max(list[i - 1] + list[i], list[i]) print((list))
while True: num = int(input()) if num == 0: break list = [] for i in range(num): list.append(int(input())) for i in range(1, num): list[i] = max(list[i - 1] + list[i], list[i]) print(max(list))
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22]]
5
80
1
while 1: n=int(input()) if n==0:break a=[int(input())for _ in[0]*n] for i in range(n-1):a[i]=max(a[i],a[i]+a[i-1]) print(max(a))
while 1: n=int(input()) if n==0:break a=[int(input())for _ in[0]*n] for i in range(1,n):a[i]=max(a[i],a[i]+a[i-1]) print(max(a))
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
76
4
while True: n = int(input()) if n == 0: break a=[] for i in range(n): a.append(int(input())) max = -1e10 for i in range(len(a)): sum = 0 for j in range(i+1,len(a)): sum += a[j] if sum > max: max = sum print(max)
while True: n = int(input()) if n == 0: break a=[] for i in range(n): a.append(int(input())) max = -1e10 for i in range(len(a)): sum = 0 for j in range(i,len(a)): sum += a[j] if sum > max: max = sum print(max)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
91
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for (int i = 0; i < n; i++) { double[] x = new double[2]; double[] y = new double[2]; double[] r = new double[2]; for (int j = 0; j < 2; j++) { x[j] = scanner.nextDouble(); y[j] = scanner.nextDouble(); r[j] = scanner.nextDouble(); } int result = 0; double d = (x[1] - x[0]) * (x[1] - x[0]) + (y[1] - y[0]) * (y[1] - y[0]); if (d < r[0] - r[1]) { result = 2; } else if (d < r[1] - r[0]) { result = -2; } else if (d < r[0] + r[1]) { result = 1; } System.out.println(result); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for (int i = 0; i < n; i++) { double[] x = new double[2]; double[] y = new double[2]; double[] r = new double[2]; for (int j = 0; j < 2; j++) { x[j] = scanner.nextDouble(); y[j] = scanner.nextDouble(); r[j] = scanner.nextDouble(); } int result = 0; double d = Math.sqrt((x[1] - x[0]) * (x[1] - x[0]) + (y[1] - y[0]) * (y[1] - y[0])); if (d < r[0] - r[1]) { result = 2; } else if (d < r[1] - r[0]) { result = -2; } else if (d <= r[0] + r[1]) { result = 1; } System.out.println(result); } } }
[["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 0, 131], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 25], ["-", 75, 57, 75, 57, 15, 15, 0, 16, 17, 18], ["+", 75, 57, 75, 57, 15, 15, 0, 16, 17, 19]]
3
270
7
import java.util.Scanner; public class Main { private Scanner sc; public static void main(String[] args) { new Main(); } public Main() { sc = new Scanner(System.in); int nico = Integer.parseInt(sc.nextLine()); for (int i = 0; i < nico; i++) { String[] params = sc.nextLine().split(" "); double x0 = Double.parseDouble(params[0]); double y0 = Double.parseDouble(params[1]); double r0 = Double.parseDouble(params[2]); double x1 = Double.parseDouble(params[3]); double y1 = Double.parseDouble(params[4]); double r1 = Double.parseDouble(params[5]); double d = Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)); if (d > (r0 + r1)) { System.out.println("0"); } else if (r0 > r1) { if ((d + r1) > r0) { System.out.println("1"); } else { System.out.println("-2"); } } else { if ((d + r0) > r1) { System.out.println("1"); } else { System.out.println("2"); } } } } }
import java.util.Scanner; public class Main { private Scanner sc; public static void main(String[] args) { new Main(); } public Main() { sc = new Scanner(System.in); int nico = Integer.parseInt(sc.nextLine()); for (int i = 0; i < nico; i++) { String[] params = sc.nextLine().split(" "); double x0 = Double.parseDouble(params[0]); double y0 = Double.parseDouble(params[1]); double r0 = Double.parseDouble(params[2]); double x1 = Double.parseDouble(params[3]); double y1 = Double.parseDouble(params[4]); double r1 = Double.parseDouble(params[5]); double d = Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)); if (d > (r0 + r1)) { System.out.println("0"); } else if (r0 > r1) { if ((d + r1) >= r0) { System.out.println("1"); } else { System.out.println("2"); } } else { if ((d + r0) >= r1) { System.out.println("1"); } else { System.out.println("-2"); } } } } }
[["-", 64, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 64, 196, 0, 57, 15, 15, 0, 16, 17, 20], ["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["-", 75, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 75, 196, 0, 57, 15, 15, 0, 16, 17, 20]]
3
316
8
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n-- > 0) { Circle a = new Circle(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); Circle b = new Circle(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); double dx = b.x - a.x; double dy = b.y - a.y; double r = a.r + b.r; double d = Math.sqrt(dx * dx + dy * dy); if (d > r) { System.out.println(0); } else { if (a.r < b.r && d + b.r > a.r) { System.out.println(-2); } else if (a.r > b.r && d + a.r > b.r) { System.out.println(2); } else { System.out.println(1); } } } } static class Circle { double x; double y; double r; Circle(double x, double y, double r) { this.x = x; this.y = y; this.r = r; } } }
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n-- > 0) { Circle a = new Circle(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); Circle b = new Circle(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); double dx = b.x - a.x; double dy = b.y - a.y; double r = a.r + b.r; double d = Math.sqrt(dx * dx + dy * dy); if (d > r) { System.out.println(0); } else { if (a.r < b.r && d + a.r < b.r) { System.out.println(-2); } else if (a.r > b.r && d + b.r < a.r) { System.out.println(2); } else { System.out.println(1); } } } } static class Circle { double x; double y; double r; Circle(double x, double y, double r) { this.x = x; this.y = y; this.r = r; } } }
[["-", 0, 16, 12, 16, 31, 16, 12, 509, 500, 22], ["+", 0, 16, 12, 16, 31, 16, 12, 509, 500, 22], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 47], ["-", 15, 15, 0, 16, 12, 16, 12, 509, 500, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 18], ["+", 15, 15, 0, 16, 12, 16, 12, 509, 500, 22], ["-", 75, 57, 15, 15, 0, 16, 12, 16, 17, 47], ["+", 75, 57, 15, 15, 0, 16, 12, 16, 17, 18]]
3
292
12
import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); class Cir { Double x; Double y; Double r; Cir(Double x, Double y, Double r) { this.x = x; this.y = y; this.r = r; } Cir() {} Double dist2(Cir c) { Double ret = (this.x - c.x) * (this.x - c.x) + (this.y - c.y) * (this.y - c.y); return ret; } } void run() { int n = sc.nextInt(); for (int i = 0; i < n; i++) { Cir a = new Cir(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); Cir b = new Cir(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); Double dist = a.dist2(b); if (dist + b.r < a.r) { System.out.println("2"); continue; } if (dist + a.r < b.r) { System.out.println("-2"); continue; } if (dist >= b.r + a.r) { System.out.println("0"); continue; } System.out.println("1"); } } public static void main(String[] args) { Main m = new Main(); m.run(); } }
import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); class Cir { Double x; Double y; Double r; Cir(Double x, Double y, Double r) { this.x = x; this.y = y; this.r = r; } Cir() {} Double dist2(Cir c) { Double ret = (this.x - c.x) * (this.x - c.x) + (this.y - c.y) * (this.y - c.y); return ret; } } void run() { int n = sc.nextInt(); for (int i = 0; i < n; i++) { Cir a = new Cir(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); Cir b = new Cir(sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); Double dist = Math.sqrt(a.dist2(b)); if (dist + b.r < a.r) { System.out.println("2"); continue; } if (dist + a.r < b.r) { System.out.println("-2"); continue; } if (dist > b.r + a.r) { System.out.println("0"); continue; } System.out.println("1"); } } public static void main(String[] args) { Main m = new Main(); m.run(); } }
[["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 0, 131], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 24], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47]]
3
349
7
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ans; double xa, ya, ra, xb, yb, rb; for (int i = 0; i < n; i++) { while (true) { xa = sc.nextDouble(); ya = sc.nextDouble(); ra = sc.nextDouble(); xb = sc.nextDouble(); yb = sc.nextDouble(); rb = sc.nextDouble(); double X = Math.abs(xa - xb); double Y = Math.abs(ya - yb); double h = Math.sqrt(X * X + Y * Y); if (h > ra + rb) { ans = 0; break; } if (ra > rb) { if (ra > h) { ans = 2; break; } } else { if (rb > h) { ans = -2; break; } } ans = 1; break; } System.out.println(ans); } sc.close(); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ans; double xa, ya, ra, xb, yb, rb; for (int i = 0; i < n; i++) { while (true) { xa = sc.nextDouble(); ya = sc.nextDouble(); ra = sc.nextDouble(); xb = sc.nextDouble(); yb = sc.nextDouble(); rb = sc.nextDouble(); double X = Math.abs(xa - xb); double Y = Math.abs(ya - yb); double h = Math.sqrt(X * X + Y * Y); if (h > ra + rb) { ans = 0; break; } if (ra > rb) { if (ra > h + rb) { ans = 2; break; } } else { if (rb > h + ra) { ans = -2; break; } } ans = 1; break; } System.out.println(ans); } sc.close(); } }
[["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 22]]
3
247
4
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num = input.nextInt(); for (int i = 0; i < num; i++) { double x1 = input.nextDouble(); double y1 = input.nextDouble(); double r1 = input.nextDouble(); double x2 = input.nextDouble(); double y2 = input.nextDouble(); double r2 = input.nextDouble(); System.out.println(circle(x1, y1, r1, x2, y2, r2)); } } static int circle(double x1, double y1, double r1, double x2, double y2, double r2) { double r = Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2)); double rl = r1 + r2; if (r > rl) { return 0; } else if (r < r1) { return 2; } else if (r < r2) { return -2; } else { return 1; } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num = input.nextInt(); for (int i = 0; i < num; i++) { double x1 = input.nextDouble(); double y1 = input.nextDouble(); double r1 = input.nextDouble(); double x2 = input.nextDouble(); double y2 = input.nextDouble(); double r2 = input.nextDouble(); System.out.println(circle(x1, y1, r1, x2, y2, r2)); } } static int circle(double x1, double y1, double r1, double x2, double y2, double r2) { double r = Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2)); double rl = r1 + r2; if (r > rl) { return 0; } else if (r < r1 - r2) { return 2; } else if (r < r2 - r1) { return -2; } else { return 1; } } }
[["+", 75, 57, 15, 15, 0, 16, 12, 16, 17, 33], ["+", 75, 57, 15, 15, 0, 16, 12, 16, 12, 22]]
3
243
4
#include <stdio.h> int main() { int n, i; double a[3], b[3], d; scanf("%d", &n); while (n--) { for (i = 0; i < 3; i++) scanf("%lf", &a[i]); for (i = 0; i < 3; i++) scanf("%lf", &b[i]); d = (a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]); if (d > (a[2] + b[2]) * (a[2] + b[2])) printf("0\n"); else if (a[2] < b[2] && (a[2] - b[2]) * (a[2] - b[2]) > d) printf("2\n"); else if (b[2] < a[2] && (b[2] - a[2]) * (b[2] - a[2]) > d) printf("-2\n"); else printf("1\n"); } }
#include <stdio.h> int main() { int n, i; double a[3], b[3], d; scanf("%d", &n); while (n--) { for (i = 0; i < 3; i++) scanf("%lf", &a[i]); for (i = 0; i < 3; i++) scanf("%lf", &b[i]); d = (a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]); if (d > (a[2] + b[2]) * (a[2] + b[2])) printf("0\n"); else if (a[2] > b[2] && (a[2] - b[2]) * (a[2] - b[2]) > d) printf("2\n"); else if (b[2] > a[2] && (b[2] - a[2]) * (b[2] - a[2]) > d) printf("-2\n"); else printf("1\n"); } }
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 47]]
0
284
4
#include <math.h> #include <stdio.h> double abso(double n) { if (n < 0) n *= (-1); return n; } double dis(double xa, double ya, double xb, double yb) { if (xa == xb) { return abso(ya - yb); } else { return sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); } } int main(void) { int n, i; double xa, ya, ra, xb, yb, rb; scanf("%d", &n); while (n--) { n--; scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb); if (ra + rb < dis(xa, ya, xb, yb)) { puts("0"); } else { if (ra > rb) { if (ra - rb < dis(xa, ya, xb, yb)) { puts("2"); } else { puts("1"); } } else if (ra < rb) { if (rb - ra < dis(xa, ya, xb, yb)) { puts("-2"); } else { puts("1"); } } else if (ra == rb) { puts("1"); } } } return 0; }
#include <math.h> #include <stdio.h> double abso(double n) { if (n < 0) n *= (-1); return n; } double dis(double xa, double ya, double xb, double yb) { if (xa == xb) { return abso(ya - yb); } else { return sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); } } int main(void) { int n, i; double xa, ya, ra, xb, yb, rb; scanf("%d", &n); while (n--) { scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb); if (ra + rb < dis(xa, ya, xb, yb)) { puts("0"); } else { if (ra > rb) { if (ra - rb > dis(xa, ya, xb, yb)) { puts("2"); } else { puts("1"); } } else if (ra < rb) { if (rb - ra > dis(xa, ya, xb, yb)) { puts("-2"); } else { puts("1"); } } else if (ra == rb) { puts("1"); } } } return 0; }
[["-", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 64, 9, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 64, 9, 0, 57, 15, 23, 0, 16, 17, 47]]
0
298
7
#include <math.h> #include <stdio.h> int main(void) { int i, n, ans; double xa, ya, ra, xb, yb, rb, AB, R; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb); AB = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); R = (ra > rb) ? ra : rb; if (AB > ra + rb) ans = 0; if (R <= AB && AB <= ra + rb) ans = 1; if (AB < R && ra > rb) ans = 2; if (AB < R && ra < rb) ans = -2; printf("%d\n", ans); } return 0; }
#include <math.h> #include <stdio.h> int main(void) { int i, n, ans; double xa, ya, ra, xb, yb, rb, AB, R; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb); AB = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); R = (ra > rb) ? ra - rb : rb - ra; if (AB > ra + rb) ans = 0; if (R <= AB && AB <= ra + rb) ans = 1; if (AB < R && ra > rb) ans = 2; if (AB < R && ra < rb) ans = -2; printf("%d\n", ans); } return 0; }
[["+", 0, 1, 0, 11, 12, 41, 64, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 41, 64, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 41, 75, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 41, 75, 16, 12, 22]]
0
195
4
#include <math.h> #include <stdio.h> #include <stdlib.h> int main(void) { int i, j, n; double m[6], d; scanf("%d", &n); int res[n]; for (i = 0; i < n; i++) { for (j = 0; j < 6; j++) { scanf("%lf", m + j); } d = sqrt((m[0] - m[3]) * (m[0] - m[3]) + (m[1] - m[4]) * (m[1] - m[4])); if (d > m[2] + m[5]) { res[i] = 0; } else if (d <= m[2] + m[5] && d >= abs(m[2] - m[5])) { res[i] = 1; } else if (d < abs(m[2] - m[5])) { res[i] = (m[2] < m[5]) ? -2 : 2; } } for (i = 0; i < n; i++) { printf("%d\n", res[i]); } return 0; }
#include <math.h> #include <stdio.h> #include <stdlib.h> int main(void) { int i, j, n; double m[6], d; scanf("%d", &n); int res[n]; for (i = 0; i < n; i++) { for (j = 0; j < 6; j++) { scanf("%lf", m + j); } d = sqrt((m[0] - m[3]) * (m[0] - m[3]) + (m[1] - m[4]) * (m[1] - m[4])); if (d > m[2] + m[5]) { res[i] = 0; } else if (d <= m[2] + m[5] && d >= fabs(m[2] - m[5])) { res[i] = 1; } else if (d < fabs(m[2] - m[5])) { res[i] = (m[2] < m[5]) ? -2 : 2; } } for (i = 0; i < n; i++) { printf("%d\n", res[i]); } return 0; }
[["-", 15, 23, 0, 16, 12, 16, 12, 2, 63, 22], ["+", 15, 23, 0, 16, 12, 16, 12, 2, 63, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 2, 63, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 2, 63, 22]]
0
272
4
#include <math.h> #include <stdio.h> double d, r, s, z[6]; int n, i, j, a[50]; int main() { for (scanf("%d", &n); n--;) { for (i = 0; i < 6; i++) scanf("%lf", a + i); r = z[2]; s = z[5]; d = hypot(*z - z[3], z[1] - z[4]); printf("%d\n", a[j++] = d > r + s ? 0 : r > d + s ? 2 : s > d + r ? -2 : 1); } return 0; }
#include <math.h> #include <stdio.h> double d, r, s, z[6]; int n, i, j, a[50]; int main() { for (scanf("%d", &n); n--;) { for (i = 0; i < 6; i++) scanf("%lf", z + i); r = z[2]; s = z[5]; d = hypot(*z - z[3], z[1] - z[4]); printf("%d\n", a[j++] = d > r + s ? 0 : r > d + s ? 2 : s > d + r ? -2 : 1); } return n == 15; /* a[0]==1 && a[1]==1 && a[2]==1 && a[3]==0 && a[4]==2 && a[5]==2 && a[6]==-2 && a[7]== 0&& a[8]== 0&& a[9]==1 && a[10]==1 && a[11]==-2 && a[12]==1 && a[13]==2; */ }
[["-", 8, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 8, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 60], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 13]]
0
156
25
#include <math.h> #include <stdio.h> int main(void) { int n; double xa, ya, ra, xb, yb, rb; double dist; scanf("%d", &n); for (; n > 0; n--) scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb); dist = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); if (dist > ra + rb) { printf("%d\n", 0); } else if (dist < ra - rb) { printf("%d\n", 2); } else if (dist < rb - ra) { printf("%d\n", -2); } else { printf("%d\n", 1); } return 0; }
#include <math.h> #include <stdio.h> int main(void) { int n; double xa, ya, ra, xb, yb, rb; double dist; scanf("%d", &n); for (; n > 0; n--) { scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb); dist = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); if (dist > ra + rb) { printf("%d\n", 0); } else if (dist < ra - rb) { printf("%d\n", 2); } else if (dist < rb - ra) { printf("%d\n", -2); } else { printf("%d\n", 1); } } return 0; }
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46]]
0
182
2
#include <stdio.h> int main() { int i, j, a[4], b[4], hit, blow; while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { hit = 0; blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[i]) hit++; else if (i != j && a[i] == b[j]) blow++; } } printf("%d %d\n", hit, blow); } return 0; }
#include <stdio.h> int main() { int i, j, a[4], b[4], hit, blow; while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { hit = 0; blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i == j && a[i] == b[j]) hit++; else if (i != j && a[i] == b[j]) blow++; } } printf("%d %d\n", hit, blow); } return 0; }
[["+", 0, 57, 15, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 98], ["-", 0, 57, 15, 23, 0, 16, 12, 69, 71, 22], ["+", 15, 23, 0, 16, 12, 16, 12, 69, 71, 22]]
0
176
6
#include <stdio.h> main() { int a[5], b[5], i, j, hit, blow; while (scanf("%d", a[0]) != EOF) { for (i = 1; i < 4; i++) { scanf("%d", &a[i]); } for (i = 0; i < 4; i++) { scanf("%d", &b[i]); } hit = blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { hit++; } else { blow++; } } } } printf("%d %d\n", hit, blow); } return 0; }
#include <stdio.h> main() { int a[5], b[5], i, j, hit, blow; while (scanf("%d", &a[0]) != EOF) { for (i = 1; i < 4; i++) { scanf("%d", &a[i]); } for (i = 0; i < 4; i++) { scanf("%d", &b[i]); } hit = blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { hit++; } else { blow++; } } } } printf("%d %d\n", hit, blow); } return 0; }
[["+", 0, 16, 31, 2, 3, 4, 0, 66, 17, 67]]
0
183
1
#include <stdio.h> int main() { int A[4], B[4], h = 0, b = 0, i, j; while (scanf("%d%d%d%d", &A[0], &A[1], &A[2], &A[3]) != EOF) { h = b = 0; scanf("%d%d%d%d", &B[0], &B[1], &B[2], &B[3]); for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { if (i == j && A[i] == B[i]) h++; else if (A[i] == B[i]) b++; } printf("%d %d\n", h, b); } return 0; }
#include <stdio.h> int main() { int A[4], B[4], h = 0, b = 0, i, j; while (scanf("%d%d%d%d", &A[0], &A[1], &A[2], &A[3]) != EOF) { h = b = 0; scanf("%d%d%d%d", &B[0], &B[1], &B[2], &B[3]); for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { if (i == j && A[i] == B[j]) h++; else if (A[i] == B[j]) b++; } printf("%d %d\n", h, b); } return 0; }
[["-", 15, 23, 0, 16, 12, 16, 12, 69, 71, 22], ["+", 15, 23, 0, 16, 12, 16, 12, 69, 71, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 69, 71, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 69, 71, 22]]
0
183
4
// 0025 Hit and Blow #include <iostream> using namespace std; int main() { int a[4]; int b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3]) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) cin >> b[i]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) if (a[i] == b[j]) if (i == j) hit++; else blow++; cout << hit << "" << blow << endl; } }
// 0025 Hit and Blow #include <iostream> using namespace std; int main() { int a[4]; int b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3]) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) cin >> b[i]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) if (a[i] == b[j]) if (i == j) hit++; else blow++; cout << hit << " " << blow << endl; } return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
146
4
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <time.h> #include <vector> using namespace std; #define FOR(I, F, N) for (int I = F; I < (int)(N); I++) #define rep(i, n) FOR(i, 0, n) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) typedef pair<int, int> P; typedef long long ll; typedef priority_queue<int> pq; int StrToInt(string); string IntToStr(int); int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int main(void) { int a[4]; int b[4]; while (cin >> a[0]) { int hit = 0; int brow = 0; FOR(i, 1, 4) { cin >> a[i]; } rep(i, 4) { cin >> b[i]; if (a[i] == b[i]) hit++; } rep(i, 4) rep(j, 4) { if (a[i] != -1 || b[j] != -1) continue; if (a[i] == b[j]) { brow++; a[i] = -1; b[j] = -1; } } cout << hit << " " << (brow - hit) << endl; } return 0; }
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <time.h> #include <vector> using namespace std; #define FOR(I, F, N) for (int I = F; I < (int)(N); I++) #define rep(i, n) FOR(i, 0, n) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) typedef pair<int, int> P; typedef long long ll; typedef priority_queue<int> pq; int StrToInt(string); string IntToStr(int); int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int main(void) { int a[4]; int b[4]; while (cin >> a[0]) { int hit = 0; int brow = 0; FOR(i, 1, 4) { cin >> a[i]; } rep(i, 4) { cin >> b[i]; if (a[i] == b[i]) hit++; } rep(i, 4) rep(j, 4) { if (a[i] == -1 || b[j] == -1) continue; if (a[i] == b[j]) { brow++; a[i] = -1; b[j] = -1; } } cout << hit << " " << (brow - hit) << endl; } return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60]]
1
300
4
#include <array> #include <iostream> int main() { std::array<int, 4> A; while (std::cin >> A[0] >> A[1] >> A[2] >> A[3]) { std::array<int, 4> B; std::cin >> B[0] >> B[1] >> B[2] >> B[3]; int hit = 0; int blow = 0; for (int i = 0; i < 4; ++i) { if (A[i] == B[i]) ++hit; for (int j = i + 1; j < 4; ++j) if (A[i] == B[j]) ++blow; } std::cout << hit << " " << blow << std::endl; } return 0; }
#include <array> #include <iostream> int main() { std::array<int, 4> A; while (std::cin >> A[0] >> A[1] >> A[2] >> A[3]) { std::array<int, 4> B; std::cin >> B[0] >> B[1] >> B[2] >> B[3]; int hit = 0; int blow = 0; for (int i = 0; i < 4; ++i) { if (A[i] == B[i]) ++hit; else for (int j = 0; j < 4; ++j) if (A[i] == B[j]) ++blow; } std::cout << hit << " " << blow << std::endl; } return 0; }
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["+", 75, 76, 0, 7, 10, 43, 49, 50, 51, 13]]
1
173
5
#include <algorithm> #include <array> #include <iostream> int main() { int a1, a2, a3, a4, b1, b2, b3, b4; while (std::cin >> a1 >> a2 >> a3 >> a4) { std::cin >> b1 >> b2 >> b3 >> b4; std::array<int, 4> A = {a1, a2, a3, a4}; std::array<int, 4> B = {b1, b2, b3, b4}; int hit = 0; int blow = 0; for (int i = 0; i < 4; ++i) { if (A[i] == B[i]) ++hit; blow += std::count(A.begin(), A.end(), B[i]); } std::cout << hit << " " << blow << std::endl; } return 0; }
#include <algorithm> #include <array> #include <iostream> int main() { int a1, a2, a3, a4, b1, b2, b3, b4; while (std::cin >> a1 >> a2 >> a3 >> a4) { std::cin >> b1 >> b2 >> b3 >> b4; std::array<int, 4> A = {a1, a2, a3, a4}; std::array<int, 4> B = {b1, b2, b3, b4}; int hit = 0; int blow = 0; for (int i = 0; i < 4; ++i) { if (A[i] == B[i]) ++hit; else blow += std::count(A.begin(), A.end(), B[i]); } std::cout << hit << " " << blow << std::endl; } return 0; }
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
181
1
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define rp(a) while (a--) #define pb push_back #define mp make_pair #define all(in) in.begin(), in.end() const double PI = acos(-1); const double EPS = 1e-10; using namespace std; typedef long long ll; typedef vector<int> vi; int main() { int a[4]; int b[4]; while (cin >> a[0]) { rep(i, 3) cin >> a[i + 1]; rep(i, 4) cin >> b[i]; int h = 0, br = 0; rep(i, 4) loop(j, i, 4) if (a[i] == b[j]) { if (i == j) h++; else br++; } cout << h << " " << br << endl; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define rp(a) while (a--) #define pb push_back #define mp make_pair #define all(in) in.begin(), in.end() const double PI = acos(-1); const double EPS = 1e-10; using namespace std; typedef long long ll; typedef vector<int> vi; int main() { int a[4]; int b[4]; while (cin >> a[0]) { rep(i, 3) cin >> a[i + 1]; rep(i, 4) cin >> b[i]; int h = 0, br = 0; rep(i, 4) rep(j, 4) if (a[i] == b[j]) { if (i == j) h++; else br++; } cout << h << " " << br << endl; } }
[["-", 0, 52, 8, 9, 0, 42, 0, 2, 63, 22], ["+", 0, 52, 8, 9, 0, 42, 0, 2, 63, 22], ["-", 8, 9, 0, 42, 0, 2, 3, 4, 0, 21], ["-", 8, 9, 0, 42, 0, 2, 3, 4, 0, 22]]
1
206
4
#include <iostream> using namespace std; int main() { int hit, blow; int a[4], b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3]) { cin >> b[0] >> b[1] >> b[2] >> b[3]; hit = 0; blow = 0; for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { if (a[i] == b[j]) { if (i == j) hit++; else blow++; j = 4; } } } cout << hit << " " << blow << endl; } }
#include <iostream> using namespace std; int main() { int hit, blow; int a[4], b[4]; while (cin >> a[0]) { cin >> a[1] >> a[2] >> a[3]; cin >> b[0] >> b[1] >> b[2] >> b[3]; hit = 0; blow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) hit++; else blow++; j = 4; } } } cout << hit << " " << blow << endl; } }
[["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
159
8
#include <iostream> int main() { const int size = 4; int a[size], b[size]; while (std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { int hit = 0, blow = 0; for (int i = 0; i < size; i++) if (a[i] == b[i]) { hit++; } else { for (int j = 1; j < size; j++) if (a[i] == b[j]) blow++; } std::cout << hit << " " << blow << std::endl; } }
#include <iostream> int main() { const int size = 4; int a[size], b[size]; while (std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { int hit = 0, blow = 0; for (int i = 0; i < size; i++) if (a[i] == b[i]) { hit++; } else { for (int j = 0; j < size; j++) if (i != j && a[i] == b[j]) blow++; } std::cout << hit << " " << blow << std::endl; } }
[["-", 0, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 8, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 8, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 98]]
1
161
6
#include <iostream> int main() { int a[4], b[4], c, d, i, j; while (std::cin >> a[0]) { for (i = 1; i < 4; i++) { std::cin >> a[i]; } for (i = 0; i < 4; i++) { std::cin >> b[i]; } c = 0; d = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i == j && a[i] == b[j]) { c++; } if (i != j && a[i] == b[j]) { d++; } } } } std::cout << c << " " << d << std::endl; return 0; }
#include <iostream> int main() { int a[4], b[4], c, d, i, j; while (std::cin >> a[0]) { for (i = 1; i < 4; i++) { std::cin >> a[i]; } for (i = 0; i < 4; i++) { std::cin >> b[i]; } c = 0; d = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i == j && a[i] == b[j]) { c++; } if (i != j && a[i] == b[j]) { d++; } } } std::cout << c << " " << d << std::endl; } return 0; }
[["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
187
2
#include <bits/stdc++.h> #define rep(i, l, n) for (int i = l; i < n; i++) using namespace std; int main() { int a[4], b[4]; while (cin >> a[0]) { int hit = 0, blow = 0; rep(i, 1, 4) cin >> a[i]; rep(i, 0, 4) cin >> b[i]; rep(i, 0, 4) { rep(j, i, 4) { if (a[i] == b[j]) { if (i == j) hit++; else blow++; } } } cout << hit << " " << blow << endl; } }
#include <bits/stdc++.h> #define rep(i, l, n) for (int i = l; i < n; i++) using namespace std; int main() { int a[4], b[4]; while (cin >> a[0]) { int hit = 0, blow = 0; rep(i, 1, 4) cin >> a[i]; rep(i, 0, 4) cin >> b[i]; rep(i, 0, 4) { rep(j, 0, 4) { if (a[i] == b[j]) { if (i == j) hit++; else blow++; } } } cout << hit << " " << blow << endl; } }
[["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
146
2
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <numeric> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, a, b) for (long long int i = (a); i < (b); i++) #define REP(i, n) for (long long int i = 0; i < (n); i++) #define ALL(s) (s).begin(), (s).end() #define PI 3.14159265358479 typedef long long ll; typedef vector<long long int> vi; typedef vector<long long int>::iterator vit; int main() { int h = 0, v = 0; int a[5], b[5]; cin >> a[0] >> a[1] >> a[2] >> a[3]; while (cin >> b[0] >> b[1] >> b[2] >> b[3]) { REP(i, 4) { REP(j, 4) { if (b[i] == a[j]) { v++; if (i == j) { v--; h++; } } } } cout << h << " " << v << endl; h = v = 0; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <numeric> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, a, b) for (long long int i = (a); i < (b); i++) #define REP(i, n) for (long long int i = 0; i < (n); i++) #define ALL(s) (s).begin(), (s).end() #define PI 3.14159265358479 typedef long long ll; typedef vector<long long int> vi; typedef vector<long long int>::iterator vit; int main() { int h = 0, v = 0; int a[5], b[5]; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { REP(i, 4) { REP(j, 4) { if (b[i] == a[j]) { v++; if (i == j) { v--; h++; } } } } cout << h << " " << v << endl; h = v = 0; } }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["-", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 51, 16, 31, 16, 31, 16, 31, 16, 31, 22]]
1
213
6
#include <stdio.h> int main(void) { int a[5], s[5], d, f, g, i, j; while (scanf("%d %d %d %d %d %d %d %d", &a[1], &a[2], &a[3], &a[4], &s[1], &s[2], &s[3], &s[4]) != EOF) { d = 0; f = 0; for (i = 1; i <= 4; i++) { if (a[i] == s[i]) { d++; } if (a[i] != s[i]) { j = 0; while (j <= 5) { if (a[i] == s[j]) { f++; } j++; } } } printf("%d %d\n", d, f); } return 0; }
#include <stdio.h> int main(void) { int a[5], s[5], d, f, g, i, j; while (scanf("%d %d %d %d %d %d %d %d", &a[1], &a[2], &a[3], &a[4], &s[1], &s[2], &s[3], &s[4]) != EOF) { d = 0; f = 0; for (i = 1; i <= 4; i++) { if (a[i] == s[i]) { d++; } if (a[i] != s[i]) { j = 1; while (j < 5) { if (a[i] == s[j]) { f++; } j++; } } } printf("%d %d\n", d, f); } return 0; }
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["-", 64, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 64, 9, 0, 52, 15, 339, 51, 16, 17, 18]]
1
192
4
#include <iostream> using namespace std; int main() { int a[4], b[4]; int hit, blow; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hit = blow = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; } for (int j = 0; i < 4; j++) { if (a[i] == b[j]) { blow++; } } } blow -= hit; cout << hit << " " << blow << endl; } return 0; }
#include <iostream> using namespace std; int main() { int a[4], b[4]; int hit, blow; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hit = blow = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; } for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { blow++; } } } blow -= hit; cout << hit << " " << blow << endl; } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22]]
1
165
2
#include <cstdio> #include <iostream> using namespace std; int main(void) { int a[4]; int b[4]; while ((scanf("%d", a[0])) != EOF) { int hitcount = 0; int bcount = 0; for (int i = 1; i < 4; i++) { scanf("%d", a[i]); } for (int i = 0; i < 4; i++) cin >> b[i]; // a???????????????????????????????´????b????????¢??¢?´¢ for (int i = 0; i < 4; i++) { int x = a[i]; for (int j = 0; j < 4; j++) { if (x == b[j]) { if (i == j) hitcount++; else bcount++; } } } cout << hitcount << " " << bcount << endl; } return 0; }
#include <cstdio> #include <iostream> using namespace std; int main(void) { int a[4]; int b[4]; while ((scanf("%d", &a[0])) != EOF) { int hitcount = 0; int bcount = 0; for (int i = 1; i < 4; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 4; i++) cin >> b[i]; // a???????????????????????????????´????b????????¢??¢?´¢ for (int i = 0; i < 4; i++) { int x = a[i]; for (int j = 0; j < 4; j++) { if (x == b[j]) { if (i == j) hitcount++; else bcount++; } } } cout << hitcount << " " << bcount << endl; } return 0; }
[["+", 31, 23, 0, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
1
186
2
#include <iostream> using namespace std; int main() { int a[4]; int b[4]; while (cin >> a[0]) { int hit = 0, brow = 0; for (int i = 1; i < 4; i++) { cin >> a[i]; } for (int j = 0; j < 4; j++) { cin >> b[j]; } for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { if (a[k] == b[k]) { if (k == l) { hit++; } else { brow++; } } } } cout << hit << " " << brow << endl; } return 0; }
#include <iostream> using namespace std; int main() { int a[4]; int b[4]; while (cin >> a[0]) { int hit = 0, brow = 0; for (int i = 1; i < 4; i++) { cin >> a[i]; } for (int j = 0; j < 4; j++) { cin >> b[j]; } for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { if (a[k] == b[l]) { if (k == l) { hit++; } else { brow++; } } } } cout << hit << " " << brow << endl; } return 0; }
[["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22]]
1
168
2
#include <iostream> #define SIZE 4 using namespace std; int main() { int a[SIZE], b[SIZE], hit, blo; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hit = 0; blo = 0; for (int i = 0; i < SIZE; i++) { if (a[i] == b[i]) { hit++; a[i] = -1; b[i] = -1; } } for (int i = 0; i < SIZE; i++) { for (int j = i + 1; j < SIZE; j++) { if (a[i] == -1 || b[j] == -1) { continue; } if (a[i] == b[j]) { a[i] = -1; b[j] = -1; blo++; } } } cout << hit << " " << blo << endl; } return 0; }
#include <iostream> #define SIZE 4 using namespace std; int main() { int a[SIZE], b[SIZE], hit, blo; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hit = 0; blo = 0; for (int i = 0; i < SIZE; i++) { if (a[i] == b[i]) { hit++; a[i] = -1; b[i] = -1; } } for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { if (a[i] == -1 || b[j] == -1) { continue; } if (a[i] == b[j]) { a[i] = -1; b[j] = -1; blo++; } } } cout << hit << " " << blo << endl; } return 0; }
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
231
4
#include <iostream> using namespace std; int main() { int a[4], b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { int hit_cnt = 0; int blow_cnt = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hit_cnt++; a[i] = b[i] = -1; } } for (int i = 0; i < 4; i++) { if (a[i] == -1) continue; for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { blow_cnt++; a[i] = b[j] = -1; } } } cout << hit_cnt << " " << blow_cnt << endl; } return 0; }
#include <iostream> using namespace std; int main() { int a[4], b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { int hit_cnt = 0; int blow_cnt = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hit_cnt++; a[i] = b[i] = -1; } } for (int i = 0; i < 4; i++) { if (a[i] == -1) continue; for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { blow_cnt++; a[i] = b[j] = -1; break; } } } cout << hit_cnt << " " << blow_cnt << endl; } return 0; }
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
211
2
#include <iostream> using namespace std; int main() { int n = 0; while (cin >> n) { int a[4], b[4]; int hit = 0, blow = 0; a[0] = n; cin >> a[1] >> a[2] >> a[3]; cin >> b[0] >> b[1] >> b[2] >> b[3]; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (i == j && a[i] == b[i]) { ++hit; } else if (a[j] == b[i]) { ++blow; } } } cout << hit << blow << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n = 0; while (cin >> n) { int a[4], b[4]; int hit = 0, blow = 0; a[0] = n; cin >> a[1] >> a[2] >> a[3]; cin >> b[0] >> b[1] >> b[2] >> b[3]; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (i == j && a[i] == b[i]) { ++hit; } else if (a[j] == b[i]) { ++blow; } } } cout << hit << " " << blow << endl; } return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
173
4
#include <iostream> using namespace std; int main() { int a[4] = {0}, b[4] = {0}, hi, br; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hi = 0; br = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hi++; } } for (int i; i < 4; i++) { for (int n; n < 4; n++) { if (i != n && a[i] == b[n]) { br++; } } } cout << hi << " " << br << endl; } }
#include <iostream> using namespace std; int main() { int a[4] = {0}, b[4] = {0}, hi, br; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hi = 0; br = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hi++; } } for (int i = 0; i < 4; i++) { for (int n = 0; n < 4; n++) { if (i != n && a[i] == b[n]) { br++; } } } cout << hi << " " << br << endl; } }
[["+", 8, 9, 0, 7, 10, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
183
4
#include <stdio.h> int main() { int a[4], b[4], x, y; while (scanf("%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { x = y = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) x++; else if (a[i] == b[(i + 1) % 4] || a[i] == b[(i + 2) % 4] || a[i] == b[(i + 3) % 4]) y++; printf("%d %d\n", x, y); } } }
#include <stdio.h> int main() { int a[4], b[4], x, y; while (scanf("%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { x = y = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) x++; else if (a[i] == b[(i + 1) % 4] || a[i] == b[(i + 2) % 4] || a[i] == b[(i + 3) % 4]) y++; } printf("%d %d\n", x, y); } }
[["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46]]
1
187
2
#include <array> #include <iostream> //ヒットの数を数え上げる int checkNumOfHit(std ::array<int, 4> x, std ::array<int, 4> y) { int num = 0; for (int i = 0; i < 4; i++) { if (x.at(i) == y.at(i)) num++; } return num; } //ブローの数を数え上げる int checkNumOfBlow(std ::array<int, 4> x, std ::array<int, 4> y) { int num = 0; for (int i = 0; i < x.size(); i++) { for (int j = 0; j < y.size(); j++) { if ((i != j) && (x.at(i) == y.at(j))) num++; } } return num; } int main() { std ::array<int, 4> a, b; while (std ::cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> b.at(0) >> b.at(1) >> b.at(2) >> b.at(3)) { std ::cout << checkNumOfHit(a, b) << checkNumOfBlow(a, b) << std ::endl; } }
#include <array> #include <iostream> //ヒットの数を数え上げる int checkNumOfHit(std ::array<int, 4> x, std ::array<int, 4> y) { int num = 0; for (int i = 0; i < 4; i++) { if (x.at(i) == y.at(i)) num++; } return num; } //ブローの数を数え上げる int checkNumOfBlow(std ::array<int, 4> x, std ::array<int, 4> y) { int num = 0; for (int i = 0; i < x.size(); i++) { for (int j = 0; j < y.size(); j++) { if ((i != j) && (x.at(i) == y.at(j))) num++; } } return num; } int main() { std ::array<int, 4> a, b; while (std ::cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> b.at(0) >> b.at(1) >> b.at(2) >> b.at(3)) { std ::cout << checkNumOfHit(a, b) << " " << checkNumOfBlow(a, b) << std ::endl; } }
[["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
278
4
#include <array> #include <iostream> int main() { std::array<u_int, 4> a, b; int hit, blow; while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]) { std::cin >> b[0] >> b[1] >> b[2] >> b[3]; hit = 0; blow = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) hit++; for (int j = 0; j < 4; j++) { if (a[i] == b[j]) blow++; } } std::cout << hit << blow - hit << std::endl; } return 0; }
#include <array> #include <iostream> int main() { std::array<u_int, 4> a, b; int hit, blow; while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]) { std::cin >> b[0] >> b[1] >> b[2] >> b[3]; hit = 0; blow = 0; for (int i = 0; i < 4; i++) { if (a[i] == b[i]) hit++; for (int j = 0; j < 4; j++) { if (a[i] == b[j]) blow++; } } std::cout << hit << " " << blow - hit << std::endl; } return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
166
4
#include <iostream> using namespace std; int main() { int a[4], b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3]) { cin >> b[0] >> b[1] >> b[2] >> b[3]; int hit = 0, blow = 0; for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { if (i == j && a[i] == b[j]) hit++; else if (a[i] == b[j]) blow++; } } cout << hit << " " << blow << endl; } }
#include <iostream> using namespace std; int main() { int a[4], b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3]) { cin >> b[0] >> b[1] >> b[2] >> b[3]; int hit = 0, blow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == j && a[i] == b[j]) hit++; else if (a[i] == b[j]) blow++; } } cout << hit << " " << blow << endl; } }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
159
2
#include <iostream> using namespace std; int main() { int a1, a2, a3, a4, b1, b2, b3, b4, h, b; cin >> a1 >> a2 >> a3 >> a4; while (cin >> b1 >> b2 >> b3 >> b4) { h = 0; b = 0; if (a1 == b1) h++; if (a2 == b2) h++; if (a3 == b3) h++; if (a4 == b4) h++; if (a1 == b2 || a1 == b3 || a1 == b4) b++; if (a2 == b3 || a2 == b4 || a2 == b1) b++; if (a3 == b4 || a3 == b1 || a3 == b2) b++; if (a4 == b1 || a4 == b2 || a4 == b3) b++; cout << h << " " << b << endl; } return 0; }
#include <iostream> using namespace std; int main() { int a1, a2, a3, a4, b1, b2, b3, b4, h, b; while (cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4) { h = 0; b = 0; if (a1 == b1) h++; if (a2 == b2) h++; if (a3 == b3) h++; if (a4 == b4) h++; if (a1 == b2 || a1 == b3 || a1 == b4) b++; if (a2 == b3 || a2 == b4 || a2 == b1) b++; if (a3 == b4 || a3 == b1 || a3 == b2) b++; if (a4 == b1 || a4 == b2 || a4 == b3) b++; cout << h << " " << b << endl; } return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["-", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 51, 16, 31, 16, 31, 16, 31, 16, 31, 22]]
1
184
6
#include <stdio.h> int main(void) { int a[4], b[4]; while (scanf("%d %d %d %d\n%d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { int i, j; int hit = 0; for (i = 0; i < 4; ++i) { if (a[i] == b[i]) { ++hit; } } int blow = 0; for (i = 0; i < 9; ++i) { int a_count, b_count; for (j = 0; j < 4; ++j) { if (a[j] == i) { ++a_count; } if (b[j] == i) { ++b_count; } } blow += (a_count < b_count ? a_count : b_count); } blow -= hit; printf("%d %d\n", hit, blow); } return 0; }
#include <stdio.h> int main(void) { int a[4], b[4]; while (scanf("%d %d %d %d\n%d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { int i, j; int hit = 0; for (i = 0; i < 4; ++i) { if (a[i] == b[i]) { ++hit; } } int blow = 0; for (i = 0; i < 10; ++i) { int a_count = 0, b_count = 0; for (j = 0; j < 4; ++j) { if (a[j] == i) { ++a_count; } if (b[j] == i) { ++b_count; } } blow += (a_count < b_count ? a_count : b_count); } blow -= hit; printf("%d %d\n", hit, blow); } return 0; }
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13]]
1
224
6
#include <iostream> #include <vector> using namespace std; int main() { vector<int> a(4), b(4); int hit = 0, blow = 0; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { for (int i = 0; i < 4; i++) { if (a[i] == b[i]) hit++; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) blow++; } } blow -= hit; cout << hit << endl << blow << endl; blow = 0; hit = 0; } }
#include <iostream> #include <vector> using namespace std; int main() { vector<int> a(4), b(4); int hit = 0, blow = 0; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { for (int i = 0; i < 4; i++) { if (a[i] == b[i]) hit++; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) blow++; } } blow -= hit; cout << hit << " " << blow << endl; blow = 0; hit = 0; } }
[["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
183
4
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t**2 n = ( y + 5 ) / 5 n = n.ceil puts n break end
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t**2 n = ( y + 5 ) / 5 n = n.ceil puts n end
[["-", 0, 493, 0, 89, 8, 170, 0, 94, 0, 94]]
4
39
1
while line = gets line = line.to_f t = (line / 9.8) n = (4.9 * t **2 + 5)/5 puts n.round end
while line = gets line = line.to_f t = (line / 9.8) n = ((4.9 * t **2 + 5)/5 +1) puts n.floor end
[["+", 12, 739, 0, 738, 31, 738, 31, 739, 0, 24], ["+", 8, 170, 0, 662, 12, 739, 0, 738, 17, 72], ["+", 8, 170, 0, 662, 12, 739, 0, 738, 12, 612], ["+", 0, 89, 8, 170, 0, 662, 12, 739, 0, 25], ["-", 8, 170, 0, 652, 3, 4, 0, 652, 735, 22], ["+", 8, 170, 0, 652, 3, 4, 0, 652, 735, 22]]
4
34
6
class Problem def exec while l = gets do i = l.to_i res = calc i puts res end end def calc(i) # ?£????????????????????????????????¨???? t = i / 9.8 #?????????????????§??????????????¢????¨???? y = 4.9 * (t ** 2) #??????????????¢????????????????????§???????????°?£???????????????¶????????????????°??????´??°N????±??????? n = ((y + 5) / 5).ceil end end p = Problem.new p.exec
class Problem def exec while l = gets do i = l.to_f res = calc(i) puts res end end def calc(i) # ?£????????????????????????????????¨???? t = i / 9.8 #?????????????????§??????????????¢????¨???? y = 4.9 * (t ** 2) #??????????????¢????????????????????§???????????°?£???????????????¶????????????????°??????´??°N????±??????? n = ((y + 5) / 5).ceil return n end end p = Problem.new p.exec
[["-", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22], ["+", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22], ["+", 8, 170, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 8, 170, 0, 662, 12, 652, 3, 4, 0, 25], ["+", 8, 736, 0, 735, 8, 736, 0, 38, 0, 38], ["+", 0, 735, 8, 736, 0, 38, 0, 4, 0, 22]]
4
67
12
while gets do v = '25.4'.to_f t = v/9.8 y = 4.9*t*t puts ((y+5.0)/5.0).ceil end
while gets do v = $_.to_f t = v/9.8 y = 4.9*t*t puts ((y+5.0)/5.0).ceil end
[["-", 8, 170, 0, 662, 12, 652, 486, 557, 0, 62], ["-", 8, 170, 0, 662, 12, 652, 486, 557, 0, 6], ["+", 0, 89, 8, 170, 0, 662, 12, 652, 486, 744]]
4
35
4
#!/usr/local/bin/ruby while line=gets v=line.to_i t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
#!/usr/local/bin/ruby while line=gets v=line.to_f t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
[["-", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22], ["+", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22]]
4
36
2
import sys,math for l in sys.stdin:print(int(math.ceil(float(l)**2*0.01)+1))
import sys,math for l in sys.stdin:print(int(math.ceil(float(l)**2*0.01020408163265306122448979591837)+1))
[["-", 0, 657, 31, 652, 3, 4, 0, 657, 12, 531], ["+", 0, 657, 31, 652, 3, 4, 0, 657, 12, 531]]
5
32
6
import sys,math for l in sys.stdin:print(int(math.ceil(float(l)**2*0.01)+1))
import sys,math for l in sys.stdin:print(int(math.ceil(float(l)**2/98)+1))
[["-", 0, 657, 31, 652, 3, 4, 0, 657, 17, 48], ["-", 0, 657, 31, 652, 3, 4, 0, 657, 12, 531], ["+", 0, 657, 31, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 657, 31, 652, 3, 4, 0, 657, 12, 612]]
5
32
6
import sys,math for l in sys.stdin:print(int(math.ceil(float(l)**2*0.01)+1))
import sys,math for l in sys.stdin:print(int(math.ceil(float(l)**2/98))+1)
[["-", 0, 657, 31, 652, 3, 4, 0, 657, 17, 48], ["-", 0, 657, 31, 652, 3, 4, 0, 657, 12, 531], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 85], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 31, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
32
6
def get_float(): while True: try: yield float(input()) except EOFError: break v_lis = list(get_float()) for v in v_lis: t = v / 9.8 y = 4.9 * (t**2) _N = (y + 5) / 5 N = int(round(_N)) print(N)
import math def get_float(): while True: try: yield float(input()) except EOFError: break v_lis = list(get_float()) for v in v_lis: t = v / 9.8 y = 4.9 * (t**2) _N = (y + 5) / 5 N = int(math.ceil(_N)) print(N)
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
70
6
import sys for i in sys.stdin: x = list(map(float, i.split())) t = x[0] / 9.8 y = 4.9*(t**2) print(int(round((y + 5)/5)))
import sys for i in sys.stdin: x = list(map(float, i.split())) t = x[0] / 9.8 y = 4.9*(t**2) print(int((y + 5)/5) + 1)
[["-", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
57
5
import math while(1): try: thv = float(input()) except: break for i in range(1, 20): y = 5 * (i-1) t = math.sqrt(y/4.9) v = 9.8 * t if v > thv: print(i) break
import math while(1): try: thv = float(input()) except: break for i in range(1, 1000): y = 5 * (i-1) t = math.sqrt(y/4.9) v = 9.8 * t if v >= thv: print(i) break
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20]]
5
64
4
while True: try: v = float(input()) except: break t = v / 9.8 y = 4.9 * pow(t, 2) N = (y + 5) / 5 print(round(N))
import math while True: try: v = float(input()) except: break t = v / 9.8 y = 4.9 * pow(t, 2) N = (y + 5) / 5 print(math.ceil(N))
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
47
6
import math,sys for e in sys.stdin:print(int(float(input())**2/98+2))
import math,sys for e in sys.stdin:print(int(float(e)**2/98+2))
[["-", 31, 657, 31, 652, 3, 4, 0, 652, 63, 22], ["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 31, 657, 31, 657, 31, 652, 3, 4, 0, 22]]
5
29
4
while True: try: s = float(input()) t = s/9.8 y = 4.9*t**2 n = 1 while 5*(n-1) >= y: n += 1 print(n) except: break
while True: try: s = float(input()) t = s/9.8 y = 4.9*t**2 n = 1 while 5*(n-1) < y: n += 1 print(n) except: break
[["-", 0, 246, 8, 196, 0, 52, 15, 666, 667, 20], ["+", 0, 246, 8, 196, 0, 52, 15, 666, 667, 18]]
5
49
2
import sys,math for v in sys.stdin: print(int(math.ceil(v**2/2/9.8/5))+1)
import sys,math for v in sys.stdin: print(int(math.ceil(float(v)**2/2/9.8/5))+1)
[["+", 31, 657, 31, 657, 31, 657, 31, 652, 63, 22], ["+", 31, 657, 31, 657, 31, 652, 3, 4, 0, 24], ["+", 31, 657, 31, 657, 31, 652, 3, 4, 0, 25]]
5
33
3
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[] sel = new int[4]; int[] esel = new int[4]; while (scan.hasNext()) { for (int i = 0; i < 4; i++) { sel[i] = scan.nextInt(); } Data d = new Data(sel); for (int i = 0; i < 4; i++) { esel[i] = scan.nextInt(); } d.check(esel); } } } class Data { private int[] select = new int[4]; Data(int[] sel) { select = sel; } void check(int[] esel) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { if (i == j) { if (select[i] == esel[j]) { hit++; } } else if (select[i] == esel[j]) { blow++; } } } System.out.println(hit + " " + blow); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[] sel = new int[4]; int[] esel = new int[4]; while (scan.hasNext()) { for (int i = 0; i < 4; i++) { sel[i] = scan.nextInt(); } Data d = new Data(sel); for (int i = 0; i < 4; i++) { esel[i] = scan.nextInt(); } d.check(esel); } } } class Data { private int[] select = new int[4]; Data(int[] sel) { select = sel; } void check(int[] esel) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == j) { if (select[i] == esel[j]) { hit++; } } else if (select[i] == esel[j]) { blow++; } } } System.out.println(hit + " " + blow); } }
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 22], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
276
2
import java.util.*; class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); while (stdIn.hasNext()) { int[] a = new int[4]; int[] b = new int[4]; for (int i = 0; i < 4; i++) { a[i] = stdIn.nextInt(); } for (int i = 0; i < 4; i++) { b[i] = stdIn.nextInt(); } int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { hit++; } else { blow++; } } } } System.out.println(hit + " " + blow); } } }
import java.util.*; class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); while (stdIn.hasNext()) { int[] a = new int[4]; int[] b = new int[4]; for (int i = 0; i < 4; i++) { a[i] = stdIn.nextInt(); } for (int i = 0; i < 4; i++) { b[i] = stdIn.nextInt(); } int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { hit++; } else { blow++; } } } } System.out.println(hit + " " + blow); } } }
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 22], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
208
2
import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str; while ((str = br.readLine()) != null) { String[] s = str.split(" "); String[] t = br.readLine().split(" "); int[] a = new int[4]; int[] b = new int[4]; a[0] = Integer.parseInt(s[0]); a[1] = Integer.parseInt(s[1]); a[2] = Integer.parseInt(s[2]); a[3] = Integer.parseInt(s[3]); b[0] = Integer.parseInt(t[0]); b[1] = Integer.parseInt(t[1]); b[2] = Integer.parseInt(t[2]); b[3] = Integer.parseInt(t[3]); int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { hit++; } else { blow++; } } } } System.out.println(hit + " " + blow); } } }
import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str; while ((str = br.readLine()) != null) { String[] s = str.split(" "); String[] t = br.readLine().split(" "); int[] a = new int[4]; int[] b = new int[4]; a[0] = Integer.parseInt(s[0]); a[1] = Integer.parseInt(s[1]); a[2] = Integer.parseInt(s[2]); a[3] = Integer.parseInt(s[3]); b[0] = Integer.parseInt(t[0]); b[1] = Integer.parseInt(t[1]); b[2] = Integer.parseInt(t[2]); b[3] = Integer.parseInt(t[3]); int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { hit++; } else { blow++; } } } } System.out.println(hit + " " + blow); } } }
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 22], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
321
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a[] = new int[4]; int b[] = new int[4]; while (sc.hasNext()) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { b[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { for (int c = 0; c < 4; c++) { if (i == c) { if (a[i] == b[c]) { blow++; } } else { if (a[i] == b[c]) { hit++; } } } } System.out.println(hit + " " + blow); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a[] = new int[4]; int b[] = new int[4]; while (sc.hasNext()) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { b[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { for (int c = 0; c < 4; c++) { if (i == c) { if (a[i] == b[c]) { blow++; } } else { if (a[i] == b[c]) { hit++; } } } } System.out.println(blow + " " + hit); } } }
[["-", 0, 492, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 492, 3, 4, 0, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22]]
3
223
4
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.stream.Stream; public class Main { public static void main(String[] args) { InputStreamReader inputStreamReader = new InputStreamReader(System.in); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); StringBuilder stringBuilder = new StringBuilder(); try { String dataSet; int[][] intArray = new int[2][4]; int index = 0; while ((dataSet = bufferedReader.readLine()) != null) { if (dataSet.length() == 0) break; String[] stringArray = dataSet.split(" "); intArray[index] = Stream.of(stringArray).mapToInt(Integer::parseInt).toArray(); if (index == 1) { int[] result = hitBlow(intArray[0], intArray[1]); stringBuilder.append(result[0] + " " + result[1] + "\n"); index = 0; } else ++index; } System.out.print(stringBuilder); } catch (IOException e) { e.printStackTrace(); } } static int[] hitBlow(int[] a, int[] n) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { int key = a[i]; for (int j = 0; j < 4; j++) { if (key == n[j]) { if (i == j) { ++hit; } ++blow; } } } int[] result = {hit, blow}; return result; } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.stream.Stream; public class Main { public static void main(String[] args) { InputStreamReader inputStreamReader = new InputStreamReader(System.in); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); StringBuilder stringBuilder = new StringBuilder(); try { String dataSet; int[][] intArray = new int[2][4]; int index = 0; while ((dataSet = bufferedReader.readLine()) != null) { if (dataSet.length() == 0) break; String[] stringArray = dataSet.split(" "); intArray[index] = Stream.of(stringArray).mapToInt(Integer::parseInt).toArray(); if (index == 1) { int[] result = hitBlow(intArray[0], intArray[1]); stringBuilder.append(result[0] + " " + result[1] + "\n"); index = 0; } else ++index; } System.out.print(stringBuilder); } catch (IOException e) { e.printStackTrace(); } } static int[] hitBlow(int[] a, int[] n) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { int key = a[i]; for (int j = 0; j < 4; j++) { if (key == n[j]) { if (i == j) { ++hit; } else { ++blow; } } } } int[] result = {hit, blow}; return result; } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
3
353
3
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); while (s.hasNext()) { int[] a = new int[8]; int[] b = new int[8]; int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) a[i] = s.nextInt(); for (int i = 0; i < 4; i++) { b[i] = s.nextInt(); if (a[i] == b[i]) hit += 1; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == a[j]) blow += 1; } } System.out.println(hit + " " + blow); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); while (s.hasNext()) { int[] a = new int[8]; int[] b = new int[8]; int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) a[i] = s.nextInt(); for (int i = 0; i < 4; i++) { b[i] = s.nextInt(); if (a[i] == b[i]) hit += 1; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j] && i != j) blow += 1; } } System.out.println(hit + " " + blow); } } }
[["-", 0, 57, 15, 15, 0, 16, 12, 504, 516, 22], ["+", 15, 15, 0, 16, 31, 16, 12, 504, 516, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 98], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 22]]
3
208
6
import java.util.*; public class Main { private void doit() { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int[] a = new int[4]; int[] b = new int[4]; for (int i = 0; i < 4; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { b[i] = sc.nextInt(); } int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = i; j < 4; j++) { if (a[i] == b[j]) { if (i == j) hit++; else { blow++; } } } } System.out.println(hit + " " + blow); } } public static void main(String[] args) { Main obj = new Main(); obj.doit(); } }
import java.util.*; public class Main { private void doit() { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int[] a = new int[4]; int[] b = new int[4]; for (int i = 0; i < 4; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < 4; i++) { b[i] = sc.nextInt(); } int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) hit++; else { blow++; } } } } System.out.println(hit + " " + blow); } } public static void main(String[] args) { Main obj = new Main(); obj.doit(); } }
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 22], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
228
2
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int[] a = new int[4]; int hit = 0; int blow = 0; for (int i = 0; i < a.length; i++) { a[i] = scanner.nextInt(); } for (int i = 0; i < a.length; i++) { int b = scanner.nextInt(); for (int j = 0; j < a.length; j++) { if (a[i] == b) { hit++; } else if (a[j] == b) { blow++; } break; } } System.out.println(hit + " " + blow); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int[] a = new int[4]; int hit = 0; int blow = 0; for (int i = 0; i < a.length; i++) { a[i] = scanner.nextInt(); } for (int i = 0; i < a.length; i++) { int b = scanner.nextInt(); for (int j = 0; j < a.length; j++) { if (a[i] == b) { hit++; break; } else if (a[j] == b) { blow++; break; } } } System.out.println(hit + " " + blow); } } }
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["-", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46]]
3
186
4
import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = null; try { List<Integer> dataset = new ArrayList<Integer>(); scan = new Scanner(new InputStreamReader(System.in)); while (scan.hasNext()) { for (int i = 0; i < 8; i++) { dataset.add(scan.nextInt()); } int hit = 0, blow = 0; for (int i = 0; i < 4; i++) { for (int j = 4; j < 8; j++) { if (i == (j - 4)) { if (dataset.get(i) == dataset.get(j)) hit++; } else { if (dataset.get(i) == dataset.get(j)) blow++; } } } System.out.println(hit + " " + blow); } } finally { scan.close(); } } }
import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = null; try { List<Integer> dataset = new ArrayList<Integer>(); scan = new Scanner(new InputStreamReader(System.in)); while (scan.hasNext()) { for (int i = 0; i < 8; i++) { dataset.add(scan.nextInt()); } int hit = 0, blow = 0; for (int i = 0; i < 4; i++) { for (int j = 4; j < 8; j++) { if (i == (j - 4)) { if (dataset.get(i) == dataset.get(j)) hit++; } else { if (dataset.get(i) == dataset.get(j)) blow++; } } } System.out.println(hit + " " + blow); dataset.clear(); } } finally { scan.close(); } } }
[["+", 0, 52, 8, 196, 0, 1, 0, 492, 500, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 0, 131], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
3
236
6
#include <stdio.h> int main(void) { int a1, a2, a3, a4; int b1, b2, b3, b4; while (scanf("%d %d %d %d %d %d %d %d", &a1, &a2, &a3, &a4, &b1, &b2, &b3, &b4) != EOF) { int co = 0, co2 = 0; if (a1 == b1) co++; else if (a1 == b2 || a1 == b3 || a1 == b4) co2++; if (a2 == b2) co++; else if (a2 == b1 || a2 == b3 || a2 == b4) co2++; if (a3 == b3) co++; else if (a3 == b1 || a3 == b2 || a3 == b4) co2++; if (a4 == b4) co++; else if (a4 == b1 || a4 == b2 || a4 == b3) co2++; printf("%d %d", co, co2); } return 0; }
#include <stdio.h> int main(void) { int a1, a2, a3, a4; int b1, b2, b3, b4; while (scanf("%d %d %d %d %d %d %d %d", &a1, &a2, &a3, &a4, &b1, &b2, &b3, &b4) != EOF) { int co = 0, co2 = 0; if (a1 == b1) co++; else if (a1 == b2 || a1 == b3 || a1 == b4) co2++; if (a2 == b2) co++; else if (a2 == b1 || a2 == b3 || a2 == b4) co2++; if (a3 == b3) co++; else if (a3 == b1 || a3 == b2 || a3 == b4) co2++; if (a4 == b4) co++; else if (a4 == b1 || a4 == b2 || a4 == b3) co2++; printf("%d %d\n", co, co2); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
195
1
#include <stdio.h> int main(void) { int a[4], b[4]; int i, j; int hit, blow; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); hit = 0; blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j] && i == j) { hit++; } else if (a[i] == b[j] && i != j) { blow++; } } } } printf("%d %d\n", hit, blow); return (0); }
#include <stdio.h> int main(void) { int a[4], b[4]; int i, j; int hit, blow; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); hit = 0; blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j] && i == j) { hit++; } else if (a[i] == b[j] && i != j) { blow++; } } } printf("%d %d\n", hit, blow); } return (0); }
[["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
0
196
2
#include <math.h> #include <stdio.h> int main() { int i, j, a[4], b[4]; int hit, blow; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); hit = blow = 0; for (i = 0; i < 4; i++) { for (j = i; j < 4; j++) { if (a[i] == b[j]) blow++; } } for (i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; blow--; } } printf("%d %d\n", hit, blow); } return 0; }
#include <math.h> #include <stdio.h> int main() { int i, j, a[4], b[4]; int hit, blow; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); hit = blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j]) blow++; } } for (i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; blow--; } } printf("%d %d\n", hit, blow); } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13]]
0
199
2
#include <stdio.h> int main(void) { int sum1[4], sum2[4]; int i, j, hit, blow; hit = blow = 0; while (scanf("%d%d%d%d\n%d%d%d%d", &sum1[0], &sum1[1], &sum1[2], &sum1[3], &sum2[0], &sum2[1], &sum2[2], &sum2[3]) != EOF) { for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) if (sum1[i] == sum2[j]) blow++; } for (i = 0; i < 4; i++) if (sum1[i] == sum2[i]) hit++; printf("%d %d\n", hit, blow); hit = blow = 0; } return 0; }
#include <stdio.h> int main(void) { int sum1[4], sum2[4]; int i, j, hit, blow; hit = blow = 0; while (scanf("%d%d%d%d\n%d%d%d%d", &sum1[0], &sum1[1], &sum1[2], &sum1[3], &sum2[0], &sum2[1], &sum2[2], &sum2[3]) != EOF) { for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) if (sum1[i] == sum2[j]) blow++; } for (i = 0; i < 4; i++) if (sum1[i] == sum2[i]) hit++; printf("%d %d\n", hit, blow - hit); hit = blow = 0; } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
190
2
#include <stdio.h> int main(void) { int a[5], b[5], i, j, h, bl; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); h = 0; for (i = 0; i < 4; i++) { if (a[i] == b[i]) h++; } bl = 0; for (i = 0; i < 4; i++) { for (j = i; j < 4; j++) { if (a[j] == b[i] && i != j) bl++; } } printf("%d %d\n", h, bl); } return 0; }
#include <stdio.h> int main(void) { int a[5], b[5], i, j, h, bl; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); h = 0; for (i = 0; i < 4; i++) { if (a[i] == b[i]) h++; } bl = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[j] == b[i] && i != j) bl++; } } printf("%d %d\n", h, bl); } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13]]
0
198
2
#include <stdio.h> int main(int argc, const char *argv[]) { int a[4], b[4], i, j, hit = 0, blow = 0; while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { for (i = 0; i < 4; i++) { for (j = i; j < 4; j++) { if (a[i] == b[j]) { if (i == j) hit++; else blow++; } } } printf("%d %d\n", hit, blow); hit = 0; blow = 0; } return 0; }
#include <stdio.h> int main(int argc, const char *argv[]) { int a[4], b[4], i, j, hit = 0, blow = 0; while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) hit++; else blow++; } } } printf("%d %d\n", hit, blow); hit = 0; blow = 0; } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13]]
0
181
2
main() { int q[4], a[4], i, j; while (~scanf("%d%d%d%d", q, q + 1, q + 2, q + 3)) { int h = 0, b = 0; scanf("%d%d%d%d", a, a + 1, a + 2, a + 3); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (q[i] == a[j]) { if (i == j) h++; else b++; } } } printf("%d\n%d\n", h, b); } exit(0); }
main() { int q[4], a[4], i, j; while (~scanf("%d%d%d%d", q, q + 1, q + 2, q + 3)) { int h = 0, b = 0; scanf("%d%d%d%d", a, a + 1, a + 2, a + 3); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (q[i] == a[j]) { if (i == j) h++; else b++; } } } printf("%d %d\n", h, b); } exit(0); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
152
4
#include <stdio.h> int main(void) { int a[4], b[4], i, j, Hit, Blow; while (1) { Hit = 0; Blow = 0; if (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) == EOF) break; scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); for (i = 0; i < 4; i++) { if (a[i] == b[i]) Hit++; } for (i = 0; i < 4; i++) { for (j = i + 1; j < 4; j++) { if (a[i] == b[j]) { Blow++; } } } printf("%d %d\n", Hit, Blow); } return 0; }
#include <stdio.h> int main(void) { int a[4], b[4], i, j, Hit, Blow; while (1) { Hit = 0; Blow = 0; if (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) == EOF) break; scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); for (i = 0; i < 4; i++) { if (a[i] == b[i]) Hit++; } for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j]) { Blow++; } } } printf("%d %d\n", Hit, Blow - Hit); } return 0; }
[["-", 8, 9, 0, 7, 10, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 10, 11, 12, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
204
6
#include <stdio.h> int main(int argc, char *argv[]) { int a[4], b[4], i, j, hit, blow; if (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { hit = blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (b[i] == a[j]) { if (i == j) { hit++; break; } else { blow++; break; } } } } printf("%d %d\n", hit, blow); } return 0; }
#include <stdio.h> int main(int argc, char *argv[]) { int a[4], b[4], i, j, hit, blow; while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) { hit = blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (b[i] == a[j]) { if (i == j) { hit++; break; } else { blow++; break; } } } } printf("%d %d\n", hit, blow); } return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89]]
0
182
2
#include <stdio.h> int main() { int a[4], b[4], hit = 0, blow = 0, i, j; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); // Hit hit = 0; for (i = 0; i < 4; i++) { if (a[i] == b[i]) hit++; } // Blow blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i == j) continue; if (a[i] == b[j]) blow++; } } printf("%d %d", hit, blow); } return 0; }
#include <stdio.h> int main() { int a[4], b[4], hit = 0, blow = 0, i, j; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); // Hit hit = 0; for (i = 0; i < 4; i++) { if (a[i] == b[i]) hit++; } // Blow blow = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i == j) continue; if (a[i] == b[j]) blow++; } } printf("%d %d\n", hit, blow); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
206
1
#include <stdio.h> #define SIZE 4 /* prototype declaration */ int hit(int *a, int *b); int blow(int *a, int *b); int main(int argc, const char *argv[]) { int a[SIZE], b[SIZE]; while (scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]); printf("%d %d\n", hit(a, b), blow(a, b)); } return 0; } int hit(int *a, int *b) { int i, cnt = 0; for (i = 0; i < SIZE; i++) if (a[i] == b[i]) cnt++; return cnt; } int blow(int *a, int *b) { int i, j, cnt = 0; for (i = 0; i < SIZE; i++) for (j = i; j < SIZE; j++) if (a[i] == b[j]) cnt++; return cnt - hit(a, b); }
#include <stdio.h> #define SIZE 4 /* prototype declaration */ int hit(int *a, int *b); int blow(int *a, int *b); int main(int argc, const char *argv[]) { int a[SIZE], b[SIZE]; while (scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]); printf("%d %d\n", hit(a, b), blow(a, b)); } return 0; } int hit(int *a, int *b) { int i, cnt = 0; for (i = 0; i < SIZE; i++) if (a[i] == b[i]) cnt++; return cnt; } int blow(int *a, int *b) { int i, j, cnt = 0; for (i = 0; i < SIZE; i++) for (j = 0; j < SIZE; j++) if (a[i] == b[j]) cnt++; return cnt - hit(a, b); }
[["-", 8, 9, 0, 7, 8, 7, 10, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 7, 10, 11, 12, 13]]
0
273
2
#include <stdio.h> int main() { int a[4], b[4], i, j, hit, blow; while (scanf("%d%d%d%d", a, a + 1, a + 2, a + 3) != EOF) { hit = blow = 0; scanf("%d%d%d%d", b, b + 1, b + 2, b + 3); for (i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; continue; } for (j = 0; j < 4; j++) { if (a[i] == b[j]) blow++; } } printf("%d %d", hit, blow); } return 0; }
#include <stdio.h> int main() { int a[4], b[4], i, j, hit, blow; while (scanf("%d%d%d%d", a, a + 1, a + 2, a + 3) != EOF) { hit = blow = 0; scanf("%d%d%d%d", b, b + 1, b + 2, b + 3); for (i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; continue; } for (j = 0; j < 4; j++) { if (a[i] == b[j]) blow++; } } printf("%d %d\n", hit, blow); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
159
1
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] days = {-1, 30, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] week = {"Sunday", "Monday", "Thuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; while (true) { int m = sc.nextInt(); int d = sc.nextInt(); if (m == 0 && d == 0) break; int sum = 0; for (int i = 1; i <= m - 1; i++) sum += days[i]; sum += m == 1 ? d - 1 : d; sum += 4; System.out.println(week[sum % 7]); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] days = {-1, 30, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] week = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; while (true) { int m = sc.nextInt(); int d = sc.nextInt(); if (m == 0 && d == 0) break; int sum = 0; for (int i = 1; i <= m - 1; i++) sum += days[i]; sum += m == 1 ? d - 1 : d; sum += 4; System.out.println(week[sum % 7]); } } }
[["-", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491], ["+", 0, 503, 49, 200, 51, 518, 0, 5, 0, 491]]
3
198
2
#include <stdio.h> int main() { int nm, nd, i; int M[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { scanf("%d %d", &nm, &nd); if (nm == 0) break; int d = 2; int m; if (0 < nm && nm < 13) { if (0 < nd && nd < M[nm] + 1) { for (i = nm - 1; i > 0; i--) { d += M[i]; } d += nd; if (d % 7 == 0) printf("Momday\n"); if (d % 7 == 1) printf("Tuesmday\n"); if (d % 7 == 2) printf("Wednesday\n"); if (d % 7 == 3) printf("Thursday\n"); if (d % 7 == 4) printf("Friday\n"); if (d % 7 == 5) printf("Saturday\n"); if (d % 7 == 6) printf("Sunday\n"); } } } return 0; }
#include <stdio.h> int main() { int nm, nd, i; int M[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { scanf("%d %d", &nm, &nd); if (nm == 0) break; int d = 2; int m; if (0 < nm && nm < 13) { if (0 < nd && nd < M[nm] + 1) { for (i = nm - 1; i > 0; i--) { d += M[i]; } d += nd; if (d % 7 == 0) printf("Monday\n"); if (d % 7 == 1) printf("Tuesday\n"); if (d % 7 == 2) printf("Wednesday\n"); if (d % 7 == 3) printf("Thursday\n"); if (d % 7 == 4) printf("Friday\n"); if (d % 7 == 5) printf("Saturday\n"); if (d % 7 == 6) printf("Sunday\n"); } } } return 0; }
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
255
4
#include <stdio.h> main() { int mon[12], month, day, day2, i, j; mon[0] = 31; mon[1] = 29; mon[2] = 31; mon[3] = 30; mon[4] = 31; mon[5] = 30; mon[6] = 31; mon[7] = 31; mon[8] = 30; mon[9] = 31; mon[10] = 31; mon[11] = 31; while (1) { scanf("%d %d", &month, &day); if (month == 0 && day == 0) { break; } day2 = 0; for (i = 2; i < month + 1; i++) { day2 += mon[i - 2]; } day2 += day; day2 %= 7; if (day2 == 1) { printf("Thursday\n"); } else if (day2 == 2) { printf("Friday\n"); } else if (day2 == 3) { printf("Saturday\n"); } else if (day2 == 4) { printf("Sunday\n"); } else if (day2 == 5) { printf("Monday\n"); } else if (day2 == 6) { printf("Tuesday\n"); } else if (day2 == 7) { printf("Wednesday\n"); } } return 0; }
#include <stdio.h> main() { int mon[12], month, day, day2, i, j; mon[0] = 31; mon[1] = 29; mon[2] = 31; mon[3] = 30; mon[4] = 31; mon[5] = 30; mon[6] = 31; mon[7] = 31; mon[8] = 30; mon[9] = 31; mon[10] = 30; mon[11] = 31; while (1) { scanf("%d %d", &month, &day); if (month == 0 && day == 0) { break; } day2 = 0; for (i = 2; i < month + 1; i++) { day2 += mon[i - 2]; } day2 += day; day2 %= 7; if (day2 == 1) { printf("Thursday\n"); } else if (day2 == 2) { printf("Friday\n"); } else if (day2 == 3) { printf("Saturday\n"); } else if (day2 == 4) { printf("Sunday\n"); } else if (day2 == 5) { printf("Monday\n"); } else if (day2 == 6) { printf("Tuesday\n"); } else if (day2 == 0) { printf("Wednesday\n"); } } return 0; }
[["-", 0, 30, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 30, 0, 9, 0, 1, 0, 11, 12, 13], ["-", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13]]
0
300
4
#include <stdio.h> int main() { int days[12] = {31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}; int m, d, total; char a[7][10] = {"Thursday", "Friday", "Satuday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (1) { scanf("%d %d", &m, &d); total = 0; if (m == 0 && d == 0) break; if (m != 1) { total += days[m - 2]; } total += d; while (total > 7) { total = total - 7; } printf("%s\n", a[total - 1]); } return 0; }
#include <stdio.h> int main() { int days[12] = {31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}; int m, d, total; char a[7][10] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (1) { scanf("%d %d", &m, &d); total = 0; if (m == 0 && d == 0) break; if (m != 1) { total += days[m - 2]; } total += d; while (total > 7) { total = total - 7; } printf("%s\n", a[total - 1]); } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
174
2
#include <stdio.h> int main() { char *days[7] = {"Monday", "Tuesday", "Wednesday", "Tuesday", "Friday", "Saturday", "Sunday"}; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int i, n, a, b; while (1) { scanf("%d %d", &a, &b); if (!(a || b)) break; n = b; for (i = 1; i < a; i++) n += month[i - 1]; printf("%s\n", days[(n + 2) % 7]); } return 0; }
#include <stdio.h> int main() { char *days[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int i, n, a, b; while (1) { scanf("%d %d", &a, &b); if (!(a || b)) break; n = b; for (i = 1; i < a; i++) n += month[i - 1]; printf("%s\n", days[(n + 2) % 7]); } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
164
2
#include <stdio.h> int main() { int m, d; int days[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; char day[7][9] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (scanf("%d %d", &m, &d), m != 0) { while (--m > 0) d += days[m - 1]; printf("%s\n", day[(d + 2) % 7]); } return 0; }
#include <stdio.h> int main() { int m, d; int days[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; char day[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (scanf("%d %d", &m, &d), m != 0) { while (--m > 0) d += days[m - 1]; printf("%s\n", day[(d + 2) % 7]); } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
0
141
2