buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define repa(i, s, ...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define repa(i, s, ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
246
2
#include <iostream> using namespace std; int solve(int p, int q, int r, int a, int n) { int k = 0; for (int i = max(r, p / q); i <= a; i++) { if (i * p == q) k++; else if (n != 1) k += solve(i * p - q, i * q, i, a / i, n - 1); } return k; } int main() { int p, q, a, n; while (cin >> p >>...
#include <iostream> using namespace std; int solve(int p, int q, int r, int a, int n) { int k = 0; for (int i = max(r, q / p); i <= a; i++) { if (i * p == q) k++; else if (n != 1) k += solve(i * p - q, i * q, i, a / i, n - 1); } return k; } int main() { int p, q, a, n; while (cin >> p >>...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 85], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 85], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 22]]
1
149
4
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; i++) const int INF = (1 << 29) + 1; int n, m; template <typename T> struct Serializer { map<T, int> enc; vector<T> dec; int operator()(const T &t) { ...
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; i++) const int INF = (1 << 29) + 1; int n, m; template <typename T> struct Serializer { map<T, int> enc; vector<T> dec; int operator()(const T &t) { ...
[["-", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 12, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 12, 16, 12, 16, 31, 69, 341, 342, 0, 22]]
1
693
4
#include <stdio.h> int calc(int type, int y, int init, double rate, int c) { int i, b = 0; if (type == 0) { for (i = 0; i < y; i++) { b += init * rate; init -= c; } return init + b; } else { for (i = 0; i < y; i++) { b = init * rate; init = init + b - c; } return in...
#include <stdio.h> int calc(int type, int y, int init, double rate, int c) { int i, b = 0; if (type == 0) { for (i = 0; i < y; i++) { b += init * rate; init -= c; } return init + b; } else { for (i = 0; i < y; i++) { b = init * rate; init = init + b - c; } return in...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
227
2
#include <stdio.h> int n; int main() { scanf("%d", &n); while (n--) { int money, year, way; double rate; scanf("%d", &money); scanf("%d", &year); scanf("%d", &way); int c, d = 0, ans; while (way--) { int flag, factorage; int y = year; scanf("%d", &flag); scanf("%...
#include <stdio.h> int n; int main() { scanf("%d", &n); while (n--) { int money, year, way; double rate; scanf("%d", &money); scanf("%d", &year); scanf("%d", &way); int c, d = 0, ans; while (way--) { int flag, factorage; int y = year; scanf("%d", &flag); scanf("%...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
242
1
#include <stdio.h> #include <stdlib.h> int main(void) { int i, j; int fmoney, lmoney; int r; int year; int b, cost; double per; int m, n; int *a; scanf("%d", &m); while (1) { if (m == 0) break; scanf("%d", &fmoney); scanf("%d", &year); scanf("%d", &n); a = (int *)malloc(...
#include <stdio.h> #include <stdlib.h> int main(void) { int i, j; int fmoney, lmoney; int r; int year; int b, cost; double per; int m, n; int *a; scanf("%d", &m); while (1) { if (m == 0) break; scanf("%d", &fmoney); scanf("%d", &year); scanf("%d", &n); a = (int *)malloc(...
[["-", 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, 1, 0, 11, 17, 110], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
0
303
8
#include <stdio.h> #include <stdlib.h> int estimate_Tanri(int operatingfund, double rate_of_interest, int period, int fee); int estimate_Fukuri(int operatingfund, double rate_of_interest, int period, int fee); int main(void) { int m; scanf("%d", &m); int i; for (i = 0; i...
#include <stdio.h> #include <stdlib.h> int estimate_Tanri(int operatingfund, double rate_of_interest, int period, int fee); int estimate_Fukuri(int operatingfund, double rate_of_interest, int period, int fee); int main(void) { int m; scanf("%d", &m); int i; for (i = 0; i...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
340
4
#include <stdio.h> int main(void) { int m, plan, set, money, year, part, total, top, answer[100] = {0}; float r; scanf("%d", &m); int i, j, k; for (i = 0; i < m; i++) { scanf(" %d %d %d", &money, &year, &part); for (j = 0; j < part; j++) { scanf(" %d %f %d", &plan, &r, &set); total = mone...
#include <stdio.h> int main(void) { int m, plan, set, money, year, part, total, top, answer[500] = {0}; double r; scanf("%d", &m); int i, j, k; for (i = 0; i < m; i++) { scanf(" %d %d %d", &money, &year, &part); for (j = 0; j < part; j++) { /* scanf(" %d %f %d", &plan, &r, &set);*/ scan...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
268
6
#include <stdio.h> int main() { int m, n; int value, year; int type, cost; int result; int i, j, k; int a, b; int max; float ratio; scanf("%d", &m); for (k = 0; k < m; k++) { scanf("%d", &value); scanf("%d", &year); scanf("%d", &n); max = 0; for (i = 0; i < n; i++) { scanf(...
#include <stdio.h> int main() { int m, n; int value, year; int type, cost; int result; int i, j, k; int a, b; int max; double ratio; scanf("%d", &m); for (k = 0; k < m; k++) { scanf("%d", &value); scanf("%d", &year); scanf("%d", &n); max = 0; for (i = 0; i < n; i++) { scanf...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
246
4
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #define pi 3.14159 using namespace std; int main() { int m; cin >> m; for (int i = 0; i < m; i++) { double a, b, money, in, sum, max; int y, c, d, n; cin >> a >> y >> n; double e[100]; for (int j =...
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #define pi 3.14159 using namespace std; int main() { int m; cin >> m; for (int i = 0; i < m; i++) { double a, b, money, in, sum, max; int y, c, d, n; cin >> a >> y >> n; double e[100]; for (int j =...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
249
2
#include <algorithm> #include <assert.h> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #incl...
#include <algorithm> #include <assert.h> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #incl...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 64, 9, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 64, 9, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 9, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 9, 0, 14, 8, 9, 0, 43, 39, 40]]
1
313
6
#include <iostream> #include <vector> using namespace std; int main(int argc, char const *argv[]) { int n, m; int first, year, ver, fee; double rate; int result = 0; vector<int> results; cin >> m; for (int i = 0; i < m; i++) { cin >> first; cin >> year; cin >> n; int temp; for (int ...
#include <iostream> #include <vector> using namespace std; int main(int argc, char const *argv[]) { int n, m; int first, year, ver, fee; double rate; int result = 0; vector<int> results; cin >> m; for (int i = 0; i < m; i++) { cin >> first; cin >> year; cin >> n; int temp; result = ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
255
4
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) int main(void) { int m; std::cin >> m; //データセットの数 while (m--) { double amt; //初期運用資金量 int year; //運用年数 int n; //運用方法の種類数 int ans = 0; std::cin >> amt >> year >> n; while (n--) { int f; //単利0、複利1 ...
#include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) int main(void) { int m; std::cin >> m; //データセットの数 while (m--) { double amt; //初期運用資金量 int year; //運用年数 int n; //運用方法の種類数 int ans = 0; std::cin >> amt >> year >> n; while (n--) { int f; //単利0、複利1 ...
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40]]
1
192
2
#include <stdio.h> int main() { int m, fand, year, n, ri, nen, com; int max, tmp, in; scanf("%d", &m); while (m--) { scanf("%d%d%d", &fand, &year, &n); max = 0; while (n--) { tmp = fand; in = 0; scanf("%d%lf%d", &ri, &nen, &com); for (int i = 0; i < year; i++) { if (r...
#include <stdio.h> int main() { int m, fand, year, n, ri, com; int max, tmp, in; double nen; scanf("%d", &m); while (m--) { scanf("%d%d%d", &fand, &year, &n); max = 0; while (n--) { tmp = fand; in = 0; scanf("%d%lf%d", &ri, &nen, &com); for (int i = 0; i < year; i++) { ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22]]
1
180
5
#include <iostream> using namespace std; int main() { int m; int n; int money, nowmoney, year; int type, tesuu; int sumrisi; int ans; double risi; cin >> m; for (int i = 0; i < m; i++) { cin >> money; cin >> year; cin >> n; ans = -1; for (int j = 0; j < n; j++) { cin >> ...
#include <iostream> using namespace std; int main() { int m; int n; int money, nowmoney, year; int type, tesuu; int sumrisi; int ans; double risi; cin >> m; for (int i = 0; i < m; i++) { cin >> money; cin >> year; cin >> n; ans = -1; for (int j = 0; j < n; j++) { cin >> ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
185
4
#include <algorithm> #include <iostream> using namespace std; int main() { int k, m, g, y, n; cin >> k; for (int i = 0; i < k; i++) { int mg = 0; cin >> g >> y >> n; for (int j = 0; j < n; j++) { int ng = g; int tf, q; double p; cin >> tf >> p >> q; if (tf) { //単利 ...
#include <algorithm> #include <iostream> using namespace std; int main() { int k, m, g, y, n; cin >> k; for (int i = 0; i < k; i++) { int mg = 0; cin >> g >> y >> n; for (int j = 0; j < n; j++) { int ng = g; int tf, q; double p; cin >> tf >> p >> q; if (tf) { //単利 ...
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
195
4
import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * Polygonal Line Search */ public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(Sy...
import static java.lang.Integer.parseInt; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * Polygonal Line Search */ public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(Sy...
[["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491]]
3
776
2
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter out; static InputReader ir; static void solve() { for (;;) { int n = ir.nextInt(); if (n =...
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter out; static InputReader ir; static void solve() { for (;;) { int n = ir.nextInt(); if (n =...
[["-", 0, 16, 12, 504, 516, 504, 71, 16, 17, 72], ["-", 0, 16, 12, 504, 516, 504, 71, 16, 12, 499]]
3
2,019
2
#include <math.h> #include <stdio.h> #define EPS 1e-5 typedef struct { int x, y; } vector_t; typedef struct { double x, y; } vectord_t; void complex_div(vector_t *a, vector_t *b, vectord_t *t) { double d = a->x * a->x + a->y * a->y; t->x = (double)(a->x * b->x + a->y * b->y) / d; t->y = (double)(a->x * b-...
#include <math.h> #include <stdio.h> #define EPS 1e-5 typedef struct { int x, y; } vector_t; typedef struct { double x, y; } vectord_t; void complex_div(vector_t *a, vector_t *b, vectord_t *t) { double d = a->x * a->x + a->y * a->y; t->x = (double)(a->x * b->x + a->y * b->y) / d; t->y = (double)(a->x * b-...
[["-", 0, 14, 8, 9, 0, 43, 49, 84, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 14, 8, 9, 0, 43, 49, 84, 0, 48]]
0
782
3
#include <iostream> using namespace std; bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i * i < n; i++) { if (n % i == 0) return false; } return true; } int main() { while (1) { int a, d, n; cin >> a >> d >> n; if (a == 0 && d == 0 && n == 0) break; int...
#include <iostream> using namespace std; bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } int main() { while (1) { int a, d, n; cin >> a >> d >> n; if (a == 0 && d == 0 && n == 0) break; in...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
145
2
#coding: utf-8 l = list(range(0, 1001)) l[1] = 0 for i in range(0, 50): if l[i] != 0: for k in range(i + i, 1001, i): l[k] = 0 continue l = [x for x in l if x] print(l) while True: l2 = list(map(int,input().split())) if l2 == [0,0,0]: break a = l2[0] d = l2[1] ...
#coding: utf-8 l = list(range(0, 1001)) l[1] = 0 for i in range(0, 50): if l[i] != 0: for k in range(i + i, 1001, i): l[k] = 0 continue l = [x for x in l if x] while True: l2 = list(map(int,input().split())) if l2 == [0,0,0]: break a = l2[0] d = l2[1] n = l2[...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
192
4
// 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], ["+", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
528
4
#include <algorithm> #include <iostream> #include <set> using namespace std; string str; set<string> S; int main() { int Tc; cin >> Tc; while (Tc > 0) { Tc--; cin >> str; for (int i = 1; i < (int)str.size(); i++) { string a = str.substr(0, i); string b = str.substr(i); string c = a...
#include <algorithm> #include <iostream> #include <set> using namespace std; string str; set<string> S; int main() { int Tc; cin >> Tc; while (Tc > 0) { Tc--; S.clear(); cin >> str; for (int i = 1; i < (int)str.size(); i++) { string a = str.substr(0, i); string b = str.substr(i); ...
[["+", 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], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
223
6
#include <iostream> #include <set> #include <string> using namespace std; string reverse(string st, int size) { string reLine; for (; size >= 0; size--) { reLine.push_back(st[size]); } return reLine; } int main() { int n; string arrivalLine; set<string> s; cin >> n; while (n--) { string fr...
#include <iostream> #include <set> #include <string> using namespace std; string reverse(string st, int size) { string reLine; for (; size > 0; size--) { reLine.push_back(st[size - 1]); } return reLine; } int main() { int n; string arrivalLine; set<string> s; cin >> n; while (n--) { string...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
252
4
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; int main(int argc, char *argv[]) { int m; string line, fr, sc; cin >> m; while (m--) { cin >> line; set<string> s; s.insert(line); for (int i = 1; i < line.size(); ++i) { fr = line.substr(0, i);...
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; int main(int argc, char *argv[]) { int m; string line, fr, sc; cin >> m; while (m--) { cin >> line; set<string> s; s.insert(line); for (int i = 1; i < line.size(); ++i) { fr = line.substr(0, i);...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
217
2
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; int main(int argc, const char *argv[]) { int n; cin >> n; while (n--) { set<string> kinds; string str; cin >> str; for (int i = 1; i < str.size(); i++) { string s1 = str.substr(i), s2 = str.subst...
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; int main(int argc, const char *argv[]) { int n; cin >> n; while (n--) { set<string> kinds; string str; cin >> str; for (int i = 1; i < str.size(); i++) { string s1 = str.substr(i), s2 = str.subst...
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
209
2
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; int main() { int M; cin >> M; for (int i = 0; i < M; ++i) { string S; cin >> S; typedef set<string> set_t; set_t all; all.insert(S); for (int j = 1; j < S.size(); ++j) { string L; for...
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; int main() { int M; cin >> M; for (int i = 0; i < M; ++i) { string S; cin >> S; typedef set<string> set_t; set_t all; all.insert(S); for (int j = 1; j < S.size(); ++j) { string L; for...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
255
4
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; typedef set<string> set_t; set_t A; int organize(string str1, string str2) { A.insert(str1 + str2); A.insert(str2 + str1); } int main() { int k; cin >> k; string train; for (int i = 0; i < k; i++) { cin >> ...
#include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; typedef set<string> set_t; set_t A; int organize(string str1, string str2) { A.insert(str1 + str2); A.insert(str2 + str1); } int main() { int k; cin >> k; string train; for (int i = 0; i < k; i++) { cin >> ...
[["+", 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], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
251
6
// 2006‘“à—\‘IB —ñŽÔ‚̕Ґ¬ƒp[ƒgII #include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; inline string reverse(string s) { reverse(s.begin(), s.end()); return s; } int main() { int t; cin >> t; while (t--) { string s; cin >> s; set<string> S; S.inse...
// 2006‘“à—\‘IB —ñŽÔ‚̕Ґ¬ƒp[ƒgII #include <algorithm> #include <iostream> #include <set> #include <string> using namespace std; inline string reverse(string s) { reverse(s.begin(), s.end()); return s; } int main() { int t; cin >> t; while (t--) { string s; cin >> s; set<string> S; S.inse...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
219
2
#include <iostream> #include <string> #include <vector> using namespace std; int m; vector<string> train; bool input() { cin >> m; for (int i = 0; i < m; i++) { string tmp; cin >> tmp; train.push_back(tmp); } return true; } string rev_str(string s) { string ret; for (int i = 0; i < s.size(); ...
#include <iostream> #include <string> #include <vector> using namespace std; int m; vector<string> train; bool input() { cin >> m; for (int i = 0; i < m; i++) { string tmp; cin >> tmp; train.push_back(tmp); } return true; } string rev_str(string s) { string ret; for (int i = 0; i < s.size(); ...
[["-", 0, 7, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40]]
1
463
3
def sol( s ) l = s.length a = Array.new for i in 1..i s1 = a[0, i] s2 = a[i..l-1] a.push( s1 + s2 ) a.push( s2 + s1 ) a.push( s1.reverse + s2 ) a.push( s2 + s1.reverse ) a.push( s1 + s2.reverse ) a.push( s2.reverse + s1 ) a.push( s1.reverse + s2.reverse ) a.push( s2.reverse + s1.reverse ) end a...
def sol( s ) l = s.length a = Array.new for i in 1..l s1 = s[0, i] s2 = s[i..(l-1)] a.push( s1 + s2 ) a.push( s2 + s1 ) a.push( s1.reverse + s2 ) a.push( s2 + s1.reverse ) a.push( s1 + s2.reverse ) a.push( s2.reverse + s1 ) a.push( s1.reverse + s2.reverse ) a.push( s2.reverse + s1.reverse ) end ...
[["-", 8, 736, 0, 88, 51, 267, 0, 475, 444, 22], ["+", 8, 736, 0, 88, 51, 267, 0, 475, 444, 22], ["-", 0, 88, 8, 170, 0, 662, 12, 742, 500, 22], ["+", 0, 88, 8, 170, 0, 662, 12, 742, 500, 22], ["+", 0, 662, 12, 742, 0, 475, 444, 739, 0, 24], ["+", 0, 662, 12, 742, 0, 475, 444, 739, 0, 25]]
4
150
8
ls = [] def add(t): if t not in ls: ls.append(t) n = int(input()) for i in range(n): t = input()[:-1] ls = [t] for j in range(1,len(t)): f, b = t[:j], t[j:] add(f+b[::-1]) add(f[::-1]+b) add(f[::-1]+b[::-1]) add(b+f) add(b+f[::-1]) add(b...
ls = [] def add(t): if t not in ls: ls.append(t) n = int(input()) for i in range(n): t = input() ls = [t] for j in range(1,len(t)): f, b = t[:j], t[j:] add(f+b[::-1]) add(f[::-1]+b) add(f[::-1]+b[::-1]) add(b+f) add(b+f[::-1]) add(b[::-1...
[["-", 8, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["-", 0, 662, 12, 206, 206, 663, 0, 664, 17, 33], ["-", 0, 662, 12, 206, 206, 663, 0, 664, 28, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 0, 73]]
5
178
5
#coding: utf-8 n = int(input()) for i in range(n): s = input() l = set([s]) for k in range(len(s)-1): t1 = s[:k+1] t2 = s[k+1:] n1 = t1 + t2[::-1] n2 = t1[::-1] + t2 n3 = t1[::-1] + t2[::-1] n4 = t2 + t1[::-1] n5 = t2[::-1] + t1 n6 = t2[::-1] ...
#coding: utf-8 n = int(input()) for i in range(n): s = input() l = set([s]) for k in range(len(s)-1): t1 = s[:k+1] t2 = s[k+1:] n1 = t1 + t2[::-1] n2 = t1[::-1] + t2 n3 = t1[::-1] + t2[::-1] n4 = t2 + t1[::-1] n5 = t2[::-1] + t1 n6 = t2[::-1] ...
[["-", 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
183
4
def main n = gets.chomp.to_i n.times do mcxi1,mcxi2 = gets.chomp.split(' ').map{ |x| to_integer(x)} puts to_mcxi(mcxi1 + mcxi2) end end def to_integer mcxi integer = 0 num = 1 mcxi.each_char do |c| if c =~ /[2-9]/ num = c.to_i next end integer += num * begin case c ...
def main n = gets.chomp.to_i n.times do mcxi1,mcxi2 = gets.chomp.split(' ').map{ |x| to_integer(x)} puts to_mcxi(mcxi1 + mcxi2) end end def to_integer mcxi integer = 0 num = 1 mcxi.each_char do |c| if c =~ /[2-9]/ num = c.to_i next end integer += num * begin case c ...
[["+", 0, 747, 64, 749, 0, 738, 12, 557, 0, 62]]
4
219
34
a={'m':1000,'c':100,'x':10,'i':1} for _ in range(int(input())): b,s,t=input(),0,1 for x in b: if x==' ':continue if x in a:s+=a[x]*t;t=1 else:t=int(x) ans='' for k in ['m','c','x','i']: c,s=divmod(s,a[k]) if c:ans+=['',str(c)][c!=0]+k print(ans)
a={'m':1000,'c':100,'x':10,'i':1} for _ in range(int(input())): b,s,t=input(),0,1 for x in b: if x==' ':continue if x in a:s+=a[x]*t;t=1 else:t=int(x) ans='' for k in ['m','c','x','i']: c,s=divmod(s,a[k]) if c:ans+=['',str(c)][c!=1]+k print(ans)
[["-", 0, 677, 12, 657, 31, 206, 206, 666, 0, 612], ["+", 0, 677, 12, 657, 31, 206, 206, 666, 0, 612]]
5
154
26
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <sstream> #include...
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <sstream> #include...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
779
2
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <complex> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #includ...
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <complex> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #includ...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
815
2
// g++ -std=c++11 temp.cpp #include <bits/stdc++.h> using namespace std; #define For(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define Rep(i, n) For(i, 0, n) #define Each(itr, v) for (auto itr : v) #define pb(s) push_back(s) #define mp(a, b) make_pair(a, b) #define all(x) (x).begin(), (x).end() #define dbg(x)...
// g++ -std=c++11 temp.cpp #include <bits/stdc++.h> using namespace std; #define For(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define Rep(i, n) For(i, 0, n) #define Each(itr, v) for (auto itr : v) #define pb(s) push_back(s) #define mp(a, b) make_pair(a, b) #define all(x) (x).begin(), (x).end() #define dbg(x)...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
525
2
#include <algorithm> #include <bitset> #include <cfloat> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; class Edge { public: int to, ...
#include <algorithm> #include <bitset> #include <cfloat> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; class Edge { public: int to, ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
662
2
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> #define INF (1 << 29) using namespace std; int main(void) { int n, m, p, a, b, x, y, z, in; double dp[(1 << 8)][31], graph[31][31]; vector<int> t; while (cin >> n >> m >> p >> a >> b) { if (!(n | m | p | a | b)) break; ...
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> #define INF (1 << 29) using namespace std; int main(void) { int n, m, p, a, b, x, y, z, in; double dp[(1 << 8)][31], graph[31][31]; vector<int> t; while (cin >> n >> m >> p >> a >> b) { if (!(n | m | p | a | b)) break; ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
417
2
#include <algorithm> #include <cfloat> #include <climits> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n, m, p, a, b; while (true) { cin >> n >> m >> p >> a >> b; if (!m && !n && !p && !a && !b) { break; } vector<vector<d...
#include <algorithm> #include <cfloat> #include <climits> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n, m, p, a, b; while (true) { cin >> n >> m >> p >> a >> b; if (!m && !n && !p && !a && !b) { break; } vector<vector<d...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
456
2
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <vector> #define ALL(v) (v).begin(), (v).end() #define REP(i, p, n) for (int i = p; i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define DUMP(list) ...
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <vector> #define ALL(v) (v).begin(), (v).end() #define REP(i, p, n) for (int i = p; i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define DUMP(list) ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
266
2
#include <iostream> using namespace std; int main() { int a, d, n; while (cin >> a >> d >> n, n) { int cnt = 0, f; while (1) { f = 0; for (int i = 2; i * i <= a; i++) { if (a & i == 0) { f = 1; break; } } if (f == 0 && a != 1) { cnt++; ...
#include <iostream> using namespace std; int main() { int a, d, n; while (cin >> a >> d >> n, n) { int cnt = 0, f; while (1) { f = 0; for (int i = 2; i * i <= a; i++) { if (a % i == 0) { f = 1; break; } } if (f == 0 && a != 1) { cnt++; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 67], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109]]
1
123
2
#include <iostream> #include <queue> using namespace std; bool flug[1000001]; // false???????´???° int main() { int a, b, n; for (int i = 2; i * i <= 1000000; i++) { if (!flug[i]) { for (int j = i * 2; j <= 1000000; j += i) { flug[j] = true; } } } while (cin >> a >> b >> n, a + b ...
#include <iostream> #include <queue> using namespace std; bool flug[1000001]; // false???????´???° int main() { int a, b, n; for (int i = 2; i * i <= 1000000; i++) { if (!flug[i]) { for (int j = i * 2; j <= 1000000; j += i) { flug[j] = true; } } } while (cin >> a >> b >> n, a + b ...
[["-", 0, 52, 8, 9, 0, 7, 26, 11, 17, 107], ["-", 0, 52, 8, 9, 0, 7, 26, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29]]
1
208
3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; while (cin >> a >> b >> n && n) { int count = 0, flag = 0; for (int i = a; i < 1000000; i += b) { for (int j = 2; j < sqrt(i); j++) { if (i % j == 0 && i != j) { flag++; break; } } ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; while (cin >> a >> b >> n && n) { int count = 0, flag = 0; for (int i = a; i <= 1000000; i += b) { for (int j = 2; j <= sqrt(i); j++) { if (i % j == 0 && i != j) { flag++; break; } } ...
[["-", 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
129
4
#include <cmath> #include <iostream> #define N 1000000 using namespace std; int arr[N]; //??¨???????????????????????? void Eratosthenes() { for (int i = 0; i < N; i++) { arr[i] = 1; } for (int i = 2; i < sqrt(N); i++) { if (arr[i]) { for (int j = 0; i * (j + 2) < N; j++) { arr[i * (j + 2)...
#include <cmath> #include <iostream> #define N 1000000 using namespace std; int arr[N]; //??¨???????????????????????? void Eratosthenes() { for (int i = 0; i < N; i++) { arr[i] = 1; } for (int i = 2; i < sqrt(N); i++) { if (arr[i]) { for (int j = 0; i * (j + 2) < N; j++) { arr[i * (j + 2)...
[["+", 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, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
214
4
#include <iostream> #include <string> using namespace std; int main() { int a, b, n; while (true) { cin >> a >> b >> n; if (a == 0 && b == 0 && n == 0) break; int count = 0, s = a; if (a < 2) a += b; while (true) { bool t = true; for (int j = 2; j * j <= s; j++) { ...
#include <iostream> #include <string> using namespace std; int main() { int a, b, n; while (true) { cin >> a >> b >> n; if (a == 0 && b == 0 && n == 0) break; int count = 0, s = a; while (s < 2) s += b; while (true) { bool t = true; for (int j = 2; j * j <= s; j++) { ...
[["-", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 8, 9, 0, 52, 8, 9, 0, 52, 0, 89], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 52, 8, 1, 0, 11, 31, 22]]
1
141
6
#include <iostream> #include <vector> using namespace std; bool isPrime(int x) { if (x == 1) { return false; } if (x == 2) { return true; } if (x % 2 == 0) { return false; } for (int i = 3; i * i < x; i += 2) { if (x % i == 0) { return false; } } return true; } int main(...
#include <iostream> #include <vector> using namespace std; bool isPrime(int x) { if (x == 1) { return false; } if (x == 2) { return true; } if (x % 2 == 0) { return false; } for (int i = 3; i * i <= x; i += 2) { if (x % i == 0) { return false; } } return true; } int main...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
184
2
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <v...
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <v...
[["+", 0, 1, 0, 11, 12, 11, 31, 69, 28, 22], ["+", 0, 11, 12, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 11, 12, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 11, 12, 11, 31, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 17, 32]]
1
242
5
#include <iostream> using namespace std; int main() { int a[100000] = {0, 0, 1, 1}, n, k = 0; for (int i = 4; i < 100000; i++) { for (int j = 2; j * j <= i; j++) { if (i % j == 0) { k++; break; } } if (!k) a[i]++; k = 0; } int b, c, d, x, s, q; while (cin >> b...
#include <iostream> using namespace std; int main() { int a[1000000] = {0, 0, 1, 1}, n, k = 0; for (int i = 4; i < 1000000; i++) { for (int j = 2; j * j <= i; j++) { if (i % j == 0) { k++; break; } } if (!k) a[i]++; k = 0; } int b, c, d, x, s, q; while (cin >>...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
189
4
#include <iostream> using namespace std; int main() { int max = 1000000; bool *pt; pt = new bool[max]; pt[1] = false; pt[2] = true; for (int i = 3; i < max; i++) { pt[i] = true; if (i % 2 == 0) { pt[i] = false; continue; } else { for (int l = 3; l * l < i; l += 2) { if...
#include <iostream> using namespace std; int main() { int max = 1000000; bool *pt; pt = new bool[max]; pt[1] = false; pt[2] = true; for (int i = 3; i < max; i++) { pt[i] = true; if (i % 2 == 0) { pt[i] = false; continue; } else { for (int l = 3; l * l <= i; l += 2) { i...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19]]
1
214
2
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define vi vector<int> #define vvi vector<vector<int>> #define ll long long int #define vl vector<ll> #define vvl vector<...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define vi vector<int> #define vvi vector<vector<int>> #define ll long long int #define vl vector<ll> #define vvl vecto...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
277
6
#include <bits/stdc++.h> using namespace std; #define rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define pb push_back #define N 100000000 #define int long long int arr[N]; void eratosthenes() { rep(i, N) { arr[i] = 1; } for (int i = 2; i < sqrt(N); i++) { if (a...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define pb push_back #define N 1000000 #define int long long int arr[N]; void eratosthenes() { rep(i, N) { arr[i] = 1; } for (int i = 2; i < sqrt(N); i++) { if (arr...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
1
253
4
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> using namespace std; #define INF 1 << 21 #define MOD 1000000007 #define MAX 1000000 int main() { int p[MAX]; memset(p, 1, sizeof(p)); p[0] = 0; ...
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> using namespace std; #define INF 1 << 21 #define MOD 1000000007 #define MAX 1000000 int main() { char p[MAX]; memset(p, 1, sizeof(p)); p[0] = 0; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
203
2
#include <cmath> #include <iostream> #include <vector> using namespace std; #define M 1e6 int main() { vector<bool> hurui(M, true); hurui[1] = true; for (int i = 2; i <= sqrt(M); i++) { if (hurui[i]) { for (int j = 2 * i; j < M; j += i) { hurui[j] = false; } } } int a, d, n; w...
#include <cmath> #include <iostream> #include <vector> using namespace std; #define M 1e6 int main() { vector<bool> hurui(M, true); hurui[1] = false; for (int i = 2; i <= sqrt(M); i++) { if (hurui[i]) { for (int j = 2 * i; j < M; j += i) { hurui[j] = false; } } } int a, d, n; ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 146], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 147]]
1
166
2
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000; int prime[MAX_N]; bool is_prime[MAX_N + 1]; int main(void) { int p = 0; for (int i = 0; i <= 100000; i++) is_prime[i] = true; is_prime[0] = is_prime[1] = false; for (int i = 2; i <= 100000; i++) { if (is_prime[i]) { prime...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1000000; int prime[MAX_N]; bool is_prime[MAX_N + 1]; int main(void) { int p = 0; for (int i = 0; i <= 1000000; i++) is_prime[i] = true; is_prime[0] = is_prime[1] = false; for (int i = 2; i <= 1000000; i++) { if (is_prime[i]) { pr...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13]]
1
214
8
#include <bits/stdc++.h> #include <iterator> using namespace std; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; /* cpp template {{{ */ /* short */ #define pb push_back #define eb emplace_back #define mp make_pair #define Fi first #define Se second #define ALL(v) begin(v),...
#include <bits/stdc++.h> #include <iterator> using namespace std; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; /* cpp template {{{ */ /* short */ #define pb push_back #define eb emplace_back #define mp make_pair #define Fi first #define Se second #define ALL(v) begin(v),...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
818
2
#include <bits/stdc++.h> using namespace std; int main() { while (1) { int a, b, n; cin >> a >> b >> n; if (a == 0 && b == 0 && n == 0) break; int count = 0, s = 0, ans; for (int j = a; count != n; j += b) { s = 0; for (int k = 2; k < sqrt(j) + 1; k++) { if (j == 1) { ...
#include <bits/stdc++.h> using namespace std; int main() { while (1) { int a, b, n; cin >> a >> b >> n; if (a == 0 && b == 0 && n == 0) break; int count = 0, s = 0, ans; for (int j = a; count != n; j += b) { s = 0; for (int k = 2; k <= sqrt(j) + 1; k++) { if (j == 1) { ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
166
2
#include <bits/stdc++.h> using namespace std; int main() { vector<bool> isprime(500000, true); isprime[0] = isprime[1] = false; for (int i = 2; i < 500000; i++) { if (isprime[i]) { for (int j = 2; i * j < 500000; j++) { isprime[i * j] = false; } } } vector<int> p; for (int i = ...
#include <bits/stdc++.h> using namespace std; int main() { vector<bool> isprime(1000000, true); isprime[0] = isprime[1] = false; for (int i = 2; i < 1000000; i++) { if (isprime[i]) { for (int j = 2; i * j < 1000000; j++) { isprime[i * j] = false; } } } vector<int> p; for (int i...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7...
1
220
10
#include <iostream> #include <vector> using namespace std; int main(int argc, char *argv[]) { const int N = 1000001; vector<bool> prime(N, true); prime[0] = false; prime[1] = false; for (int i = 2; i < N; i++) { if (prime[i]) { for (int j = i + i; j < N; j += i) { prime[j] = false; } ...
#include <iostream> #include <vector> using namespace std; int main(int argc, char *argv[]) { const int N = 1000001; vector<bool> prime(N, true); prime[0] = false; prime[1] = false; for (int i = 2; i < N; i++) { if (prime[i]) { for (int j = i + i; j < N; j += i) { prime[j] = false; } ...
[["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
176
3
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; const int MAX_SIZE = 100000; int prime[MAX_SIZE]; bool isPrime[MAX_SIZE]; int p; int main() { fill(isPrime, isPrime + MAX_SIZE, true); p = 0; isPrime[0] = isPrime[1] = false; for (int i = 2; i <= MAX_SIZE; i++)...
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; const int MAX_SIZE = 1000000; int prime[MAX_SIZE]; bool isPrime[MAX_SIZE]; int p; int main() { fill(isPrime, isPrime + MAX_SIZE, true); p = 0; isPrime[0] = isPrime[1] = false; for (int i = 2; i <= MAX_SIZE; i++...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
220
2
#include <cstring> #include <iostream> using namespace std; bool t[1000000]; int main() { memset(t, true, sizeof(t)); t[0] = false; t[1] = false; for (int i = 2; i < 1000000; i += 2) { t[i] = false; } for (int i = 3; i * 2 < 1000000; i += 2) { if (!t[i]) continue; for (int j = i * 2; j < 1...
#include <cstring> #include <iostream> using namespace std; bool t[1000000]; int main() { memset(t, true, sizeof(t)); t[0] = false; t[1] = false; for (int i = 4; i < 1000000; i += 2) { t[i] = false; } for (int i = 3; i * 2 < 1000000; i += 2) { if (!t[i]) continue; for (int j = i * 2; j < 1...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
203
2
import static java.util.Arrays.sort; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n != 0) { int[] score = new int[n]; for (int i = 0; i < n; i++) score[i] = sc.nextInt(); ...
import static java.util.Arrays.sort; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n != 0) { int[] score = new int[n]; for (int i = 0; i < n; i++) score[i] = sc.nextInt(); ...
[["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 499]]
3
160
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] array = new int[20]; int c = 0; for (int i = 0;; i++) { int n = sc.nextInt(); int[] array2 = new int[n]; if (n == 0) { break; } int mi...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] array = new int[20]; int c = 0; for (int i = 0;; i++) { int n = sc.nextInt(); int[] array2 = new int[n]; if (n == 0) { break; } int mi...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 499], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
3
285
4
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i; int n, max = 0, min = 1000, sum = 0, ave; while (true) { n = sc.nextInt(); if (n == 0) { break; } max = 0; min = 1000; sum = 0; ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i; int n, max = 0, min = 1000, sum = 0, ave; while (true) { n = sc.nextInt(); if (n == 0) { break; } max = 0; min = 1000; sum = 0; ...
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
3
174
1
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n; while ((n = in.nextInt()) != 0) { int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; int point = 0; for (int i = 0; i < n; i++) { int j...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n; while ((n = in.nextInt()) != 0) { int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; int point = 0; for (int i = 0; i < n; i++) { int j...
[["+", 0, 492, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 3, 4, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 16, 12, 23, 0, 16, 12, 499], ["+", 0, 492, 3, 4, 0, 16, 12, 23, 0, 25]]
3
141
4
#include <stdio.h> int main() { int i, j, n[i], s[i], t, a, b, r[i]; i = 0; while (1) { scanf("%d", &n[i]); if (n[i] == 0) break; t = 0; a = 0; b = 1000; for (j = 0; j < n[i]; j++) { scanf("%d", &s[j]); t += s[j]; if (a < s[j]) { a = s[j]; } if...
#include <stdio.h> int main() { int i, j, n[21], s[100], t, a, b, r[100]; i = 0; while (1) { scanf("%d", &n[i]); if (n[i] == 0) break; t = 0; a = 0; b = 1000; for (j = 0; j < n[i]; j++) { scanf("%d", &s[j]); t += s[j]; if (a < s[j]) { a = s[j]; } ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
210
6
#include <stdio.h> int main(void) { int h, max, min, t = 0, ave, i, sc; while (scanf("%d", &h), h != 0) { for (i = 1; i <= h; i++) { scanf("%d", &sc); t = t + sc; if (i == 1) { max = sc; min = sc; } else if (max < sc) { max = sc; } else if (min > sc) { ...
#include <stdio.h> int main(void) { int h, max, min, t = 0, ave, i, sc; while (scanf("%d", &h), h != 0) { t = 0; for (i = 1; i <= h; i++) { scanf("%d", &sc); t = t + sc; if (i == 1) { max = sc; min = sc; } else if (max < sc) { max = sc; } else if (min >...
[["+", 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]]
0
150
4
#include <stdio.h> int main(void) { int n, sum, ave, max, min; int num; int i; scanf("%d", &n); while (n != 0) { sum = 0; ave = 0; min = 1001; max = -1; for (i = 0; i < n; i++) { scanf("%d", &num); sum += num; if (max <= num) { max = num; } if (min ...
#include <stdio.h> int main(void) { int n, sum, ave, max, min; int num; int i; scanf("%d", &n); while (n != 0) { sum = 0; ave = 0; min = 1001; max = -1; for (i = 0; i < n; i++) { scanf("%d", &num); sum += num; if (max <= num) { max = num; } if (min ...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
0
150
4
#include <stdio.h> int sumSB(int n, int s[]) { int i, re, min = s[0], max = s[0]; for (i = 0; i < n; i++) { if (min > s[i]) { min = s[i]; } else if (max < s[i]) { max = s[i]; } } return (min + max); } int main(void) { int n, i, sum = 0, score[128], ave; while (1) { sum...
#include <stdio.h> int sumSB(int n, int s[]) { int i, re, min = s[0], max = s[0]; for (i = 0; i < n; i++) { if (min > s[i]) { min = s[i]; } else if (max < s[i]) { max = s[i]; } } return (min + max); } int main(void) { int n, i, sum = 0, score[128], ave; while (1) { sum...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
210
1
#include <stdio.h> int main() { int n; int i; int max, min, sum; int score[101]; while (1) { scanf("%d", &n); if (n == 0) break; sum = 0; for (i = 0; i < n; i++) { scanf("%d", &score[i]); sum += score[i]; if (i == 0) { max = score[i]; min = score[i...
#include <stdio.h> int main() { int n; int i; int max, min, sum; int score[101]; while (1) { scanf("%d", &n); if (n == 0) break; sum = 0; for (i = 0; i < n; i++) { scanf("%d", &score[i]); sum += score[i]; if (i == 0) { max = score[i]; min = score[i...
[["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
0
165
4
#include <stdio.h> int getfinalscore(int, int scores[]); int main(void) { int i = 0, j = 0, k = 0; int n[20]; int s[20][100]; int finalscore[20]; for (i = 0;; i++) { scanf("%d", &n[i]); if (n[i] == 0) break; for (j = 0; j < n[i]; j++) { scanf("%d", &s[i][j]); } } /*i??????...
#include <stdio.h> int getfinalscore(int, int scores[]); int main(void) { int i = 0, j = 0, k = 0; int n[20]; int s[20][100]; int finalscore[20]; for (i = 0;; i++) { scanf("%d", &n[i]); if (n[i] == 0) break; for (j = 0; j < n[i]; j++) { scanf("%d", &s[i][j]); } } /*i??????...
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
0
284
1
#include <stdio.h> #define S_MAX 1000 int main(void) { int sum, min, max, n, t, i; while (scanf("%d", &n), n != 0) { sum = min = 0, max = S_MAX; for (i = 0; i < n; i++) { scanf("%d", &t); if (min > t) min = t; if (max < t) max = t; sum += t; } printf("%d...
#include <stdio.h> #define S_MAX 1000 int main(void) { int sum, min, max, n, t, i; while (scanf("%d", &n), n != 0) { sum = max = 0, min = S_MAX; for (i = 0; i < n; i++) { scanf("%d", &t); if (min > t) min = t; if (max < t) max = t; sum += t; } printf("%d...
[["-", 0, 1, 0, 34, 31, 11, 12, 11, 31, 22], ["+", 0, 1, 0, 34, 31, 11, 12, 11, 31, 22], ["-", 8, 9, 0, 1, 0, 34, 12, 11, 31, 22], ["+", 8, 9, 0, 1, 0, 34, 12, 11, 31, 22]]
0
127
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n) { vector<int> score(n, 0); for (int i = 0; i < n; i++) cin >> score[i]; sort(score.begin(), score.end()); int total = 0; for (int i = 1; i < n - 1; i++) total += scor...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n, n != 0) { vector<int> score(n, 0); for (int i = 0; i < n; i++) cin >> score[i]; sort(score.begin(), score.end()); int total = 0; for (int i = 1; i < n - 1; i++) total...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 79], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 13]]
1
114
4
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include...
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include...
[["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 25]]
1
444
2
#include <algorithm> #include <iostream> #define rep(i, a) for (int i = 0; i < (a); ++i) int n; int main() { while (std::cin >> n, n) { int ma = 0, mi = 1001, S = 0; rep(i, n) { int a; std::cin >> a; ma = std::max(ma, a); mi = std::min(mi, a); S += a; } std::cout << (...
#include <algorithm> #include <iostream> #define rep(i, a) for (int i = 0; i < (a); ++i) int n; int main() { while (std::cin >> n, n) { int ma = 0, mi = 1001, S = 0; rep(i, n) { int a; std::cin >> a; ma = std::max(ma, a); mi = std::min(mi, a); S += a; } std::cout << (...
[["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 25]]
1
110
4
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sst...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sst...
[["-", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13]]
1
250
2
#include <iostream> using namespace std; int main() { int a[2020]; int x, i = 0; while (cin >> x) { a[i++] = x; } void saiten(int *a, int b); saiten(a, 0); } void saiten(int *a, int j) { int max = 0, min = 0, ave = 0; if (a[j] != 0) { for (int k = j + 1; k <= j + a[j]; k++) { if (max < a[k...
#include <iostream> using namespace std; int main() { int a[2020]; int x, i = 0; while (cin >> x) { a[i++] = x; } void saiten(int *a, int b); saiten(a, 0); } void saiten(int *a, int j) { int max = 0, min = 1000, ave = 0; if (a[j] != 0) { for (int k = j + 1; k <= j + a[j]; k++) { if (max < ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
196
2
#include <cstdio> using namespace std; int main() { int min, max, sum, n, score; while (1) { scanf("%d", &n); if (!n) break; max = 0; min = 10000; sum = 0; for (int i = 0; i < n; i++) { scanf("%d", &score); if (max < score) max = score; if (min > score) ...
#include <cstdio> using namespace std; int main() { int min, max, sum, n, score; while (1) { scanf("%d", &n); if (!n) break; max = 0; min = 10000; sum = 0; for (int i = 0; i < n; i++) { scanf("%d", &score); if (max < score) max = score; if (min > score) ...
[["-", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22]]
1
133
2
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; int par[123]; int find(int x) { return (par[x] == x) ? x : par[x] = find(par[x]); } void unite(int a, int b) { par[find(a)] = find(b); } int ex[123][1234], ey[123][1234]; int evx[12...
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; int par[123]; int find(int x) { return (par[x] == x) ? x : par[x] = find(par[x]); } void unite(int a, int b) { par[find(a)] = find(b); } int ex[123][1234], ey[123][1234]; int evx[12...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
1,167
4
#include <algorithm> #include <cstdio> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> using namespace std; #define FOR(i, n) for (int i = 0; i < n; i++) #define bit(i) static_cast<bitset<8>>(i) typedef long long ll; typedef unsigned long lo...
#include <algorithm> #include <cstdio> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> using namespace std; #define FOR(i, n) for (int i = 0; i < n; i++) #define bit(i) static_cast<bitset<8>>(i) typedef long long ll; typedef unsigned long lo...
[["+", 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
2,475
4
#include <bits/stdc++.h> using namespace std; int w, h; vector<string> field; int dist(pair<int, int> a, pair<int, int> b) { queue<pair<pair<int, int>, int>> bfs; set<pair<int, int>> already; bfs.push(make_pair(a, 0)); while (!bfs.empty()) { pair<int, int> pos; int cost; tie(pos, cost) = bfs.front()...
#include <bits/stdc++.h> using namespace std; int w, h; vector<string> field; int dist(pair<int, int> a, pair<int, int> b) { queue<pair<pair<int, int>, int>> bfs; set<pair<int, int>> already; bfs.push(make_pair(a, 0)); while (!bfs.empty()) { pair<int, int> pos; int cost; tie(pos, cost) = bfs.front()...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
886
2
#include <algorithm> #include <complex> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> #define ll long long int using namespace std; const int INF ...
#include <algorithm> #include <complex> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> #define ll long long int using namespace std; const int INF ...
[["+", 15, 23, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 15, 23, 0, 2, 3, 4, 0, 16, 12, 13]]
1
776
2
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i, a, b) for (i = a; i < b; ++i) #define rep(i, n) REP(i, 0, n) #define ll long long #define ull unsigned ll typedef long double ld; #define ALL(a) (a).begin(), (a).end() #define ifnot(a) if (not a) #define dump(x) cerr << #...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i, a, b) for (i = a; i < b; ++i) #define rep(i, n) REP(i, 0, n) #define ll long long #define ull unsigned ll typedef long double ld; #define ALL(a) (a).begin(), (a).end() #define ifnot(a) if (not a) #define dump(x) cerr << #...
[["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
1
1,433
2
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; #define MAX 12 #define mk make_pair #define INF 1 << 28 string s[20]; bool vis[20][20]; int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; int n, w, h, d[MAX][MAX], c; int dp[1 << MAX][MAX]; int rec(int s, int v) { if (dp[s][v] >= ...
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; #define MAX 12 #define mk make_pair #define INF 1 << 28 string s[20]; bool vis[20][20]; int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; int n, w, h, d[MAX][MAX], c; int dp[1 << MAX][MAX]; int rec(int s, int v) { if (dp[s][v] >= ...
[["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 51, 16, 12, 23, 0, 16, 12, 103, 0, 125], ["+", 51, 16, 12, 23, 0, 16, 12, 103, 0, 125], ["-", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]]
1
784
5
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef pair<int, int> P;...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef pair<int, int> P;...
[["+", 51, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33]]
1
966
2
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; void run() { for (;;) { long a, d, n; a = ni(); d = ni(); n = ni(); if ((a | d | n) == 0) break; int cnt = 0; for (long ite = a;; ite += d) { boolean f = true; ...
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc; void run() { for (;;) { long a, d, n; a = ni(); d = ni(); n = ni(); if ((a | d | n) == 0) break; int cnt = 0; for (long ite = a;; ite += d) { boolean f = true; ...
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
3
241
2
import java.util.Arrays; import java.util.Scanner; public class Main { static int[] createPrimes(int n) { int[] ans = new int[n + 1]; Arrays.fill(ans, 1); ans[0] = ans[1] = 0; int max = (int)Math.sqrt(n) + 1; for (int i = 2; i < max / 2 + 1; i++) { ans[i * 2] = 0; } for (int i = ...
import java.util.Arrays; import java.util.Scanner; public class Main { static int[] createPrimes(int n) { int[] ans = new int[n + 1]; Arrays.fill(ans, 1); ans[0] = ans[1] = 0; int max = (int)Math.sqrt(n) + 1; for (int i = 2; i < n / 2 + 1; i++) { ans[i * 2] = 0; } for (int i = 3;...
[["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22]]
3
324
2
import java.util.Scanner; public class Main { static boolean[] primes; static void primeSet(final int MAX) { primes = new boolean[MAX + 1]; primes[2] = true; for (int i = 3; i <= MAX; i += 2) { primes[i] = true; } int rt = (int)Math.sqrt(MAX); for (int i = 3; i <= rt; i += 2) { ...
import java.util.Scanner; public class Main { static boolean[] primes; static void primeSet(final int MAX) { primes = new boolean[MAX + 1]; primes[2] = true; for (int i = 3; i <= MAX; i += 2) { primes[i] = true; } int rt = (int)Math.sqrt(MAX); for (int i = 3; i <= rt; i += 2) { ...
[["-", 0, 492, 3, 4, 0, 16, 31, 5, 0, 62], ["-", 0, 492, 3, 4, 0, 16, 31, 5, 0, 491], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72]]
3
275
4
#include <stdio.h> #define N 1000010 int c[N]; int main(void) { int i, j, a, d, n; c[0] = c[1] = 1; for (i = 2; i * i < N; ++i) if (!c[i]) for (j = i * i; j < N; j += i) c[j] = 1; while (scanf("%d%d%d", &a, &d, &n), a) { for (i = 1; i < n; i += !c[a]) a += d; printf("%d\n", a); ...
#include <stdio.h> #define N 1000010 int c[N]; int main(void) { int i, j, a, d, n; c[0] = c[1] = 1; for (i = 2; i * i < N; ++i) if (!c[i]) for (j = i * i; j < N; j += i) c[j] = 1; while (scanf("%d%d%d", &a, &d, &n), a) { for (i = !c[a]; i < n; i += !c[a]) a += d; printf("%d\n", ...
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 8, 9, 0, 7, 10, 11, 12, 91, 17, 111], ["+", 0, 7, 10, 11, 12, 91, 28, 69, 28, 22], ["+", 0, 7, 10, 11, 12, 91, 28, 69, 0, 70], ["+", 0, 7, 10, 11, 12, 91, 28, 69, 71, 22], ["+", 0, 7, 10, 11, 12, 91, 28, 69, 0, 73]]
0
144
6
#include <iostream> int main() { while (1) { int judgeNum = 0; int pointSum = 0; int maximumPoint = 0; int minimumPoint = 1000; std::cin >> judgeNum; if (judgeNum == 0) { break; } for (int i = 0; i < judgeNum; i++) { int point; std::cin >> point; if (point >...
#include <iostream> int main() { while (1) { int judgeNum = 0; int pointSum = 0; int maximumPoint = 0; int minimumPoint = 1000; std::cin >> judgeNum; if (judgeNum == 0) { break; } for (int i = 0; i < judgeNum; i++) { int point; std::cin >> point; if (point >...
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
132
1
#include <iostream> using namespace std; int N, S; int main() { while (cin >> N && N > 0) { int sum = 0; int largest = 0; int smallest = 1000; for (int i = 0; i < N; ++i) { cin >> S; if (largest < S) { largest = S; } else if (smallest > S) { smallest = S; } ...
#include <iostream> using namespace std; int N, S; int main() { while (cin >> N && N > 0) { int sum = 0; int largest = 0; int smallest = 1000; for (int i = 0; i < N; ++i) { cin >> S; if (largest < S) { largest = S; } if (smallest > S) { smallest = S; } ...
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
113
1
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n; while (1) { cin >> n; if (n ==...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using namespace std; int main() { int n; while (1) { cin >> n; if (n ==...
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
148
1
#include <iostream> using namespace std; int N, S; int main() { while (cin >> N && N > 0) { // N??????????????????????????????????????§while???????????? int sum = 0; int min = 1001; // min????°?????????¨????????? int max = -1; int average = -1; for (int i = 0; i < N; i++) { cin >>...
#include <iostream> using namespace std; int N, S; int main() { while (cin >> N && N > 0) { // N??????????????????????????????????????§while???????????? int sum = 0; int min = 1001; // min????°?????????¨????????? int max = -1; int average = -1; for (int i = 0; i < N; i++) { cin >>...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
117
4
#include <iostream> using namespace std; int N, S; int main() { while (cin >> N && N > 0) { int sum = 0; int largest = 0; int smallest = 1000; for (int i = 0; i < N; i++) { cin >> S; sum += S; if (S > largest) largest = S; if (S < smallest) smallest = S; }...
#include <iostream> using namespace std; int N, S; int main() { while (cin >> N && N > 0) { int sum = 0; int largest = 0; int smallest = 1000; for (int i = 0; i < N; i++) { cin >> S; sum += S; if (S > largest) largest = S; if (S < smallest) smallest = S; }...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 85], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 25]]
1
102
6
#include <algorithm> #include <iostream> using namespace std; int MIN, MAX, n, sum, a, i; int main() { while (true) { cin >> n; if (!n) { break; } MIN = 10000000; MAX = 0; sum = 0; for (i = 0; i < n; i++) { cin >> a; MIN = min(MIN, a); MAX = max(MAX, a); sum +...
#include <algorithm> #include <iostream> using namespace std; int MIN, MAX, n, sum, a, i; int main() { while (true) { cin >> n; if (!n) { break; } MIN = 10000000; MAX = 0; sum = 0; for (i = 0; i < n; i++) { cin >> a; MIN = min(MIN, a); MAX = max(MAX, a); sum +...
[["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 25]]
1
113
4
#include <bits/stdc++.h> #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define INF 1e09 using namespace std; int main() { int n; int total, maxim, minim; int tmp; while (cin >> n) { total = 0; maxim = -INF; minim = INF; REP(i, n) { cin >> tmp; total += tmp; maxim = ma...
#include <bits/stdc++.h> #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define INF 1e09 using namespace std; int main() { int n; int total, maxim, minim; int tmp; while (cin >> n and n) { total = 0; maxim = -INF; minim = INF; REP(i, n) { cin >> tmp; total += tmp; maxi...
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 355], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
114
2
#include <iostream> using namespace std; int main() { int a, n, sum, min, max, i; while (1) { cin >> n; if (n == 0) { break; } cin >> min; sum = min; max = min; for (i = 0; i < n - 1; i++) { cin >> a; sum = sum + a; if (min > a) { min = a; } if...
#include <iostream> using namespace std; int main() { int a, n, sum, min, max, i; while (1) { cin >> n; if (n == 0) { break; } cin >> min; sum = min; max = min; for (i = 0; i < n - 1; i++) { cin >> a; sum = sum + a; if (min > a) { min = a; } if...
[["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 25]]
1
125
4
#include <iostream> using namespace std; int main() { int n, s; while (cin >> n && n > 0) { int large = 0; int small = 1000; int sum = 0; for (int i = 0; i > n; ++i) { cin >> s; sum = sum + s; if (large < s) { large = s; } if (small > s) { small = s; ...
#include <iostream> using namespace std; int main() { int n, s; while (cin >> n && n > 0) { int large = 0; int small = 1000; int sum = 0; for (int i = 0; i < n; ++i) { cin >> s; sum = sum + s; if (large < s) { large = s; } if (small > s) { small = s; ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
1
121
2
#include <iostream> using namespace std; int main() { int n, max, min, s; long sum; while (true) { cin >> n; sum = max = min = 0; if (n == 0) break; for (int i = 0; i < n; i++) { cin >> s; if (s < min) min = s; if (s > max) max = s; sum += s; } ...
#include <iostream> using namespace std; int main() { int n, max, min, s; long sum; while (true) { cin >> n; sum = max = 0; min = 1000; if (n == 0) break; for (int i = 0; i < n; i++) { cin >> s; if (s < min) min = s; if (s > max) max = s; sum +...
[["+", 8, 9, 0, 1, 0, 11, 12, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 1, 0, 11, 12, 11, 12, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
117
4