buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
while True: M,T,P,R=list(map(int,input().split())) if M==T==P==R==0:break PB=[[False]*P for i in range(T+1)] PN=[[0]*P for i in range(T+1)] TM=[M]*(T+1) for i in range(R): m,t,p,r=list(map(int,input().split())) if r==0: PB[t][p-1]=True TM[t]=m else...
while True: M,T,P,R=list(map(int,input().split())) if M==T==P==R==0:break PB=[[False]*P for i in range(T+1)] PN=[[0]*P for i in range(T+1)] TM=[M]*(T+1) for i in range(R): m,t,p,r=list(map(int,input().split())) if r==0: PB[t][p-1]=True TM[t]+=m els...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]]
5
378
2
#include <algorithm> #include <cctype> #include <iostream> #include <string> #include <vector> using namespace std; const char *p; string str; int parse() { int num; char *e; p++; if (*p == '[') { vector<int> v; for (;;) { if (*p == '[') { num = parse(); v.push_back(num); ...
#include <algorithm> #include <cctype> #include <iostream> #include <string> #include <vector> using namespace std; const char *p; string str; int parse() { int num; char *e; p++; if (*p == '[') { vector<int> v; for (;;) { if (*p == '[') { num = parse(); v.push_back(num); ...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
241
3
#include <algorithm> #include <cctype> #include <iostream> #include <string> #include <vector> using namespace std; string S; size_t cur; int digit() { int n = S[cur++] - '0'; return n; } int number() { int n = digit(); while (isdigit(S[cur])) n = n * 10 + digit(); return n; } int expression() { vec...
#include <algorithm> #include <cctype> #include <iostream> #include <string> #include <vector> using namespace std; string S; size_t cur; int digit() { int n = S[cur++] - '0'; return n; } int number() { int n = digit(); while (isdigit(S[cur])) n = n * 10 + digit(); return n; } int expression() { vec...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
316
4
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int expr(string &str, int &itr); int number(string &str, int &itr); int main() { int N; int start; string str; cin >> N; for (int i = 0; i < N; i++) { cin >> str; start = 0; cout ...
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int expr(string &str, int &itr); int number(string &str, int &itr); int main() { int N; int start; string str; cin >> N; for (int i = 0; i < N; i++) { cin >> str; start = 0; cout ...
[["-", 8, 9, 0, 7, 8, 9, 0, 7, 0, 88], ["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 8, 9, 0, 7, 8, 9, 0, 7, 0, 35]]
1
306
4
//============================================================================ // Name : aoj1188.cpp // Author : afterCmidday // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================...
//============================================================================ // Name : aoj1188.cpp // Author : afterCmidday // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================...
[["-", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["-", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["-", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
354
6
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { while (1) { int n, m, c, s, g; int a[110][110][30]; fill(&a[0][0][0], &a[109][109][29], 10000...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { while (1) { int n, m, c, s, g; int a[110][110][30]; fill(&a[0][0][0], &a[109][109][29], 10000...
[["-", 28, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["+", 28, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 31, 22]]
1
952
4
#include <cmath> #include <complex> #include <iomanip> #include <iostream> #include <queue> #include <tuple> #include <vector> using namespace std; typedef complex<double> Point; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(c) (c).begin(), (c).end() const double eps = 1e-8, inf = 1e+8; template <typen...
#include <cmath> #include <complex> #include <iomanip> #include <iostream> #include <queue> #include <tuple> #include <vector> using namespace std; typedef complex<double> Point; #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(c) (c).begin(), (c).end() const double eps = 1e-8, inf = 1e+8; template <typen...
[["-", 51, 16, 12, 23, 0, 16, 31, 91, 17, 92], ["+", 51, 16, 12, 23, 0, 16, 31, 91, 17, 111], ["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 37, 0, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 37, 0, 69, 341, 342, 0, 16, 31, 22]]
1
834
6
#define _USE_MATH_DEFINES #include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define EPS 1e-8 #define INF 1000000 struc...
#define _USE_MATH_DEFINES #include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define EPS 1e-8 #define INF 1000000 struc...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
1,898
2
#include <cmath> #include <complex> #include <iostream> #include <queue> #include <utility> #include <vector> using namespace std; typedef complex<double> Point; typedef pair<Point, Point> Line; #define EPS 1e-9 #define INF 1e9 // ?????¢, ??????, ?????? double dis(Point a, Point b) { return abs(a - b); } double dot(P...
#include <cmath> #include <complex> #include <iostream> #include <queue> #include <utility> #include <vector> using namespace std; typedef complex<double> Point; typedef pair<Point, Point> Line; #define EPS 1e-9 #define INF 1e9 // ?????¢, ??????, ?????? double dis(Point a, Point b) { return abs(a - b); } double dot(P...
[["-", 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]]
1
1,006
3
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; int INF = 1 << 28; int ex(int v, int r) { return (v * (100 + r)) / 100; } void run() { for (;;) { int x = ni(); int y = ni(); int s = ni(); if ((x | y | s) == 0) break; int max = 0; ...
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; int INF = 1 << 28; int ex(int v, int r) { return (v * (100 + r)) / 100; } void run() { for (;;) { int x = ni(); int y = ni(); int s = ni(); if ((x | y | s) == 0) break; int max = 0; ...
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 499], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 499]]
3
269
2
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { while (sc.hasNext()) { int x = sc.nextInt(); int y = sc.nextInt(); int s = sc.nextInt(); if (x == 0 && y == 0 && s == 0) break; ...
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { while (sc.hasNext()) { int x = sc.nextInt(); int y = sc.nextInt(); int s = sc.nextInt(); if (x == 0 && y == 0 && s == 0) break; ...
[["-", 0, 7, 502, 503, 49, 200, 51, 16, 31, 22], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 17, 72]]
3
213
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; #define MP make_pair long gcd(long a, long b) { if (a % b == 0) return b; else ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <functional> #include <iostream> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; #define MP make_pair long gcd(long a, long b) { if (a % b == 0) return b; else ...
[["+", 51, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 51, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
232
6
#include <bits/stdc++.h> typedef long long LL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define DECIM8 fixed << setprecision(8) #define SZ(a) int((a).size()) #define SORT(c) s...
#include <bits/stdc++.h> typedef long long LL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define DECIM8 fixed << setprecision(8) #define SZ(a) int((a).size()) #define SORT(c) s...
[["-", 0, 7, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+...
1
221
10
#include <bits/stdc++.h> using namespace std; inline int calc(int p, int x) { return p * (100 + x) / 100; } int main() { for (int x, y, s; cin >> x >> y >> s && (x | y | s);) { int res = 0; for (int a = 1; a < s; ++a) { for (int b = 1; b < s; ++b) { if (calc(a, x) + calc(b, y) != s) ...
#include <bits/stdc++.h> using namespace std; inline int calc(int p, int x) { return p * (100 + x) / 100; } int main() { for (int x, y, s; cin >> x >> y >> s && (x | y | s);) { int res = 0; for (int a = 1; a < s; ++a) { for (int b = 1; b < s; ++b) { if (calc(a, x) + calc(b, x) != s) ...
[["-", 51, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["+", 51, 16, 31, 16, 12, 2, 3, 4, 0, 22]]
1
150
2
#include <stdio.h> int main() { int x, y, s; while (1) { scanf("%d%d%d", &x, &y, &s); if (x == 0 && y == 0 && s == 0) break; int X = 100 + x; int Y = 100 + y; int max = 0; for (int i = 1; i < 100; i++) for (int j = 1; j < 100; j++) { if (i * X / 100 + j * X / 100 == s &...
#include <stdio.h> int main() { int x, y, s; while (1) { scanf("%d%d%d", &x, &y, &s); if (x == 0 && y == 0 && s == 0) break; int X = 100 + x; int Y = 100 + y; int max = 0; for (int i = 1; i < s; i++) for (int j = 1; j < s; j++) { if (i * X / 100 + j * X / 100 == s && ma...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 8, 9, 0, 7, 8, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 12, 22]]
1
159
4
#include <iostream> using namespace std; int f(int v, int per) { return v * (100 + per) / 100; } int main() { int x, y, s; while (cin >> x >> y >> s, x || y || s) { int ans = 0; for (int i = 1; i <= s - 1; ++i) { for (int j = 0; j <= s - 1; ++j) { if (f(i, x) + f(j, x) == s) { ans ...
#include <iostream> using namespace std; int f(int v, int per) { return v * (100 + per) / 100; } int main() { int x, y, s; while (cin >> x >> y >> s, x || y || s) { int ans = 0; for (int i = 1; i <= s - 1; ++i) { for (int j = 1; j <= s - 1; ++j) { if (f(i, x) + f(j, x) == s) { ans ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
147
2
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; double net_of_tax(int n, int rate) { double ret, tmp1, tmp2; ret = (double)(n * 100) / (rate + 100); tmp1 = floor(ret); tmp2 = ceil(ret); if ((floor((double)(tmp1 * (rate + 10...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; double net_of_tax(int n, int rate) { double ret, tmp1, tmp2; ret = (double)(n * 100) / (rate + 100); tmp1 = floor(ret); tmp2 = ceil(ret); if ((floor((double)(tmp1 * (rate + 10...
[["+", 0, 57, 64, 9, 0, 37, 0, 16, 17, 33], ["+", 0, 57, 64, 9, 0, 37, 0, 16, 12, 13]]
1
314
2
#include <iostream> using namespace std; int main() { int a, b, c, d, e, f; while (true) { b = 0; cin >> c >> d >> e; if ((c == 0 && d == 0) && e == 0) { break; } for (int i = 0; i <= e; i++) { for (int j = 0; j <= e; j++) { a = (i * (100 + c)) / 100 + (j * (100 + c)) / 100;...
#include <iostream> using namespace std; int main() { int a, b, c, d, e, f; while (true) { b = 0; cin >> c >> d >> e; if ((c == 0 && d == 0) && e == 0) { break; } for (int i = 1; i <= e; i++) { for (int j = 1; j <= e; j++) { a = (i * (100 + c)) / 100 + (j * (100 + c)) / 100;...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
176
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define mp(a, b) make_pair(a, b) #define pb(a) push_back(a) #define dbg(x) cout << #x "=...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define mp(a, b) make_pair(a, b) #define pb(a) push_back(a) #define dbg(x) cout << #x "=...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
304
2
#include <bits/stdc++.h> using namespace std; int addTax(int base, int tax) { return base * (100 + tax) / 100; } int sumPrice(int item1, int item2, int tax) { return addTax(item1, tax) + addTax(item2, tax); } int main() { int x, y, s; while (cin >> x >> y >> s, x || y || s) { int ans = 0; for (int p = ...
#include <bits/stdc++.h> using namespace std; int addTax(int base, int tax) { return base * (100 + tax) / 100; } int sumPrice(int item1, int item2, int tax) { return addTax(item1, tax) + addTax(item2, tax); } int main() { int x, y, s; while (cin >> x >> y >> s, x || y || s) { int ans = 0; for (int p = ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 85], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
167
4
#include <cstdio> #include <iostream> #include <string> using namespace std; string str; int main() { int i, j; // 2????????????????¨???? int x, y, s; int max = 0; int a, b; // 2????????????????¨???? while (1) { cin >> x >> y >> s; if (x == 0 && y == 0 && s == 0) break; max = 0; for (...
#include <cstdio> #include <iostream> #include <string> using namespace std; string str; int main() { int i, j; // 2テ」ツ?、テ」ツ?ョテ・ツ閉?・ツ督?」ツ?ョテァツィツ偲ヲツ環? int x, y, s; int max = 0; int a, b; // 2テ」ツ?、テ」ツ?ョテ・ツ閉?・ツ督?」ツ?ョテァツィツ偲ィツセツシ while (1) { cin >> x >> y >> s; if (x == 0 && y == 0 && s == 0) brea...
[["-", 8, 9, 0, 7, 8, 7, 15, 16, 17, 18], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 17, 19]]
1
187
2
#include <algorithm> #include <iostream> using namespace std; inline int deTax(int rate, int yen) { return yen * 100 / (100 + rate); } inline int enTax(int rate, int yen) { return yen * (100 + rate) / 100; } int main() { while (1) { int x, y, s; cin >> x >> y >> s; if (!x && !y && !s) break; ...
#include <algorithm> #include <iostream> using namespace std; inline int deTax(int rate, double yen) { return yen * 100 / (100 + rate); } inline int enTax(int rate, double yen) { return yen * (100 + rate) / 100; } int main() { while (1) { int x, y, s; cin >> x >> y >> s; if (!x && !y && !s) break;...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
201
6
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; double eps = 1e-8; bool eq(double a, double b) { return (-eps < a - b && a - b < eps); } bool eq(P a, P b) { return (abs(a - b) < eps); } double dot(P a, P b) { return real(b * conj(a)); } double cross(P a, P b) { return imag(b * conj(a)); } ...
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; double eps = 1e-8; bool eq(double a, double b) { return (-eps < a - b && a - b < eps); } bool eq(P a, P b) { return (abs(a - b) < eps); } double dot(P a, P b) { return real(b * conj(a)); } double cross(P a, P b) { return imag(b * conj(a)); } ...
[["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 38], ["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 146]]
1
1,129
4
import java.util.Arrays; import java.util.Scanner; public class Main { final static int MAX = 200000; public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 目的の大きさよりも大きいものを作る boolean[] s = new boolean[MAX]; Arrays.fill(s, true); s[0] = false; s[1] = false; ...
import java.util.Arrays; import java.util.Scanner; public class Main { final static int MAX = 300000; public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 目的の大きさよりも大きいものを作る boolean[] s = new boolean[MAX]; Arrays.fill(s, true); s[0] = false; s[1] = false; ...
[["-", 0, 235, 8, 498, 0, 124, 49, 200, 51, 499], ["+", 0, 235, 8, 498, 0, 124, 49, 200, 51, 499]]
3
222
2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(isr); Main app = new Main(); ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(isr); Main app = new Main(); ...
[["+", 0, 7, 502, 503, 49, 200, 51, 16, 17, 72], ["+", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499]]
3
247
2
import java.util.Arrays; import java.util.Scanner; public class Main { static boolean p[]; public static void main(String[] args) { // TODO // ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ Scanner sc = new Scanner(System.in); int n, i, count; while (true) { n = sc.nextInt(); if (n == 0) ...
import java.util.Arrays; import java.util.Scanner; public class Main { static boolean p[]; public static void main(String[] args) { // TODO // ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ Scanner sc = new Scanner(System.in); int n, i, count; while (true) { n = sc.nextInt(); if (n == 0) ...
[["+", 8, 196, 0, 7, 502, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 502, 11, 12, 16, 12, 499]]
3
231
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == 0) break; int count = 0; for (int i = n + 1; i <= 2 * n; i++) { int num = (int)Math.sqrt(i) + 1; ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == 0) break; int count = 0; for (int i = n + 1; i <= 2 * n; i++) { int num = (int)Math.sqrt(i); ...
[["-", 8, 196, 0, 503, 49, 200, 51, 16, 17, 72], ["-", 8, 196, 0, 503, 49, 200, 51, 16, 12, 499], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
186
4
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner sc = new Scanner(System.in); boolean a[] = new boolean[123456 * 2 + 1]; Arrays.fill(a, true); a[0] = a[1] = false; for (int i = 2; i * i <= 123456 * 2; i++) { if (!a[i]) ...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner sc = new Scanner(System.in); boolean a[] = new boolean[123456 * 2 + 1]; Arrays.fill(a, true); a[0] = a[1] = false; for (int i = 2; i * i <= 123456 * 2; i++) { if (!a[i]) ...
[["+", 0, 7, 502, 503, 49, 200, 51, 16, 17, 72], ["+", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499]]
3
201
2
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { ArrayList<Integer> numlist = new ArrayList<Integer>(); numlist.add(2); for (int i = 3; i < 123457; i += 2) { boolean TF = true; for (Integer integer : numlist) { if (in...
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { ArrayList<Integer> numlist = new ArrayList<Integer>(); numlist.add(2); for (int i = 3; i < 123457 * 2; i += 2) { boolean TF = true; for (Integer integer : numlist) { if...
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 48], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 18]]
3
216
4
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0, count = 0; boolean check = true; while (sc.hasNext()) { n = sc.nextInt(); count = 0; //テ・ツ按敕ヲツ慊淌・ツ個? check = true; if (n == 0) break...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0, count = 0; boolean check = true; while (sc.hasNext()) { n = sc.nextInt(); count = 0; //テ・ツ按敕ヲツ慊淌・ツ個? check = true; if (n == 0) break...
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
3
154
2
#include <stdio.h> int main(void) { int n, i, j, c, f; while (scanf("%d", &n), n) { c = 0; for (i = n + 1; i <= 2 * n; i++) { f = 1; for (j = 2; j * j <= i; j++) { if (!(i & j)) { f = 0; break; } } if (f) c++; } printf("%d\n", c); ...
#include <stdio.h> int main(void) { int n, i, j, c, f; while (scanf("%d", &n), n) { c = 0; for (i = n + 1; i <= 2 * n; i++) { f = 1; for (j = 2; j * j <= i; j++) { if (!(i % j)) { f = 0; break; } } if (f) c++; } printf("%d\n", c); ...
[["-", 15, 23, 0, 91, 28, 23, 0, 16, 17, 67], ["+", 15, 23, 0, 91, 28, 23, 0, 16, 17, 109]]
0
117
2
#include <stdbool.h> #include <stdio.h> #define N 123456 int main() { int i, j, k, count; bool p[N * 2 + 1]; for (i = 0; i < N * 2 + 1; i++) { p[i] = 1; } p[0] = 0; p[1] = 0; for (i = 0; i < N; i++) { if (p[i] == 1) { for (j = 2; i * j < 2 * N + 1; j++) { p[i * j] = 0; } ...
#include <stdbool.h> #include <stdio.h> #define N 123456 int main() { int i, j, k, count; bool p[N * 2 + 1]; for (i = 0; i < N * 2 + 1; i++) { p[i] = 1; } p[0] = 0; p[1] = 0; for (i = 0; i < N; i++) { if (p[i] == 1) { for (j = 2; i * j < 2 * N + 1; j++) { p[i * j] = 0; } ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
0
210
2
#include <stdio.h> #define N 123456 * 2 + 5 int main(void) { int a[N], i, j, l = 1, count; for (i = 0; i < N; i++) a[i] = 1; a[0] = a[1] = 0; for (i = 2; i * i < N; i++) { if (a[i]) for (j = i + i; j < N; j = j + i) { a[j] = 0; } } while (1) { scanf("%d", &l); if (l =...
#include <stdio.h> #define N 123456 * 2 + 5 int main(void) { int a[N], i, j, l = 1, count; for (i = 0; i < N; i++) a[i] = 1; a[0] = a[1] = 0; for (i = 2; i * i < N; i++) { if (a[i]) for (j = i + i; j < N; j = j + i) { a[j] = 0; } } while (1) { scanf("%d", &l); if (l =...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
0
179
2
#include <math.h> #include <stdio.h> #include <string.h> int sosu(int n) { int i; if (n <= 1) return 0; ; for (i = 2; i <= sqrt(n); i++) { if (n % i == 0) return 0; } return 1; } int main() { int n, i; int ans; while (1) { scanf("%d", &n); if (n == 0) break; for (i = ...
#include <math.h> #include <stdio.h> #include <string.h> int sosu(int n) { int i; if (n <= 1) return 0; ; for (i = 2; i <= sqrt(n); i++) { if (n % i == 0) return 0; } return 1; } int main() { int n, i; int ans; while (1) { scanf("%d", &n); if (n == 0) break; ans = 0; ...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 12, 13]]
0
137
6
#include <math.h> #include <stdio.h> int isprime(int x) { if (x == 2) return 1; if (x < 2 || x % 2 == 0) return 0; int i; for (i = 3; i <= sqrt(x); i += 2) if (x % i == 0) return 0; return 1; } int main(void) { int n, x, i; for (;;) { scanf("%d", &n); if (n == 0) break...
#include <math.h> #include <stdio.h> int isprime(int x) { if (x == 2) return 1; if (x < 2 || x % 2 == 0) return 0; int i; for (i = 3; i <= sqrt(x); i += 2) if (x % i == 0) return 0; return 1; } int main(void) { int n, x, i; for (;;) { scanf("%d", &n); if (n == 0) break...
[["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 12, 13]]
0
152
2
#include <stdio.h> int main() { int n, i, j, l, d, c; while (1) { c = 0; scanf("%d", &n); if (n == 0) break; if (n == 1) printf("1\n"); else { for (i = n + 1; i <= n * 2; i++) { d = 0; for (j = 2; j * j < i; j++) { if (i % j == 0) { d++; ...
#include <stdio.h> int main() { int n, i, j, l, d, c; while (1) { c = 0; scanf("%d", &n); if (n == 0) break; if (n == 1) printf("1\n"); else { for (i = n + 1; i <= n * 2; i++) { d = 0; for (j = 2; j * j <= i; j++) { if (i % j == 0) { d++; ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
0
143
2
#include <stdio.h> #define MAX 123456 int main() { int n, n2, flag[MAX], i, j, count; while (1) { scanf("%d", &n); if (n == 0) break; n2 = 2 * n; for (i = 0; i < n2 + 1; i++) { flag[i] = 0; } count = 0; flag[0] -= 1; flag[1] -= 1; for (i = 2; i < n2 + 1; i++) { ...
#include <stdio.h> #define MAX 246912 int main() { int n, n2, flag[MAX], i, j, count; while (1) { scanf("%d", &n); if (n == 0) break; n2 = 2 * n; for (i = 0; i < n2 + 1; i++) { flag[i] = 0; } count = 0; flag[0] -= 1; flag[1] -= 1; for (i = 2; i < n2 + 1; i++) { ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
0
218
2
a['___'], c; main(i, j) { for (; ++i * i < 1e6;) for (j = i; j < 1e6;) a[j += i] = 1; for (; scanf("%d", &j), i = j; c = !printf("%d\n", c)) for (; j++ <= i * 2;) c += !a[j]; }
a['___'], c; main(i, j) { for (; ++i * i < 1e6;) for (j = i; j < 1e6;) a[j += i] = 1; for (; scanf("%d", &j), i = j; c = !printf("%d\n", c)) for (; ++j <= i * 2;) c += !a[j]; }
[["-", 0, 7, 8, 7, 15, 16, 31, 27, 28, 22], ["+", 0, 7, 8, 7, 15, 16, 31, 27, 28, 22]]
0
99
15
#include <math.h> #include <stdio.h> int IsPrime(int n); int main() { int n, i, j, count, ans[1000000]; j = 0; while (1) { scanf("%d", &n); if (n == 0) break; count = 0; for (i = n; i <= 2 * n; i++) { if (IsPrime(i)) { count++; } } ans[j] = count; j++; } f...
#include <math.h> #include <stdio.h> int IsPrime(int n); int main() { int n, i, j, count, ans[1000000]; j = 0; while (1) { scanf("%d", &n); if (n == 0) break; count = 0; for (i = n + 1; i <= 2 * n; i++) { if (IsPrime(i)) { count++; } } ans[j] = count; j++; }...
[["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 12, 13]]
0
209
2
#include <stdio.h> int makelist(int *list, int kazu) { int i, j; for (i = 0; i < kazu; i++) { list[i] = 1; } list[0] = 0; list[1] = 0; for (i = 2; i < kazu; i++) { if (list[i]) { for (j = 2 * i; j < kazu; j += i) { list[j] = 0; } } } return 0; } int main() { int list[...
#include <stdio.h> int makelist(int *list, int kazu) { int i, j; for (i = 0; i < kazu; i++) { list[i] = 1; } list[0] = 0; list[1] = 0; for (i = 2; i < kazu; i++) { if (list[i]) { for (j = 2 * i; j < kazu; j += i) { list[j] = 0; } } } return 0; } int main() { int list[...
[["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 12, 13]]
0
206
2
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for (int64 i = 0; i < (n); i++) #define FOR(i, a, b) for (int64 i = (a); i < (b); i++) #define all(x) x.begin(), x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_...
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for (int64 i = 0; i < (n); i++) #define FOR(i, a, b) for (int64 i = (a); i < (b); i++) #define all(x) x.begin(), x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
273
2
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #inclu...
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #inclu...
[["-", 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, 26, 11, 17, 107], ["-", 0, 14, 8, 9, 0, 7, 26, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29]]
1
436
5
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<int> sprime(21800, 0); sprime[0] = 2; int a = 1; for (int i = 3; i < 123456 * 2; i += 2) { int k = 3; while (k <= sqrt(i)) { if (i % k == 0) break; ...
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<int> sprime(200000, 0); sprime[0] = 2; int a = 1; for (int i = 3; i < 123456 * 2; i += 2) { int k = 3; while (k <= sqrt(i)) { if (i % k == 0) break; ...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
175
2
#include <iostream> #include <list> #include <math.h> #include <vector> using namespace std; using vec = vector<int>; using lst = list<int>; bool check(int x, lst &sosu) { for (auto s : sosu) { if (sqrt(x) < s) return true; if (x % s == 0) return false; } return true; } int main() { vec c...
#include <iostream> #include <list> #include <math.h> #include <vector> using namespace std; using vec = vector<int>; using lst = list<int>; bool check(int x, lst &sosu) { for (auto s : sosu) { if (sqrt(x) < s) return true; if (x % s == 0) return false; } return true; } int main() { vec c...
[["-", 12, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
218
2
loop do h = gets.chomp.to_i if h == 0 break end cells = Array.new(h) H.times do |i| cells[i] = gets.chomp.split(" ").map(&:to_i) end ans = 0 loop do flg = false for i in 0...H for j in 0...5 if cells[i][j] == -1 next end cnt = 0 for ...
loop do h = gets.chomp.to_i if h == 0 break end cells = Array.new(h) h.times do |i| cells[i] = gets.chomp.split(" ").map(&:to_i) end ans = 0 loop do flg = false for i in 0...h for j in 0...5 if cells[i][j] == -1 next end cnt = 0 for ...
[["-", 0, 652, 196, 737, 8, 736, 0, 652, 486, 743], ["+", 0, 652, 196, 737, 8, 736, 0, 652, 486, 22], ["-", 8, 736, 0, 88, 51, 267, 0, 475, 444, 743], ["+", 8, 736, 0, 88, 51, 267, 0, 475, 444, 22], ["-", 8, 170, 0, 88, 51, 267, 0, 475, 444, 743], ["+", 8, 170, 0, 88, 51, 267, 0, 475, 444, 22], ["-", 8, 170, 0, 662, 12...
4
259
10
a = int(input()) global s s = 0 def de(ppp,h): re = False co = 0 global s for lo in ppp: for j ,cell in enumerate(lo): k = j p = j if k <= 2: while cell == lo[k+1] and cell != None: co += 1 if k == 3: j = k+1 break k += 1 j = k if co >= 2: re = True s +...
a = int(input()) global s s = 0 def de(ppp,h): re = False co = 0 global s for lo in ppp: for j ,cell in enumerate(lo): k = j p = j if k <= 2: while cell == lo[k+1] and cell != None: co += 1 if k == 3: j = k+1 break k += 1 j = k if co >= 2: re = True s +...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 52, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]]
5
290
4
import java.awt.Point; import java.io.FileInputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Scanner; public class Main { static int r, n; static int[] xl, xr, h; private static void start() { int i, j; Point[] height = new Point[41]; for (i = 0; i < 41; i++) ...
import java.awt.Point; import java.io.FileInputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Scanner; public class Main { static int r, n; static int[] xl, xr, h; private static void start() { int i, j; Point[] height = new Point[41]; for (i = 0; i < 41; i++) ...
[["-", 51, 16, 31, 16, 31, 74, 51, 509, 119, 22], ["+", 51, 16, 31, 16, 31, 74, 51, 509, 119, 22]]
3
526
4
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int hm[43]; int r, n; int main() { while (cin >> r >> n, r) { REP(i, 43) hm[i] = 0; REP(i, n) { int xl, xr, h; cin >> xl >> xr >> h; for (int i = xl + 21; i < xr + 21; ++i) hm[i] = m...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int hm[43]; int r, n; int main() { while (cin >> r >> n, r) { REP(i, 43) hm[i] = 0; REP(i, n) { int xl, xr, h; cin >> xl >> xr >> h; for (int i = xl + 21; i < xr + 21; ++i) hm[i] = m...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
1
194
4
#include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int n, r, diff = 20; while (std::cin >> r >> n, r) { vector<int> hl(50, 0), hr(50, 0); for (int i = 0; i < n; i++) { int xl, xr, h; std::cin >> xl >> xr >> h; for (int j = xl + 1; j...
#include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int n, r, diff = 20; while (std::cin >> r >> n, r) { vector<int> hl(50, 0), hr(50, 0); for (int i = 0; i < n; i++) { int xl, xr, h; std::cin >> xl >> xr >> h; for (int j = xl; j < x...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
245
4
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int r, n, sl, sr, h; int height[40]; double sunrise[40]; while (true) { cin >> r >> n; if (r == 0 && n == 0) { break; } for (int i = 0; i < 40; i++) { height[i] = 0; sunrise[i] = -5...
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int r, n, sl, sr, h; int height[40]; double sunrise[40]; while (true) { cin >> r >> n; if (r == 0 && n == 0) { break; } for (int i = 0; i < 40; i++) { height[i] = 0; sunrise[i] = -5...
[["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 31, 22], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
286
4
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 57, 64, 9, 0, 57, 75, 76, 0, 95]]
1
602
3
#include "bits/stdc++.h" using namespace std; //#define int long long #define REP(i, s, n) for (signed i = (s); i < signed(n); i++) #define rep(i, n) REP(i, 0, n) #define all(c) (c).begin(), (c).end() using VV = vector<vector<int>>; using V = vector<int>; using P = pair<int, int>; using IP = pair<int, P>; signed main...
#include "bits/stdc++.h" using namespace std; //#define int long long #define REP(i, s, n) for (signed i = (s); i < signed(n); i++) #define rep(i, n) REP(i, 0, n) #define all(c) (c).begin(), (c).end() using VV = vector<vector<int>>; using V = vector<int>; using P = pair<int, int>; using IP = pair<int, P>; signed main...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 151], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 3, 4, 0, 16, 12, 23, 0, 16, 17, 18], ["+", 3, 4,...
1
261
8
#include <cmath> #include <iostream> using namespace std; int r, n, L, R, h, i, x; int main() { while (cin >> r >> n, r) { int A[41] = {}, B[41] = {}; for (i = 0; i < n; i++) { cin >> L >> R >> h; for (x = L; x <= R; x++) { if (x != R) A[x + 20] = max(A[x + 20], h); ...
#include <cmath> #include <iostream> using namespace std; int r, n, L, R, h, i, x; int main() { while (cin >> r >> n, r) { int A[41] = {}, B[41] = {}; for (i = 0; i < n; i++) { cin >> L >> R >> h; for (x = L; x <= R; x++) { if (x != R) A[x + 20] = max(A[x + 20], h); ...
[["+", 0, 52, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29], ["-", 341, 342, 0, 16, 31, 16, 31, 27, 17, 29]]
1
239
37
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) int s[21][41]; int main(void) { int r, n, xl, xr, h; while (cin >> r >> n && r) { rep(i, 41) rep(j, 41) s[i][j] = 0; rep(i, n) { cin >> xl >> xr >> h; for (int y = 0; y < h; ++y) { for (int x =...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) int s[21][41]; int main(void) { int r, n, xl, xr, h; while (cin >> r >> n && r) { rep(i, 21) rep(j, 41) s[i][j] = 0; rep(i, n) { cin >> xl >> xr >> h; for (int y = 0; y < h; ++y) { for (int x =...
[["-", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13]]
1
285
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { while (true) { int r, n; cin >> r >> n; if (r == 0 && n == 0) { break; } bool grid[21][41]; for (int i = 0; i < 21; i++) { for (int j = 0; j < 41; j++) { grid[i]...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { while (true) { int r, n; cin >> r >> n; if (r == 0 && n == 0) { break; } bool grid[21][41]; for (int i = 0; i < 21; i++) { for (int j = 0; j < 41; j++) { grid[i]...
[["-", 12, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22]]
1
335
4
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define rep(i, n) repl(i, 0, n) #define each(itr, v) for (auto itr : v) #define pb(s) push_back(s) #define all(x) (...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define rep(i, n) repl(i, 0, n) #define each(itr, v) for (auto itr : v) #define pb(s) push_back(s) #define all(x) (...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
515
2
//#define __USE_MINGW_ANSI_STDIO 0 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #defi...
//#define __USE_MINGW_ANSI_STDIO 0 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #defi...
[["-", 31, 16, 31, 74, 51, 23, 0, 16, 17, 72], ["+", 31, 16, 31, 74, 51, 23, 0, 16, 17, 48]]
1
380
2
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i, n) for (ll(i) = (0); (i) < (n); ++i) #define rep(i, s, g) for (ll(i) = (s); (i) < (g); ++i) #define rrep(i, s, g) for (ll(i) = (s); i >= (g); --(i)) #define PB push_back #define MP make_pair ...
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i, n) for (ll(i) = (0); (i) < (n); ++i) #define rep(i, s, g) for (ll(i) = (s); (i) < (g); ++i) #define rrep(i, s, g) for (ll(i) = (s); i >= (g); --(i)) #define PB push_back #define MP make_pair ...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
507
2
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> #include <functional> // #define int long long #define inf 1000000007 #define ...
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> #include <functional> // #define int long long #define inf 1000000007 #define ...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
913
4
#include <bits/stdc++.h> using namespace std; int hs[100][100]; int main() { int n; double r; while (cin >> r >> n, r + n) { memset(hs, 0, sizeof(hs)); for (int i = 0; i < n; i++) { int x1, x2, h; cin >> x1 >> x2 >> h; x1 += 20; x2 += 20; for (int i = x1; i < x2; i++) { ...
#include <bits/stdc++.h> using namespace std; int hs[100][100]; int main() { int n; double r; while (cin >> r >> n, r + n) { memset(hs, 0, sizeof(hs)); for (int i = 0; i < n; i++) { int x1, x2, h; cin >> x1 >> x2 >> h; x1 += 20; x2 += 20; for (int i = x1; i < x2; i++) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
302
2
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> using namespace std; //#define int long long #define rep(i, n) for (int i = 0; i < (n); ++i) int main(void) { cin.tie(0); ios::sync_with_stdio(false); int x, y, s, a, b, ans; while (cin >> x >> y >> s, x | y | s) { ans = 0; f...
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> using namespace std; //#define int long long #define rep(i, n) for (int i = 0; i < (n); ++i) int main(void) { cin.tie(0); ios::sync_with_stdio(false); int x, y, s, a, b, ans; while (cin >> x >> y >> s, x | y | s) { ans = 0; f...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
187
4
#include <bits/stdc++.h> using namespace std; main() { int x, y, s; while (cin >> x >> y >> s, x + y + s) { int mx = 0; for (int i = 1; i < s - 1; i++) { for (int j = i + 1; j < s; j++) { if (i * (100 + x) / 100 + j * (100 + x) / 100 == s) { mx = max(mx, i * (100 + y) / 100 + j * (1...
#include <bits/stdc++.h> using namespace std; main() { int x, y, s; while (cin >> x >> y >> s, x + y + s) { int mx = 0; for (int i = 1; i < s - 1; i++) { for (int j = i; j < s; j++) { if (i * (100 + x) / 100 + j * (100 + x) / 100 == s) { mx = max(mx, i * (100 + y) / 100 + j * (100 +...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
136
2
#include <iostream> using namespace std; int main() { int x, y, s; int max = 0, ss; while (cin >> x >> y >> s && !(x == 0 && y == 0 && s == 0)) { for (int i = 1; i < s; i++) { for (int j = 1; j < s; j++) { if (i * (100 + x) / 100 + j * (100 + x) / 100 == s) { ss = i * (100 + y) / 100 ...
#include <iostream> using namespace std; int main() { int x, y, s; int max, ss; while (cin >> x >> y >> s && !(x == 0 && y == 0 && s == 0)) { max = 0; for (int i = 1; i < s; i++) { for (int j = 1; j < s; j++) { if (i * (100 + x) / 100 + j * (100 + x) / 100 == s) { ss = i * (100 + ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
152
6
#include <iostream> using namespace std; int func(int a, int x) { return a + (a * x / 100); } int main(void) { int x, y, s; while (cin >> x >> y >> s, x | y | s) { int ans = 0; for (int i = 1; i < 100; i++) { for (int j = 1; j < 100; j++) { if (func(i, x) + func(j, x) == s) { a...
#include <iostream> using namespace std; int func(int a, int x) { return a + (a * x / 100); } int main(void) { int x, y, s; while (cin >> x >> y >> s, x | y | s) { int ans = 0; for (int i = 1; i < 1000; i++) { for (int j = 1; j < 1000; j++) { if (func(i, x) + func(j, x) == s) { ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
147
4
#include <iostream> using namespace std; int x, y, s; int main() { while (true) { cin >> x; cin >> y; cin >> s; if (x == 0 && y == 0 && s == 0) break; int bef, aft, max; max = 0; for (int i = 0; i <= s; ++i) { for (int j = 0; j <= s; ++j) { bef = i * (100 + x) / 100...
#include <iostream> using namespace std; int x, y, s; int main() { while (true) { cin >> x; cin >> y; cin >> s; if (x == 0 && y == 0 && s == 0) break; int bef, aft, max; max = 0; for (int i = 1; i <= s; ++i) { for (int j = 1; j <= s; ++j) { bef = i * (100 + x) / 100...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
164
6
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> #define INF 2147483647 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; int main() { int x, y, s; while (cin >> x >> ...
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> #define INF 2147483647 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; int main() { int x, y, s; while (cin >> x >> ...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
246
2
#include <bits/stdc++.h> // Shrotening #define fst first #define snd second #define pb push_back #define mp make_pair // Loop #define FOR(i, a, b) for (auto i = (a); i < (b); ++i) #define RFOR(i, a, b) for (auto i = (a); i >= (b); --i) #define REP(i, a) for (long i = 0; i < (a); ++i) #define RREP(i, a) for (long i =...
#include <bits/stdc++.h> // Shrotening #define fst first #define snd second #define pb push_back #define mp make_pair // Loop #define FOR(i, a, b) for (auto i = (a); i < (b); ++i) #define RFOR(i, a, b) for (auto i = (a); i >= (b); --i) #define REP(i, a) for (long i = 0; i < (a); ++i) #define RREP(i, a) for (long i =...
[["-", 51, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["+", 51, 16, 31, 16, 12, 2, 3, 4, 0, 22]]
1
380
2
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { int x, y, z, ans = 0; cin >> x >> y >> z; if (!x && !y && !z) break; for (int i = 0; i < z; i++) { for (int j = 0; j < z; j++) { if (int(i * (100 + x) / 100) + int(j * (100 + x) / 100) == z) ...
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { int x, y, z, ans = 0; cin >> x >> y >> z; if (!x && !y && !z) break; for (int i = 1; i < z; i++) { for (int j = 1; j < z; j++) { if (int(i * (100 + x) / 100) + int(j * (100 + x) / 100) == z) ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
153
4
#include <bits/stdc++.h> using namespace std; long getPrice(long orig, long r) { double d = double(orig) * (100 + r) / 100; return floor(d); } long getOrig(long pr, long r) { double d = double(pr) / (100 + r) * 100; if (getPrice(floor(d), r) == pr) { return floor(d); } if (getPrice(ceil(d), r) == pr) ...
#include <bits/stdc++.h> using namespace std; long getPrice(long orig, long r) { double d = double(orig) * (100 + r) / 100; return floor(d); } long getOrig(long pr, long r) { double d = double(pr) / (100 + r) * 100; if (getPrice(floor(d), r) == pr) { return floor(d); } if (getPrice(ceil(d), r) == pr) ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
261
2
while true rateA,rateB,s = gets.split(" ").map(&:to_i) break if rateA ==0 && rateB == 0 && s == 0 a=[] $roop = 1 for i in 1..s/2 sa = i*(100+rateA)/100 (s/2..s).to_a.reverse.each do |j| sb = j*(100+rateA)/100 if sa + sb < s break en...
while true rateA,rateB,s = gets.split(" ").map(&:to_i) break if rateA ==0 && rateB == 0 && s == 0 a=[] $roop = 1 for i in 1..s/2 sa = i*(100+rateA)/100 (1..s-sa).to_a.reverse.each do |j| sb = j*(100+rateA)/100 if sa + sb < s break e...
[["-", 486, 652, 486, 739, 0, 475, 756, 738, 31, 22], ["-", 486, 652, 486, 739, 0, 475, 756, 738, 17, 85], ["-", 486, 652, 486, 739, 0, 475, 756, 738, 12, 612], ["+", 486, 652, 486, 652, 486, 739, 0, 475, 756, 612], ["+", 486, 652, 486, 739, 0, 475, 444, 738, 17, 33], ["+", 486, 652, 486, 739, 0, 475, 444, 738, 12, 22]...
4
183
19
def tax_exclude(price, tax) return nil if ((price + 1) * 100) % (100 + tax) == 0 possible_price = ((price + 1) / ((100 + tax) / 100.0)).to_i return nil if possible_price < ((price) / ((100 + tax) / 100.0)) possible_price end while true old_tax, new_tax, sum = gets.split(" ").map(&:to_i) break if [old_tax, ...
def tax_exclude(price, tax) return nil if ((price + 1) * 100) % (100 + tax) == 0 possible_price = ((price + 1) / ((100 + tax) / 100.0)).to_i return nil if possible_price < ((price) / ((100 + tax) / 100.0)) possible_price end while true old_tax, new_tax, sum = gets.split(" ").map(&:to_i) break if [old_tax, ...
[["-", 0, 738, 12, 739, 0, 738, 31, 739, 0, 24], ["-", 31, 652, 486, 739, 0, 738, 12, 739, 0, 25], ["-", 12, 652, 486, 739, 0, 738, 12, 739, 0, 24], ["-", 12, 652, 486, 739, 0, 738, 12, 739, 0, 25]]
4
190
4
import math def f(s, x): return int(math.floor(s * (100 + x) / 100.0)) while True: (x, y, s) = list(map(int, input().split())) if x + y + s == 0: break ans = 0 for i in range(1, s): for j in range(1, s - i): if f(i, x) + f(j, x) == s: ans = max(ans, f(i, y) + f(j, y)) print(ans)
import math def f(s, x): return int(math.floor(s * (100 + x) / 100.0)) while True: (x, y, s) = list(map(int, input().split())) if x + y + s == 0: break ans = 0 for i in range(1, s): for j in range(1, s - i + 1): if f(i, x) + f(j, x) == s: ans = max(ans, f(i, y) + f(j, y)) print(ans...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
130
2
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: x,y,s = map(int,input().split()) if (x,y,s) == (0,0,0): break ans = 0 for i in range(1,s-1): for j in range(1,s-1): if i*(100+x)//100 + j*(100+x)//100== s: ans = max(ans,i*(100+y)//100 + j*(100+y)//100...
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: x,y,s = map(int,input().split()) if (x,y,s) == (0,0,0): break ans = 0 for i in range(1,s-1): for j in range(1,s-i + 1): if i*(100+x)//100 + j*(100+x)//100== s: ans = max(ans,i*(100+y)//100 + j*(100+y)/...
[["+", 12, 652, 3, 4, 0, 657, 31, 657, 12, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72]]
5
121
6
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: x,y,s = map(int,input().split()) if (x,y,s) == (0,0,0): break ans = 0 for i in range(1,s-1): for j in range(1,s-1): if i*(100+x)//100 + j*(100+x)//100== s: ans = max(ans,i*(100+y)//100 + j*(100+y)//100...
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: x,y,s = map(int,input().split()) if (x,y,s) == (0,0,0): break ans = 0 for i in range(1,s//2 + 1): for j in range(1,s-i + 1): if i*(100+x)//100 + j*(100+x)//100== s: ans = max(ans,i*(100+y)//100 + j*(10...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 12, 652, 3, 4, 0, 657, 31, 657, 17, 676], ["+", 12, 652, 3, 4, 0, 657, 31, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 12, 652, 3, 4, 0, 657, 31, 657, 12, 22]]
5
121
6
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; int ex(int src, int ratio) { return (src * (100 + ratio)) / 100; } void run() { for (;;) { int h = ni(); if (h == 0) { break; } int[][] f = new int[h][5]; for (int i = 0; i < h; ++i) { ...
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; int ex(int src, int ratio) { return (src * (100 + ratio)) / 100; } void run() { for (;;) { int h = ni(); if (h == 0) { break; } int[][] f = new int[h][5]; for (int i = 0; i < h; ++i) { ...
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35]]
3
412
2
#include <stdio.h> int main() { int h, i, j, c, s, f, k; while (scanf("%d", &h), h) { int d[20][6] = {0}; for (i = s = 0; i < h; i++) { for (j = 0; j < 5; j++) scanf("%d", &d[h - i - 1][j]); } /*for(i=0;i<20;i++){ for(j=0;j<5;j++){ printf("%d ",d[i][j]); } pri...
#include <stdio.h> int main() { int h, i, j, c, s, f, k; while (scanf("%d", &h), h) { int d[20][6] = {0}; for (i = s = 0; i < h; i++) { for (j = 0; j < 5; j++) scanf("%d", &d[h - i - 1][j]); } /*for(i=0;i<20;i++){ for(j=0;j<5;j++){ printf("%d ",d[i][j]); } pri...
[["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
0
324
4
#include <stdio.h> int main(void) { int H, stone[10][5] = {0}; int a, i, j, k, score = 0; while (1) { scanf("%d", &H); if (H == 0) { break; } score = 0; for (i = 0; i < H; i++) { scanf("%d %d %d %d %d", &stone[i][0], &stone[i][1], &stone[i][2], &stone[i][3], &stone[i][...
#include <stdio.h> int main(void) { int H, stone[10][5] = {0}; int a, i, j, k, score = 0; while (1) { scanf("%d", &H); if (H == 0) { break; } score = 0; for (i = 0; i < H; i++) { scanf("%d %d %d %d %d", &stone[i][0], &stone[i][1], &stone[i][2], &stone[i][3], &stone[i][...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
626
5
#include <stdio.h> #define NUM 10 void drop(int puz[][5], int i, int j) { int k; for (k = i; k > 0; k--) puz[k][j] = puz[k - 1][j]; puz[0][j] = 0; } int main(void) { int score = 0; int tscore = 0; int count = 0; int h, i, j; int puz[NUM][5] = {0}; replay: while (1) { scanf("%d", &h); ...
#include <stdio.h> #define NUM 10 void drop(int puz[][5], int i, int j) { int k; for (k = i; k > 0; k--) puz[k][j] = puz[k - 1][j]; puz[0][j] = 0; } int main(void) { int score = 0; int tscore = 0; int count = 0; int h, i, j; int puz[NUM][5] = {0}; replay: while (1) { scanf("%d", &h); ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
0
702
2
#include <stdio.h> int h; int memo[11][5]; int bf, ans; int main() { int i, j, k; while (1) { scanf("%d", &h); if (h == 0) break; bf = -1; ans = 0; for (i = 0; i < h; i++) for (j = 0; j < 5; j++) scanf("%d", &memo[i][j]); while (ans != bf) { bf = ans; //消す作業...
#include <stdio.h> int h; int memo[11][5]; int bf, ans; int main() { int i, j, k; while (1) { scanf("%d", &h); if (h == 0) break; bf = -1; ans = 0; for (i = 0; i < h; i++) for (j = 0; j < 5; j++) scanf("%d", &memo[i][j]); while (ans != bf) { bf = ans; //消す作業...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
0
349
3
// Name: Chain Disappearance Puzzle // Level: 2 // Category: シミュレーション // Note: /** * 素直にシミュレーションすればよい。 * 消える石にマークする処理と、消えたところに石を詰める処理は別々に行わないといけないことに注意する。 * * オーダーは O(H^2)。 */ #include <algorithm> #include <iostream> #include <vector> using namespace std; void mark(vector<vector<int>> &field, int r, int c, int ...
// Name: Chain Disappearance Puzzle // Level: 2 // Category: シミュレーション // Note: /** * 素直にシミュレーションすればよい。 * 消える石にマークする処理と、消えたところに石を詰める処理は別々に行わないといけないことに注意する。 * * オーダーは O(H^2)。 */ #include <algorithm> #include <iostream> #include <vector> using namespace std; void mark(vector<vector<int>> &field, int r, int c, int ...
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
511
4
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; #define loop(i, a, b) for (int i = (a); i < ull(b); ++i) #define rep(i, n) loop(i, 0, n) #define all(a) (a).begin(), (a).end() const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; int main() { int n; wh...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; #define loop(i, a, b) for (int i = (a); i < ull(b); ++i) #define rep(i, n) loop(i, 0, n) #define all(a) (a).begin(), (a).end() const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; int main() { int n; wh...
[["-", 31, 69, 28, 69, 28, 2, 3, 4, 0, 13], ["+", 31, 69, 28, 69, 28, 2, 3, 4, 0, 22]]
1
406
2
//連鎖消滅パズル #include <iostream> using namespace std; #define ISEQUAL(i, a, b, c) \ Data[a][i] == Data[b][i] && Data[b][i] == Data[c][i] && Data[a][i] != 0 int main() { int RowNum = 0; //行数 int *Data[5]; //数値データ[列][行] int Points = 0; ...
#include <iostream> using namespace std; #define ISEQUAL(i, a, b, c) \ Data[a][i] == Data[b][i] && Data[b][i] == Data[c][i] && Data[a][i] != 0 int main() { int RowNum = 0; //行数 int *Data[5]; //数値データ[列][行] int Points = 0; //...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 147], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
493
4
#include <bits/stdc++.h> using namespace std; // void pfield(vector<vector<int> >, int); int main() { int cols; while (cin >> cols, cols) { vector<vector<int>> field(5, vector<int>()); // [col][line] for (int il = 0; il < cols; ++il) { for (int ic = 0; ic < 5; ++ic) { int num; cin >> ...
#include <bits/stdc++.h> using namespace std; // void pfield(vector<vector<int> >, int); int main() { int cols; while (cin >> cols, cols) { vector<vector<int>> field(5, vector<int>()); // [col][line] for (int il = 0; il < cols; ++il) { for (int ic = 0; ic < 5; ++ic) { int num; cin >> ...
[["+", 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, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
348
4
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define mp make_pair #define pb push_back #define fi first #define se second #define INF 1000000005 #def...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define mp make_pair #define pb push_back #define fi first #define se second #define INF 1000000005 #def...
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98]]
1
461
6
#include <algorithm> #include <iostream> using namespace std; int map[20][5]; int h, ans; void DFS() { bool move = false; for (int i = 0; i < h; i++) { int cnt = 0, set = 0; for (int j = 0; j < 5; j++) { if (map[i][j] != set) { if (cnt >= 3 && set != 0) { for (int k = 0; k < cnt; k++...
#include <algorithm> #include <iostream> using namespace std; int map[20][5]; int h, ans; void DFS() { bool move = false; for (int i = 0; i < h; i++) { int cnt = 0, set = 0; for (int j = 0; j < 5; j++) { if (map[i][j] != set) { if (cnt >= 3 && set != 0) { for (int k = 0; k < cnt; k++...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
416
2
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, c; while (cin >> n, n != 0) { int a[n][5], sum = 0; ; for (i = 0; i < n; i++) for (j = 0; j < 5; j++) cin >> a[i][j]; while (1) { c = 0; for (i = 0; i < n; i++) { if (a[i][0] != 0 && a[i][0] == ...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, c; while (cin >> n, n != 0) { int a[n][5], sum = 0; ; for (i = 0; i < n; i++) for (j = 0; j < 5; j++) cin >> a[i][j]; while (1) { c = 0; for (i = 0; i < n; i++) { if (a[i][0] != 0 && a[i][0] == ...
[["+", 0, 7, 8, 7, 10, 11, 12, 16, 17, 33], ["+", 0, 7, 8, 7, 10, 11, 12, 16, 12, 13], ["-", 0, 7, 8, 7, 8, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 7, 8, 7, 15, 16, 12, 13]]
1
861
4
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define pf push_front #define mp make_pair #define fr first #define sc second #define Rep(i, n) for (int i = 0; i < (n); i++) #define All(v) v.begin(), v.end() typedef pair<int, int> Pii; typedef pair<int, Pii> Pip; const int INF =...
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define pf push_front #define mp make_pair #define fr first #define sc second #define Rep(i, n) for (int i = 0; i < (n); i++) #define All(v) v.begin(), v.end() typedef pair<int, int> Pii; typedef pair<int, Pii> Pip; const int INF =...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
376
2
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) int read() { int i; scanf("%lld", &i); return i; } signed main() { while (true) { int H = read(); if (H == 0) break; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define FOR(i, a, b) for (int i = int(a); i < int(b); i++) #define REP(i, b) FOR(i, 0, b) int read() { int i; scanf("%lld", &i); return i; } signed main() { while (true) { int H = read(); if (H == 0) break; ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
417
4
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) int tile[11][5]; int main() { int h; while (cin >> h, h) { REP(i, 11) REP(j, 5) { tile[i][j] = -1; } REP(i, h) REP(j, 5) { cin >> tile[h - 1 - i][j]; } int ans = 0; bool update = false; while (true) {...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) int tile[11][5]; int main() { int h; while (cin >> h, h) { REP(i, 11) REP(j, 5) { tile[i][j] = -1; } REP(i, h) REP(j, 5) { cin >> tile[h - 1 - i][j]; } int ans = 0; bool update = false; while (true) {...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
498
2
#include <iostream> using namespace std; int main() { while (1) { int H; cin >> H; if (H == 0) break; int S[10][5]; for (int y = 0; y < H; y++) { for (int x = 0; x < 5; x++) { cin >> S[y][x]; } } int sco = 0; while (1) { bool flg = false; for...
#include <iostream> using namespace std; int main() { while (1) { int H; cin >> H; if (H == 0) break; int S[10][5]; for (int y = 0; y < H; y++) { for (int x = 0; x < 5; x++) { cin >> S[y][x]; } } int sco = 0; while (1) { bool flg = false; for...
[["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22]]
1
525
2
#include <bits/stdc++.h> using namespace std; #define INF 1e9 signed main() { ios::sync_with_stdio(false); cin.tie(0); while (1) { int h; cin >> h; if (h == 0) break; int c[15][5] = {}; for (int i = 0; i < h; i++) { for (int j = 0; j < 5; j++) { cin >> c[i][j]; ...
#include <bits/stdc++.h> using namespace std; #define INF 1e9 signed main() { ios::sync_with_stdio(false); cin.tie(0); while (1) { int h; cin >> h; if (h == 0) break; int c[15][5] = {}; for (int i = 0; i < h; i++) { for (int j = 0; j < 5; j++) { cin >> c[i][j]; ...
[["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
1
426
2
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define INF 100000000 typede...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define INF 100000000 typede...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
971
2
#include <algorithm> #include <iostream> using namespace std; typedef pair<int, int> P; bool prime[2160000]; int val[1200][1200]; P dp[1200][1200]; int xs[] = {1, 0, -1, 0}, ys[] = {0, 1, 0, -1}; bool solve() { int m, n; cin >> m >> n; if (m == 0 && n == 0) return false; for (int i = 0; i < 1200; i++) ...
#include <algorithm> #include <iostream> using namespace std; typedef pair<int, int> P; bool prime[2160000]; int val[1200][1200]; P dp[1200][1200]; int xs[] = {1, 0, -1, 0}, ys[] = {0, 1, 0, -1}; bool solve() { int m, n; cin >> m >> n; if (m == 0 && n == 0) return false; for (int i = 0; i < 1200; i++) ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
552
2
#include <bits/stdc++.h> using namespace std; bool isNotPrime[1000200] = {1, 1}; int prime() { for (int i = 2; i * i < 1000200; i++) { for (int j = 2 * i; j < 1000200; j += i) { isNotPrime[j] = 1; } } } int sc[1050][1050] = {}; int dp[1050][1050][2]; #define T_MAX 1000000 int main() { prime(); int...
#include <bits/stdc++.h> using namespace std; bool isNotPrime[1000200] = {1, 1}; int prime() { for (int i = 2; i * i < 1000200; i++) { for (int j = 2 * i; j < 1000200; j += i) { isNotPrime[j] = 1; } } } int sc[1050][1050] = {}; int dp[1050][1050][2]; #define T_MAX 1000000 int main() { prime(); int...
[["-", 341, 342, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 341, 342, 0, 69, 341, 342, 0, 16, 12, 13]]
1
1,549
2
#include "bits/stdc++.h" using namespace std; bool isso(long long int a) { if (a == 1 || a == 0) return false; for (long long int i = 2; i * i <= a; ++i) { if ((a % i)) { } else { return false; } } return true; } int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; pair<bool, int> caves[1...
#include "bits/stdc++.h" using namespace std; bool isso(long long int a) { if (a == 1 || a == 0) return false; for (long long int i = 2; i * i <= a; ++i) { if ((a % i)) { } else { return false; } } return true; } int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; pair<bool, int> caves[1...
[["-", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120]]
1
830
2
#include <algorithm> #include <cstdio> #include <iomanip> #include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define pii pair<int, int> #define MAXM 1000001 #define MAXSQM 1002 int diff[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int map[MAXSQM][MAXSQM] = {}; bool ...
#include <algorithm> #include <cstdio> #include <iomanip> #include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define pii pair<int, int> #define MAXM 1000001 #define MAXSQM 1003 int diff[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int map[MAXSQM][MAXSQM] = {}; bool ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 60], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 17, 32]]
1
830
6
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #define MAX_M 1000000 using namespace std; typedef struct { int num, prime, last; } HOLE; int M, N; HOLE h[1000 + 2][1000 + 2]; bool prime_judge(int x) { if (x == 0 || x == 1) return false; for (int i = 2; i * ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #define MAX_M 1000000 using namespace std; typedef struct { int num, prime, last; } HOLE; int M, N; HOLE h[1000 + 2][1000 + 2]; bool prime_judge(int x) { if (x == 0 || x == 1) return false; for (int i = 2; i * ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
839
8
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> typedef long long ll; typedef unsigned long long ull; using namespace std; #define pb pus...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> typedef long long ll; typedef unsigned long long ull; using namespace std; #define pb pus...
[["-", 12, 23, 0, 16, 12, 16, 12, 118, 119, 120], ["+", 12, 23, 0, 16, 12, 16, 12, 118, 119, 120]]
1
689
2
#include "bits/stdc++.h" // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1189&lang=jp using namespace std; typedef long long ll; typedef pair<int, int> pii; #define INF 1 << 30 #define MAX_M 1000010 bool Prime[MAX_M]; int Caves[1002][1002]; pii dp[1002][1002]; void init_prime() { Prime[2] = true; for (...
#include "bits/stdc++.h" // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1189&lang=jp using namespace std; typedef long long ll; typedef pair<int, int> pii; #define INF 1 << 30 #define MAX_M 1000010 bool Prime[MAX_M]; int Caves[1002][1002]; pii dp[1002][1002]; void init_prime() { Prime[2] = true; for (...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
862
2
#include <complex> #include <cstring> #include <iostream> #include <vector> using namespace std; #define loop(i, a, b) for (int i = (a); i < int(b); i++) #define rep(i, n) loop(i, 0, n) #define all(c) (c).begin(), (c).end() typedef complex<int> P; const int MAX_M = 1.5e6 + 10; const int SIZE = 1100; int ps[MAX_M / 2...
#include <complex> #include <cstring> #include <iostream> #include <vector> using namespace std; #define loop(i, a, b) for (int i = (a); i < int(b); i++) #define rep(i, n) loop(i, 0, n) #define all(c) (c).begin(), (c).end() typedef complex<int> P; const int MAX_M = 1.5e6 + 10; const int SIZE = 1500; int ps[MAX_M / 2...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
590
2