buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> using namespace std; int dp[3001][3001]; int main(void) { int N, T, S; int A[3001], B[3001]; int i, j; cin >> N >> T >> S; for (i = 0; i < N; i++) { cin >> A[i] >> B[i]; } for (i = 0; i <= N; i++) { for (j = 0; j <= T; j++) { dp[i][j] = 0; } } int TT; for (i = 0; i < N; i++) { for (j = 0; j <= T; j++) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if (j < S && S < j + B[i]) { TT = S + B[i]; } else { TT = j + B[i]; } if (TT <= T && dp[i + 1][TT] < dp[i][j] + A[i]) { dp[i + 1][TT] = dp[i][j] + A[i]; } } } /*for(i=0;i<N;i++){ for(j=0;j<=T;j++){ cout<<dp[i][j]<<" "; } cout<<endl; }*/ int MAX = -1; for (i = 0; i <= T; i++) { MAX = max(MAX, dp[N - 1][i]); } cout << MAX << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int dp[3001][3001]; int main(void) { int N, T, S; int A[3001], B[3001]; int i, j; cin >> N >> T >> S; for (i = 0; i < N; i++) { cin >> A[i] >> B[i]; } for (i = 0; i <= N; i++) { for (j = 0; j <= T; j++) { dp[i][j] = 0; } } int TT; for (i = 0; i < N; i++) { for (j = 0; j <= T; j++) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if (j < S && S < j + B[i]) { TT = S + B[i]; } else { TT = j + B[i]; } if (TT <= T && dp[i + 1][TT] < dp[i][j] + A[i]) { dp[i + 1][TT] = dp[i][j] + A[i]; } } } /*for(i=0;i<N;i++){ for(j=0;j<=T;j++){ cout<<dp[i][j]<<" "; } cout<<endl; }*/ int MAX = -1; for (i = 0; i <= T; i++) { MAX = max(MAX, dp[N][i]); } cout << MAX << endl; return 0; }
[["-", 0, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
323
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, j) REP((i), 0, (j)) #define REP(i, j, k) for (int i = (j); (i) < (k); ++i) #define BW(a, x, b) ((a) <= (x) && (x) <= (b)) #define ALL(v) (v).begin(), (v).end() #define LENGTHOF(x) (sizeof(x) / sizeof(*(x))) #define AFILL(a, b) fill((int *)a, (int *)(a + LENGTHOF(a)), b) #define MP make_pair #define PB push_back #define F first #define S second #define INF 1 << 30 #define EPS 1e-10 typedef pair<int, int> pi; typedef pair<int, pi> pii; typedef vector<int> vi; typedef queue<int> qi; typedef long long ll; int N, T, S, s[2][3000]; int dp[3001][3001]; int dfs(int n, int t) { // printf("%d %d\n", n,t); if (n == N) return 0; if (dp[n][t] != -1) return dp[n][t]; int res = 0; res = max(res, dfs(n + 1, t)); if (!(t < S && t + s[1][n] > S) && s[1][n] + t <= T) res = max(res, dfs(n + 1, t + s[1][n]) + s[0][n]); else if (t < S && t + s[1][n] > S && S + s[1][n] + 1 <= T) res = max(res, dfs(n + 1, S + s[1][n] + 1) + s[0][n]); return dp[n][t] = res; } int main() { scanf("%d%d%d", &N, &T, &S); rep(i, N) scanf("%d%d", &s[0][i], &s[1][i]); memset(dp, -1, sizeof(dp)); printf("%d\n", dfs(0, 0)); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, j) REP((i), 0, (j)) #define REP(i, j, k) for (int i = (j); (i) < (k); ++i) #define BW(a, x, b) ((a) <= (x) && (x) <= (b)) #define ALL(v) (v).begin(), (v).end() #define LENGTHOF(x) (sizeof(x) / sizeof(*(x))) #define AFILL(a, b) fill((int *)a, (int *)(a + LENGTHOF(a)), b) #define MP make_pair #define PB push_back #define F first #define S second #define INF 1 << 30 #define EPS 1e-10 typedef pair<int, int> pi; typedef pair<int, pi> pii; typedef vector<int> vi; typedef queue<int> qi; typedef long long ll; int N, T, S, s[2][3000]; int dp[3001][3001]; int dfs(int n, int t) { // printf("%d %d\n", n,t); if (n == N) return 0; if (dp[n][t] != -1) return dp[n][t]; int res = 0; res = max(res, dfs(n + 1, t)); if (!(t <= S && t + s[1][n] > S) && s[1][n] + t <= T) res = max(res, dfs(n + 1, t + s[1][n]) + s[0][n]); else if (t <= S && t + s[1][n] > S && S + s[1][n] <= T) res = max(res, dfs(n + 1, S + s[1][n]) + s[0][n]); return dp[n][t] = res; } int main() { scanf("%d%d%d", &N, &T, &S); rep(i, N) scanf("%d%d", &s[0][i], &s[1][i]); memset(dp, -1, sizeof(dp)); printf("%d\n", dfs(0, 0)); return 0; }
[["-", 31, 91, 28, 23, 0, 16, 31, 16, 17, 18], ["+", 31, 91, 28, 23, 0, 16, 31, 16, 17, 19], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 18], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 19], ["-", 15, 339, 51, 16, 12, 16, 31, 16, 17, 72], ["-", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13], ["-", 0, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
445
#include <algorithm> #include <iostream> using namespace std; int main() { int N, T, S, M[3001] = {}; cin >> N >> T >> S; for (int n = 0; n < N; n++) { int mise_fun, mise_time; cin >> mise_fun >> mise_time; for (int t = T; t >= mise_time; t--) if (t <= S || t >= S + mise_time) M[t] = max(M[t], M[t - mise_time] + mise_fun); } cout << *max_element(M + 1, M + T) << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int N, T, S, M[3001] = {}; cin >> N >> T >> S; for (int n = 0; n < N; n++) { int mise_fun, mise_time; cin >> mise_fun >> mise_time; for (int t = T; t >= mise_time; t--) if (t <= S || t >= S + mise_time) M[t] = max(M[t], M[t - mise_time] + mise_fun); } cout << *max_element(M + 1, M + T + 1) << endl; return 0; }
[["+", 12, 66, 28, 2, 3, 4, 0, 16, 17, 72], ["+", 12, 66, 28, 2, 3, 4, 0, 16, 12, 13]]
1
131
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, T, S; cin >> N >> T >> S; vector<int> A(N); vector<int> B(N); vector<int> dp(T + 1, 0); for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; } int ans = 0; for (int n = 0; n < N; n++) { for (int t = T - B[n]; t >= 0; t--) { if (t < S && S < t + B[n]) continue; dp[t] = max(dp[t] + A[n], dp[t + B[n]]); ans = max(ans, dp[t + B[n]]); } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, T, S; cin >> N >> T >> S; vector<int> A(N); vector<int> B(N); vector<int> dp(T + 1, 0); for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; } int ans = 0; for (int n = 0; n < N; n++) { for (int t = T - B[n]; t >= 0; t--) { if (t < S && S < t + B[n]) continue; dp[t + B[n]] = max(dp[t] + A[n], dp[t + B[n]]); ans = max(ans, dp[t + B[n]]); } } cout << ans << endl; return 0; }
[["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 69, 341, 342, 0, 16, 12, 69, 28, 22], ["+", 341, 342, 0, 16, 12, 69, 341, 342, 0, 70], ["+", 341, 342, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 341, 342, 0, 16, 12, 69, 341, 342, 0, 73]]
1
203
#include <bits/stdc++.h> using namespace std; int dp[3001][3001]; int a[3001], b[3001]; int N, T, S; int rec(int idx, int time) { if (idx == N || time == T) return (0); if (~dp[idx][time]) return (dp[idx][time]); int ret = max(rec(idx + 1, time), rec(idx, time + 1)); if ((time + b[idx] <= S || time >= S) && time + b[idx] <= T) { ret = max(ret, rec(idx + 1, time + b[idx]) + a[idx]); } return (dp[idx][time] = ret); } int main() { fill_n(*dp, 3001 * 3001, -1); cin >> N >> T >> S; for (int i = 1; i <= N; i++) { cin >> a[i] >> b[i]; } cout << rec(0, 0) << endl; }
#include <bits/stdc++.h> using namespace std; int dp[3001][3001]; int a[3000], b[3000]; int N, T, S; int rec(int idx, int time) { if (idx == N || time == T) return (0); if (~dp[idx][time]) return (dp[idx][time]); int ret = max(rec(idx + 1, time), rec(idx, time + 1)); if ((time + b[idx] <= S || time >= S) && time + b[idx] <= T) { ret = max(ret, rec(idx + 1, time + b[idx]) + a[idx]); } return (dp[idx][time] = ret); } int main() { fill_n(*dp, 3001 * 3001, -1); cin >> N >> T >> S; for (int i = 0; i < N; i++) { cin >> a[i] >> b[i]; } cout << rec(0, 0) << endl; }
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
237
#include <algorithm> #include <iostream> using namespace std; #define reps(i, j, n) for (int i = (j); i < (n); ++i) #define rep(i, j) reps(i, 0, j) #define INF (1 << 30) int dp[3001][3001]; int main() { int a[3001], b[3001]; int ans = 0, N, T, S; cin >> N >> T >> S; reps(i, 1, N) cin >> a[i] >> b[i]; reps(i, 1, N) reps(j, 1, T + 1) { dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]); int dis = j - b[i]; if (dis >= 0 && (S <= dis || j <= S)) { dp[i][j] = max(dp[i][j], dp[i - 1][dis] + a[i]); } ans = max(dp[i][j], ans); } cout << ans << endl; }
#include <algorithm> #include <iostream> using namespace std; #define reps(i, j, n) for (int i = (j); i < (n); ++i) #define rep(i, j) reps(i, 0, j) #define INF (1 << 30) int dp[3001][3001]; int main() { int a[3001], b[3001]; int ans = 0, N, T, S; cin >> N >> T >> S; reps(i, 1, N + 1) cin >> a[i] >> b[i]; reps(i, 1, N + 1) reps(j, 1, T + 1) { dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]); int dis = j - b[i]; if (dis >= 0 && (S <= dis || j <= S)) { dp[i][j] = max(dp[i][j], dp[i - 1][dis] + a[i]); } ans = max(dp[i][j], ans); } cout << ans << endl; }
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
231
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int main() { int N, T, S, A, B, dp[3001]; for (int i = 0; i <= 3000; i++) dp[i] = 0; cin >> N >> T >> S; for (int i = 0; i < N; i++) { cin >> A >> B; for (int j = T; j >= 0; j--) { if (dp[j] == -1 || (j != S && j + B > S) || j + B > T) continue; dp[j + B] = max(dp[j + B], dp[j] + A); } // puts(""); } int ans = 0; for (int i = T; i >= 0; i--) { ans = max(ans, dp[i]); } printf("%d\n", ans); }
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int main() { int N, T, S, A, B, dp[3001]; for (int i = 0; i <= 3000; i++) dp[i] = 0; cin >> N >> T >> S; for (int i = 0; i < N; i++) { cin >> A >> B; for (int j = T; j >= 0; j--) { if (dp[j] == -1 || (j < S && j + B > S) || j + B > T) continue; dp[j + B] = max(dp[j + B], dp[j] + A); } // puts(""); } int ans = 0; for (int i = T; i >= 0; i--) { ans = max(ans, dp[i]); } printf("%d\n", ans); }
[["-", 31, 16, 12, 23, 0, 16, 31, 16, 17, 79], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 17, 18]]
1
196
#include <bits/stdc++.h> using namespace std; int N, T, S, A[3000], B[3000]; int dp[3010]; int main() { scanf("%d%d%d", &N, &T, &S); for (int i = 0; i < N; i++) scanf("%d%d", &A[i], &B[i]); for (int i = 0; i < N; i++) { for (int j = T; j >= 0; j--) { dp[j] = max(dp[j], dp[j]); if (j - B[i] < 0 || (j > S && j - B[i] < S)) continue; dp[j] = max(dp[j], dp[j - B[i]] + A[i]); } } printf("%d\n", *max_element(dp, dp + T)); return 0; }
#include <bits/stdc++.h> using namespace std; int N, T, S, A[3000], B[3000]; int dp[3010]; int main() { scanf("%d%d%d", &N, &T, &S); for (int i = 0; i < N; i++) scanf("%d%d", &A[i], &B[i]); for (int i = 0; i < N; i++) { for (int j = T; j >= 0; j--) { dp[j] = max(dp[j], dp[j]); if (j - B[i] < 0 || (j > S && j - B[i] < S)) continue; dp[j] = max(dp[j], dp[j - B[i]] + A[i]); } } printf("%d\n", *max_element(dp, dp + T + 1)); return 0; }
[["+", 0, 66, 28, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 66, 28, 2, 3, 4, 0, 16, 12, 13]]
1
211
#include <stdio.h> int a, b, c, d[3001], e[3001], f[3001][3001], i, j, m = 0, k; int main(void) { scanf("%d %d %d", &a, &b, &c); for (i = 0; i < a; i++) { scanf("%d %d", &d[i], &e[i]); } for (i = 0; i <= a; i++) { for (j = 0; j <= b; j++) { f[i][j] = -1; } } f[0][0] = 0; for (i = 0; i < a; i++) { for (j = 0; j <= b; j++) { if (f[i][j] != -1) { if (j < c && c < e[i] + j && b >= c + e[i]) { if (f[i + 1][c + e[i]] < f[i][j] + d[i]) { f[i + 1][c + e[i]] = f[i][j] + d[i]; } if (f[i][j] > f[i + 1][j]) { f[i + 1][j] = f[i][j]; } } else { if (f[i][j] + d[i] > f[i + 1][j + e[i]]) { if (j + e[i] <= b) { f[i + 1][j + e[i]] = f[i][j] + d[i]; } } if (f[i][j] > f[i + 1][j]) { f[i + 1][j] = f[i][j]; } } } } } for (i = 0; i <= b; i++) { if (m < f[a][i]) { m = f[a][i]; } } printf("%d\n", m); return 0; }
#include <stdio.h> int a, b, c, d[3001], e[3001], f[3001][3001], i, j, m = 0, k; int main(void) { scanf("%d %d %d", &a, &b, &c); for (i = 0; i < a; i++) { scanf("%d %d", &d[i], &e[i]); } for (i = 0; i <= a; i++) { for (j = 0; j <= b; j++) { f[i][j] = -1; } } f[0][0] = 0; for (i = 0; i < a; i++) { for (j = 0; j <= b; j++) { if (f[i][j] != -1) { if (j < c && c < e[i] + j) { if (b >= c + e[i]) { if (f[i + 1][c + e[i]] < f[i][j] + d[i]) { f[i + 1][c + e[i]] = f[i][j] + d[i]; } } if (f[i][j] > f[i + 1][j]) { f[i + 1][j] = f[i][j]; } } else { if (f[i][j] + d[i] > f[i + 1][j + e[i]]) { if (j + e[i] <= b) { f[i + 1][j + e[i]] = f[i][j] + d[i]; } } if (f[i][j] > f[i + 1][j]) { f[i + 1][j] = f[i][j]; } } } } } for (i = 0; i <= b; i++) { if (m < f[a][i]) { m = f[a][i]; } } printf("%d\n", m); return 0; }
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 64, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
482
#include <bits/stdc++.h> #define INF (1 << 31) //#define int long long using namespace std; int n, t, s, a[3005], b[3005], dp[3005]; signed main() { cin >> n >> t >> s; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i]; int ans = 0; for (int i = 1; i <= n; ++i) { for (int j = t; 0 < j - b[i]; --j) { int nx = j - b[i]; if ((s <= j) || (nx <= s)) dp[j] = max(dp[j], dp[nx] + a[i]); ans = max(ans, dp[j]); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define INF (1 << 31) //#define int long long using namespace std; int n, t, s, a[3005], b[3005], dp[3005]; signed main() { cin >> n >> t >> s; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i]; int ans = 0; for (int i = 1; i <= n; ++i) { for (int j = t; 0 <= j - b[i]; --j) { int nx = j - b[i]; if ((s <= nx) || (j <= s)) dp[j] = max(dp[j], dp[nx] + a[i]); ans = max(ans, dp[j]); } } cout << ans << endl; return 0; }
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 15, 339, 51, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 23, 0, 16, 12, 22], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 31, 22], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 31, 22]]
1
182
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> using namespace std; int a[100001], b[100001], dp[3001][3001]; int main(void) { int i, j, n, s, t, max, sum, x; scanf("%d %d %d", &n, &t, &s); for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]); for (i = 0; i < n; i++) { for (j = 0; j <= t; j++) { dp[i][j] = -1; } } dp[0][0] = 0; sum = 0; for (i = 0; i < n; i++) { for (j = 0; j <= t; j++) { if (dp[i][j] != -1) { if (j < s && j + b[i] > s) { x = (s - j) + (j + b[i]); x = x - j; } else x = b[i]; if (dp[i + 1][j + x] < dp[i][j] + a[i] && j + x <= t) { dp[i + 1][j + x] = dp[i][j] + a[i]; } if (dp[i + 1][j] < dp[i][j]) dp[i + 1][j] = dp[i][j]; } } } max = -1; for (i = 0; i < t; i++) { if (max < dp[n - 1][i]) max = dp[n - 1][i]; } printf("%d\n", max); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> using namespace std; int a[100001], b[100001], dp[3001][3001]; int main(void) { int i, j, n, s, t, max, sum, x; scanf("%d %d %d", &n, &t, &s); for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]); for (i = 0; i < n; i++) { for (j = 0; j <= t; j++) { dp[i][j] = -1; } } dp[0][0] = 0; sum = 0; for (i = 0; i < n; i++) { for (j = 0; j <= t; j++) { if (dp[i][j] != -1) { if (j < s && j + b[i] > s) { x = (s - j) + (j + b[i]); x = x - j; } else x = b[i]; if (dp[i + 1][j + x] < dp[i][j] + a[i] && j + x <= t) { dp[i + 1][j + x] = dp[i][j] + a[i]; } if (dp[i + 1][j] < dp[i][j]) dp[i + 1][j] = dp[i][j]; } } } max = -1; for (i = 0; i <= t; i++) { if (max < dp[n][i]) max = dp[n][i]; } printf("%d\n", max); return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 12, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
405
#include <algorithm> #include <cstdio> using namespace std; int n, t, s; int markets[3001][2], dp[3001][3001]; int main() { scanf("%d%d%d", &n, &t, &s); for (int i = 1; i <= n; i++) { scanf("%d%d", &markets[i][0], &markets[i][1]); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= t; j++) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); if (j >= markets[i][1]) { if (j < s || j > s && j - markets[i][1] > s) { dp[i][j] = max(dp[i][j], dp[i - 1][j - markets[i][1]] + markets[i][0]); } } } } printf("%d\n", dp[n][t]); return 0; }
#include <algorithm> #include <cstdio> using namespace std; int n, t, s; int markets[3001][2], dp[3001][3001]; int main() { scanf("%d%d%d", &n, &t, &s); for (int i = 1; i <= n; i++) { scanf("%d%d", &markets[i][0], &markets[i][1]); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= t; j++) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); if (j >= markets[i][1]) { if (j <= s || j > s && j - markets[i][1] >= s) { dp[i][j] = max(dp[i][j], dp[i - 1][j - markets[i][1]] + markets[i][0]); } } } } printf("%d\n", dp[n][t]); return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["-", 15, 339, 51, 16, 12, 16, 12, 16, 17, 47], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 17, 20]]
1
260
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int N, T, S; int A[3010]; int B[3010]; int dp[3010][3010]; int main() { cin >> N >> T >> S; for (int i = 0; i < N; i++) cin >> A[i] >> B[i]; for (int i = 0; i < N; i++) { if (i > 0) { for (int j = 0; j <= T; j++) dp[i][j] = max(dp[i][j], dp[i - 1][j]); } for (int j = 0; j < T; j++) { if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]); if (j <= S && j + B[i] > S) continue; if (j + B[i] > T) continue; dp[i + 1][j + B[i]] = max(dp[i + 1][j + B[i]], dp[i][j] + A[i]); } } int ans = 0; for (int i = 0; i <= N; i++) { for (int j = 0; j <= T; j++) { ans = max(ans, dp[i][j]); } } cout << ans << "\n"; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int N, T, S; int A[3010]; int B[3010]; int dp[3010][3010]; int main() { cin >> N >> T >> S; for (int i = 0; i < N; i++) cin >> A[i] >> B[i]; for (int i = 0; i < N; i++) { if (i > 0) { for (int j = 0; j <= T; j++) dp[i][j] = max(dp[i][j], dp[i - 1][j]); } for (int j = 0; j < T; j++) { if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]); if (j < S && j + B[i] > S) continue; if (j + B[i] > T) continue; dp[i + 1][j + B[i]] = max(dp[i + 1][j + B[i]], dp[i][j] + A[i]); } } int ans = 0; for (int i = 0; i <= N; i++) { for (int j = 0; j <= T; j++) { ans = max(ans, dp[i][j]); } } cout << ans << "\n"; return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18]]
1
339
#include <algorithm> #include <cstdio> using namespace std; int a[3000], b[3000]; int dp[5000]; int main() { int n, t, s; scanf("%d%d%d", &n, &t, &s); for (int i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]); int res = 0; for (int i = 0; i < n; i++) { for (int j = t - b[i]; j >= 0; j--) { if (i > s && s > i - b[i]) continue; dp[j + b[i]] = max(dp[j + b[i]], dp[j] + a[i]); res = max(res, dp[j + b[i]]); } } printf("%d\n", res); }
#include <algorithm> #include <cstdio> using namespace std; int a[3000], b[3000]; int dp[5000]; int main() { int n, t, s; scanf("%d%d%d", &n, &t, &s); for (int i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]); int res = 0; for (int i = 0; i < n; i++) { for (int j = t - b[i]; j >= 0; j--) { if (j < s && s < j + b[i]) continue; dp[j + b[i]] = max(dp[j + b[i]], dp[j] + a[i]); res = max(res, dp[j + b[i]]); } } printf("%d\n", res); }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["-", 15, 339, 51, 16, 12, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 12, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 17, 72]]
1
206
#include <algorithm> #include <cstdio> #include <vector> using namespace std; class Market { public: int time; int cost; Market() {} Market(int _time, int _cost) { time = _time; cost = _cost; } }; int n, t, s; vector<Market> market; const int INF = 1000000; int dp[3001][3001]; void debug() { printf("|----|"); for (int j = 0; j <= t; j++) { printf("|-%2d-", j); } puts(""); for (int i = 0; i <= n; i++) { printf("|-%2d-|", i); for (int j = 0; j <= t; j++) { printf("|%3d ", dp[i][j]); } puts(""); } puts(""); } int main() { scanf("%d %d %d", &n, &t, &s); int a, b; market.push_back(Market(0, 0)); for (int i = 0; i < n; i++) { scanf("%d %d", &b, &a); market.push_back(Market(a, b)); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= s; j++) { if (market[i].time > j) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); } else { dp[i][j] = max(dp[i - 1][j - market[i].time] + market[i].cost, max(dp[i - 1][j], dp[i][j - 1])); } } } // debug(); for (int i = 1; i <= n; i++) { for (int j = s + 1; j <= t; j++) { if (j - market[i].time > s) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); } else { dp[i][j] = max(dp[i - 1][j - market[i].time] + market[i].cost, max(dp[i - 1][j], dp[i][j - 1])); } } } // debug(); printf("%d\n", dp[n][t - 1]); }
#include <algorithm> #include <cstdio> #include <vector> using namespace std; class Market { public: int time; int cost; Market() {} Market(int _time, int _cost) { time = _time; cost = _cost; } }; int n, t, s; vector<Market> market; const int INF = 1000000; int dp[3001][3001]; void debug() { printf("|----|"); for (int j = 0; j <= t; j++) { printf("|-%2d-", j); } puts(""); for (int i = 0; i <= n; i++) { printf("|-%2d-|", i); for (int j = 0; j <= t; j++) { printf("|%3d ", dp[i][j]); } puts(""); } puts(""); } int main() { scanf("%d %d %d", &n, &t, &s); int a, b; market.push_back(Market(0, 0)); for (int i = 0; i < n; i++) { scanf("%d %d", &b, &a); market.push_back(Market(a, b)); } /* for(int i=0;i<=n;i++){ printf("%d:%d,%d\n",i,market[i].time,market[i].cost); } */ for (int i = 1; i <= n; i++) { for (int j = 1; j <= s; j++) { if (market[i].time > j) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); } else { dp[i][j] = max(dp[i - 1][j - market[i].time] + market[i].cost, max(dp[i - 1][j], dp[i][j - 1])); } } } // debug(); for (int i = 1; i <= n; i++) { for (int j = s + 1; j <= t; j++) { if (j - market[i].time < s) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); } else { dp[i][j] = max(dp[i - 1][j - market[i].time] + market[i].cost, max(dp[i - 1][j], dp[i][j - 1])); } } } // debug(); printf("%d\n", dp[n][t]); }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
564
#include <algorithm> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n, T, S; scanf("%d%d%d", &n, &T, &S); int a[3000], b[3000]; rep(i, n) scanf("%d%d", a + i, b + i); static int dp[3001][3001]; rep(i, n + 1) dp[0][i] = 0; for (int t = 1; t <= T; t++) rep(i, n + 1) { // 何もせずに t 秒すごす dp[t][i] = dp[t - 1][i]; if (i > 0) { // 夜店 i を見逃す dp[t][i] = max(dp[t][i], dp[t - 1][i - 1]); // 夜店 i で遊ぶ if (t - b[i - 1] >= 0 && !(t - b[i - 1] < S && S < t)) { dp[t][i] = max(dp[t][i], dp[t - b[i - 1]][i - 1] + a[i - 1]); } } } printf("%d\n", dp[T][n]); return 0; }
#include <algorithm> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n, T, S; scanf("%d%d%d", &n, &T, &S); int a[3000], b[3000]; rep(i, n) scanf("%d%d", a + i, b + i); // dp[t][i+1] := ( 時刻 t で夜店 0..i だけを考えたときの満足度 ) static int dp[3001][3001]; rep(i, n + 1) dp[0][i] = 0; for (int t = 1; t <= T; t++) rep(i, n + 1) { // 何もせずに 1 秒すごす dp[t][i] = dp[t - 1][i]; if (i > 0) { // 夜店 i を見逃す dp[t][i] = max(dp[t][i], dp[t][i - 1]); // 夜店 i で遊ぶ if (t - b[i - 1] >= 0 && !(t - b[i - 1] < S && S < t)) { dp[t][i] = max(dp[t][i], dp[t - b[i - 1]][i - 1] + a[i - 1]); } } } printf("%d\n", dp[T][n]); return 0; }
[["-", 0, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
286
// AOJ 0574 #include <iostream> #include <map> #define REP(i, x) for (int i = 0; i < (x); i++) #define TRI(a, b) nails[1 + (((a)-1) * ((a) + 4)) / 2 + 1 + (b)] using namespace std; typedef pair<int, int> P; const int NMAX = 5008; int nails[NMAX * (NMAX + 1) / 2]; int N, M; void put(int a, int b, int x) { TRI(a, b)++; TRI(a, b + 1)--; TRI(a + x - 1, b)--; TRI(a + x, b + 1)++; TRI(a + x - 1, b + x)++; TRI(a + x, b + x)--; } int count() { int sum = 0; for (int a = 1; a <= N; a++) { for (int b = 1; b <= a; b++) { if (TRI(a, b) > 0) { sum++; } } } return sum; } void accumulate() { for (int a = 1; a <= N; a++) for (int b = 1; b <= a + 1; b++) TRI(a + 1, b) += TRI(a, b); for (int a = 1; a <= N; a++) for (int b = 1; b <= a + 1; b++) TRI(a + 1, b + 1) += TRI(a, b); for (int a = 1; a <= N; a++) for (int b = 1; b <= a + 1; b++) TRI(a, b + 1) += TRI(a, b); } int main() { cin >> N >> M; REP(i, M) { int a, b, x; cin >> a >> b >> x; put(a, b, x + 1); } accumulate(); cout << count() << endl; }
// AOJ 0574 #include <iostream> #include <map> #define REP(i, x) for (int i = 0; i < (x); i++) #define TRI(a, b) nails[1 + (((a)-1) * ((a) + 4)) / 2 + 1 + (b)] using namespace std; typedef pair<int, int> P; const int NMAX = 5008; int nails[NMAX * (NMAX + 1) / 2]; int N, M; void put(int a, int b, int x) { TRI(a, b)++; TRI(a, b + 1)--; TRI(a + x - 1, b)--; TRI(a + x, b + 1)++; TRI(a + x - 1, b + x)++; TRI(a + x, b + x)--; } /* void show() { REP(a,N+1) { REP(b,a+2) { cout << TRI(a,b); } cout << endl; } }*/ int count() { int sum = 0; for (int a = 1; a <= N; a++) { for (int b = 1; b <= a; b++) { if (TRI(a, b) > 0) { sum++; } } } return sum; } void accumulate() { // show(); for (int a = 1; a <= N; a++) for (int b = 1; b <= a + 1; b++) TRI(a + 1, b) += TRI(a, b); // show(); for (int a = 1; a <= N; a++) for (int b = 1; b <= a + 1; b++) TRI(a + 1, b + 1) += TRI(a, b); // show(); for (int a = 1; a <= N; a++) for (int b = 1; b <= a + 1; b++) TRI(a, b + 1) += TRI(a, b); // show(); } int main() { cin >> N >> M; REP(i, M) { int a, b, x; cin >> a >> b >> x; put(a, b, x + 2); } accumulate(); cout << count() << endl; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
407
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int N, M; int dp[5010][5010]; int main() { cin >> N >> M; for (int i = 0; i < M; i++) { int a, b, x; cin >> a >> b >> x; dp[a - 1][b - 1] = max(dp[a - 1][b - 1], x + 1); } for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { dp[i + 1][j] += max(dp[i + 1][j], dp[i][j] - 1); dp[i + 1][j + 1] += max(dp[i + 1][j + 1], dp[i][j] - 1); } } int ans = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { ans += dp[i][j] != 0; } } cout << ans << "\n"; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int N, M; int dp[5010][5010]; int main() { cin >> N >> M; for (int i = 0; i < M; i++) { int a, b, x; cin >> a >> b >> x; dp[a - 1][b - 1] = max(dp[a - 1][b - 1], x + 1); } for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - 1); dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - 1); } } int ans = 0; for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { ans += dp[i][j] != 0; } } cout << ans << "\n"; return 0; }
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
264
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int member = in.nextInt(); int sum, cnt = 0; int[][] num = new int[member][3]; for (int i = 0; i < member; i++) { for (int j = 0; j < 3; j++) { num[i][j] = in.nextInt(); } } for (int k = 0; k < 3; k++) { for (int i = 0; i < member; i++) { for (int j = 0; j < member; j++) { if (i == j) { if (j == 4) break; else j++; } if (num[i][k] == num[j][k]) { num[j][k] = 0; cnt++; } if (cnt > 0) num[i][k] = 0; } cnt = 0; } } for (int i = 0; i < member; i++) { sum = num[i][0] + num[i][1] + num[i][2]; System.out.println(sum); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int member = in.nextInt(); int sum, cnt = 0; int[][] num = new int[member][3]; for (int i = 0; i < member; i++) { for (int j = 0; j < 3; j++) { num[i][j] = in.nextInt(); } } for (int k = 0; k < 3; k++) { for (int i = 0; i < member; i++) { for (int j = 0; j < member; j++) { if (i == j) { if (j == member - 1) break; else j++; } if (num[i][k] == num[j][k]) { num[j][k] = 0; cnt++; } } if (cnt > 0) num[i][k] = 0; cnt = 0; } } for (int i = 0; i < member; i++) { sum = num[i][0] + num[i][1] + num[i][2]; System.out.println(sum); } } }
[["-", 64, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46]]
3
285
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // INPUT int n = sc.nextInt(); if (2 > n && n < 200) System.exit(-1); int[][] arr = new int[n][3]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { arr[i][j] = sc.nextInt(); } } // PROCESSING int[][] work = new int[n][3]; int[] sum = new int[n]; for (int i = 0; i < n; i++) { sum[i] = 0; } for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { work[j][i] = arr[j][i]; for (int k = 0; k < n; k++) { if (j != k && arr[j][i] == arr[k][i]) { work[k][i] = 0; } } } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { sum[i] += work[i][j]; } } // OUTPUT for (int i = 0; i < n; i++) System.out.println(sum[i]); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // INPUT int n = sc.nextInt(); if (2 > n && n < 200) System.exit(-1); int[][] arr = new int[n][3]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { arr[i][j] = sc.nextInt(); } } // PROCESSING int[][] work = new int[n][3]; int[] sum = new int[n]; for (int i = 0; i < n; i++) { sum[i] = 0; } for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { work[j][i] = arr[j][i]; for (int k = 0; k < n; k++) { if (j != k && arr[j][i] == arr[k][i]) { work[j][i] = 0; } } } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { sum[i] += work[i][j]; } } // OUTPUT for (int i = 0; i < n; i++) System.out.println(sum[i]); } }
[["-", 0, 1, 0, 11, 31, 504, 516, 504, 71, 22], ["+", 0, 1, 0, 11, 31, 504, 516, 504, 71, 22]]
3
346
#include <math.h> #include <stdio.h> int main() { int n, i, k, j, o, flag = 0; scanf("%d", &n); int data[n][3], copy_data[n][3], sum[n]; for (i = 0; i < n; i++) { sum[i] = 0; for (k = 0; k < 3; k++) { scanf("%d", &data[i][k]); } } for (i = 0; i < n; i++) { for (k = 0; k < 3; k++) { for (j = i + 1; j < n; j++) { if (data[i][k] == data[j][k]) { data[j][k] = 0; flag = 1; } if (flag == 1) { data[i][k] = 0; flag = 0; } } } } for (i = 0; i < n; i++) { for (k = 0; k < 3; k++) { sum[i] += data[i][k]; } } for (i = 0; i < n; i++) { printf("%d\n", sum[i]); } return 0; }
#include <math.h> #include <stdio.h> int main() { int n, i, k, j, o, flag = 0; scanf("%d", &n); int data[n][3], copy_data[n][3], sum[n]; for (i = 0; i < n; i++) { sum[i] = 0; for (k = 0; k < 3; k++) { scanf("%d", &data[i][k]); } } for (i = 0; i < n; i++) { for (k = 0; k < 3; k++) { for (j = i + 1; j < n; j++) { if (data[i][k] == data[j][k]) { data[j][k] = 0; flag = 1; } } if (flag == 1) { data[i][k] = 0; flag = 0; } } } for (i = 0; i < n; i++) { for (k = 0; k < 3; k++) { sum[i] += data[i][k]; } } for (i = 0; i < n; i++) { printf("%d\n", sum[i]); } return 0; }
[["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
0
287
#include <stdio.h> int main() { int n, i, j, k, flag = 0; scanf("%d\n", &n); int score[n][3]; int result[n][3]; for (i = 0; i < n; i++) { scanf("%d %d %d\n", &score[n][0], &score[n][1], &score[n][2]); } for (i = 0; i < n; i++) { for (k = 0; k < 3; k++) { for (j = 0; j < n; j++) { if (i != j && score[i][k] == score[j][k]) flag = 1; } if (flag == 0) { result[i][k] = score[i][k]; } else { result[i][k] = 0; flag = 0; } } } for (i = 0; i < n; i++) { printf("%d\n", result[i][0] + result[i][1] + result[i][2]); } return 0; }
#include <stdio.h> int main() { int n, i, j, k, flag = 0; scanf("%d\n", &n); int score[n][3]; int result[n][3]; for (i = 0; i < n; i++) { scanf("%d %d %d\n", &score[i][0], &score[i][1], &score[i][2]); } for (i = 0; i < n; i++) { for (k = 0; k < 3; k++) { for (j = 0; j < n; j++) { if (i != j && score[i][k] == score[j][k]) flag = 1; } if (flag == 0) { result[i][k] = score[i][k]; } else { result[i][k] = 0; flag = 0; } } } for (i = 0; i < n; i++) { printf("%d\n", result[i][0] + result[i][1] + result[i][2]); } return 0; }
[["-", 3, 4, 0, 66, 28, 69, 28, 69, 71, 22], ["+", 3, 4, 0, 66, 28, 69, 28, 69, 71, 22]]
0
262
#include <stdio.h> #include <string.h> int main(void) { int number = 0; int i = 0; int j = 0; int input_first[200] = {0}; int input_second[200] = {0}; int input_third[200] = {0}; int check_num = 0; int result[200]; int count = 0; scanf("%d", &number); while (i < number) { scanf("%d", &input_first[i]); scanf("%d", &input_second[i]); scanf("%d", &input_third[i]); i++; } i = 0; while (i < number) { j = 0; check_num = input_first[i]; while (j < number) { if (i == j) { j++; continue; } if (check_num == input_first[j]) { input_first[j] = 0; input_first[i] = 0; } j++; } check_num = input_second[i]; j = 0; while (j < number) { if (i == j) { j++; continue; } if (check_num == input_second[j]) { input_second[j] = 0; input_second[i] = 0; } j++; } check_num = input_third[i]; j = 0; while (j < number) { if (i == j) { j++; continue; } if (check_num == input_third[j]) { input_third[j] = 0; input_third[i] = 0; } j++; } i++; } for (i = 0; i < number; i++) { result[i] += input_first[i]; result[i] += input_second[i]; result[i] += input_third[i]; } for (i = 0; i < number; i++) { printf("%d\n", result[i]); } return 0; }
#include <stdio.h> #include <string.h> int main(void) { int number = 0; int i = 0; int j = 0; int input_first[200] = {0}; int input_second[200] = {0}; int input_third[200] = {0}; int check_num = 0; int result[200] = {0}; int count = 0; scanf("%d", &number); while (i < number) { scanf("%d", &input_first[i]); scanf("%d", &input_second[i]); scanf("%d", &input_third[i]); i++; } i = 0; while (i < number) { j = 0; check_num = input_first[i]; while (j < number) { if (i == j) { j++; continue; } if (check_num == input_first[j]) { input_first[j] = 0; input_first[i] = 0; } j++; } check_num = input_second[i]; j = 0; while (j < number) { if (i == j) { j++; continue; } if (check_num == input_second[j]) { input_second[j] = 0; input_second[i] = 0; } j++; } check_num = input_third[i]; j = 0; while (j < number) { if (i == j) { j++; continue; } if (check_num == input_third[j]) { input_third[j] = 0; input_third[i] = 0; } j++; } i++; } for (i = 0; i < number; i++) { result[i] += input_first[i]; result[i] += input_second[i]; result[i] += input_third[i]; } for (i = 0; i < number; i++) { printf("%d\n", result[i]); } return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
0
403
#include <stdio.h> #include <string.h> int main(void) { int number = 0; int i = 0; int j = 0; int input_first[200] = {0}; int input_second[200] = {0}; int input_third[200] = {0}; int check_num = 0; int result[200]; int count = 0; scanf("%d", &number); while (i < number) { scanf("%d", &input_first[i]); scanf("%d", &input_second[i]); scanf("%d", &input_third[i]); i++; } i = 0; while (i < number) { j = 0; check_num = input_first[i]; while (j < number) { if (i == j) { j++; if (j == number) { result[i] += input_first[i]; break; } continue; } if (check_num == input_first[j]) { break; } j++; if (j == number) { result[i] += input_first[i]; break; } } check_num = input_second[i]; j = 0; while (j < number) { if (i == j) { j++; if (j == number) { result[i] += input_second[i]; break; } continue; } if (check_num == input_second[j]) { break; } j++; if (j == number) { result[i] += input_second[i]; break; } } check_num = input_third[i]; j = 0; while (j < number) { if (i == j) { j++; if (j == number) { result[i] += input_third[i]; break; } continue; } if (check_num == input_third[j]) { break; } j++; if (j == number) { result[i] += input_third[i]; break; } } i++; } for (i = 0; i < number; i++) { printf("%d\n", result[i]); } return 0; }
#include <stdio.h> #include <string.h> int main(void) { int number = 0; int i = 0; int j = 0; int input_first[200] = {0}; int input_second[200] = {0}; int input_third[200] = {0}; int check_num = 0; int result[200] = {0}; int count = 0; scanf("%d", &number); while (i < number) { scanf("%d", &input_first[i]); scanf("%d", &input_second[i]); scanf("%d", &input_third[i]); i++; } i = 0; while (i < number) { j = 0; check_num = input_first[i]; while (j < number) { if (i == j) { j++; if (j == number) { result[i] += input_first[i]; break; } continue; } if (check_num == input_first[j]) { break; } j++; if (j == number) { result[i] += input_first[i]; break; } } check_num = input_second[i]; j = 0; while (j < number) { if (i == j) { j++; if (j == number) { result[i] += input_second[i]; break; } continue; } if (check_num == input_second[j]) { break; } j++; if (j == number) { result[i] += input_second[i]; break; } } check_num = input_third[i]; j = 0; while (j < number) { if (i == j) { j++; if (j == number) { result[i] += input_third[i]; break; } continue; } if (check_num == input_third[j]) { break; } j++; if (j == number) { result[i] += input_third[i]; break; } } i++; } for (i = 0; i < number; i++) { printf("%d\n", result[i]); } return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
0
442
#include <stdio.h> int main(void) { int n, p[200][3], t[200], i, j, k, flg; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d %d", &p[i][0], &p[i][1], &p[i][2]); t[i] = 0; } for (i = 0; i < 3; i++) { for (j = 0; j < n; i++) { flg = 1; for (k = 0; k < n; k++) { if (p[j][i] == p[k][i] && j != k) { flg = 0; break; } } if (flg == 1) { t[j] += p[j][i]; } } } for (i = 0; i < n; i++) { printf("%d\n", t[i]); } return 0; }
#include <stdio.h> int main(void) { int n, p[200][3], t[200], i, j, k, flg; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d %d", &p[i][0], &p[i][1], &p[i][2]); t[i] = 0; } for (i = 0; i < 3; i++) { for (j = 0; j < n; j++) { flg = 1; for (k = 0; k < n; k++) { if (p[j][i] == p[k][i] && j != k) { flg = 0; break; } } if (flg == 1) { t[j] += p[j][i]; } } } for (i = 0; i < n; i++) { printf("%d\n", t[i]); } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22]]
0
230
/*??°???????????????(Unique number)*/ #include <stdio.h> int main() { int i, k, l, x, N; int data[200][3]; int sum[200]; scanf("%d", &N); for (i = 0; i < N; i++) { for (k = 0; k < 3; k++) { scanf("%d", &data[i][k]); } } for (i = 0; i < N; i++) { for (k = 0; k < 3; k++) { x = 0; for (l = 0; l < N; l++) { if (data[i][k] == data[l][k] && i != l) { x++; } } if (x == 0) { sum[i] += data[i][k]; } } } for (i = 0; i < N; i++) { printf("%d\n", sum[i]); } return 0; }
/*??°???????????????(Unique number)*/ #include <stdio.h> int main() { int i, k, l, x, N; int data[200][3]; int sum[200] = {0}; scanf("%d", &N); for (i = 0; i < N; i++) { for (k = 0; k < 3; k++) { scanf("%d", &data[i][k]); } } for (i = 0; i < N; i++) { for (k = 0; k < 3; k++) { x = 0; for (l = 0; l < N; l++) { if (data[i][k] == data[l][k] && i != l) { x++; } } if (x == 0) { sum[i] += data[i][k]; } } } for (i = 0; i < N; i++) { printf("%d\n", sum[i]); } return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
0
219
#include <stdio.h> int main() { int n, i, j, k; int sub[200][3], score[200][3], total[200] = {0}; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) { scanf("%d", sub[i][j]); score[i][j] = sub[i][j]; } } for (i = 0; i < 3; i++) { for (j = 0; j < n; j++) { for (k = j + 1; k < n; k++) { if (sub[j][i] == sub[k][i]) { score[j][i] = 0; score[k][i] = 0; } } } } for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) { total[i] += score[i][j]; } printf("%d\n", total[i]); } return 0; }
#include <stdio.h> int main() { int n, i, j, k; int sub[200][3], score[200][3], total[200] = {0}; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) { scanf("%d", &sub[i][j]); score[i][j] = sub[i][j]; } } for (i = 0; i < 3; i++) { for (j = 0; j < n; j++) { for (k = j + 1; k < n; k++) { if (sub[j][i] == sub[k][i]) { score[j][i] = 0; score[k][i] = 0; } } } } for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) { total[i] += score[i][j]; } printf("%d\n", total[i]); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
260
#include <stdio.h> int main(void) { int a[3][201] = {0}; int b[222] = {0}; int c[3][1001] = {0}; int n, i, j, x, y; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) { scanf("%d", &a[j][i]); c[j][a[j][i]]++; } } for (i = 0; i < 3; i++) { for (j = 0; j < n; j++) { if (c[i][a[i][j]] != 2) { b[j] += a[i][j]; } } } for (i = 0; i < n; i++) { printf("%d\n", b[i]); } }
#include <stdio.h> int main(void) { int a[3][201] = {0}; int b[222] = {0}; int c[3][1001] = {0}; int n, i, j, x, y; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) { scanf("%d", &a[j][i]); c[j][a[j][i]]++; } } for (i = 0; i < 3; i++) { for (j = 0; j < n; j++) { if (c[i][a[i][j]] < 2) { b[j] += a[i][j]; } } } for (i = 0; i < n; i++) { printf("%d\n", b[i]); } }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
0
218
#include <math.h> #include <stdio.h> int main() { int num, a[200][3], i, j, score[200], h, k; scanf("%d", &num); for (i = 0; i < num; i++) { for (j = 0; j < 3; j++) scanf("%d", &a[i][j]); score[i] = 0; } for (i = 0; i < 3; i++) { for (j = 0; j < num; j++) { h = 0; for (k = 0; k < num; k++) { if (j == k) continue; if (a[j] == a[k]) { h = 1; break; } } if (h == 0) score[j] += a[j][i]; } } for (i = 0; i < num; i++) printf("%d\n", score[i]); return 0; }
#include <math.h> #include <stdio.h> int main() { int num, a[200][3], i, j, score[200], h, k; scanf("%d", &num); for (i = 0; i < num; i++) { for (j = 0; j < 3; j++) scanf("%d", &a[i][j]); score[i] = 0; } for (i = 0; i < 3; i++) { for (j = 0; j < num; j++) { h = 0; for (k = 0; k < num; k++) { if (j == k) continue; if (a[j][i] == a[k][i]) { h = 1; break; } } if (h == 0) score[j] += a[j][i]; } } for (i = 0; i < num; i++) printf("%d\n", score[i]); return 0; }
[["+", 0, 57, 15, 23, 0, 16, 31, 69, 0, 70], ["+", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 69, 0, 73], ["+", 15, 23, 0, 16, 12, 69, 28, 69, 0, 73], ["+", 0, 57, 15, 23, 0, 16, 12, 69, 0, 70], ["+", 0, 57, 15, 23, 0, 16, 12, 69, 71, 22]]
0
220
#include <stdio.h> int main(void) { int input[200][3]; int N, i, j; scanf("%d", &N); //人数を入力 for (i = 0; i < N; i++) scanf("%d%d%d", &input[i][0], &input[i][1], &input[i][2]); for (i = 0; i < N; i++) { int hantei[3] = {1, 1, 1}; for (j = 1; j < N; j++) { if (i != j) { if (input[i][0] == input[j][0]) hantei[0] = 0; if (input[i][1] == input[j][1]) hantei[1] = 0; if (input[i][2] == input[j][2]) hantei[2] = 0; } } printf("%d\n", input[i][0] * hantei[0] + input[i][1] * hantei[1] + input[i][2] * hantei[2]); } return 0; }
#include <stdio.h> int main(void) { int input[200][3]; int N, i, j; scanf("%d", &N); //人数を入力 for (i = 0; i < N; i++) scanf("%d%d%d", &input[i][0], &input[i][1], &input[i][2]); for (i = 0; i < N; i++) { int hantei[3] = {1, 1, 1}; for (j = 0; j < N; j++) { if (i != j) { if (input[i][0] == input[j][0]) hantei[0] = 0; if (input[i][1] == input[j][1]) hantei[1] = 0; if (input[i][2] == input[j][2]) hantei[2] = 0; } } printf("%d\n", input[i][0] * hantei[0] + input[i][1] * hantei[1] + input[i][2] * hantei[2]); } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13]]
1
260
#include <stdio.h> int main(void) { int n; int i, j; int a[1000], b[1000], c[1000]; int a1[1000], b1[1000], c1[1000]; int sum[1000]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d %d", &a[i], &b[i], &c[i]); a1[i] = a[i]; b1[i] = b[i]; c1[i] = c[i]; } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (a[i] == a[j] && i != j) { a1[i] = 0; } if (b[i] == b[j] && i != j) { b1[i] = 0; } if (c[i] == c[j] && i != j) { c1[i] = 0; } } } for (i = 0; i < n; i++) { sum[i] += (a1[i] + b1[i] + c1[i]); printf("%d\n", sum[i]); } return 0; }
#include <stdio.h> int main(void) { int n; int i, j; int a[1000], b[1000], c[1000]; int a1[1000], b1[1000], c1[1000]; int sum[1000]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d %d", &a[i], &b[i], &c[i]); a1[i] = a[i]; b1[i] = b[i]; c1[i] = c[i]; } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (a[i] == a[j] && i != j) { a1[i] = 0; } if (b[i] == b[j] && i != j) { b1[i] = 0; } if (c[i] == c[j] && i != j) { c1[i] = 0; } } } for (i = 0; i < n; i++) { sum[i] = (a1[i] + b1[i] + c1[i]); printf("%d\n", sum[i]); } return 0; }
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32]]
1
293
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int result[200] = {0}; int main() { int member; cin >> member; int time1[200], time2[200], time3[200]; for (int i = 0; i < member; i++) { cin >> time1[i] >> time2[i] >> time3[i]; } int sign[200] = {0}; for (int i = 0; i < member; i++) { for (int a = 0; a < member; a++) { if (time1[i] == time1[a]) { sign[i]++; } } if (sign[i] == 1) result[i] = time1[i]; } int sign2[200] = {0}; for (int i = 0; i < member; i++) { for (int a = 0; a < member; a++) { if (time2[i] == time2[a]) { sign2[i]++; } } if (sign2[i] == 1) result[i] = time2[i]; } int sign3[200] = {0}; for (int i = 0; i < member; i++) { for (int a = 0; a < member; a++) { if (time3[i] == time3[a]) { sign3[i]++; } } if (sign3[i] == 1) result[i] = time3[i]; } for (int i = 0; i < member; i++) cout << result[i] << endl; cin >> result[123]; }
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int result[200] = {0}; int main() { int member; cin >> member; int time1[200], time2[200], time3[200]; for (int i = 0; i < member; i++) { cin >> time1[i] >> time2[i] >> time3[i]; } int sign[200] = {0}; for (int i = 0; i < member; i++) { for (int a = 0; a < member; a++) { if (time1[i] == time1[a]) { sign[i]++; } } if (sign[i] == 1) result[i] += time1[i]; } int sign2[200] = {0}; for (int i = 0; i < member; i++) { for (int a = 0; a < member; a++) { if (time2[i] == time2[a]) { sign2[i]++; } } if (sign2[i] == 1) result[i] += time2[i]; } int sign3[200] = {0}; for (int i = 0; i < member; i++) { for (int a = 0; a < member; a++) { if (time3[i] == time3[a]) { sign3[i]++; } } if (sign3[i] == 1) result[i] += time3[i]; } for (int i = 0; i < member; i++) cout << result[i] << endl; cin >> result[123]; }
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107]]
1
355
#include <iostream> using namespace std; int a[1000], b[1000], c[1000], p[3][1000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> p[j][i]; } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 1000; j++) a[j] = 0; for (int j = 0; j < n; j++) { b[j] = p[i][j]; a[b[j]]++; } for (int j = 0; j < n; j++) { if (a[b[j]] == 1) c[j]++; } } for (int i = 0; i < n; i++) cout << c[i] << endl; return 0; }
#include <iostream> using namespace std; int a[1000], b[1000], c[1000], p[3][1000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> p[j][i]; } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 1000; j++) a[j] = 0; for (int j = 0; j < n; j++) { b[j] = p[i][j]; a[b[j]]++; } for (int j = 0; j < n; j++) { if (a[b[j]] == 1) c[j] += b[j]; } } for (int i = 0; i < n; i++) cout << c[i] << endl; return 0; }
[["-", 8, 9, 0, 57, 64, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 1, 0, 11, 12, 69, 28, 22], ["+", 64, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 64, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 64, 1, 0, 11, 12, 69, 341, 342, 0, 73]]
1
220
#include <iostream> using namespace std; int main(void) { int n; cin >> n; int a[200][3], cnt[101][3]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cnt[i][j] = 0; } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { int s; cin >> s; a[i][j] = s; cnt[s][j]++; } } for (int i = 0; i < n; i++) { int res = 0; for (int j = 0; j < 3; j++) { int s = a[i][j]; if (cnt[s][j] == 1) res += s; } cout << res << endl; } return 0; }
#include <iostream> using namespace std; int main(void) { int n; cin >> n; int a[200][3], cnt[101][3]; for (int i = 0; i < 101; i++) { for (int j = 0; j < 3; j++) { cnt[i][j] = 0; } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { int s; cin >> s; a[i][j] = s; cnt[s][j]++; } } for (int i = 0; i < n; i++) { int res = 0; for (int j = 0; j < 3; j++) { int s = a[i][j]; if (cnt[s][j] == 1) res += s; } cout << res << endl; } return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
210
#include <cstdio> #include <iostream> #include <map> using namespace std; const int N = 222; int main() { int n; cin >> n; int board[N][3] = {0}; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> board[i][j]; } } int ans[N] = {0}; for (int i = 0; i < 3; i++) { map<int, int> memo; for (int j = 0; j < n; j++) { memo[board[j][i]]++; } for (int j = 0; j < n; j++) { int t = board[j][i]; int k = (memo[t] == 1) ? t : 0; ans[j] += k; } } for (int i = 0; i < 5; i++) { printf("%d\n", ans[i]); } }
#include <cstdio> #include <iostream> #include <map> using namespace std; const int N = 222; int main() { int n; cin >> n; int board[N][3] = {0}; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> board[i][j]; } } int ans[N] = {0}; for (int i = 0; i < 3; i++) { map<int, int> memo; for (int j = 0; j < n; j++) { memo[board[j][i]]++; } for (int j = 0; j < n; j++) { int t = board[j][i]; int k = (memo[t] == 1) ? t : 0; ans[j] += k; } } for (int i = 0; i < n; i++) { printf("%d\n", ans[i]); } }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
225
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <typeinfo> #include <vector> #define syosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<double, double> pdd; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<P> vp; typedef vector<vp> vvp; typedef pair<int, P> pip; typedef vector<pip> vip; const int inf = 1 << 28; const ll INF = 1ll << 60; const double pi = acos(-1); const double eps = 1e-10; const ll mod = 1e9 + 7; const vi emp; const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, -0}; const int DX[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, DY[8] = {1, 0, -1, 1, -1, 1, 0, -1}; int n; int main() { cin >> n; vvi a(3, vi(101, -1)); for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) { int x; cin >> x; if (a[j][x] != -1 || a[j][x] == -2) a[j][x] = -2; else a[j][x] = i; } vi ans(n); for (int i = 0; i < 3; i++) for (int j = 0; j < 101; j++) { if (a[i][j] > 0) ans[a[i][j]] += j; } for (int i = 0; i < n; i++) cout << ans[i] << endl; }
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <typeinfo> #include <vector> #define syosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<double, double> pdd; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<P> vp; typedef vector<vp> vvp; typedef pair<int, P> pip; typedef vector<pip> vip; const int inf = 1 << 28; const ll INF = 1ll << 60; const double pi = acos(-1); const double eps = 1e-10; const ll mod = 1e9 + 7; const vi emp; const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, -0}; const int DX[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, DY[8] = {1, 0, -1, 1, -1, 1, 0, -1}; int n; int main() { cin >> n; vvi a(3, vi(101, -1)); for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) { int x; cin >> x; if (a[j][x] != -1 || a[j][x] == -2) a[j][x] = -2; else a[j][x] = i; } vi ans(n); for (int i = 0; i < 3; i++) for (int j = 0; j < 101; j++) { if (a[i][j] >= 0) ans[a[i][j]] += j; } for (int i = 0; i < n; i++) cout << ans[i] << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
481
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 1 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; \ } #define dumpc(o) \ if (DBG) { \ cerr << #o; \ for (auto &e : (o)) \ cerr << " " << e; \ cerr << endl; \ } #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++) #define all(c) c.begin(), c.end() const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9 + 7); signed main() { int n; cin >> n; vector<vector<int>> v(n, vector<int>(3)); rep(i, 0, n) rep(j, 0, 3) cin >> v[i][j]; vector<int> ans(n, 0); rep(i, 0, 3) { vector<int> t(150, 0); rep(j, 0, n) { t[v[j][i]]++; } rep(j, 0, n) { if (t[v[j][i]] == 1) ans[j] += v[j][i]; } } rep(i, 0, 5) { cout << ans[i] << endl; } return 0; }
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 1 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; \ } #define dumpc(o) \ if (DBG) { \ cerr << #o; \ for (auto &e : (o)) \ cerr << " " << e; \ cerr << endl; \ } #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++) #define all(c) c.begin(), c.end() const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9 + 7); signed main() { int n; cin >> n; vector<vector<int>> v(n, vector<int>(3)); rep(i, 0, n) rep(j, 0, 3) cin >> v[i][j]; vector<int> ans(n, 0); rep(i, 0, 3) { vector<int> t(150, 0); rep(j, 0, n) { t[v[j][i]]++; } rep(j, 0, n) { if (t[v[j][i]] == 1) ans[j] += v[j][i]; } } rep(i, 0, n) { cout << ans[i] << endl; } return 0; }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
273
#include <iostream> using namespace std; int main() { int n, h = 0, h1 = 0, h2 = 0; cin >> n; int ans[n], p[n], p1[n], p2[n]; for (int i = 0; i < n; i++) ans[i] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { if (j == 0) cin >> p[i]; else if (j == 1) cin >> p1[i]; else cin >> p2[i]; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (p[i] == p[j]) { p[j] = 0; h = 1; } if (p1[i] == p1[j]) { p1[j] = 0; h1 = 1; } if (p2[i] == p2[j]) { p2[j] = 0; h2 = 1; } if (h == 1) { p[i] = 0; h = 0; } if (h1 == 1) { p1[i] = 0; h1 = 0; } if (h2 == 1) { p2[i] = 0; h2 = 0; } } } for (int i = 0; i < n; i++) ans[i] = p[i] + p1[i] + p2[i]; for (int i = 0; i < n; i++) cout << ans[i] << endl; return 0; }
#include <iostream> using namespace std; int main() { int n, h = 0, h1 = 0, h2 = 0; cin >> n; int ans[n], p[n], p1[n], p2[n]; for (int i = 0; i < n; i++) ans[i] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { if (j == 0) cin >> p[i]; else if (j == 1) cin >> p1[i]; else cin >> p2[i]; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (p[i] == p[j]) { p[j] = 0; h = 1; } if (p1[i] == p1[j]) { p1[j] = 0; h1 = 1; } if (p2[i] == p2[j]) { p2[j] = 0; h2 = 1; } } if (h == 1) { p[i] = 0; h = 0; } if (h1 == 1) { p1[i] = 0; h1 = 0; } if (h2 == 1) { p2[i] = 0; h2 = 0; } } for (int i = 0; i < n; i++) ans[i] = p[i] + p1[i] + p2[i]; for (int i = 0; i < n; i++) cout << ans[i] << endl; return 0; }
[["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
366
#include <cstring> #include <iostream> using namespace std; int main() { int n; cin >> n; int po[201][3], a[201] = {0}; int ch[101][3]; memset(ch, 0, sizeof(ch)); for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> po[i][j]; ch[j][po[i][j]]++; } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { if (ch[j][po[i][j]] < 2) a[i] += po[i][j]; } } for (int i = 0; i < n; i++) cout << a[i] << endl; }
#include <cstring> #include <iostream> using namespace std; int main() { int n; cin >> n; int po[201][3], a[201] = {0}; int ch[3][101]; memset(ch, 0, sizeof(ch)); for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> po[i][j]; ch[j][po[i][j]]++; } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { if (ch[j][po[i][j]] < 2) a[i] += po[i][j]; } } for (int i = 0; i < n; i++) cout << a[i] << endl; }
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
203
#include <iostream> using namespace std; int main() { int n, game[201][3], flg, sum[201]; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> game[i][j]; } } for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { flg = 0; for (int k = j + 1; k < n; k++) { if (game[j][i] == game[k][i]) { game[k][i] = 0; flg++; } } if (flg != 0) { game[j][i] = 0; } } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { sum[i] += game[i][j]; } } for (int i = 0; i < n; i++) { cout << sum[i] << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, game[201][3], flg, sum[201] = {}; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> game[i][j]; } } for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { flg = 0; for (int k = j + 1; k < n; k++) { if (game[j][i] == game[k][i]) { game[k][i] = 0; flg++; } } if (flg != 0) { game[j][i] = 0; } } } for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { sum[i] += game[i][j]; } } for (int i = 0; i < n; i++) { cout << sum[i] << endl; } return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
1
254
N = gets.to_i arr = Array.new(){ Array.new() } score = Array.new(N) { |i| i=0 } while (line = gets) do arr << line.split.map(&:to_i) end arr = arr.transpose arr.each_with_index { |a,n| a.each_with_index { |num, i| a.delete_at(i); score[i] += num if !a.index(num); a.insert(i, num) }} p score
N = gets.to_i arr = Array.new(){ Array.new() } score = Array.new(N) { |i| i=0 } while (line = gets) do arr << line.split.map(&:to_i) end arr = arr.transpose arr.each_with_index { |a,n| a.each_with_index { |num, i| a.delete_at(i); score[i] += num if !a.index(num); a.insert(i, num) }} puts score
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22]]
4
111
n = int(input()) lst = [list(map(int,input().split())) for i in range(n)] p = [0 for i in range(n)] for i in range(3): dic = [[] for _ in range(101)] for j in range(n): print(lst) dic[lst[j][i]].append(j) for x in range(101): l = dic[x] if lst: if len(l) == 1: p[l[0]] += x for i in p: print(i)
n = int(input()) lst = [list(map(int,input().split())) for i in range(n)] p = [0 for i in range(n)] for i in range(3): dic = [[] for _ in range(101)] for j in range(n): dic[lst[j][i]].append(j) for x in range(101): l = dic[x] if lst: if len(l) == 1: p[l[0]] += x for i in p: print(i)
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
137
import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; public class Main { static final InputStream in = System.in; static final PrintWriter out = new PrintWriter(System.out); static final int INF = Integer.MAX_VALUE / 2; static final long LINF = Long.MAX_VALUE / 2; static int n; static String str; public static void main(String[] args) throws IOException { InputReader ir = new InputReader(in); n = ir.nextInt(); str = ir.next(); int len = str.length(); int cnt = 0; lo1: while (n-- > 0) { String old = ir.next(); lo2: for (int i = 0; i <= old.length() - len; i++) { if (str.charAt(i) != old.charAt(0)) continue; lo3: for (int j = 1;; j++) { if (i + (len - 1) * j >= old.length()) continue lo2; for (int k = 0; k < len; k++) { if (str.charAt(i + j * k) != old.charAt(k)) continue lo3; if (k == len - 1) { cnt++; continue lo1; } } } } } out.println(cnt); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; } public int readByte() { if (lenbuf == -1) throw new InputMismatchException(); if (curbuf >= lenbuf) { curbuf = 0; try { lenbuf = in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while ((b = readByte()) != -1 && isSpaceChar(b)) ; return b; } public String next() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int nextInt() { int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public long nextLong() { int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public int[] toIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } } }
import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; public class Main { static final InputStream in = System.in; static final PrintWriter out = new PrintWriter(System.out); static final int INF = Integer.MAX_VALUE / 2; static final long LINF = Long.MAX_VALUE / 2; static int n; static String str; public static void main(String[] args) throws IOException { InputReader ir = new InputReader(in); n = ir.nextInt(); str = ir.next(); int len = str.length(); int cnt = 0; lo1: while (n-- > 0) { String old = ir.next(); lo2: for (int i = 0; i <= old.length() - len; i++) { if (old.charAt(i) != str.charAt(0)) continue; lo3: for (int j = 1;; j++) { if (i + (len - 1) * j >= old.length()) continue lo2; for (int k = 0; k < len; k++) { if (old.charAt(i + j * k) != str.charAt(k)) continue lo3; if (k == len - 1) { cnt++; continue lo1; } } } } } out.println(cnt); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; } public int readByte() { if (lenbuf == -1) throw new InputMismatchException(); if (curbuf >= lenbuf) { curbuf = 0; try { lenbuf = in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while ((b = readByte()) != -1 && isSpaceChar(b)) ; return b; } public String next() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int nextInt() { int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public long nextLong() { int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public int[] toIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } } }
[["-", 0, 57, 15, 15, 0, 16, 31, 492, 500, 22], ["+", 0, 57, 15, 15, 0, 16, 31, 492, 500, 22], ["-", 0, 57, 15, 15, 0, 16, 12, 492, 500, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 492, 500, 22]]
3
862
// include---------------------------------------------------------------------------------------------------------------------- #include <bits/stdc++.h> // using // namespace-------------------------------------------------------------------------------------------------------------- using namespace std; // define----------------------------------------------------------------------------------------------------------------------- #define rep(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, s, n) for (int i = s; i < (int)n; i++) #define per(i, n) for (int i = n; i >= 0; i--) #define ROF(i, s, n) for (int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define MP make_pair #define EACH(i, n) \ for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i) #define SZ(a) int((a).size()) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cout << #x << " = " << (x) << "\n"; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << "\n"; #define sq(n) (n) * (n) // typedef---------------------------------------------------------------------------------------------------------------------- typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef unsigned int uint; typedef unsigned long long ull; typedef priority_queue<int> maxpq; typedef priority_queue<int, vector<int>, greater<int>> minpq; // const------------------------------------------------------------------------------------------------------------------------ static const double EPS = 1e-10; static const double PI = acos(-1.0); static const int mod = 1000000007; static const int INF = 1 << 25; static const LL LL_INF = 1152921504606846976; // global----------------------------------------------------------------------------------------------------------------------- int n, m, ans = 0; string ar; string str; //#define DEBUG // int dp[200000000][] int main() { scanf("%d", &n); cin >> str; ar.resize(n); for (int i = 0; i < n; i++) { cin >> ar; while (ar.size() >= str.size() && str[0] != ar[0]) { ar = ar.substr(1, ar.size() - 1); } while (ar.size() >= str.size() && str[str.size() - 1] != ar[ar.size() - 1]) { ar = ar.substr(0, ar.size() - 1); } if (ar.size() < str.size()) { continue; } for (int j = 0; j < ar.size(); j++) { if (ar[j] == str[0]) { bool d = true; for (int k = j + 1; k < ar.size(); k++) { if (ar[k] == str[1]) { for (int e = 0; e < str.size(); e++) { if (j + e * (k - j) >= ar.size()) { d = false; break; } if (ar[j + e * (k - j)] != str[e]) { d = false; break; } } if (d) { break; } } } if (d) { // debug( ar ); ans++; break; } } } } printf("%d\n", ans); return 0; }
// include---------------------------------------------------------------------------------------------------------------------- #include <bits/stdc++.h> // using // namespace-------------------------------------------------------------------------------------------------------------- using namespace std; // define----------------------------------------------------------------------------------------------------------------------- #define rep(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, s, n) for (int i = s; i < (int)n; i++) #define per(i, n) for (int i = n; i >= 0; i--) #define ROF(i, s, n) for (int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define MP make_pair #define EACH(i, n) \ for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i) #define SZ(a) int((a).size()) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define CLR(a) memset((a), 0, sizeof(a)) #define dump(x) cout << #x << " = " << (x) << "\n"; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << "\n"; #define sq(n) (n) * (n) // typedef---------------------------------------------------------------------------------------------------------------------- typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef unsigned int uint; typedef unsigned long long ull; typedef priority_queue<int> maxpq; typedef priority_queue<int, vector<int>, greater<int>> minpq; // const------------------------------------------------------------------------------------------------------------------------ static const double EPS = 1e-10; static const double PI = acos(-1.0); static const int mod = 1000000007; static const int INF = 1 << 25; static const LL LL_INF = 1152921504606846976; // global----------------------------------------------------------------------------------------------------------------------- int n, m, ans = 0; string ar; string str; //#define DEBUG // int dp[200000000][] int main() { scanf("%d", &n); cin >> str; ar.resize(n); for (int i = 0; i < n; i++) { cin >> ar; while (ar.size() >= str.size() && str[0] != ar[0]) { ar = ar.substr(1, ar.size() - 1); } while (ar.size() >= str.size() && str[str.size() - 1] != ar[ar.size() - 1]) { ar = ar.substr(0, ar.size() - 1); } if (ar.size() < str.size()) { continue; } for (int j = 0; j < ar.size(); j++) { if (ar[j] == str[0]) { bool d = false; for (int k = j + 1; k < ar.size(); k++) { if (ar[k] == str[1]) { d = true; for (int e = 0; e < str.size(); e++) { if (j + e * (k - j) >= ar.size()) { d = false; break; } if (ar[j + e * (k - j)] != str[e]) { d = false; break; } } if (d) { break; } } } if (d) { // debug( ar ); ans++; break; } } } } printf("%d\n", ans); return 0; }
[["-", 0, 57, 64, 9, 0, 43, 49, 50, 51, 146], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 51, 147], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 146], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
618
#include <iostream> #include <string> int main() { int n; std::cin >> n; std::string str; std::cin >> str; int res = 0; for (int i = 0; i < n; i++) { std::string sign; std::cin >> sign; for (int j = 0; j < sign.size(); j++) { if (sign[j] == str[0]) { for (int k = j + 1; k < sign.size(); k++) { if (sign[k] == str[1]) { int aida = k - j; bool flg = true; for (int l = 1; l <= str.size() - 2; l++) { if (k + aida * l >= sign.size() || sign[k + aida * l] != sign[l + 1]) flg = false; } if (flg) { res++; goto next; } } } } } next:; } std::cout << res << std::endl; return 0; }
#include <iostream> #include <string> int main() { int n; std::cin >> n; std::string str; std::cin >> str; int res = 0; for (int i = 0; i < n; i++) { std::string sign; std::cin >> sign; for (int j = 0; j < sign.size(); j++) { if (sign[j] == str[0]) { for (int k = j + 1; k < sign.size(); k++) { if (sign[k] == str[1]) { int aida = k - j; bool flg = true; for (int l = 1; l <= str.size() - 2; l++) { if (k + aida * l >= sign.size() || sign[k + aida * l] != str[l + 1]) flg = false; } if (flg) { res++; goto next; } } } } } next:; } std::cout << res << std::endl; return 0; }
[["-", 15, 339, 51, 16, 12, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 16, 12, 69, 28, 22]]
1
228
#include <stdio.h> #include <string.h> int main(void) { int N; char shop_name[100]; char old_board[200]; int cut_i, cut_j, cut_k; int count; int board_num; int len; int shop_len; int hantei1, hantei2; scanf("%d", &N); scanf("%s", shop_name); shop_len = strlen(shop_name); count = 0; for (board_num = 0; board_num < N; board_num++) { scanf("%s", old_board); len = strlen(old_board); hantei1 = 0; for (cut_i = 0; cut_i < len; cut_i++) { for (cut_j = 1; cut_j < len; cut_j++) { if (cut_i + cut_j * (shop_len - 1) >= len) break; hantei2 = 1; for (cut_k = 0; cut_k < shop_len && hantei1; cut_k++) { if (old_board[cut_i + cut_j * cut_k] != shop_name[cut_k]) hantei2 = 0; } if (hantei2) hantei1 = 1; } } if (hantei1) count++; } printf("%d\n", count); return 0; }
#include <stdio.h> #include <string.h> int main(void) { int N; char shop_name[100]; char old_board[200]; int cut_i, cut_j, cut_k; int count; int board_num; int len; int shop_len; int hantei1, hantei2; scanf("%d", &N); scanf("%s", shop_name); shop_len = strlen(shop_name); count = 0; for (board_num = 0; board_num < N; board_num++) { scanf("%s", old_board); len = strlen(old_board); hantei1 = 0; for (cut_i = 0; cut_i < len; cut_i++) { for (cut_j = 1; cut_j < len; cut_j++) { if (cut_i + cut_j * (shop_len - 1) >= len) break; hantei2 = 1; for (cut_k = 0; cut_k < shop_len && hantei2; cut_k++) { if (old_board[cut_i + cut_j * cut_k] != shop_name[cut_k]) hantei2 = 0; } if (hantei2) hantei1 = 1; } } if (hantei1) count++; } printf("%d\n", count); return 0; }
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
230
#include <iostream> #include <stdlib.h> #include <string.h> #include <vector> using namespace std; int main() { int n; cin >> n; char storeName[25 + 1]; cin >> storeName; int storeNameLen = strlen(storeName); int canMake = 0; for (int i = 0; i < n; i++) { char board[100 + 1]; cin >> board; int boardLen = strlen(board); vector<int> *charlist = new vector<int>[2]; for (int j = 0; j < 2; j++) { for (int k = 0; board[k] != '\0'; k++) { if (board[k] == storeName[j]) charlist[j].push_back(k); } } if (charlist[0].size() > 0 && charlist[1].size() > 0) { bool isExist = false; for (int j = 0; j < charlist[0].size(); j++) { for (int k = 0; k < charlist[1].size(); k++) { if (charlist[1][k] > charlist[0][j]) { int interval = charlist[1][k] - charlist[0][j]; int pos = charlist[1][k]; bool allSame = true; for (int l = 2; l < storeNameLen; l++) { pos += interval; if (pos > boardLen) break; if (board[pos] != storeName[l]) { allSame = false; break; } } if (allSame) { isExist = true; canMake++; break; } } } if (isExist) break; } } } cout << canMake << endl; return 0; }
#include <iostream> #include <stdlib.h> #include <string.h> #include <vector> using namespace std; int main() { int n; cin >> n; char storeName[25 + 1]; cin >> storeName; int storeNameLen = strlen(storeName); int canMake = 0; for (int i = 0; i < n; i++) { char board[100 + 1]; cin >> board; int boardLen = strlen(board); vector<int> *charlist = new vector<int>[2]; for (int j = 0; j < 2; j++) { for (int k = 0; board[k] != '\0'; k++) { if (board[k] == storeName[j]) charlist[j].push_back(k); } } if (charlist[0].size() > 0 && charlist[1].size() > 0) { bool isExist = false; for (int j = 0; j < charlist[0].size(); j++) { for (int k = 0; k < charlist[1].size(); k++) { if (charlist[1][k] > charlist[0][j]) { int interval = charlist[1][k] - charlist[0][j]; int pos = charlist[1][k]; bool allSame = true; for (int l = 2; l < storeNameLen; l++) { pos += interval; if (pos > boardLen || board[pos] != storeName[l]) { allSame = false; break; } } if (allSame) { isExist = true; canMake++; break; } } } if (isExist) break; } } } cout << canMake << endl; return 0; }
[["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25], ["-", 0, 7, 8, 9, 0, 57, 64, 93, 0, 94], ["-", 0, 7, 8, 9, 0, 57, 64, 93, 0, 35], ["-", 64, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106]]
1
371
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) { string t; cin >> t; for (int i = 0; i < s.size(); i++) { //テ・ツ按敕」ツつ?」ツ?ョテヲツ鳴?・ツュツ? if (s[0] != t[i]) continue; // cout << i << " " << endl; for (int j = 1; i + 1 + (s.size() - 1) * j <= t.size(); j++) { //テゥツ鳴禿ゥツ堋? for (int k = 1; k < s.size(); k++) { // 2テヲツ鳴?・ツュツ療ァツ崢ョテ、ツサツ・テゥツ卍? // cout << " " << i + j*k; if (s[k] != t[i + j * k]) break; if (k == s.size() - 1) { cnt++; i = s.size(); j = i + 1 + (s.size() - 1) * j + 1; break; } } // cout << endl; } // cout << endl; } } cout << cnt << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) { string t; cin >> t; for (int i = 0; i < t.size(); i++) { //テ・ツ按敕」ツつ?」ツ?ョテヲツ鳴?・ツュツ? if (s[0] != t[i]) continue; // cout << i << " " << endl; for (int j = 1; i + 1 + (s.size() - 1) * j <= t.size(); j++) { //テゥツ鳴禿ゥツ堋? for (int k = 1; k < s.size(); k++) { // 2テヲツ鳴?・ツュツ療ァツ崢ョテ、ツサツ・テゥツ卍? // cout << " " << i + j*k; if (s[k] != t[i + j * k]) break; if (k == s.size() - 1) { cnt++; i = t.size(); j = i + 1 + (s.size() - 1) * j + 1; //テ」ツδォテ」ツδシテ」ツδ曜テ」ツつ津ヲツ環愿」ツ?妥」ツつ? break; } } // cout << endl; } // cout << endl; } } cout << cnt << endl; return 0; }
[["-", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["-", 0, 1, 0, 11, 12, 2, 63, 118, 28, 22], ["+", 0, 1, 0, 11, 12, 2, 63, 118, 28, 22]]
1
266
#include <iostream> #include <string> using namespace std; int main() { int n, c = 0, ans = 0; int count = 0, cou = 0; string name, prob, newname; cin >> n; cin >> name; for (int i = 0; i < n; i++) { cin >> prob; int flag = 0; for (int e = 0; e < prob.size(); e++) { c = 0; for (int j = 0; j < prob.size(); j++) { if (flag == 1) break; c++; newname = ""; count = e; for (int k = 0; k < prob.size(); k++) { newname += prob[count]; // count += c; // if(prob.size() < count) break; // cout << newname << " " << count << endl; count += c; if (newname.size() == name.size() || prob.size() < count) { if (newname == name) { ans++; flag = 1; } break; } } } } cout << ans << endl; } // cout << newname << endl return 0; }
#include <iostream> #include <string> using namespace std; int main() { int n, c = 0, ans = 0; int count = 0, cou = 0; string name, prob, newname; cin >> n; cin >> name; for (int i = 0; i < n; i++) { cin >> prob; int flag = 0; for (int e = 0; e < prob.size(); e++) { c = 0; for (int j = 0; j < prob.size(); j++) { if (flag == 1) break; c++; newname = ""; count = e; for (int k = 0; k < prob.size(); k++) { newname += prob[count]; count += c; if (newname.size() == name.size() || prob.size() < count) { if (newname == name) { ans++; flag = 1; } break; } } } } } cout << ans << endl; return 0; }
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
223
#include <iostream> #include <string> using namespace std; int main() { int n; string name; string board; int count = 0; cin >> n >> name; for (int i = 0; i < n; i++) { cin >> board; bool x = 0; for (int j = 0; j < board.size() && !x; j++) { if (name[0] == board[j]) { for (int k = j + 1; k < board.size() && !x; k++) { if (board[k] = name[1]) { for (int l = 0, m = j; !x && m < board.size(); l++, m += k - j) { if (name[l] != board[m]) break; if (l == name.size() - 1) x = 1; } } } if (x) count++; } } } cout << count << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { int n; string name; string board; int count = 0; cin >> n >> name; for (int i = 0; i < n; i++) { cin >> board; bool x = 0; for (int j = 0; j < board.size() && !x; j++) { if (name[0] == board[j]) { for (int k = j + 1; k < board.size() && !x; k++) { if (board[k] == name[1]) { for (int l = 0, m = j; !x && m < board.size(); l++, m += k - j) { if (name[l] != board[m]) break; if (l == name.size() - 1) x = 1; } } } if (x) count++; } } } cout << count << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
214
#include <bits/stdc++.h> typedef long long ll; using namespace std; int INF = 1e9; int MOD = 1e9 + 7; main() { int N, cnt = 0; string S, T; cin >> N >> S; for (int i = 0; i < N; i++) { cin >> T; int c = 2; for (int j = 0; j < T.length(); j++) { if (S[0] != T[j]) continue; for (int k = j + 1; k < T.length(); k++) { if (S[1] != T[k]) continue; for (int l = 1; l <= S.length() - 2; l++) { if (k + (k - j) * l >= T.length()) break; if (S[l + 1] == T[k + (k - j) * l]) c++; } if (c / S.length()) goto next; c = 0; } } next: if (c / S.length()) cnt++; } cout << cnt << endl; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; int INF = 1e9; int MOD = 1e9 + 7; main() { int N, cnt = 0; string S, T; cin >> N >> S; for (int i = 0; i < N; i++) { cin >> T; int c = 2; for (int j = 0; j < T.length(); j++) { if (S[0] != T[j]) continue; for (int k = j + 1; k < T.length(); k++) { if (S[1] != T[k]) continue; for (int l = 1; l <= S.length() - 2; l++) { if (k + (k - j) * l >= T.length()) break; if (S[l + 1] == T[k + (k - j) * l]) c++; } if (c / S.length()) goto next; c = 2; } } next: if (c / S.length()) cnt++; } cout << cnt << endl; }
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13]]
1
246
//============================================================================ // Name : AOL.cpp // Author : Akari Fujii // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <algorithm> #include <cctype> #include <iostream> #include <string> using namespace std; int main() { int n; int d = 0; cin >> n; int flag1, flag2; string s1, s2; cin >> s1; int m1 = s1.size(); for (int i = 0; i < n; i++) { cin >> s2; int m2 = s2.size(); flag2 = 0; for (int j = 0; j < m2 - m1; j++) { if (s2[j] == s1[0]) { for (int k = 0; k < 33; k++) { if (m2 - j > (k + 1) * (m1 - 1)) { flag1 = 1; for (int l = 1; l < m1; l++) { if (s2[j + l * (k + 1)] == !s1[l]) flag1 = 0; } if (flag1 == 1) flag2 = 1; } } } } if (flag2 == 1) d += 1; } cout << d << endl; return 0; }
//============================================================================ // Name : AOL.cpp // Author : Akari Fujii // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <algorithm> #include <cctype> #include <iostream> #include <string> using namespace std; int main() { int n; int d = 0; cin >> n; int flag1, flag2; string s1, s2; cin >> s1; int m1 = s1.size(); for (int i = 0; i < n; i++) { cin >> s2; int m2 = s2.size(); flag2 = 0; for (int j = 0; j < m2 - m1 + 1; j++) { if (s2[j] == s1[0]) { for (int k = 0; k < 50; k++) { if (m2 - j > (k + 1) * (m1 - 1)) { flag1 = 1; for (int l = 1; l < m1; l++) { if (s2[j + l * (k + 1)] != s1[l]) flag1 = 0; } if (flag1 == 1) flag2 = 1; } } } } if (flag2 == 1) d += 1; } cout << d << endl; return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 12, 91, 17, 111], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
235
#include <iostream> #include <string> using namespace std; int main() { int N; int ans = 0; bool flag; string target; string instr; cin >> N; cin >> target; for (int i = 0; i < N; ++i) { cin >> instr; for (int j = 0; j < (int)instr.size(); ++j) { if (target[0] != instr[j]) continue; for (int k = 1; j + k * ((int)target.size() - 1) < (int)instr.size(); ++k) { flag = true; for (int l = 1; l < (int)target.size() - 1; ++l) { if (target[l] != instr[j + k * l]) { flag = false; break; } } if (flag) { ++ans; break; } } if (flag) break; } } cout << ans << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { int N; int ans = 0; bool flag; string target; string instr; cin >> N; cin >> target; for (int i = 0; i < N; ++i) { cin >> instr; for (int j = 0; j < (int)instr.size(); ++j) { if (target[0] != instr[j]) continue; for (int k = 1; j + k * ((int)target.size() - 1) < (int)instr.size(); ++k) { flag = true; for (int l = 1; l < (int)target.size(); ++l) { if (target[l] != instr[j + k * l]) { flag = false; break; } } if (flag) { ++ans; break; } } if (flag) break; } } cout << ans << endl; return 0; }
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
213
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) typedef long long ll; int main() { int N; string name; cin >> N >> name; int ans = 0; REP(m, N) { string sb; cin >> sb; if (name.length() > sb.length()) continue; string::size_type idx; int flag = 0; while ((idx = sb.find(name[0])) != string::npos) { sb = sb.substr(idx); // cout << sb << endl; // cout << idx << endl; FOR(i, 1, 100) { REP(j, sb.length()) { if (j * i >= sb.length()) { break; } if (sb[j * i] != name[j]) { break; } if (j == name.length() - 1) { flag = 1; goto end; } } } if (idx + 1 >= sb.length()) break; sb = sb.substr(idx + 1); } end:; if (flag) ans++; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) typedef long long ll; int main() { int N; string name; cin >> N >> name; int ans = 0; REP(m, N) { string sb; cin >> sb; if (name.length() > sb.length()) continue; string::size_type idx; int flag = 0; while ((idx = sb.find(name[0])) != string::npos) { sb = sb.substr(idx); // cout << sb << endl; // cout << idx << endl; FOR(i, 1, 100) { REP(j, sb.length()) { if (j * i >= sb.length()) { break; } if (sb[j * i] != name[j]) { break; } if (j == name.length() - 1) { flag = 1; goto end; } } } if (1 == sb.length()) break; sb = sb.substr(1); } end:; if (flag) ans++; } cout << ans << endl; return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72]]
1
271
#include <algorithm> #include <iostream> using namespace std; #define ll long long int struct ST { ll x1, x2; ll y1, y2; ll z1, z2; }; ll x[100 + 10] = {0}; ll y[100 + 10] = {0}; ll z[100 + 10] = {0}; ll area = 0; int main() { ST fish[50 + 10]; int n, k; int i, j; int xi, yi, zi; int cnt = 0; /* cin >> n; for (i = 0; i < n; i++) { cin >> x[i]; } sort(x, x + n); for (i = 0; i < n + 5; i++) { cout << x[i] << " "; } */ cin >> n >> k; for (i = 0; i < n; i++) { cin >> fish[i].x1 >> fish[i].y1 >> fish[i].z1 >> fish[i].x2 >> fish[i].y2 >> fish[i].z2; x[i * 2] = fish[i].x1; x[(i * 2) + 1] = fish[i].x2; y[i * 2] = fish[i].y1; y[(i * 2) + 1] = fish[i].y2; z[i * 2] = fish[i].z1; z[(i * 2) + 1] = fish[i].z2; } sort(x, x + (n * 2)); sort(y, y + (n * 2)); sort(z, z + (n * 2)); for (xi = 0; xi < n * 2 - 1; xi++) { for (yi = 0; yi < n * 2 - 1; yi++) { for (zi = 0; zi < n * 2 - 1; zi++) { cnt = 0; for (i = 0; i < n; i++) { if (fish[i].x1 > x[xi] || x[xi + 1] > fish[i].x2) { continue; } if (fish[i].y1 > y[yi] || y[yi + 1] > fish[i].y2) { continue; } if (fish[i].z1 > z[zi] || x[zi + 1] > fish[i].z2) { continue; } cnt++; } if (cnt >= k) { area += (x[xi + 1] - x[xi]) * (y[yi + 1] - y[yi]) * (z[zi + 1] - z[zi]); } } } } cout << area << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; #define ll long long int struct ST { ll x1, x2; ll y1, y2; ll z1, z2; }; ll x[100 + 10] = {0}; ll y[100 + 10] = {0}; ll z[100 + 10] = {0}; ll area = 0; int main() { ST fish[50 + 10]; int n, k; int i, j; int xi, yi, zi; int cnt = 0; cin >> n >> k; for (i = 0; i < n; i++) { cin >> fish[i].x1 >> fish[i].y1 >> fish[i].z1 >> fish[i].x2 >> fish[i].y2 >> fish[i].z2; x[i * 2] = fish[i].x1; x[(i * 2) + 1] = fish[i].x2; y[i * 2] = fish[i].y1; y[(i * 2) + 1] = fish[i].y2; z[i * 2] = fish[i].z1; z[(i * 2) + 1] = fish[i].z2; } sort(x, x + (n * 2)); sort(y, y + (n * 2)); sort(z, z + (n * 2)); for (xi = 0; xi < n * 2 - 1; xi++) { for (yi = 0; yi < n * 2 - 1; yi++) { for (zi = 0; zi < n * 2 - 1; zi++) { cnt = 0; for (i = 0; i < n; i++) { if (fish[i].x1 > x[xi] || x[xi + 1] > fish[i].x2) { continue; } if (fish[i].y1 > y[yi] || y[yi + 1] > fish[i].y2) { continue; } if (fish[i].z1 > z[zi] || z[zi + 1] > fish[i].z2) { continue; } cnt++; } if (cnt >= k) { area += (x[xi + 1] - x[xi]) * (y[yi + 1] - y[yi]) * (z[zi + 1] - z[zi]); } } } } cout << area << endl; return 0; }
[["-", 15, 339, 51, 16, 12, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 16, 31, 69, 28, 22]]
1
545
#include <algorithm> #include <cstdio> #include <vector> using namespace std; int coun[105][105][105]; vector<int> x, y, z; int rx[52][2], ry[52][2], rz[52][2]; int n, m; int compress1(int x1[52], int x2[52]) { for (int i = 0; i < n; i++) { x.push_back(x1[i]); x.push_back(x2[i]); } sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end()); for (int i = 0; i < n; i++) { rx[i][0] = find(x.begin(), x.end(), x1[i]) - x.begin(); rx[i][1] = find(x.begin(), x.end(), x2[i]) - x.begin(); } return x.size(); } int compress2(int x1[52], int x2[52]) { for (int i = 0; i < n; i++) { y.push_back(x1[i]); y.push_back(x2[i]); } sort(y.begin(), y.end()); y.erase(unique(y.begin(), y.end()), y.end()); for (int i = 0; i < n; i++) { ry[i][0] = find(y.begin(), y.end(), x1[i]) - y.begin(); ry[i][1] = find(y.begin(), y.end(), x2[i]) - y.begin(); } return y.size(); } int compress3(int x1[52], int x2[52]) { for (int i = 0; i < n; i++) { z.push_back(x1[i]); z.push_back(x2[i]); } sort(z.begin(), z.end()); z.erase(unique(z.begin(), z.end()), z.end()); for (int i = 0; i < n; i++) { rz[i][0] = find(z.begin(), z.end(), x1[i]) - z.begin(); rz[i][1] = find(z.begin(), z.end(), x2[i]) - z.begin(); } return z.size(); } void paint() { for (int i = 0; i < n; i++) { for (int tx = rx[i][0]; tx < rx[i][1]; tx++) { for (int ty = ry[i][0]; ty < ry[i][1]; ty++) { for (int tz = rz[i][0]; tz < rz[i][1]; tz++) { coun[tx][ty][tz]++; } } } } } int main() { int a[52], b[52], c[52], d[52], e[52], f[52]; scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { scanf("%d %d %d %d %d %d", &a[i], &b[i], &c[i], &d[i], &e[i], &f[i]); } int w = compress1(a, d); int h = compress2(b, d); int p = compress3(c, f); paint(); long long ans = 0; for (int i = 0; i <= w; i++) { for (int j = 0; j <= h; j++) { for (int k = 0; k <= p; k++) { if (coun[i][j][k] >= m) { long long s1 = (x[i + 1] - x[i]), s2 = (y[j + 1] - y[j]), s3 = (z[k + 1] - z[k]); ans += s1 * s2 * s3; } } } } // long long ans = 0; printf("%lld\n", ans); return 0; }
#include <algorithm> #include <cstdio> #include <vector> using namespace std; int coun[105][105][105]; vector<int> x, y, z; int rx[52][2], ry[52][2], rz[52][2]; int n, m; int compress1(int x1[52], int x2[52]) { for (int i = 0; i < n; i++) { x.push_back(x1[i]); x.push_back(x2[i]); } sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end()); for (int i = 0; i < n; i++) { rx[i][0] = find(x.begin(), x.end(), x1[i]) - x.begin(); rx[i][1] = find(x.begin(), x.end(), x2[i]) - x.begin(); } return x.size(); } int compress2(int x1[52], int x2[52]) { for (int i = 0; i < n; i++) { y.push_back(x1[i]); y.push_back(x2[i]); } sort(y.begin(), y.end()); y.erase(unique(y.begin(), y.end()), y.end()); for (int i = 0; i < n; i++) { ry[i][0] = find(y.begin(), y.end(), x1[i]) - y.begin(); ry[i][1] = find(y.begin(), y.end(), x2[i]) - y.begin(); } return y.size(); } int compress3(int x1[52], int x2[52]) { for (int i = 0; i < n; i++) { z.push_back(x1[i]); z.push_back(x2[i]); } sort(z.begin(), z.end()); z.erase(unique(z.begin(), z.end()), z.end()); for (int i = 0; i < n; i++) { rz[i][0] = find(z.begin(), z.end(), x1[i]) - z.begin(); rz[i][1] = find(z.begin(), z.end(), x2[i]) - z.begin(); } return z.size(); } void paint() { for (int i = 0; i < n; i++) { for (int tx = rx[i][0]; tx < rx[i][1]; tx++) { for (int ty = ry[i][0]; ty < ry[i][1]; ty++) { for (int tz = rz[i][0]; tz < rz[i][1]; tz++) { coun[tx][ty][tz]++; } } } } } int main() { int a[52], b[52], c[52], d[52], e[52], f[52]; scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { scanf("%d %d %d %d %d %d", &a[i], &b[i], &c[i], &d[i], &e[i], &f[i]); } int w = compress1(a, d); int h = compress2(b, e); int p = compress3(c, f); paint(); long long ans = 0; for (int i = 0; i <= w; i++) { for (int j = 0; j <= h; j++) { for (int k = 0; k <= p; k++) { if (coun[i][j][k] >= m) { long long s1 = (x[i + 1] - x[i]), s2 = (y[j + 1] - y[j]), s3 = (z[k + 1] - z[k]); ans += s1 * s2 * s3; } } } } // long long ans = 0; printf("%lld\n", ans); return 0; }
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22]]
1
1,021
def main(): n, k = map(int, input().split()) plst = [] xlst = [] ylst = [] dlst = [] for i in range(n): x1,y1,d1,x2,y2,d2 = map(int, input().split()) plst.append((x1,y1,d1,x2,y2,d2)) xlst.append(x1) xlst.append(x2) ylst.append(y1) ylst.append(y2) dlst.append(d1) dlst.append(d2) xlst = list(set(xlst)) ylst = list(set(ylst)) dlst = list(set(dlst)) xlst.sort() ylst.sort() dlst.sort() xdic = {} ydic = {} ddic = {} for i, v in enumerate(xlst): xdic[v] = i for i, v in enumerate(ylst): ydic[v] = i for i, v in enumerate(dlst): ddic[v] = i new_map = [[[0] * len(dlst) for _ in ylst] for _ in xlst] for p in plst: x1, y1, d1, x2, y2, d2 = p x1, y1, d1, x2, y2, d2 = xdic[x1], ydic[y1], ddic[d1], xdic[x2], ydic[y2], ddic[d2] for x in range(x1, x2): for y in range(y1, y2): for d in range(d1, d2): new_map[x][y][d] += 1 ans = 0 for i in range(len(xlst) - 1): xlsti = xlst[i] xlsti1 = xlst[i - 1] x = xdic[xlsti] for j in range(len(ylst) - 1): ylstj = ylst[j] ylstj1 = ylst[j - 1] y = ydic[ylstj] for z in range(len(dlst) - 1): dlstz = dlst[z] dlstz1 = dlst[z - 1] d = ddic[dlstz] if new_map[x][y][d] >= k: ans += (xlsti1 - xlsti) * (ylstj1 - ylstj) * (dlstz1 - dlstz) print(ans) main()
def main(): n, k = map(int, input().split()) plst = [] xlst = [] ylst = [] dlst = [] for i in range(n): x1,y1,d1,x2,y2,d2 = map(int, input().split()) plst.append((x1,y1,d1,x2,y2,d2)) xlst.append(x1) xlst.append(x2) ylst.append(y1) ylst.append(y2) dlst.append(d1) dlst.append(d2) xlst = list(set(xlst)) ylst = list(set(ylst)) dlst = list(set(dlst)) xlst.sort() ylst.sort() dlst.sort() xdic = {} ydic = {} ddic = {} for i, v in enumerate(xlst): xdic[v] = i for i, v in enumerate(ylst): ydic[v] = i for i, v in enumerate(dlst): ddic[v] = i new_map = [[[0] * len(dlst) for _ in ylst] for _ in xlst] for p in plst: x1, y1, d1, x2, y2, d2 = p x1, y1, d1, x2, y2, d2 = xdic[x1], ydic[y1], ddic[d1], xdic[x2], ydic[y2], ddic[d2] for x in range(x1, x2): for y in range(y1, y2): for d in range(d1, d2): new_map[x][y][d] += 1 ans = 0 for i in range(len(xlst) - 1): xlsti = xlst[i] xlsti1 = xlst[i + 1] x = xdic[xlsti] for j in range(len(ylst) - 1): ylstj = ylst[j] ylstj1 = ylst[j + 1] y = ydic[ylstj] for z in range(len(dlst) - 1): dlstz = dlst[z] dlstz1 = dlst[z + 1] d = ddic[dlstz] if new_map[x][y][d] >= k: ans += (xlsti1 - xlsti) * (ylstj1 - ylstj) * (dlstz1 - dlstz) print(ans) main()
[["-", 0, 1, 0, 662, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 206, 206, 657, 17, 72]]
5
490
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <vector> using namespace std; #define MAX_N 60 #define MAX_K 3 #define MAX_D 6 #define MAX_C 4096 int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int dp[MAX_N][MAX_N][MAX_K + 1][MAX_C]; int x[MAX_N][MAX_N]; int h, w, K, a; char c; char T[12] = ".123456789#"; int b[MAX_N][MAX_N]; int gx[6], gy[6]; int power[10] = {1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144}; int hantei(int p, int q, vector<int> r) { int v = p, w = q; for (int o = 5; o >= 0; o--) { v -= dy[r[o]]; w -= dx[r[o]]; gy[o] = v; gx[o] = w; } for (int o = 0; o <= 5; o++) { if (p == gy[o] && q == gx[o]) { return 0; } } return 1; } int DP() { int X, Y, F, G, H, dir[6], maxn; // zentansaku(first 6) for (int i = 0; i < 4096; i++) { memset(b, 0, sizeof(b)); X = 1; Y = 1; F = x[1][1]; G = 0; b[Y][X] = 1; for (int j = 0; j < 6; j++) { a = (i / (int)pow(4, j)) % 4; X += dx[a]; Y += dy[a]; if (x[Y][X] == 10) { goto E; } if (a == 2 || a == 3) { G++; } if (b[Y][X] == 0) { F += x[Y][X]; } b[Y][X] = 1; } if (G <= K) { dp[Y][X][G][i] = F; } E:; } // dp. for (int i = 0; i < K; i++) { for (int j = 1; j <= h; j++) { for (int k = 1; k <= w; k++) { if (x[j][k] <= 9) { for (int l = 0; l <= K; l++) { for (int m = 0; m < MAX_C; m++) { if (dp[j][k][l][m] >= 0) { for (int n = 0; n < 6; n++) { dir[n] = (m / power[n]) % 4; } if (l < K) { if (x[j - 1][k] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } a += 2048; vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 2}; if (hantei(j - 1, k, A) == 1) { H = x[j - 1][k]; } else { H = 0; } X = j; Y = k; dp[j - 1][k][l + 1][a] = max(dp[j - 1][k][l + 1][a], dp[j][k][l][m] + H); } if (x[j][k - 1] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } a += 3072; vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 3}; if (hantei(j, k - 1, A) == 1) { H = x[j][k - 1]; } else { H = 0; } dp[j][k - 1][l + 1][a] = max(dp[j][k - 1][l + 1][a], dp[j][k][l][m] + H); } } if (x[j + 1][k] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 0}; if (hantei(j + 1, k, A) == 1) { H = x[j + 1][k]; } else { H = 0; } dp[j + 1][k][l][a] = max(dp[j + 1][k][l][a], dp[j][k][l][m] + H); } if (x[j][k + 1] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } a += 1024; vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 1}; if (hantei(j, k + 1, A) == 1) { H = x[j][k + 1]; } else { H = 0; } dp[j][k + 1][l][a] = max(dp[j][k + 1][l][a], dp[j][k][l][m] + H); } } } } } } } } maxn = 0; for (int i = 0; i <= K; i++) { for (int j = 0; j < MAX_C; j++) { maxn = max(maxn, dp[h][w][i][j]); } } return maxn; } int main() { // shokika. for (int i = 0; i < MAX_N; i++) { for (int j = 0; j < MAX_N; j++) { for (int k = 0; k <= MAX_K; k++) { for (int l = 0; l < MAX_C; l++) { dp[i][j][k][l] = -1; } } } } for (int i = 0; i < MAX_N; i++) { for (int j = 0; j < MAX_N; j++) { x[i][j] = 10; } } // cin. cin >> h >> w >> K; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> c; for (int k = 0; k < 11; k++) { if (c == T[k]) { x[i][j] = k; } } } } cout << DP() << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <vector> using namespace std; #define MAX_N 60 #define MAX_K 3 #define MAX_D 6 #define MAX_C 4096 int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int dp[MAX_N][MAX_N][MAX_K + 1][MAX_C]; int x[MAX_N][MAX_N]; int h, w, K, a; char c; char T[12] = ".123456789#"; int b[MAX_N][MAX_N]; int gx[6], gy[6]; int power[10] = {1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144}; int hantei(int p, int q, vector<int> r) { int v = p, w = q; for (int o = 5; o >= 0; o--) { v -= dy[r[o]]; w -= dx[r[o]]; gy[o] = v; gx[o] = w; } for (int o = 0; o <= 5; o++) { if (p == gy[o] && q == gx[o]) { return 0; } } return 1; } int DP() { int X, Y, F, G, H, dir[6], maxn; // zentansaku(first 6) for (int i = 0; i < 4096; i++) { memset(b, 0, sizeof(b)); X = 1; Y = 1; F = x[1][1]; G = 0; b[Y][X] = 1; for (int j = 0; j < 6; j++) { a = (i / (int)pow(4, j)) % 4; X += dx[a]; Y += dy[a]; if (x[Y][X] == 10) { goto E; } if (a == 2 || a == 3) { G++; } if (b[Y][X] == 0) { F += x[Y][X]; } b[Y][X] = 1; } if (G <= K) { dp[Y][X][G][i] = F; } E:; } // dp. for (int i = 0; i < 5; i++) { for (int j = 1; j <= h; j++) { for (int k = 1; k <= w; k++) { if (x[j][k] <= 9) { for (int l = 0; l <= K; l++) { for (int m = 0; m < MAX_C; m++) { if (dp[j][k][l][m] >= 0) { for (int n = 0; n < 6; n++) { dir[n] = (m / power[n]) % 4; } if (l < K) { if (x[j - 1][k] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } a += 2048; vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 2}; if (hantei(j - 1, k, A) == 1) { H = x[j - 1][k]; } else { H = 0; } X = j; Y = k; dp[j - 1][k][l + 1][a] = max(dp[j - 1][k][l + 1][a], dp[j][k][l][m] + H); } if (x[j][k - 1] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } a += 3072; vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 3}; if (hantei(j, k - 1, A) == 1) { H = x[j][k - 1]; } else { H = 0; } dp[j][k - 1][l + 1][a] = max(dp[j][k - 1][l + 1][a], dp[j][k][l][m] + H); } } if (x[j + 1][k] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 0}; if (hantei(j + 1, k, A) == 1) { H = x[j + 1][k]; } else { H = 0; } dp[j + 1][k][l][a] = max(dp[j + 1][k][l][a], dp[j][k][l][m] + H); } if (x[j][k + 1] <= 9) { a = 0; for (int n = 1; n < 6; n++) { a += power[n - 1] * dir[n]; } a += 1024; vector<int> A = {dir[1], dir[2], dir[3], dir[4], dir[5], 1}; if (hantei(j, k + 1, A) == 1) { H = x[j][k + 1]; } else { H = 0; } dp[j][k + 1][l][a] = max(dp[j][k + 1][l][a], dp[j][k][l][m] + H); } } } } } } } } maxn = 0; for (int i = 0; i <= K; i++) { for (int j = 0; j < MAX_C; j++) { maxn = max(maxn, dp[h][w][i][j]); } } return maxn; } int main() { // shokika. for (int i = 0; i < MAX_N; i++) { for (int j = 0; j < MAX_N; j++) { for (int k = 0; k <= MAX_K; k++) { for (int l = 0; l < MAX_C; l++) { dp[i][j][k][l] = -1; } } } } for (int i = 0; i < MAX_N; i++) { for (int j = 0; j < MAX_N; j++) { x[i][j] = 10; } } // cin. cin >> h >> w >> K; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> c; for (int k = 0; k < 11; k++) { if (c == T[k]) { x[i][j] = k; } } } } cout << DP() << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
1,649
import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; int t1 = 0; //直角三角形 int t2 = 0; //鋭角三角形 int t3 = 0; //鈍角三角形 outer: while ((line = br.readLine()) != null && !line.isEmpty()) { StringTokenizer st = new StringTokenizer(line); int[] e = new int[3]; for (int i = 0; i < 3; i++) { e[i] = parseInt(st.nextToken()); } for (int i = 0; i < 3; i++) { if (!(e[i % 3] < e[(i + 1) % 3] + e[(i + 2) % 3])) { continue outer; } } Arrays.sort(e); int t = e[2] * e[2] - e[0] * e[0] - e[1] * e[1]; if (t == 0) { t1++; } else if (t < 0) { t2++; } else { t3++; } } System.out.format("%d %d %d %d\n", t1 + t2 + t3, t1, t2, t3); } }
import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; int t1 = 0; //直角三角形 int t2 = 0; //鋭角三角形 int t3 = 0; //鈍角三角形 outer: while ((line = br.readLine()) != null && !line.isEmpty()) { StringTokenizer st = new StringTokenizer(line); int[] e = new int[3]; for (int i = 0; i < 3; i++) { e[i] = parseInt(st.nextToken()); } for (int i = 0; i < 3; i++) { if (!(e[i % 3] < e[(i + 1) % 3] + e[(i + 2) % 3])) { break outer; } } Arrays.sort(e); int t = e[2] * e[2] - e[0] * e[0] - e[1] * e[1]; if (t == 0) { t1++; } else if (t < 0) { t2++; } else { t3++; } } System.out.format("%d %d %d %d\n", t1 + t2 + t3, t1, t2, t3); } }
[["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
3
326
import java.util.*; public class Main { private static int check(int[] lines) { if (lines[0] + lines[1] <= lines[2]) { return 0; } for (int i = 0, i_len = lines.length; i < i_len; i += 1) { lines[i] *= lines[i]; } if (lines[0] + lines[1] > lines[2]) { return 1; } else if (lines[0] + lines[1] == lines[2]) { return 2; } return 3; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] results = new int[4]; int count = 0; while (sc.hasNext()) { String[] inputs = (sc.nextLine()).split(" "); int[] lines = new int[inputs.length]; for (int i = 0, i_len = lines.length; i < i_len; i += 1) { lines[i] = Integer.parseInt(inputs[i]); } Arrays.sort(lines); ++results[check(lines)]; if (results[0] == 1) { break; } ++count; } System.out.print(count + " "); for (int i = 1, i_len = results.length - 1; i < i_len; i += 1) { System.out.print(results[i] + " "); } System.out.println(results[results.length - 1]); } }
import java.util.*; public class Main { private static int check(int[] lines) { if (lines[0] + lines[1] <= lines[2]) { return 0; } for (int i = 0, i_len = lines.length; i < i_len; i += 1) { lines[i] *= lines[i]; } if (lines[0] + lines[1] == lines[2]) { return 1; } else if (lines[0] + lines[1] > lines[2]) { return 2; } return 3; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] results = new int[4]; int count = 0; while (sc.hasNext()) { String[] inputs = (sc.nextLine()).split(" "); int[] lines = new int[inputs.length]; for (int i = 0, i_len = lines.length; i < i_len; i += 1) { lines[i] = Integer.parseInt(inputs[i]); } Arrays.sort(lines); ++results[check(lines)]; if (results[0] == 1) { break; } ++count; } System.out.print(count + " "); for (int i = 1, i_len = results.length - 1; i < i_len; i += 1) { System.out.print(results[i] + " "); } System.out.println(results[results.length - 1]); } }
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 60], ["-", 0, 57, 75, 57, 15, 15, 0, 16, 17, 60], ["+", 0, 57, 75, 57, 15, 15, 0, 16, 17, 47]]
3
349
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] len_list = new int[3]; int[] triangles = new int[3]; while (true) { for (int i = 0; i < 3; i++) { int len = sc.nextInt(); len_list[i] = len; } Arrays.sort(len_list); // 3辺の長さ int l1 = len_list[0]; int l2 = len_list[1]; int l3 = len_list[2]; // 存在しない場合出力 if (l1 + l2 <= l3) { int t1 = triangles[0]; int t2 = triangles[1]; int t3 = triangles[2]; System.out.println(t1 + t2 + t3 + " " + t1 + " " + t2 + " " + t3); break; } int s1 = l1 * l1 + l2 * l2; int s2 = l3 * l3; if (s1 > s2) { triangles[0]++; } else { if (s1 == s2) { triangles[1]++; } else { triangles[2]++; } } } } }
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] len_list = new int[3]; int[] triangles = new int[3]; while (true) { for (int i = 0; i < 3; i++) { int len = sc.nextInt(); len_list[i] = len; } Arrays.sort(len_list); // 3辺の長さ int l1 = len_list[0]; int l2 = len_list[1]; int l3 = len_list[2]; // 存在しない場合出力 if (l1 + l2 <= l3) { int t1 = triangles[0]; int t2 = triangles[1]; int t3 = triangles[2]; System.out.println(t1 + t2 + t3 + " " + t2 + " " + t1 + " " + t3); break; } int s1 = l1 * l1 + l2 * l2; int s2 = l3 * l3; if (s1 > s2) { triangles[0]++; } else { if (s1 == s2) { triangles[1]++; } else { triangles[2]++; } } } } }
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 3, 4, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 16, 12, 22]]
3
260
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; class Main { public static void main(String[] a) { int sankaku = 0; int eikaku = 0; int donkaku = 0; int cyokkaku = 0; int maximum, middle, minimal; int[] hen = new int[3]; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = ""; try { while (true) { str = br.readLine(); if (str == null) { System.out.println(sankaku + " " + cyokkaku + " " + eikaku + " " + donkaku); } StringTokenizer st = new StringTokenizer(str, " "); for (int i = 0; i < 3; i++) { hen[i] = Integer.parseInt(st.nextToken()); } maximum = Math.max(hen[0], Math.max(hen[1], hen[2])); if (hen[0] == maximum) hen[0] = 0; else if (hen[1] == maximum) hen[1] = 0; else if (hen[2] == maximum) hen[2] = 0; middle = Math.max(hen[0], Math.max(hen[1], hen[2])); if (hen[0] == middle) hen[0] = 0; else if (hen[1] == middle) hen[1] = 0; else if (hen[2] == middle) hen[2] = 0; minimal = Math.max(hen[0], Math.max(hen[1], hen[2])); if (maximum <= middle + minimal || minimal <= maximum - middle) { System.out.println(sankaku + " " + cyokkaku + " " + eikaku + " " + donkaku); System.exit(0); } else if (maximum * maximum == (minimal * minimal + middle * middle)) { sankaku++; cyokkaku++; } else if (maximum * maximum > minimal * minimal + middle * middle) { sankaku++; donkaku++; } else if (maximum * maximum < minimal * minimal + middle * middle) { sankaku++; eikaku++; } } } catch (Exception e) { System.exit(0); } } }
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; class Main { public static void main(String[] a) { int sankaku = 0; int eikaku = 0; int donkaku = 0; int cyokkaku = 0; int maximum, middle, minimal; int[] hen = new int[3]; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = ""; try { while (true) { str = br.readLine(); if (str == null) { System.out.println(sankaku + " " + cyokkaku + " " + eikaku + " " + donkaku); } StringTokenizer st = new StringTokenizer(str, " "); for (int i = 0; i < 3; i++) { hen[i] = Integer.parseInt(st.nextToken()); } maximum = Math.max(hen[0], Math.max(hen[1], hen[2])); if (hen[0] == maximum) hen[0] = 0; else if (hen[1] == maximum) hen[1] = 0; else if (hen[2] == maximum) hen[2] = 0; middle = Math.max(hen[0], Math.max(hen[1], hen[2])); if (hen[0] == middle) hen[0] = 0; else if (hen[1] == middle) hen[1] = 0; else if (hen[2] == middle) hen[2] = 0; minimal = Math.max(hen[0], Math.max(hen[1], hen[2])); if (maximum >= middle + minimal || minimal <= maximum - middle) { System.out.println(sankaku + " " + cyokkaku + " " + eikaku + " " + donkaku); System.exit(0); } else if (maximum * maximum == (minimal * minimal + middle * middle)) { sankaku++; cyokkaku++; } else if (maximum * maximum > minimal * minimal + middle * middle) { sankaku++; donkaku++; } else if (maximum * maximum < minimal * minimal + middle * middle) { sankaku++; eikaku++; } } } catch (Exception e) { System.exit(0); } } }
[["-", 0, 57, 15, 15, 0, 16, 31, 16, 17, 19], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 17, 20]]
3
509
#include <stdio.h> int main(void) { int a, b, c; int s = 0, p = 0, cnt = 0, count = 0; int i = 0; int j; int t; while (scanf("%d%d%d", &a, &b, &c) != EOF) { if (c > a) t = a, a = c, c = t; if (b > a) t = a, a = b, b = t; if (a < b + c) { s++; if (a * a == b * b + c * c) p++; else if (a * a < b * b + c * c) cnt++; else count++; } } printf("%d %d %d %d\n", s, p, cnt, count); return 0; }
#include <stdio.h> int main(void) { int a, b, c; int s = 0, p = 0, cnt = 0, count = 0; int i = 0; int j; int t; while (scanf("%d%d%d", &a, &b, &c) != EOF) { if (c > a) t = a, a = c, c = t; if (b > a) t = a, a = b, b = t; if (a < b + c) { s++; if (a * a == b * b + c * c) p++; else if (a * a < b * b + c * c) cnt++; else count++; } else break; } printf("%d %d %d %d\n", s, p, cnt, count); return 0; }
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 75, 76, 0, 93, 0, 35]]
0
173
#include <stdio.h> int multi(int ar[3]) { int i; for (i = 0; i < 3; i++) { ar[i] = ar[i] * ar[i]; } } int main() { int cnt = 0, cnt_a = 0, cnt_b = 0, cnt_c = 0; while (1) { int array[3]; int temp, i, j; for (i = 0; i < 3; i++) { scanf("%d", &array[i]); } for (i = 0; i < 2; i++) { for (j = i + 1; j < 3; j++) { if (array[i] < array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } } /*for( i=0; i<3; i++ ){ printf("%d",array[i]); } */ if (array[0] >= array[1] + array[2] || array[0] <= array[1] - array[2]) break; cnt++; multi(array); /*for( i=0; i<3; i++ ){ printf("%d",array[i]); }*/ if (array[0] < array[1] + array[2]) cnt_a++; if (array[0] == array[1] + array[2]) cnt_b++; if (array[0] > array[1] + array[2]) cnt_c++; } printf("%d %d %d %d\n", cnt, cnt_a, cnt_b, cnt_c); return 0; }
#include <stdio.h> int multi(int ar[3]) { int i; for (i = 0; i < 3; i++) { ar[i] = ar[i] * ar[i]; } } int main() { int cnt = 0, cnt_a = 0, cnt_b = 0, cnt_c = 0; while (1) { int array[3]; int temp, i, j; for (i = 0; i < 3; i++) { scanf("%d", &array[i]); } for (i = 0; i < 2; i++) { for (j = i + 1; j < 3; j++) { if (array[i] < array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } } /*for( i=0; i<3; i++ ){ printf("%d",array[i]); } */ if (array[0] >= array[1] + array[2] || array[0] <= array[1] - array[2]) break; cnt++; multi(array); /*for( i=0; i<3; i++ ){ printf("%d",array[i]); }*/ if (array[0] < array[1] + array[2]) cnt_a++; if (array[0] == array[1] + array[2]) cnt_b++; if (array[0] > array[1] + array[2]) cnt_c++; } printf("%d %d %d %d\n", cnt, cnt_b, cnt_a, cnt_c); return 0; }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
309
#include <stdio.h> int main() { int a[3], b, i, j, e = 0, f = 0, g = 0, h = 0; while (scanf("%d %d %d", &a[0], &a[1], &a[2]) != EOF) { for (i = 0; i < 2; i++) { for (j = i + 1; j < 3; j++) { if (a[i] < a[j]) { b = a[i]; a[i] = a[j]; a[j] = b; } } } if (a[0] <= a[1] + a[2]) continue; else e++; if (a[0] * a[0] > a[1] * a[1] + a[2] * a[2]) f++; else if (a[0] * a[0] == a[1] * a[1] + a[2] * a[2]) g++; else h++; } printf("%d %d %d %d\n", e, g, h, f); return 0; }
#include <stdio.h> int main() { int a[3], b, i, j, e = 0, f = 0, g = 0, h = 0; while (scanf("%d %d %d", &a[0], &a[1], &a[2]) != EOF) { for (i = 0; i < 2; i++) { for (j = i + 1; j < 3; j++) { if (a[i] < a[j]) { b = a[i]; a[i] = a[j]; a[j] = b; } } } if (a[0] >= a[1] + a[2]) break; else e++; if (a[0] * a[0] > a[1] * a[1] + a[2] * a[2]) f++; else if (a[0] * a[0] == a[1] * a[1] + a[2] * a[2]) g++; else h++; } printf("%d %d %d %d\n", e, g, h, f); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["-", 0, 52, 8, 9, 0, 57, 64, 116, 0, 117], ["+", 0, 52, 8, 9, 0, 57, 64, 93, 0, 94]]
0
254
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repc(i, s, e) for (int i = (s); i < (e); i++) #define pb(n) push_back((n)) #define mp(n, m) make_pair((n), (m)) #define all(r) r.begin(), r.end() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 10000000; const int mod = 1e9 + 7; const double EPS = 1e-9; int main() { vi v(3, 0), ans(3, 0); double d; int n = 0; while (cin >> v[0] >> v[1] >> v[2]) { sort(all(v)); d = (double)(v[0] * v[0] + v[1] * v[1] - v[2] * v[2]) / (2 * v[0] * v[1]); if (v[2] >= v[1] + v[0]) { cout << n; for (int i = 0; i < 3; i++) { cout << " " << ans[i]; } cout << endl; break; } if (d > 0) ans[0]++; else if (d < 0) ans[1]++; else ans[2]++; n++; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repc(i, s, e) for (int i = (s); i < (e); i++) #define pb(n) push_back((n)) #define mp(n, m) make_pair((n), (m)) #define all(r) r.begin(), r.end() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 10000000; const int mod = 1e9 + 7; const double EPS = 1e-9; int main() { vi v(3, 0), ans(3, 0); double d; int n = 0; while (cin >> v[0] >> v[1] >> v[2]) { sort(all(v)); d = (double)(v[0] * v[0] + v[1] * v[1] - v[2] * v[2]) / (2 * v[0] * v[1]); if (v[2] >= v[1] + v[0]) { cout << n; for (int i = 0; i < 3; i++) { cout << " " << ans[i]; } cout << endl; break; } if (d > 0) ans[1]++; else if (d < 0) ans[2]++; else ans[0]++; n++; } }
[["-", 64, 1, 0, 27, 28, 69, 341, 342, 0, 13], ["+", 64, 1, 0, 27, 28, 69, 341, 342, 0, 13], ["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13]]
1
347
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual ///Studio 2015\Projects\programing_contest_c++\Debug\b.answer" int main() { vector<int> nums(4); while (1) { vector<int> vs(3); cin >> vs[0] >> vs[1] >> vs[2]; sort(vs.begin(), vs.end()); if (vs[0] + vs[1] <= vs[2]) { break; } else { int l = vs[0] * vs[0] + vs[1] * vs[1]; int r = vs[2] * vs[2]; if (l < r) { nums[3]++; } else if (l == r) { nums[2]++; } else { nums[1]++; } nums[0]++; } } cout << nums[0] << " " << nums[1] << " " << nums[2] << " " << nums[3] << endl; return 0; }
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual ///Studio 2015\Projects\programing_contest_c++\Debug\b.answer" int main() { vector<int> nums(4); while (1) { vector<int> vs(3); cin >> vs[0] >> vs[1] >> vs[2]; sort(vs.begin(), vs.end()); if (vs[0] + vs[1] <= vs[2]) { break; } else { int l = vs[0] * vs[0] + vs[1] * vs[1]; int r = vs[2] * vs[2]; if (l < r) { nums[3]++; } else if (l == r) { nums[1]++; } else { nums[2]++; } nums[0]++; } } cout << nums[0] << " " << nums[1] << " " << nums[2] << " " << nums[3] << endl; return 0; }
[["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13]]
1
250
#include <bits/stdc++.h> #define sqr(x) ((x) * (x)) using namespace std; int a[3], p, q, r; int main() { ios::sync_with_stdio(false); while (cin >> a[0] >> a[1] >> a[2]) { sort(a, a + 3); if (a[0] + a[1] <= a[2]) break; if (sqr(a[0]) + sqr(a[1]) == sqr(a[2])) p++; else if (sqr(a[0]) + sqr(a[1]) < sqr(a[2])) q++; else r++; } cout << p + q + r << ' ' << p << ' ' << q << ' ' << r << endl; return 0; }
#include <bits/stdc++.h> #define sqr(x) ((x) * (x)) using namespace std; int a[3], p, q, r; int main() { ios::sync_with_stdio(false); while (cin >> a[0] >> a[1] >> a[2]) { sort(a, a + 3); if (a[0] + a[1] <= a[2]) break; if (sqr(a[0]) + sqr(a[1]) == sqr(a[2])) p++; else if (sqr(a[0]) + sqr(a[1]) > sqr(a[2])) q++; else r++; } cout << p + q + r << ' ' << p << ' ' << q << ' ' << r << endl; return 0; }
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47]]
1
180
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { int a, b, c; a = b = c = 0; while (1) { int k[3]; for (int d = 0; d < 3; d++) cin >> k[d]; sort(k, k + 3); if (k[0] + k[1] <= k[2]) { printf("%d %d %d %d\n", a + b + c, b, a, c); return 0; } int e = k[0] * k[0] + k[1] * k[1], f = k[2] * k[2]; if (e < f) a++; else if (e == f) b++; else c++; } }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int main() { int a, b, c; a = b = c = 0; while (1) { int k[3]; for (int d = 0; d < 3; d++) cin >> k[d]; sort(k, k + 3); if (k[0] + k[1] <= k[2]) { printf("%d %d %d %d\n", a + b + c, b, a, c); return 0; } int e = k[0] * k[0] + k[1] * k[1], f = k[2] * k[2]; if (e > f) a++; else if (e == f) b++; else c++; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
175
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 0.0000000001 #define INF 1e9 #define MOD 1000000007 #define rep(i, n) for (i = 0; i < n; i++) #define loop(i, a, n) for (i = a; i < n; i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define first F #define second S typedef vector<int> vi; typedef pair<int, int> pii; int main(void) { vi l(3); vi n(4, 0); while (scanf("%d %d %d", &l[0], &l[1], &l[2]) != EOF) { sort(all(l)); if (l[0] + l[1] > l[2]) n[0]++; else continue; int hypo = l[0] * l[0] + l[1] * l[1]; if (hypo == l[2] * l[2]) n[1]++; else if (hypo > l[2] * l[2]) n[2]++; else if (hypo < l[2] * l[2]) n[3]++; } printf("%d %d %d %d\n", n[0], n[1], n[2], n[3]); }
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 0.0000000001 #define INF 1e9 #define MOD 1000000007 #define rep(i, n) for (i = 0; i < n; i++) #define loop(i, a, n) for (i = a; i < n; i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define first F #define second S typedef vector<int> vi; typedef pair<int, int> pii; int main(void) { vi l(3); vi n(4, 0); while (scanf("%d %d %d", &l[0], &l[1], &l[2]) != EOF) { sort(all(l)); if (l[0] + l[1] > l[2]) n[0]++; else break; int hypo = l[0] * l[0] + l[1] * l[1]; if (hypo == l[2] * l[2]) n[1]++; else if (hypo > l[2] * l[2]) n[2]++; else if (hypo < l[2] * l[2]) n[3]++; } printf("%d %d %d %d\n", n[0], n[1], n[2], n[3]); }
[["-", 8, 9, 0, 57, 75, 76, 0, 116, 0, 117], ["+", 8, 9, 0, 57, 75, 76, 0, 93, 0, 94]]
1
300
#include <algorithm> #include <iostream> using namespace std; int main() { int e[3]; int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0; while (cin >> e[0] >> e[1] >> e[2]) { sort(e, e + 3); int a = e[0], b = e[1], m = e[2]; if (m < a + b) { ++cnt1; if (m * m < a * a + b * b) ++cnt3; else if (m * m == a * a + b * b) ++cnt2; else ++cnt4; } } cout << cnt1 << " " << cnt2 << " " << cnt3 << " " << cnt4 << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int e[3]; int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0; while (cin >> e[0] >> e[1] >> e[2]) { sort(e, e + 3); int a = e[0], b = e[1], m = e[2]; if (m < a + b) { ++cnt1; if (m * m < a * a + b * b) ++cnt3; else if (m * m == a * a + b * b) ++cnt2; else ++cnt4; } else break; } cout << cnt1 << " " << cnt2 << " " << cnt3 << " " << cnt4 << endl; return 0; }
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 75, 76, 0, 93, 0, 35]]
1
168
#include <iostream> using namespace std; typedef unsigned int U4; #define TRUE 1 #define FALSE 0 #define ACUTE_TRIANGLE 0 #define RIGHT_TRIANGLE 1 #define OBTUSE_TRIANGLE 2 U4 TrinagleNum = 0; U4 AcuteTriangleNum = 0; U4 RightTriangleNum = 0; U4 ObtuseTriangleNum = 0; U4 U4_TriangleCheck(U4, U4, U4); U4 U4_TypeCheck(U4, U4, U4); void V_LengthSort(U4 *, U4 *, U4 *); int main(void) { U4 a; U4 b; U4 c; while (1) { cin >> a >> b >> c; if (U4_TriangleCheck(a, b, c) == TRUE) { TrinagleNum++; if (U4_TypeCheck(a, b, c) == ACUTE_TRIANGLE) { AcuteTriangleNum++; } else if (U4_TypeCheck(a, b, c) == OBTUSE_TRIANGLE) { ObtuseTriangleNum++; } else { RightTriangleNum++; } } else { break; } } cout << TrinagleNum << " " << RightTriangleNum << " " << AcuteTriangleNum << " " << ObtuseTriangleNum << endl; } U4 U4_TriangleCheck(U4 a, U4 b, U4 c) { if ((a + b > c) && (b + c > a) && (c + a > b)) { return TRUE; } else { return FALSE; } } U4 U4_TypeCheck(U4 a, U4 b, U4 c) { U4 LongLength; U4 MiddleLength; U4 ShortLength; U4 LongLengthSquare; U4 MiddleLengthSquare; U4 ShortLengthSquare; LongLength = a; MiddleLength = b; ShortLength = c; V_LengthSort(&LongLength, &MiddleLength, &ShortLength); LongLengthSquare = LongLength * LongLength; MiddleLengthSquare = MiddleLength * MiddleLength; ShortLengthSquare = ShortLength * ShortLength; if (MiddleLengthSquare + ShortLengthSquare > LongLengthSquare) { return OBTUSE_TRIANGLE; } else if (MiddleLengthSquare + ShortLengthSquare < LongLengthSquare) { return ACUTE_TRIANGLE; } else { return RIGHT_TRIANGLE; } } void V_LengthSort(U4 *Long, U4 *Middle, U4 *Short) { U4 buff; if ((*Long >= *Middle) && (*Long >= *Short)) { // Do Nothing } else if (*Middle >= *Short) { buff = *Long; *Long = *Middle; *Middle = buff; } else { buff = *Long; *Long = *Short; *Short = buff; } }
#include <iostream> using namespace std; typedef unsigned int U4; #define TRUE 1 #define FALSE 0 #define ACUTE_TRIANGLE 0 #define RIGHT_TRIANGLE 1 #define OBTUSE_TRIANGLE 2 U4 TrinagleNum = 0; U4 AcuteTriangleNum = 0; U4 RightTriangleNum = 0; U4 ObtuseTriangleNum = 0; U4 U4_TriangleCheck(U4, U4, U4); U4 U4_TypeCheck(U4, U4, U4); void V_LengthSort(U4 *, U4 *, U4 *); int main(void) { U4 a; U4 b; U4 c; while (1) { cin >> a >> b >> c; if (U4_TriangleCheck(a, b, c) == TRUE) { TrinagleNum++; if (U4_TypeCheck(a, b, c) == ACUTE_TRIANGLE) { AcuteTriangleNum++; } else if (U4_TypeCheck(a, b, c) == OBTUSE_TRIANGLE) { ObtuseTriangleNum++; } else { RightTriangleNum++; } } else { break; } } cout << TrinagleNum << " " << RightTriangleNum << " " << AcuteTriangleNum << " " << ObtuseTriangleNum << endl; } U4 U4_TriangleCheck(U4 a, U4 b, U4 c) { if ((a + b > c) && (b + c > a) && (c + a > b)) { return TRUE; } else { return FALSE; } } U4 U4_TypeCheck(U4 a, U4 b, U4 c) { U4 LongLength; U4 MiddleLength; U4 ShortLength; U4 LongLengthSquare; U4 MiddleLengthSquare; U4 ShortLengthSquare; LongLength = a; MiddleLength = b; ShortLength = c; V_LengthSort(&LongLength, &MiddleLength, &ShortLength); LongLengthSquare = LongLength * LongLength; MiddleLengthSquare = MiddleLength * MiddleLength; ShortLengthSquare = ShortLength * ShortLength; if (MiddleLengthSquare + ShortLengthSquare > LongLengthSquare) { return ACUTE_TRIANGLE; } else if (MiddleLengthSquare + ShortLengthSquare < LongLengthSquare) { return OBTUSE_TRIANGLE; } else { return RIGHT_TRIANGLE; } } void V_LengthSort(U4 *Long, U4 *Middle, U4 *Short) { U4 buff; if ((*Long >= *Middle) && (*Long >= *Short)) { // Do Nothing } else if (*Middle >= *Short) { buff = *Long; *Long = *Middle; *Middle = buff; } else { buff = *Long; *Long = *Short; *Short = buff; } }
[["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 22], ["-", 75, 76, 0, 57, 64, 9, 0, 37, 0, 22], ["+", 75, 76, 0, 57, 64, 9, 0, 37, 0, 22]]
1
444
/** * */ // #include {{{ #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <chrono> #include <cmath> #include <cstdint> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <forward_list> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #ifdef LOCAL #include <fmt/format.h> #include <fmt/ostream.h> #endif using namespace std; // }}} // type {{{ using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using i128 = __int128_t; using u128 = __uint128_t; template <typename T> using MaxHeap = priority_queue<T, vector<T>, less<T>>; template <typename T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; // }}} // hide {{{ #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-const-variable" #endif // }}} // 適宜調整 constexpr bool AUTOFLUSH = false; constexpr int IOS_PREC = 12; constexpr int INF_I32 = 1'010'000'000; constexpr i64 INF_I64 = 1'010'000'000'000'000'000LL; constexpr auto INF = INF_I64; constexpr double EPS = 1e-12; constexpr i64 MOD = 1'000'000'007; // hide {{{ #ifdef __clang__ #pragma clang diagnostic pop #endif // }}} // util {{{ constexpr i32 I32_MAX = numeric_limits<i32>::max(); constexpr i32 I32_MIN = numeric_limits<i32>::min(); constexpr i64 I64_MAX = numeric_limits<i64>::max(); constexpr i64 I64_MIN = numeric_limits<i64>::min(); constexpr double PI = 3.14159265358979323846; template <typename F> class RecursiveFunc { public: RecursiveFunc(F &&f) : f_(f) {} template <typename... Args> decltype(auto) operator()(Args &&...args) const { return f_(*this, forward<Args>(args)...); } private: F f_; }; template <typename F> auto RECURSIVE(F &&f) { return RecursiveFunc<decay_t<F>>(forward<F>(f)); } template <typename T> int GETBIT(T x, int i) { return (x >> i) & 1; } template <typename T> T SETBIT(T x, int i) { return x | (T(1) << i); } template <typename T> T CLEARBIT(T x, int i) { return x & ~(T(1) << i); } template <typename T> constexpr const T &MAX(const T &x, const T &y) { return std::max(x, y); } template <typename T, typename Comp> constexpr const T &MAX(const T &x, const T &y, Comp comp) { return std::max(x, y, comp); } template <typename T> constexpr T MAX(initializer_list<T> ilist) { return std::max(ilist); } template <typename T, typename Comp> constexpr T MAX(initializer_list<T> ilist, Comp comp) { return std::max(ilist, comp); } template <typename T> constexpr const T &MIN(const T &x, const T &y) { return std::min(x, y); } template <typename T, typename Comp> constexpr const T &MIN(const T &x, const T &y, Comp comp) { return std::min(x, y, comp); } template <typename T> constexpr T MIN(initializer_list<T> ilist) { return std::min(ilist); } template <typename T, typename Comp> constexpr T MIN(initializer_list<T> ilist, Comp comp) { return std::min(ilist, comp); } template <typename T> constexpr T ABS(T x) { static_assert(is_signed<T>::value, "ABS(): argument must be signed"); return x < 0 ? -x : x; } template <typename T> constexpr T abs_diff(T x, T y) { return x < y ? y - x : x - y; } template <typename T> constexpr bool is_odd(T x) { return x % 2 != 0; } template <typename T> constexpr bool is_even(T x) { return x % 2 == 0; } template <typename T> constexpr bool parity_same(T x, T y) { return (is_odd(x) && is_odd(y)) || (is_even(x) && is_even(y)); } template <typename T> constexpr int cmp(T x, T y) { return (y < x) - (x < y); } template <typename T> constexpr int sgn(T x) { return cmp(x, T(0)); } constexpr i64 ipow(i64 a, i64 b) { assert(b >= 0); i64 res(1); for (i64 i = 0; i < b; ++i) res *= a; return res; } pair<i64, i64> divmod(i64 a, i64 b) { return make_pair(a / b, a % b); } constexpr i64 div_ceil(i64 a, i64 b) { return a / b + (((a < 0) ^ (b > 0)) && (a % b)); } constexpr i64 div_floor(i64 a, i64 b) { return a / b - (((a > 0) ^ (b > 0)) && (a % b)); } constexpr i64 modulo(i64 a, i64 b) { assert(0 < b); i64 r = a % b; return r >= 0 ? r : r + b; } template <typename T> constexpr T CLAMP(T x, T lo, T hi) { assert(lo <= hi); if (x < lo) return lo; else if (hi < x) return hi; else return x; } template <typename T, typename U> bool chmax(T &xmax, const U &x) { if (xmax < x) { xmax = x; return true; } else { return false; } } template <typename T, typename U> bool chmin(T &xmin, const U &x) { if (x < xmin) { xmin = x; return true; } else { return false; } } template <typename T> constexpr int SIZE(const T &c) { return static_cast<int>(c.size()); } template <typename T, size_t N> constexpr int SIZE(const T (&)[N]) { return static_cast<int>(N); } template <typename InputIt, typename T> int argfind(InputIt first, InputIt last, const T &x) { auto it = find(first, last, x); return distance(first, it); } template <typename InputIt> int argmax(InputIt first, InputIt last) { auto it = max_element(first, last); return distance(first, it); } template <typename InputIt> int argmin(InputIt first, InputIt last) { auto it = min_element(first, last); return distance(first, it); } template <typename InputIt> bool alltrue(InputIt first, InputIt last) { return all_of(first, last, [](bool b) { return b; }); } template <typename InputIt> bool anytrue(InputIt first, InputIt last) { return any_of(first, last, [](bool b) { return b; }); } template <typename InputIt> bool allfalse(InputIt first, InputIt last) { return !anytrue(first, last); } template <typename InputIt> bool anyfalse(InputIt first, InputIt last) { return !alltrue(first, last); } // hash {{{ template <typename T> struct myhash { size_t operator()(const T &x) const { hash<T> h; return h(x); } }; template <typename T> size_t myhash_value(const T &x) { return hash<T>()(x); } template <typename T> void myhash_combine(size_t &seed, const T &x) { seed ^= myhash_value(x) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } template <typename T1, typename T2> struct myhash<pair<T1, T2>> { size_t operator()(const pair<T1, T2> &p) const { size_t seed = 0; myhash_combine(seed, p.first); myhash_combine(seed, p.second); return seed; } }; template <size_t I = 0, typename... TS, enable_if_t<I == sizeof...(TS), nullptr_t> = nullptr> void TUPLEHASH(size_t &, const tuple<TS...> &) {} template <size_t I = 0, typename... TS, enable_if_t<I<sizeof...(TS), nullptr_t> = nullptr> void TUPLEHASH( size_t &seed, const tuple<TS...> &t) { myhash_combine(seed, get<I>(t)); TUPLEHASH<I + 1, TS...>(seed, t); } template <typename... TS> struct myhash<tuple<TS...>> { size_t operator()(const tuple<TS...> &t) const { size_t seed = 0; TUPLEHASH(seed, t); return seed; } }; template <typename Seq> void SEQHASH(size_t &seed, const Seq &v) { for (const auto &e : v) myhash_combine(seed, e); } template <typename T> struct myhash<vector<T>> { size_t operator()(const vector<T> &v) const { size_t seed = 0; SEQHASH(seed, v); return seed; } }; template <typename T, size_t N> struct myhash<array<T, N>> { size_t operator()(const array<T, N> &v) const { size_t seed = 0; SEQHASH(seed, v); return seed; } }; template <typename T> using HashSet = unordered_set<T, myhash<T>>; template <typename K, typename V> using HashMap = unordered_map<K, V, myhash<K>>; template <typename T> using HashMultiSet = unordered_multiset<T, myhash<T>>; template <typename K, typename V> using HashMultiMap = unordered_multimap<K, V, myhash<K>>; // }}} template <typename T, typename... Args> void vec_emplace_front(vector<T> &v, Args &&...args) { v.emplace(begin(v), args...); } template <typename K, typename V> pair<typename map<K, V>::iterator, bool> insert_or_assign(map<K, V> &m, const K &k, const V &v) { auto it = m.lower_bound(k); if (it != end(m) && !m.key_comp()(k, it->first)) { it->second = v; return make_pair(it, false); } else { auto it_ins = m.insert(it, make_pair(k, v)); return make_pair(it_ins, true); } } template <typename K, typename V> pair<typename HashMap<K, V>::iterator, bool> insert_or_assign(HashMap<K, V> &m, const K &k, const V &v) { auto it = m.find(k); if (it != end(m)) { it->second = v; return make_pair(it, false); } else { auto it_ins = m.insert(it, make_pair(k, v)); return make_pair(it_ins, true); } } template <typename T> string TO_STRING(const T &x) { ostringstream out; out << x; return out.str(); } template <typename InputIt> string JOIN(InputIt first, InputIt last, const string &sep) { ostringstream out; while (first != last) { out << *first++; if (first != last) out << sep; } return out.str(); } template <typename InputIt> auto SUM(InputIt first, InputIt last) { using T = typename iterator_traits<InputIt>::value_type; return accumulate(first, last, T()); } template <typename T> void UNIQ(T &c) { c.erase(unique(begin(c), end(c)), end(c)); } template <typename T, typename F> enable_if_t<rank<T>::value == 0> ARRAY_FOREACH(T &e, F f) { f(e); } template <typename Array, typename F> enable_if_t<rank<Array>::value != 0> ARRAY_FOREACH(Array &ary, F f) { for (auto &e : ary) ARRAY_FOREACH(e, f); } template <typename Array, typename U> enable_if_t<rank<Array>::value != 0> ARRAY_FILL(Array &ary, const U &v) { ARRAY_FOREACH(ary, [&v](auto &elem) { elem = v; }); } template <typename T> T POP_BACK(vector<T> &que) { T x = que.back(); que.pop_back(); return x; } template <typename T> T POP_BACK(deque<T> &que) { T x = que.back(); que.pop_back(); return x; } template <typename T> T POP_FRONT(deque<T> &que) { T x = que.front(); que.pop_front(); return x; } template <typename T, typename C> T POP(stack<T, C> &stk) { T x = stk.top(); stk.pop(); return x; } template <typename T, typename C> T POP(queue<T, C> &que) { T x = que.front(); que.pop(); return x; } template <typename T, typename Cont, typename Cmp> T POP(priority_queue<T, Cont, Cmp> &que) { T x = que.top(); que.pop(); return x; } template <typename T> void RD(T &x) { cin >> x; #ifdef LOCAL if (!cin) assert(false); #endif } template <typename T> void RD(vector<T> &v, int n) { v.reserve(n); for (int i = 0; i < n; ++i) { T e; RD(e); v.emplace_back(e); } } template <typename T, size_t N> void RD(array<T, N> &v) { for (size_t i = 0; i < N; ++i) { RD(v[i]); } } // 出力 {{{ // FPRINTSEQ {{{ template <typename InputIt> ostream &FPRINTSEQ(ostream &out, InputIt first, InputIt last) { while (first != last) { out << *first++; if (first != last) out << ' '; } return out; } template <typename InputIt> ostream &PRINTSEQ(InputIt first, InputIt last) { return FPRINTSEQ(cout, first, last); } template <typename InputIt> ostream &DPRINTSEQ(InputIt first, InputIt last) { #ifdef LOCAL FPRINTSEQ(cerr, first, last); #endif return cerr; } // }}} // 1次元生配列 {{{ template <typename T, size_t N> ostream &FPRINTARRAY1(ostream &out, const T (&c)[N]) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T, size_t N> ostream &PRINTARRAY1(const T (&c)[N]) { return FPRINTARRAY1(cout, c); } template <typename T, size_t N> ostream &DPRINTARRAY1(const T (&c)[N]) { #ifdef LOCAL FPRINTARRAY1(cerr, c); #endif return cerr; } // }}} // 2次元生配列 {{{ template <typename T, size_t N1, size_t N2> ostream &FPRINTARRAY2(ostream &out, const T (&c)[N1][N2]) { out << '\n'; for (const auto &e : c) { FPRINTARRAY1(out, e) << '\n'; } return out; } template <typename T, size_t N1, size_t N2> ostream &PRINTARRAY2(const T (&c)[N1][N2]) { return FPRINTARRAY2(cout, c); } template <typename T, size_t N1, size_t N2> ostream &DPRINTARRAY2(const T (&c)[N1][N2]) { #ifdef LOCAL FPRINTARRAY2(cerr, c); #endif return cerr; } // }}} // 非mapコンテナ {{{ template <typename T> ostream &operator<<(ostream &out, const vector<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } // 特別扱い template <typename T> ostream &operator<<(ostream &out, const vector<vector<T>> &c) { out << '\n'; for (const auto &e : c) { out << e << '\n'; } return out; } // 特別扱い ostream &operator<<(ostream &out, const vector<string> &c) { out << '\n'; for (const string &e : c) { out << e << '\n'; } return out; } template <typename T> ostream &operator<<(ostream &out, const deque<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const set<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const HashSet<T> &c) { return out << set<T>(begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const multiset<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const HashMultiSet<T> &c) { return out << multiset<T>(begin(c), end(c)); } template <typename T, size_t N> ostream &operator<<(ostream &out, const array<T, N> &c) { return FPRINTSEQ(out, begin(c), end(c)); } // }}} // mapコンテナ {{{ template <typename InputIt> ostream &FPRINTMAP(ostream &out, InputIt first, InputIt last) { out << "{\n"; for (auto it = first; it != last; ++it) { out << " " << it->first << " : " << it->second << '\n'; } out << "}\n"; return out; } template <typename InputIt> ostream &PRINTMAP(InputIt first, InputIt last) { return FPRINTMAP(cout, first, last); } template <typename InputIt> ostream &DPRINTMAP(InputIt first, InputIt last) { #ifdef LOCAL FPRINTMAP(cerr, first, last); #endif return cerr; } template <typename K, typename V> ostream &operator<<(ostream &out, const map<K, V> &c) { return FPRINTMAP(out, begin(c), end(c)); } template <typename K, typename V> ostream &operator<<(ostream &out, const HashMap<K, V> &c) { return out << map<K, V>(begin(c), end(c)); } template <typename K, typename V> ostream &operator<<(ostream &out, const multimap<K, V> &c) { return FPRINTMAP(out, begin(c), end(c)); } template <typename K, typename V> ostream &operator<<(ostream &out, const HashMultiMap<K, V> &c) { return out << multimap<K, V>(begin(c), end(c)); } // }}} // stack/queue/priority_queue {{{ template <typename T, typename C> ostream &operator<<(ostream &out, stack<T, C> c) { while (!c.empty()) { out << c.top(); c.pop(); if (!c.empty()) out << ' '; } return out; } template <typename T, typename C> ostream &operator<<(ostream &out, queue<T, C> c) { while (!c.empty()) { out << c.front(); c.pop(); if (!c.empty()) out << ' '; } return out; } template <typename T, typename Cont, typename Cmp> ostream &operator<<(ostream &out, priority_queue<T, Cont, Cmp> c) { while (!c.empty()) { out << c.top(); c.pop(); if (!c.empty()) out << ' '; } return out; } // }}} // pair/tuple {{{ template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &p) { return out << '(' << p.first << ',' << p.second << ')'; } template <size_t I = 0, typename... TS, enable_if_t<I == sizeof...(TS), nullptr_t> = nullptr> ostream &FPRINTTUPLE(ostream &out, const tuple<TS...> &) { if (sizeof...(TS) == 0) out << '('; return out << ')'; } template <size_t I = 0, typename... TS, enable_if_t<I<sizeof...(TS), nullptr_t> = nullptr> ostream &FPRINTTUPLE(ostream &out, const tuple<TS...> &t) { if (I == 0) out << '('; else out << ','; out << get<I>(t); return FPRINTTUPLE<I + 1, TS...>(out, t); } template <typename... TS> ostream &operator<<(ostream &out, const tuple<TS...> &t) { return FPRINTTUPLE(out, t); } // }}} // PRINT {{{ ostream &FPRINT(ostream &out) { return out; } template <typename T, typename... TS> ostream &FPRINT(ostream &out, const T &x, const TS &...args) { out << x; if (sizeof...(args)) out << ' '; return FPRINT(out, args...); } template <typename... TS> ostream &FPRINTLN(ostream &out, const TS &...args) { FPRINT(out, args...); return out << '\n'; } template <typename... TS> ostream &PRINT(const TS &...args) { return FPRINT(cout, args...); } template <typename... TS> ostream &PRINTLN(const TS &...args) { return FPRINTLN(cout, args...); } template <typename... TS> ostream &DPRINT(const TS &...args) { #ifdef LOCAL FPRINT(cerr, args...); #endif return cerr; } template <typename... TS> ostream &DPRINTLN(const TS &...args) { #ifdef LOCAL FPRINTLN(cerr, args...); #endif return cerr; } // }}} // }}} void FLUSH() { cout.flush(); } [[noreturn]] void EXIT() { #ifdef LOCAL cout.flush(); cerr.flush(); #else FLUSH(); #endif // quick_exit(0); // does not work on codeforces _Exit(0); } struct IoInit { IoInit() { #ifndef LOCAL cin.tie(nullptr); ios::sync_with_stdio(false); #endif cout << fixed << setprecision(IOS_PREC); #ifdef LOCAL cerr << fixed << setprecision(IOS_PREC); #endif if (AUTOFLUSH) cout << unitbuf; } } IOINIT; #define FOR(i, start, end) for (i64 i = (start); i < (end); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(f, c, ...) \ (([&](decltype((c)) cc) { \ return (f)(begin(cc), end(cc), ##__VA_ARGS__); \ })(c)) #define GENERIC(f) \ ([](auto &&...args) -> decltype(auto) { \ return (f)(forward<decltype(args)>(args)...); \ }) #define DBG(x) DPRINTLN('L', __LINE__, ':', #x, ':', (x)) #define PAIR make_pair #define TUPLE make_tuple // }}} void solve() { array<int, 3> ans{}; while (true) { array<int, 3> v; RD(v); ALL(sort, v); int a = v[0]; int b = v[1]; int c = v[2]; if (a + b <= c) break; int lhs = a * a + b * b; int rhs = c * c; if (lhs < rhs) { ++ans[1]; } else if (lhs == rhs) { ++ans[0]; } else { ++ans[2]; } } PRINT(ALL(SUM, ans)); PRINT(' '); PRINTLN(ans); } signed main(signed /*argc*/, char ** /*argv*/) { solve(); EXIT(); }
/** * */ // #include {{{ #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <chrono> #include <cmath> #include <cstdint> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <forward_list> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #ifdef LOCAL #include <fmt/format.h> #include <fmt/ostream.h> #endif using namespace std; // }}} // type {{{ using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using i128 = __int128_t; using u128 = __uint128_t; template <typename T> using MaxHeap = priority_queue<T, vector<T>, less<T>>; template <typename T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; // }}} // hide {{{ #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-const-variable" #endif // }}} // 適宜調整 constexpr bool AUTOFLUSH = false; constexpr int IOS_PREC = 12; constexpr int INF_I32 = 1'010'000'000; constexpr i64 INF_I64 = 1'010'000'000'000'000'000LL; constexpr auto INF = INF_I64; constexpr double EPS = 1e-12; constexpr i64 MOD = 1'000'000'007; // hide {{{ #ifdef __clang__ #pragma clang diagnostic pop #endif // }}} // util {{{ constexpr i32 I32_MAX = numeric_limits<i32>::max(); constexpr i32 I32_MIN = numeric_limits<i32>::min(); constexpr i64 I64_MAX = numeric_limits<i64>::max(); constexpr i64 I64_MIN = numeric_limits<i64>::min(); constexpr double PI = 3.14159265358979323846; template <typename F> class RecursiveFunc { public: RecursiveFunc(F &&f) : f_(f) {} template <typename... Args> decltype(auto) operator()(Args &&...args) const { return f_(*this, forward<Args>(args)...); } private: F f_; }; template <typename F> auto RECURSIVE(F &&f) { return RecursiveFunc<decay_t<F>>(forward<F>(f)); } template <typename T> int GETBIT(T x, int i) { return (x >> i) & 1; } template <typename T> T SETBIT(T x, int i) { return x | (T(1) << i); } template <typename T> T CLEARBIT(T x, int i) { return x & ~(T(1) << i); } template <typename T> constexpr const T &MAX(const T &x, const T &y) { return std::max(x, y); } template <typename T, typename Comp> constexpr const T &MAX(const T &x, const T &y, Comp comp) { return std::max(x, y, comp); } template <typename T> constexpr T MAX(initializer_list<T> ilist) { return std::max(ilist); } template <typename T, typename Comp> constexpr T MAX(initializer_list<T> ilist, Comp comp) { return std::max(ilist, comp); } template <typename T> constexpr const T &MIN(const T &x, const T &y) { return std::min(x, y); } template <typename T, typename Comp> constexpr const T &MIN(const T &x, const T &y, Comp comp) { return std::min(x, y, comp); } template <typename T> constexpr T MIN(initializer_list<T> ilist) { return std::min(ilist); } template <typename T, typename Comp> constexpr T MIN(initializer_list<T> ilist, Comp comp) { return std::min(ilist, comp); } template <typename T> constexpr T ABS(T x) { static_assert(is_signed<T>::value, "ABS(): argument must be signed"); return x < 0 ? -x : x; } template <typename T> constexpr T abs_diff(T x, T y) { return x < y ? y - x : x - y; } template <typename T> constexpr bool is_odd(T x) { return x % 2 != 0; } template <typename T> constexpr bool is_even(T x) { return x % 2 == 0; } template <typename T> constexpr bool parity_same(T x, T y) { return (is_odd(x) && is_odd(y)) || (is_even(x) && is_even(y)); } template <typename T> constexpr int cmp(T x, T y) { return (y < x) - (x < y); } template <typename T> constexpr int sgn(T x) { return cmp(x, T(0)); } constexpr i64 ipow(i64 a, i64 b) { assert(b >= 0); i64 res(1); for (i64 i = 0; i < b; ++i) res *= a; return res; } pair<i64, i64> divmod(i64 a, i64 b) { return make_pair(a / b, a % b); } constexpr i64 div_ceil(i64 a, i64 b) { return a / b + (((a < 0) ^ (b > 0)) && (a % b)); } constexpr i64 div_floor(i64 a, i64 b) { return a / b - (((a > 0) ^ (b > 0)) && (a % b)); } constexpr i64 modulo(i64 a, i64 b) { assert(0 < b); i64 r = a % b; return r >= 0 ? r : r + b; } template <typename T> constexpr T CLAMP(T x, T lo, T hi) { assert(lo <= hi); if (x < lo) return lo; else if (hi < x) return hi; else return x; } template <typename T, typename U> bool chmax(T &xmax, const U &x) { if (xmax < x) { xmax = x; return true; } else { return false; } } template <typename T, typename U> bool chmin(T &xmin, const U &x) { if (x < xmin) { xmin = x; return true; } else { return false; } } template <typename T> constexpr int SIZE(const T &c) { return static_cast<int>(c.size()); } template <typename T, size_t N> constexpr int SIZE(const T (&)[N]) { return static_cast<int>(N); } template <typename InputIt, typename T> int argfind(InputIt first, InputIt last, const T &x) { auto it = find(first, last, x); return distance(first, it); } template <typename InputIt> int argmax(InputIt first, InputIt last) { auto it = max_element(first, last); return distance(first, it); } template <typename InputIt> int argmin(InputIt first, InputIt last) { auto it = min_element(first, last); return distance(first, it); } template <typename InputIt> bool alltrue(InputIt first, InputIt last) { return all_of(first, last, [](bool b) { return b; }); } template <typename InputIt> bool anytrue(InputIt first, InputIt last) { return any_of(first, last, [](bool b) { return b; }); } template <typename InputIt> bool allfalse(InputIt first, InputIt last) { return !anytrue(first, last); } template <typename InputIt> bool anyfalse(InputIt first, InputIt last) { return !alltrue(first, last); } // hash {{{ template <typename T> struct myhash { size_t operator()(const T &x) const { hash<T> h; return h(x); } }; template <typename T> size_t myhash_value(const T &x) { return hash<T>()(x); } template <typename T> void myhash_combine(size_t &seed, const T &x) { seed ^= myhash_value(x) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } template <typename T1, typename T2> struct myhash<pair<T1, T2>> { size_t operator()(const pair<T1, T2> &p) const { size_t seed = 0; myhash_combine(seed, p.first); myhash_combine(seed, p.second); return seed; } }; template <size_t I = 0, typename... TS, enable_if_t<I == sizeof...(TS), nullptr_t> = nullptr> void TUPLEHASH(size_t &, const tuple<TS...> &) {} template <size_t I = 0, typename... TS, enable_if_t<I<sizeof...(TS), nullptr_t> = nullptr> void TUPLEHASH( size_t &seed, const tuple<TS...> &t) { myhash_combine(seed, get<I>(t)); TUPLEHASH<I + 1, TS...>(seed, t); } template <typename... TS> struct myhash<tuple<TS...>> { size_t operator()(const tuple<TS...> &t) const { size_t seed = 0; TUPLEHASH(seed, t); return seed; } }; template <typename Seq> void SEQHASH(size_t &seed, const Seq &v) { for (const auto &e : v) myhash_combine(seed, e); } template <typename T> struct myhash<vector<T>> { size_t operator()(const vector<T> &v) const { size_t seed = 0; SEQHASH(seed, v); return seed; } }; template <typename T, size_t N> struct myhash<array<T, N>> { size_t operator()(const array<T, N> &v) const { size_t seed = 0; SEQHASH(seed, v); return seed; } }; template <typename T> using HashSet = unordered_set<T, myhash<T>>; template <typename K, typename V> using HashMap = unordered_map<K, V, myhash<K>>; template <typename T> using HashMultiSet = unordered_multiset<T, myhash<T>>; template <typename K, typename V> using HashMultiMap = unordered_multimap<K, V, myhash<K>>; // }}} template <typename T, typename... Args> void vec_emplace_front(vector<T> &v, Args &&...args) { v.emplace(begin(v), args...); } template <typename K, typename V> pair<typename map<K, V>::iterator, bool> insert_or_assign(map<K, V> &m, const K &k, const V &v) { auto it = m.lower_bound(k); if (it != end(m) && !m.key_comp()(k, it->first)) { it->second = v; return make_pair(it, false); } else { auto it_ins = m.insert(it, make_pair(k, v)); return make_pair(it_ins, true); } } template <typename K, typename V> pair<typename HashMap<K, V>::iterator, bool> insert_or_assign(HashMap<K, V> &m, const K &k, const V &v) { auto it = m.find(k); if (it != end(m)) { it->second = v; return make_pair(it, false); } else { auto it_ins = m.insert(it, make_pair(k, v)); return make_pair(it_ins, true); } } template <typename T> string TO_STRING(const T &x) { ostringstream out; out << x; return out.str(); } template <typename InputIt> string JOIN(InputIt first, InputIt last, const string &sep) { ostringstream out; while (first != last) { out << *first++; if (first != last) out << sep; } return out.str(); } template <typename InputIt> auto SUM(InputIt first, InputIt last) { using T = typename iterator_traits<InputIt>::value_type; return accumulate(first, last, T()); } template <typename T> void UNIQ(T &c) { c.erase(unique(begin(c), end(c)), end(c)); } template <typename T, typename F> enable_if_t<rank<T>::value == 0> ARRAY_FOREACH(T &e, F f) { f(e); } template <typename Array, typename F> enable_if_t<rank<Array>::value != 0> ARRAY_FOREACH(Array &ary, F f) { for (auto &e : ary) ARRAY_FOREACH(e, f); } template <typename Array, typename U> enable_if_t<rank<Array>::value != 0> ARRAY_FILL(Array &ary, const U &v) { ARRAY_FOREACH(ary, [&v](auto &elem) { elem = v; }); } template <typename T> T POP_BACK(vector<T> &que) { T x = que.back(); que.pop_back(); return x; } template <typename T> T POP_BACK(deque<T> &que) { T x = que.back(); que.pop_back(); return x; } template <typename T> T POP_FRONT(deque<T> &que) { T x = que.front(); que.pop_front(); return x; } template <typename T, typename C> T POP(stack<T, C> &stk) { T x = stk.top(); stk.pop(); return x; } template <typename T, typename C> T POP(queue<T, C> &que) { T x = que.front(); que.pop(); return x; } template <typename T, typename Cont, typename Cmp> T POP(priority_queue<T, Cont, Cmp> &que) { T x = que.top(); que.pop(); return x; } template <typename T> void RD(T &x) { cin >> x; #ifdef LOCAL if (!cin) assert(false); #endif } template <typename T> void RD(vector<T> &v, int n) { v.reserve(n); for (int i = 0; i < n; ++i) { T e; RD(e); v.emplace_back(e); } } template <typename T, size_t N> void RD(array<T, N> &v) { for (size_t i = 0; i < N; ++i) { RD(v[i]); } } // 出力 {{{ // FPRINTSEQ {{{ template <typename InputIt> ostream &FPRINTSEQ(ostream &out, InputIt first, InputIt last) { while (first != last) { out << *first++; if (first != last) out << ' '; } return out; } template <typename InputIt> ostream &PRINTSEQ(InputIt first, InputIt last) { return FPRINTSEQ(cout, first, last); } template <typename InputIt> ostream &DPRINTSEQ(InputIt first, InputIt last) { #ifdef LOCAL FPRINTSEQ(cerr, first, last); #endif return cerr; } // }}} // 1次元生配列 {{{ template <typename T, size_t N> ostream &FPRINTARRAY1(ostream &out, const T (&c)[N]) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T, size_t N> ostream &PRINTARRAY1(const T (&c)[N]) { return FPRINTARRAY1(cout, c); } template <typename T, size_t N> ostream &DPRINTARRAY1(const T (&c)[N]) { #ifdef LOCAL FPRINTARRAY1(cerr, c); #endif return cerr; } // }}} // 2次元生配列 {{{ template <typename T, size_t N1, size_t N2> ostream &FPRINTARRAY2(ostream &out, const T (&c)[N1][N2]) { out << '\n'; for (const auto &e : c) { FPRINTARRAY1(out, e) << '\n'; } return out; } template <typename T, size_t N1, size_t N2> ostream &PRINTARRAY2(const T (&c)[N1][N2]) { return FPRINTARRAY2(cout, c); } template <typename T, size_t N1, size_t N2> ostream &DPRINTARRAY2(const T (&c)[N1][N2]) { #ifdef LOCAL FPRINTARRAY2(cerr, c); #endif return cerr; } // }}} // 非mapコンテナ {{{ template <typename T> ostream &operator<<(ostream &out, const vector<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } // 特別扱い template <typename T> ostream &operator<<(ostream &out, const vector<vector<T>> &c) { out << '\n'; for (const auto &e : c) { out << e << '\n'; } return out; } // 特別扱い ostream &operator<<(ostream &out, const vector<string> &c) { out << '\n'; for (const string &e : c) { out << e << '\n'; } return out; } template <typename T> ostream &operator<<(ostream &out, const deque<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const set<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const HashSet<T> &c) { return out << set<T>(begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const multiset<T> &c) { return FPRINTSEQ(out, begin(c), end(c)); } template <typename T> ostream &operator<<(ostream &out, const HashMultiSet<T> &c) { return out << multiset<T>(begin(c), end(c)); } template <typename T, size_t N> ostream &operator<<(ostream &out, const array<T, N> &c) { return FPRINTSEQ(out, begin(c), end(c)); } // }}} // mapコンテナ {{{ template <typename InputIt> ostream &FPRINTMAP(ostream &out, InputIt first, InputIt last) { out << "{\n"; for (auto it = first; it != last; ++it) { out << " " << it->first << " : " << it->second << '\n'; } out << "}\n"; return out; } template <typename InputIt> ostream &PRINTMAP(InputIt first, InputIt last) { return FPRINTMAP(cout, first, last); } template <typename InputIt> ostream &DPRINTMAP(InputIt first, InputIt last) { #ifdef LOCAL FPRINTMAP(cerr, first, last); #endif return cerr; } template <typename K, typename V> ostream &operator<<(ostream &out, const map<K, V> &c) { return FPRINTMAP(out, begin(c), end(c)); } template <typename K, typename V> ostream &operator<<(ostream &out, const HashMap<K, V> &c) { return out << map<K, V>(begin(c), end(c)); } template <typename K, typename V> ostream &operator<<(ostream &out, const multimap<K, V> &c) { return FPRINTMAP(out, begin(c), end(c)); } template <typename K, typename V> ostream &operator<<(ostream &out, const HashMultiMap<K, V> &c) { return out << multimap<K, V>(begin(c), end(c)); } // }}} // stack/queue/priority_queue {{{ template <typename T, typename C> ostream &operator<<(ostream &out, stack<T, C> c) { while (!c.empty()) { out << c.top(); c.pop(); if (!c.empty()) out << ' '; } return out; } template <typename T, typename C> ostream &operator<<(ostream &out, queue<T, C> c) { while (!c.empty()) { out << c.front(); c.pop(); if (!c.empty()) out << ' '; } return out; } template <typename T, typename Cont, typename Cmp> ostream &operator<<(ostream &out, priority_queue<T, Cont, Cmp> c) { while (!c.empty()) { out << c.top(); c.pop(); if (!c.empty()) out << ' '; } return out; } // }}} // pair/tuple {{{ template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &p) { return out << '(' << p.first << ',' << p.second << ')'; } template <size_t I = 0, typename... TS, enable_if_t<I == sizeof...(TS), nullptr_t> = nullptr> ostream &FPRINTTUPLE(ostream &out, const tuple<TS...> &) { if (sizeof...(TS) == 0) out << '('; return out << ')'; } template <size_t I = 0, typename... TS, enable_if_t<I<sizeof...(TS), nullptr_t> = nullptr> ostream &FPRINTTUPLE(ostream &out, const tuple<TS...> &t) { if (I == 0) out << '('; else out << ','; out << get<I>(t); return FPRINTTUPLE<I + 1, TS...>(out, t); } template <typename... TS> ostream &operator<<(ostream &out, const tuple<TS...> &t) { return FPRINTTUPLE(out, t); } // }}} // PRINT {{{ ostream &FPRINT(ostream &out) { return out; } template <typename T, typename... TS> ostream &FPRINT(ostream &out, const T &x, const TS &...args) { out << x; if (sizeof...(args)) out << ' '; return FPRINT(out, args...); } template <typename... TS> ostream &FPRINTLN(ostream &out, const TS &...args) { FPRINT(out, args...); return out << '\n'; } template <typename... TS> ostream &PRINT(const TS &...args) { return FPRINT(cout, args...); } template <typename... TS> ostream &PRINTLN(const TS &...args) { return FPRINTLN(cout, args...); } template <typename... TS> ostream &DPRINT(const TS &...args) { #ifdef LOCAL FPRINT(cerr, args...); #endif return cerr; } template <typename... TS> ostream &DPRINTLN(const TS &...args) { #ifdef LOCAL FPRINTLN(cerr, args...); #endif return cerr; } // }}} // }}} void FLUSH() { cout.flush(); } [[noreturn]] void EXIT() { #ifdef LOCAL cout.flush(); cerr.flush(); #else FLUSH(); #endif // quick_exit(0); // does not work on codeforces _Exit(0); } struct IoInit { IoInit() { #ifndef LOCAL cin.tie(nullptr); ios::sync_with_stdio(false); #endif cout << fixed << setprecision(IOS_PREC); #ifdef LOCAL cerr << fixed << setprecision(IOS_PREC); #endif if (AUTOFLUSH) cout << unitbuf; } } IOINIT; #define FOR(i, start, end) for (i64 i = (start); i < (end); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(f, c, ...) \ (([&](decltype((c)) cc) { \ return (f)(begin(cc), end(cc), ##__VA_ARGS__); \ })(c)) #define GENERIC(f) \ ([](auto &&...args) -> decltype(auto) { \ return (f)(forward<decltype(args)>(args)...); \ }) #define DBG(x) DPRINTLN('L', __LINE__, ':', #x, ':', (x)) #define PAIR make_pair #define TUPLE make_tuple // }}} void solve() { array<int, 3> ans{}; while (true) { array<int, 3> v; RD(v); ALL(sort, v); int a = v[0]; int b = v[1]; int c = v[2]; if (a + b <= c) break; int lhs = a * a + b * b; int rhs = c * c; if (lhs < rhs) { ++ans[2]; } else if (lhs == rhs) { ++ans[0]; } else { ++ans[1]; } } PRINT(ALL(SUM, ans)); PRINT(' '); PRINTLN(ans); } signed main(signed /*argc*/, char ** /*argv*/) { solve(); EXIT(); }
[["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13]]
1
5,161
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int a = 0, b = 0, c = 0; int e[3]; while (scanf("%d%d%d", &e[0], &e[1], &e[2]) != EOF) { sort(e, e + 3); if (e[2] >= e[1] + e[0]) continue; if (e[2] * e[2] == e[0] * e[0] + e[1] * e[1]) a++; if (e[2] * e[2] < e[0] * e[0] + e[1] * e[1]) b++; if (e[2] * e[2] > e[0] * e[0] + e[1] * e[1]) c++; } printf("%d %d %d %d\n", a + b + c, a, b, c); return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int a = 0, b = 0, c = 0; int e[3]; while (scanf("%d%d%d", &e[0], &e[1], &e[2]) != EOF) { sort(e, e + 3); if (e[2] >= e[1] + e[0]) break; if (e[2] * e[2] == e[0] * e[0] + e[1] * e[1]) a++; if (e[2] * e[2] < e[0] * e[0] + e[1] * e[1]) b++; if (e[2] * e[2] > e[0] * e[0] + e[1] * e[1]) c++; } printf("%d %d %d %d\n", a + b + c, a, b, c); return 0; }
[["-", 0, 52, 8, 9, 0, 57, 64, 116, 0, 117], ["+", 0, 52, 8, 9, 0, 57, 64, 93, 0, 94]]
1
224
/** * File : JOI_2005_triangle_types.cpp * Author : Kazune Takahashi * Created : 2018-3-8 21:20:52 * Powered by Visual Studio Code */ #include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ; #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <iomanip> // << fixed << setprecision(xxx) #include <iostream> #include <map> // if (M.find(key) != M.end()) { } #include <queue> #include <random> // random_device rd; mt19937 mt(rd()); #include <set> #include <stack> #include <string> // to_string(nnn) // substr(m, n) // stoi(nnn) #include <tuple> #include <vector> using namespace std; #define DEBUG 0 // change 0 -> 1 if we need debug. typedef long long ll; // const int dx[4] = {1, 0, -1, 0}; // const int dy[4] = {0, 1, 0, -1}; // const int C = 1e6+10; // const ll M = 1000000007; int cnt[3] = {0, 0, 0}; int main() { int a[3]; while (cin >> a[0] >> a[1] >> a[2]) { sort(a, a + 3); if (a[0] + a[1] <= a[2]) { cout << cnt[0] + cnt[1] + cnt[2] << " " << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl; return 0; } int s = a[0] * a[0] + a[1] * a[1]; int t = a[2] * a[2]; if (s < t) { cnt[2]++; } else if (s == t) { cnt[1]++; } else { cnt[0]++; } } }
/** * File : JOI_2005_triangle_types.cpp * Author : Kazune Takahashi * Created : 2018-3-8 21:20:52 * Powered by Visual Studio Code */ #include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ; #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <iomanip> // << fixed << setprecision(xxx) #include <iostream> #include <map> // if (M.find(key) != M.end()) { } #include <queue> #include <random> // random_device rd; mt19937 mt(rd()); #include <set> #include <stack> #include <string> // to_string(nnn) // substr(m, n) // stoi(nnn) #include <tuple> #include <vector> using namespace std; #define DEBUG 0 // change 0 -> 1 if we need debug. typedef long long ll; // const int dx[4] = {1, 0, -1, 0}; // const int dy[4] = {0, 1, 0, -1}; // const int C = 1e6+10; // const ll M = 1000000007; int cnt[3] = {0, 0, 0}; int main() { int a[3]; while (cin >> a[0] >> a[1] >> a[2]) { sort(a, a + 3); if (a[0] + a[1] <= a[2]) { cout << cnt[0] + cnt[1] + cnt[2] << " " << cnt[1] << " " << cnt[0] << " " << cnt[2] << endl; return 0; } int s = a[0] * a[0] + a[1] * a[1]; int t = a[2] * a[2]; if (s < t) { cnt[2]++; } else if (s == t) { cnt[1]++; } else { cnt[0]++; } } }
[["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 13], ["+", 31, 16, 31, 16, 12, 69, 341, 342, 0, 13]]
1
254
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { vector<int> cnt(3, 0); while (true) { vector<int> v(3); cin >> v[0] >> v[1] >> v[2]; sort(v.begin(), v.end()); if (v[2] >= v[0] + v[1]) break; if (v[2] * v[2] > v[0] * v[0] + v[1] * v[1]) cnt[2]++; if (v[2] * v[2] == v[0] * v[0] + v[1] * v[1]) cnt[1]++; else cnt[0]++; } cout << cnt[0] + cnt[1] + cnt[2] << cnt[1] << " " << cnt[0] << " " << cnt[2] << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { vector<int> cnt(3, 0); while (true) { vector<int> v(3); cin >> v[0] >> v[1] >> v[2]; sort(v.begin(), v.end()); if (v[2] >= v[0] + v[1]) break; if (v[2] * v[2] > v[0] * v[0] + v[1] * v[1]) cnt[2]++; else if (v[2] * v[2] == v[0] * v[0] + v[1] * v[1]) cnt[1]++; else cnt[0]++; } cout << cnt[0] + cnt[1] + cnt[2] << " " << cnt[1] << " " << cnt[0] << " " << cnt[2] << endl; }
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 151], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
219
#include <algorithm> #include <iostream> using namespace std; int main() { int Length[3]; int Triangle[4] = {0}; bool flag = 0; while (cin >> Length[0] >> Length[1] >> Length[2]) { sort(Length, Length + 3); if (Length[0] + Length[1] <= Length[2]) flag = 1; if (flag == 1) continue; if (Length[0] * Length[0] + Length[1] * Length[1] == Length[2] * Length[2]) Triangle[1]++; else if (Length[0] * Length[0] + Length[1] * Length[1] < Length[2] * Length[2]) Triangle[2]++; else Triangle[3]++; Triangle[0]++; } cout << Triangle[0] << " " << Triangle[1] << " " << Triangle[2] << " " << Triangle[3] << "\n"; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int Length[3]; int Triangle[4] = {0}; bool flag = 0; while (cin >> Length[0] >> Length[1] >> Length[2]) { sort(Length, Length + 3); if (Length[0] + Length[1] <= Length[2]) flag = 1; if (flag == 1) continue; if (Length[0] * Length[0] + Length[1] * Length[1] == Length[2] * Length[2]) Triangle[1]++; else if (Length[0] * Length[0] + Length[1] * Length[1] > Length[2] * Length[2]) Triangle[2]++; else Triangle[3]++; Triangle[0]++; } cout << Triangle[0] << " " << Triangle[1] << " " << Triangle[2] << " " << Triangle[3] << "\n"; return 0; }
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47]]
1
225
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, count1 = 0, count2 = 0, count3 = 0, count4 = 0; while (cin >> a >> b >> c) { int ia, ib, ic, max, z; ia = a * a; ib = b * b; ic = c * c; if (ia >= ib && ia >= ic) { if (a < b + c) { max = ia; ia = ic; } else break; } else if (ib >= ia && ib >= ic) { if (b < a + c) { max = ib; ib = ic; } else break; } else if (ic >= ia && ic >= ib) { if (c < a + b) { max = ic; } else break; } else break; count1++; if (max == ia + ib) count2++; else if (max < ia + ib) count3++; else count4++; break; } cout << count1 << " " << count2 << " " << count3 << " " << count4 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, count1 = 0, count2 = 0, count3 = 0, count4 = 0; while (cin >> a >> b >> c) { int ia, ib, ic, max, z; ia = a * a; ib = b * b; ic = c * c; if (ia >= ib && ia >= ic) { if (a < b + c) { max = ia; ia = ic; } else break; } else if (ib >= ia && ib >= ic) { if (b < a + c) { max = ib; ib = ic; } else break; } else if (ic >= ia && ic >= ib) { if (c < a + b) { max = ic; } else break; } else break; count1++; if (max == ia + ib) count2++; else if (max < ia + ib) count3++; else count4++; } cout << count1 << " " << count2 << " " << count3 << " " << count4 << endl; return 0; }
[["-", 8, 9, 0, 52, 8, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 52, 8, 9, 0, 93, 0, 35]]
1
235
#include <iostream> using namespace std; int main() { int a, b, c; int ansn = 0, ans1 = 0, ans2 = 0, ans3 = 0; while (cin >> a >> b >> c) { if (a + b > c && b + c > a && c + a > b) { ansn++; if (a < b) { int swap = a; a = b; b = swap; } if (a < c) { int swap = a; a = c; c = swap; } int A = b * b + c * c - a * a; if (A > 0) ans1++; else if (A == 0) ans2++; else ans3++; } else break; } cout << ansn << " " << ans1 << " " << ans2 << " " << ans3 << endl; return 0; }
#include <iostream> using namespace std; int main() { int a, b, c; int ansn = 0, ans1 = 0, ans2 = 0, ans3 = 0; while (cin >> a >> b >> c) { if (a + b > c && b + c > a && c + a > b) { ansn++; if (a < b) { int swap = a; a = b; b = swap; } if (a < c) { int swap = a; a = c; c = swap; } int A = b * b + c * c - a * a; if (A == 0) ans1++; else if (A > 0) ans2++; else ans3++; } else break; } cout << ansn << " " << ans1 << " " << ans2 << " " << ans3 << endl; return 0; }
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47]]
1
183
#include <bits/stdc++.h> using namespace std; int main() { int hen[3]; int cnt = 0; int d = 0; int e = 0; while (1) { for (int i = 0; i < 3; i++) { cin >> hen[i]; } sort(hen, hen + 3); int judge = pow(hen[0], 2) + pow(hen[1], 2); int most = pow(hen[2], 2); if (hen[0] + hen[1] > hen[2] && hen[1] + hen[2] > hen[0] && hen[2] + hen[0] > hen[1]) { if (judge < most) { d++; } else if (judge > most) { e++; } else if (judge == most) { cnt++; } } else { break; } } cout << cnt + d + e << " " << cnt << " " << d << " " << e << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int hen[3]; int cnt = 0; int d = 0; int e = 0; while (1) { for (int i = 0; i < 3; i++) { cin >> hen[i]; } sort(hen, hen + 3); int judge = pow(hen[0], 2) + pow(hen[1], 2); int most = pow(hen[2], 2); if (hen[0] + hen[1] > hen[2] && hen[1] + hen[2] > hen[0] && hen[2] + hen[0] > hen[1]) { if (judge < most) { d++; } else if (judge > most) { e++; } else if (judge == most) { cnt++; } } else { break; } } cout << cnt + e + d << " " << cnt << " " << e << " " << d << endl; return 0; }
[["-", 31, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
227
#include <algorithm> #include <iostream> using namespace std; const double EPS = 1e-8; int main() { int v[3], ans[3], ansn = 0; bool f = false; fill(ans, ans + 3, 0); while (cin >> v[0] >> v[1] >> v[2]) { if (f) continue; sort(v, v + 3); if (v[2] >= v[1] + v[0]) { cout << ansn; for (int i = 0; i < 3; i++) cout << ans[i]; cout << endl; f = true; } else { double w[3]; for (int i = 0; i < 3; i++) w[i] = (double)v[i]; double a = (w[0] * w[0] + w[1] * w[1] - w[2] * w[2]) / (2 * w[0] * w[1]); ansn++; if (a > EPS) ans[1]++; else if (a < -EPS) ans[2]++; else ans[0]++; } } }
#include <algorithm> #include <iostream> using namespace std; const double EPS = 1e-8; int main() { int v[3], ans[3], ansn = 0; bool f = false; fill(ans, ans + 3, 0); while (cin >> v[0] >> v[1] >> v[2]) { if (f) continue; sort(v, v + 3); if (v[2] >= v[1] + v[0]) { cout << ansn; for (int i = 0; i < 3; i++) cout << ' ' << ans[i]; cout << endl; f = true; } else { double w[3]; for (int i = 0; i < 3; i++) w[i] = (double)v[i]; double a = (w[0] * w[0] + w[1] * w[1] - w[2] * w[2]) / (2 * w[0] * w[1]); ansn++; if (a > EPS) ans[1]++; else if (a < -EPS) ans[2]++; else ans[0]++; } } }
[["+", 8, 1, 0, 16, 31, 16, 12, 103, 0, 104], ["+", 8, 1, 0, 16, 31, 16, 12, 103, 0, 125], ["+", 64, 9, 0, 7, 8, 1, 0, 16, 17, 151]]
1
260
#include <algorithm> #include <iostream> #include <math.h> using namespace std; int main() { double a, b, c; int cnt[4]; fill(cnt, cnt + 4, 0); while (cin >> a >> b >> c) { double array[3]; int sum = a + b + c; int Max = max(a, max(b, c)); int remain = sum - Max; if (Max >= remain) { continue; } array[0] = a; array[1] = b; array[2] = c; sort(array, array + 3); double Max_angle = 0; do { double tmp = (array[0] * array[0] + array[2] * array[2] - array[1] * array[1]) / (2 * array[0] * array[2]); Max_angle = max(Max_angle, acos(tmp)); } while (next_permutation(array, array + 3)); cnt[0]++; if (Max_angle > M_PI / 2.0) cnt[3]++; else if (Max_angle < M_PI / 2.0) cnt[2]++; else cnt[1]++; } for (int i = 0; i < 4; i++) { if (i == 0) cout << cnt[i]; else cout << " " << cnt[i]; } cout << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> using namespace std; int main() { double a, b, c; int cnt[4]; fill(cnt, cnt + 4, 0); while (cin >> a >> b >> c) { double array[3]; int sum = a + b + c; int Max = max(a, max(b, c)); int remain = sum - Max; if (Max >= remain) { break; } array[0] = a; array[1] = b; array[2] = c; sort(array, array + 3); double Max_angle = 0; do { double tmp = (array[0] * array[0] + array[2] * array[2] - array[1] * array[1]) / (2 * array[0] * array[2]); Max_angle = max(Max_angle, acos(tmp)); } while (next_permutation(array, array + 3)); cnt[0]++; if (Max_angle > M_PI / 2.0) cnt[3]++; else if (Max_angle < M_PI / 2.0) cnt[2]++; else cnt[1]++; } for (int i = 0; i < 4; i++) { if (i == 0) cout << cnt[i]; else cout << " " << cnt[i]; } cout << endl; return 0; }
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
300
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i) #define REP(i, n) FOR(i, 0, n) #define FORIT(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) template <class T> void debug(T begin, T end) { for (T i = begin; i != end; ++i) cerr << *i << " "; cerr << endl; } inline bool valid(int x, int y, int W, int H) { return (x >= 0 && y >= 0 && x < W && y < H); } typedef long long ll; const int INF = 100000000; const double EPS = 1e-8; const int MOD = 1000000007; int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main() { int a, b, c; int ans[4] = {}; while (cin >> a >> b >> c) { if (!(c > b - a)) continue; if (!(c > a - b)) continue; if (!(c < a + b)) continue; if (a > b) swap(a, b); if (b > c) swap(b, c); int D = a * a + b * b - c * c; ans[0]++; if (D > 0) ans[1]++; if (D == 0) ans[2]++; if (D < 0) ans[3]++; } printf("%d %d %d %d\n", ans[0], ans[2], ans[1], ans[3]); return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i) #define REP(i, n) FOR(i, 0, n) #define FORIT(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) template <class T> void debug(T begin, T end) { for (T i = begin; i != end; ++i) cerr << *i << " "; cerr << endl; } inline bool valid(int x, int y, int W, int H) { return (x >= 0 && y >= 0 && x < W && y < H); } typedef long long ll; const int INF = 100000000; const double EPS = 1e-8; const int MOD = 1000000007; int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main() { int a, b, c; int ans[4] = {}; while (cin >> a >> b >> c) { if (!(c > b - a)) break; if (!(c > a - b)) break; if (!(c < a + b)) break; if (a > b) swap(a, b); if (b > c) swap(b, c); int D = a * a + b * b - c * c; ans[0]++; if (D > 0) ans[1]++; if (D == 0) ans[2]++; if (D < 0) ans[3]++; } printf("%d %d %d %d\n", ans[0], ans[2], ans[1], ans[3]); return 0; }
[["-", 0, 52, 8, 9, 0, 57, 64, 116, 0, 117], ["+", 0, 52, 8, 9, 0, 57, 64, 93, 0, 94]]
1
397
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int length[3]; int w = 0, x = 0, y = 0, z = 0; while (cin >> length[0] >> length[1] >> length[2]) { sort(length, length + 3); if (length[2] < length[0] + length[1]) { w++; if (pow(length[2], 2) == pow(length[0], 2) + pow(length[1], 2)) y++; else if (pow(length[2], 2) < pow(length[0], 2) + pow(length[1], 2)) z++; else x++; } } cout << w << ' ' << y << ' ' << z << ' ' << x << endl; }
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int length[3]; int w = 0, x = 0, y = 0, z = 0; while (cin >> length[0] >> length[1] >> length[2]) { sort(length, length + 3); if (length[2] < length[0] + length[1]) { w++; if (pow(length[2], 2) == pow(length[0], 2) + pow(length[1], 2)) y++; else if (pow(length[2], 2) < pow(length[0], 2) + pow(length[1], 2)) z++; else x++; } else { cout << w << ' ' << y << ' ' << z << ' ' << x << endl; break; } } }
[["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 94], ["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 35], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
190
#include <algorithm> #include <cstdio> using namespace std; int main() { int a, b, c; int na, nb, nc, nd; na = nb = nc = nd = 0; while (1) { scanf("%d %d %d", &a, &b, &c); if (a < b) swap(a, b); if (a < c) swap(a, c); if (a >= b + c) break; na++; if (b * b + c * c == a * a) nc++; else if (b * b + c * c < a * a) nd++; else nb++; } printf("%d %d %d %d\n", na, nb, nc, nd); return (0); }
#include <algorithm> #include <cstdio> using namespace std; int main() { int a, b, c; int na, nb, nc, nd; na = nb = nc = nd = 0; while (1) { scanf("%d %d %d", &a, &b, &c); if (a < b) swap(a, b); if (a < c) swap(a, c); if (a >= b + c) break; na++; if (b * b + c * c == a * a) nc++; else if (b * b + c * c < a * a) nd++; else nb++; } printf("%d %d %d %d\n", na, nc, nb, nd); return (0); }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
161
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) typedef long long ll; int main() { int a, b, c; int d, e, f; d = e = f = 0; while (true) { cin >> a >> b >> c; if (!(a < b + c && b < a + c && c < a + b)) { break; } vector<int> vec; vec.push_back(a); vec.push_back(b); vec.push_back(c); sort(vec.begin(), vec.end()); int p = vec[0] * vec[0] + vec[1] * vec[1]; int g = vec[2]; if (p == g * g) { e++; } else if (p > g * g) { d++; } else { f++; } } cout << d + e + f << " " << d << " " << e << " " << f << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) typedef long long ll; int main() { int a, b, c; int d, e, f; d = e = f = 0; while (true) { cin >> a >> b >> c; if (!(a < b + c && b < a + c && c < a + b)) { break; } vector<int> vec; vec.push_back(a); vec.push_back(b); vec.push_back(c); sort(vec.begin(), vec.end()); int p = vec[0] * vec[0] + vec[1] * vec[1]; int g = vec[2]; if (p == g * g) { d++; } else if (p > g * g) { e++; } else { f++; } } cout << d + e + f << " " << d << " " << e << " " << f << endl; return 0; }
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22]]
1
257
def triangle?(a, b, c) return false if a + b <= c true end sankaku = 0 eikaku = 0 chokaku = 0 donkaku = 0 end_flg = false loop do line = gets if line == "\n" break; end next if end_flg a, b, c = line.split.map(&:to_i).sort if !triangle?(a, b, c) puts "#{sankaku} #{chokaku} #{eikaku} #{donkaku}" end_flg = true else break; end sankaku += 1 if a**2 + b**2 > c **2 eikaku += 1 elsif a**2 + b**2 == c **2 chokaku += 1 else donkaku += 1 end end
def triangle?(a, b, c) return false if a + b <= c true end sankaku = 0 eikaku = 0 chokaku = 0 donkaku = 0 end_flg = false loop do line = gets if line == "\n" break; end next if end_flg a, b, c = line.split.map(&:to_i).sort if !triangle?(a, b, c) puts "#{sankaku} #{chokaku} #{eikaku} #{donkaku}" end_flg = true break; end sankaku += 1 if a**2 + b**2 > c **2 eikaku += 1 elsif a**2 + b**2 == c **2 chokaku += 1 else donkaku += 1 end end
[["-", 196, 737, 8, 736, 0, 121, 75, 95, 0, 95]]
4
142
f = True cnt = 0 l = [0,0,0] while f: t = [int(s) for s in input().split()] t.sort() if t[0]+t[1] <= t[2]: f = False continue if t[0]**2+t[1]**2 > t[2]**2: l[0]+=1 elif t[0]**2+t[1]**2 == t[2]**2: l[1]+=1 else: l[2]+=1 print(sum(l),l[0],l[1],l[2])
f = True cnt = 0 l = [0,0,0] while f: t = [int(s) for s in input().split()] t.sort() if t[0]+t[1] <= t[2]: f = False break if t[0]**2+t[1]**2 > t[2]**2: l[0]+=1 elif t[0]**2+t[1]**2 == t[2]**2: l[1]+=1 else: l[2]+=1 print(sum(l),l[1],l[0],l[2])
[["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 206, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 612]]
5
147
ans = [0 for i in range(4)] while True: sides = sorted([int(inp) for inp in input().split()]) if sides[2] >= sides[1] + sides[0]: print(ans[0], ans[1], ans[2], ans[3]) break if sides[2]**2 > sides[1]**2 + sides[0]**2: ans[3]+=1 elif sides[2]**2 == sides[1]**2 + sides[0]**2: ans[2]+=1 else: ans[1]+=1 ans[0]+=1
ans = [0 for i in range(4)] while True: sides = sorted([int(inp) for inp in input().split()]) if sides[2] >= sides[1] + sides[0]: print(ans[0], ans[1], ans[2], ans[3]) break if sides[2]**2 > sides[1]**2 + sides[0]**2: ans[3]+=1 elif sides[2]**2 == sides[1]**2 + sides[0]**2: ans[1]+=1 else: ans[2]+=1 ans[0]+=1
[["-", 64, 196, 0, 1, 0, 677, 31, 206, 206, 612], ["+", 64, 196, 0, 1, 0, 677, 31, 206, 206, 612], ["-", 8, 196, 0, 1, 0, 677, 31, 206, 206, 612], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 206, 612]]
5
145
r=a=o=0 while 1: l,m,n=sorted(list(map(int,input().split()))) if l+m<=n:break c=l*l+m*m-n*n if c>0:a+=1 elif c<0:o+=1 else:r+=1 print(sum(r,a,o),r,a,o)
r=a=o=0 while 1: l,m,n=sorted(list(map(int,input().split()))) if l+m<=n:break c=l*l+m*m-n*n if c>0:a+=1 elif c<0:o+=1 else:r+=1 print(r+a+o,r,a,o)
[["-", 0, 1, 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, 21], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
93
a,b,c,d = 0,0,0,0 while 1: lng=list(map(int,input().split())) lng.sort() if lng[0] + lng[1] <= lng[2]: print('%d %d %d %d' % (a,b,c,d)) break else: a += 1 if lng[0]**2 + lng[1]**2 == lng[2]**2: b += 1 elif lng[0]**2 + lng[1]**2 >= lng[2]**2: d += 1 else: c += 1
a,b,c,d = 0,0,0,0 while 1: lng=list(map(int,input().split())) lng.sort() if lng[0] + lng[1] <= lng[2]: print('%d %d %d %d' % (a,b,c,d)) break else: a += 1 if lng[0]**2 + lng[1]**2 == lng[2]**2: b += 1 elif lng[0]**2 + lng[1]**2 <= lng[2]**2: d += 1 else: c += 1
[["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 20], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 667, 19]]
5
133
# -*- coding: utf-8 -*- import sys from math import sqrt def calc_triangle_type(edge_length_str): edge_length = edge_length_str.split(" ") edge_length = list(map(lambda x: int(x), edge_length)) edge_length_sorted = sorted(edge_length) if edge_length_sorted[0] + edge_length_sorted[1] <= edge_length_sorted[2]: return None right_angled_longest_edge = sqrt( edge_length_sorted[0] * edge_length_sorted[0] + edge_length_sorted[1] * edge_length_sorted[1]) if edge_length_sorted[2] < right_angled_longest_edge: return 0 elif edge_length_sorted[2] == right_angled_longest_edge: return 1 else: return 2 def main(): inputStr = sys.stdin.read() lines = inputStr.split("\n") counts_by_tryangle_type = {0: 0, 1: 0, 2: 0} total_triangle = 0 for line in lines[:-1]: tryangle_type = calc_triangle_type(line) if tryangle_type is None: continue counts_by_tryangle_type[tryangle_type] = counts_by_tryangle_type[tryangle_type] + 1 total_triangle = total_triangle + 1 print("{} {} {} {}".format(total_triangle, counts_by_tryangle_type[1], counts_by_tryangle_type[0], counts_by_tryangle_type[2])) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- import sys from math import sqrt def calc_triangle_type(edge_length_str): edge_length = edge_length_str.split(" ") edge_length = list(map(lambda x: int(x), edge_length)) edge_length_sorted = sorted(edge_length) if edge_length_sorted[0] + edge_length_sorted[1] <= edge_length_sorted[2]: return None right_angled_longest_edge = sqrt( edge_length_sorted[0] * edge_length_sorted[0] + edge_length_sorted[1] * edge_length_sorted[1]) if edge_length_sorted[2] < right_angled_longest_edge: return 0 elif edge_length_sorted[2] == right_angled_longest_edge: return 1 else: return 2 def main(): inputStr = sys.stdin.read() lines = inputStr.split("\n") counts_by_tryangle_type = {0: 0, 1: 0, 2: 0} total_triangle = 0 for line in lines[:-1]: tryangle_type = calc_triangle_type(line) if tryangle_type is None: break counts_by_tryangle_type[tryangle_type] = counts_by_tryangle_type[tryangle_type] + 1 total_triangle = total_triangle + 1 print("{} {} {} {}".format(total_triangle, counts_by_tryangle_type[1], counts_by_tryangle_type[0], counts_by_tryangle_type[2])) if __name__ == '__main__': main()
[["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
228
t=[0]*4 while True: try: l=sorted(map(int,input().split())) if l[2]>=l[1]+l[0]: continue t[0]+=1 r=l[2]**2-(l[1]**2+l[0]**2) if r>0: t[3]+=1 elif r<0: t[2]+=1 else: t[1]+=1 except EOFError: break; print(" ".join(map(str,t)))
t=[0]*4 while True: try: l=sorted(map(int,input().split())) if l[2]>=l[1]+l[0]: break t[0]+=1 r=l[2]**2-(l[1]**2+l[0]**2) if r>0: t[3]+=1 elif r<0: t[2]+=1 else: t[1]+=1 except EOFError: break; print(" ".join(map(str,t)))
[["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
127
k=l=m=n=0 while True: a,b,c=sorted(map(int,input().split())) if a+b<=c:break k+=1 if a**2+b**2<c**2:l+=1 elif a**2+b**2>c**2:n+=1 else:m+=1 print(k,l,m,n)
k=l=m=n=0 while True: a,b,c=sorted(map(int,input().split())) if a+b<=c:break k+=1 if a**2+b**2>c**2:m+=1 elif a**2+b**2<c**2:n+=1 else:l+=1 print(k,l,m,n)
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 47], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 667, 18], ["-", 75, 76, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 31, 22]]
5
91
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); while (scan.hasNext()) { int n = scan.nextInt(); int[] num = new int[n]; for (int i = 0; i < n; i++) { num[i] = scan.nextInt(); } Arrays.sort(num); System.out.println(1); int j = 0; for (int i = 2; i <= num[0]; i++) { for (j = 0; j < n; j++) { if (num[j] % i != 0) { break; } } if (j == n - 1) { System.out.println(i); } } } } }
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); while (scan.hasNext()) { int n = scan.nextInt(); int[] num = new int[n]; for (int i = 0; i < n; i++) { num[i] = scan.nextInt(); } Arrays.sort(num); System.out.println(1); int j = 0; for (int i = 2; i <= num[0]; i++) { for (j = 0; j < n; j++) { if (num[j] % i != 0) { break; } } if (j == n) { System.out.println(i); } } } } }
[["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]]
3
188
#include <stdio.h> int mintwo(int kouyaku1, int kouyaku2); int minthree(int kouyaku1, int kouyaku2, int kouyaku3); void kouyakutwo(); void kouyakuthree(); int main(void) { int n = 0; scanf("%d", &n); if (n == 2) { kouyakutwo(); } else { kouyakuthree(); } } void kouyakutwo() { int kouyaku1 = 0, kouyaku2 = 0, i = 1; int minvalue; scanf("%d %d", &kouyaku1, &kouyaku2); //数値を入力 minvalue = mintwo(kouyaku1, kouyaku2); while (i <= minvalue) { if (kouyaku1 % i == 0 && kouyaku2 % i == 0) { printf("%d ", i); } i = i + 1; } } void kouyakuthree() { int kouyaku1 = 0, kouyaku2 = 0, kouyaku3 = 0; int i = 1; int minvalue; scanf("%d %d %d", &kouyaku1, &kouyaku2, &kouyaku3); minvalue = minthree(kouyaku1, kouyaku2, kouyaku3); while (i <= minvalue) { if (kouyaku1 % i == 0 && kouyaku2 % i == 0 && kouyaku3 % i == 0) { printf("%d \n", i); } i = i + 1; } } int mintwo(int kouyaku1, int kouyaku2) { int minvalu; if (kouyaku1 < kouyaku2) { minvalu = kouyaku1; } else { minvalu = kouyaku2; } return minvalu; } int minthree(int kouyaku1, int kouyaku2, int kouyaku3) { int minvalu; minvalu = kouyaku1; if (minvalu > kouyaku2) { minvalu = kouyaku2; } if (minvalu > kouyaku3) { minvalu = kouyaku3; } return minvalu; }
#include <stdio.h> int mintwo(int kouyaku1, int kouyaku2); int minthree(int kouyaku1, int kouyaku2, int kouyaku3); void kouyakutwo(); void kouyakuthree(); int main(void) { int n = 0; scanf("%d", &n); if (n == 2) { kouyakutwo(); } else { kouyakuthree(); } } void kouyakutwo() { int kouyaku1 = 0, kouyaku2 = 0, i = 1; int minvalue; scanf("%d %d", &kouyaku1, &kouyaku2); //数値を入力 minvalue = mintwo(kouyaku1, kouyaku2); while (i <= minvalue) { if (kouyaku1 % i == 0 && kouyaku2 % i == 0) { printf("%d\n", i); } i = i + 1; } } void kouyakuthree() { int kouyaku1 = 0, kouyaku2 = 0, kouyaku3 = 0; int i = 1; int minvalue; scanf("%d %d %d", &kouyaku1, &kouyaku2, &kouyaku3); minvalue = minthree(kouyaku1, kouyaku2, kouyaku3); while (i <= minvalue) { if (kouyaku1 % i == 0 && kouyaku2 % i == 0 && kouyaku3 % i == 0) { printf("%d\n", i); } i = i + 1; } } int mintwo(int kouyaku1, int kouyaku2) { int minvalu; if (kouyaku1 < kouyaku2) { minvalu = kouyaku1; } else { minvalu = kouyaku2; } return minvalu; } int minthree(int kouyaku1, int kouyaku2, int kouyaku3) { int minvalu; minvalu = kouyaku1; if (minvalu > kouyaku2) { minvalu = kouyaku2; } if (minvalu > kouyaku3) { minvalu = kouyaku3; } return minvalu; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
344
#include <algorithm> #include <iostream> using namespace std; int gcd(int m, int n) { if (n == 0 || m == 0) return m + n; return gcd(n % m, m); } int main() { int n; cin >> n; int a[3] = {}; int g; if (n == 2) { cin >> a[0] >> a[1]; sort(a, a + n); g = gcd(a[0], a[1]); for (int i = 1; i <= g; i++) { if (g % i == 0) cout << i << endl; } } else if (n == 3) { cin >> a[0] >> a[1] >> a[2]; sort(a, a + n); g = gcd(a[1], a[2]); g = gcd(g, a[3]); for (int i = 1; i <= g; i++) { if (g % i == 0) cout << i << endl; } } return 0; }
#include <algorithm> #include <iostream> using namespace std; int gcd(int m, int n) { if (n == 0 || m == 0) return m + n; return gcd(n % m, m); } int main() { int n; cin >> n; int a[3] = {}; int g; if (n == 2) { cin >> a[0] >> a[1]; sort(a, a + n); g = gcd(a[0], a[1]); for (int i = 1; i <= g; i++) { if (g % i == 0) cout << i << endl; } } else if (n == 3) { cin >> a[0] >> a[1] >> a[2]; sort(a, a + n); g = gcd(a[0], a[1]); g = gcd(g, a[2]); for (int i = 1; i <= g; i++) { if (g % i == 0) cout << i << endl; } } return 0; }
[["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["+", 12, 2, 3, 4, 0, 69, 341, 342, 0, 13]]
1
238
#include <stdio.h> int GCD(int a, int b) { int A, B, buff; // A >= B if (b > a) { A = b; B = a; } else { A = a; B = b; } while (A % B) { buff = B; B = A % B; A = buff; } return B; } int main() { int N, a, b, c; int G; int GC[100000000]; scanf("%d", &N); if (!(N - 2)) { scanf("%d %d", &a, &b); G = GCD(a, b); for (int i = 1; i <= G; i++) { if (a % i == 0 && b % i == 0) { GC[i] = i; } else GC[i] = -i; } for (int j = 1; j <= G; j++) { if (GC[j] < 0) continue; printf("%d\n", GC[j]); } } else { scanf("%d %d %d", &a, &b, &c); G = GCD(c, GCD(a, b)); for (int i = 1; i <= G; i++) { if (a % i == 0 && b % i == 0 && c % i == 0) { GC[i] = i; } else GC[i] = -i; } for (int j = 1; j <= G; j++) { if (GC[j] < 0) continue; printf("%d\n", GC[j]); } } return 0; }
#include <stdio.h> int GCD(int a, int b) { int A, B, buff; // A >= B if (b > a) { A = b; B = a; } else { A = a; B = b; } while (A % B) { buff = B; B = A % B; A = buff; } return B; } int main() { int N, a, b, c; int G; int GC[1000000]; scanf("%d", &N); if (!(N - 2)) { scanf("%d %d", &a, &b); G = GCD(a, b); for (int i = 1; i <= G; i++) { if (a % i == 0 && b % i == 0) { GC[i] = i; } else GC[i] = -i; } for (int j = 1; j <= G; j++) { if (GC[j] < 0) continue; printf("%d\n", GC[j]); } } else { scanf("%d %d %d", &a, &b, &c); G = GCD(c, GCD(a, b)); for (int i = 1; i <= G; i++) { if (a % i == 0 && b % i == 0 && c % i == 0) { GC[i] = i; } else GC[i] = -i; } for (int j = 1; j <= G; j++) { if (GC[j] < 0) continue; printf("%d\n", GC[j]); } } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
358
// Vol5 588 #include <stdio.h> #include <string.h> int main() { int n, s = 0; char c, l = '+'; while (1) { scanf("%d", &n); scanf("%c", &c); if (l == '+') { s += n; } else if (l == '-') { s -= n; } else if (l == '*') { s *= n; } else { s /= n; } l = c; if (c == '=') { printf("%d\n", s); break; } } return 0; }
// Vol5 588 #include <stdio.h> #include <string.h> int main() { int n, s = 0; char c, l = '+'; while (1) { scanf("%d\n", &n); scanf("%c", &c); if (l == '+') { s += n; } else if (l == '-') { s -= n; } else if (l == '*') { s *= n; } else { s /= n; } l = c; if (c == '=') { printf("%d\n", s); break; } } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
133
#include <iostream> using namespace std; int main() { int n, rst; char k; cin >> rst; while (1) { cin >> k; if (k = '=') break; cin >> n; switch (k) { case '+': rst += n; break; case '-': rst -= n; break; case '*': rst *= n; break; case '/': rst /= n; break; } } cout << rst << endl; return 0; }
#include <iostream> using namespace std; int main() { int n, rst; char k; cin >> rst; while (1) { cin >> k; if (k == '=') break; cin >> n; switch (k) { case '+': rst += n; break; case '-': rst -= n; break; case '*': rst *= n; break; case '/': rst /= n; break; } } cout << rst << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
107