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
def aop() i = 0 b = [] a =[] c = [] while c = gets b = c.split(',').map(&:to_f) puts b a[i] = b i += 1 end t = 0 for i in 1..a.length-2 x = ((a[0][0]-a[i][0])**2 + (a[0][1]-a[i][1])**2)**(1/2.0) y = ((a[0][0]-a[i+1][0])**2 + (a[0][1]-a[i+1][1])**2)**(1/2.0) z = ((a[i+1][0]-a[...
def aop() i = 0 b = [] a =[] c = [] while c = gets b = c.split(',').map(&:to_f) a[i] = b i += 1 end t = 0 for i in 1..a.length-2 x = ((a[0][0]-a[i][0])**2 + (a[0][1]-a[i][1])**2)**(1/2.0) y = ((a[0][0]-a[i+1][0])**2 + (a[0][1]-a[i+1][1])**2)**(1/2.0) z = ((a[i+1][0]-a[i][0])**2 +...
[["-", 8, 736, 0, 89, 8, 170, 0, 652, 735, 22], ["-", 0, 89, 8, 170, 0, 652, 3, 4, 0, 22]]
4
269
2
point = Array.new def solve(point) source = point[0] point.delete_at(0) # point.sort{|p1,p2| p1[1] <=> p2[1]} sum = 0 while point.size > 1 do p1 = point[0] p2 = point[1] a = getDistance(source, p1) b = getDistance(source,p2) c = getDistance(p1, p2) z = (a + b + c) / 2 ...
point = Array.new def solve(point) source = point[0] point.delete_at(0) # point.sort{|p1,p2| p1[1] <=> p2[1]} sum = 0 while point.size > 1 do p1 = point[0] p2 = point[1] a = getDistance(source, p1) b = getDistance(source,p2) c = getDistance(p1, p2) z = (a + b + c) / 2 ...
[["-", 0, 738, 12, 652, 3, 4, 0, 752, 0, 753], ["+", 0, 738, 12, 652, 3, 4, 0, 752, 0, 753]]
4
214
2
import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; import java.io.*; import java.util.*; public class Main { int INF = 1 << 28; // long INF = 1L << 62; double EPS = 1e-10; void run() { Scanner sc = new Scanner(System.in); for (;;) { int n ...
import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; import java.io.*; import java.util.*; public class Main { int INF = 1 << 28; // long INF = 1L << 62; double EPS = 1e-10; void run() { Scanner sc = new Scanner(System.in); for (;;) { int n ...
[["-", 0, 57, 64, 1, 0, 492, 3, 4, 0, 499], ["+", 0, 57, 64, 1, 0, 492, 3, 4, 0, 499]]
3
661
4
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string...
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string...
[["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 72], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
406
4
#include <cstdio> #include <iostream> #include <string> #include <utility> using namespace std; int main() { while (1) { int n, m, atari, d; int a[10]; // amida string s[30]; scanf(" %d", &n); if (n == 0) break; for (int i = 0; i < n; ++i) a[i] = i + 1; scanf(" %d %d %d", &...
#include <cstdio> #include <iostream> #include <string> #include <utility> using namespace std; int main() { while (1) { int n, m, atari, d; int a[10]; // amida string s[30]; scanf(" %d", &n); if (n == 0) break; for (int i = 0; i < n; ++i) a[i] = i + 1; scanf(" %d %d %d", &...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 16, 12, 69, 341, 342, 0, 1...
1
525
8
#include <iostream> #include <string> #include <vector> using namespace std; int n, m, atari, d; bool check(vector<int> line, vector<vector<int>> sideline, int col = -1, int row = -1) { int i, j; if (col != -1 && row != -1) sideline[col][row] = 1; for (i = 0; i < d; i++) { for (j = 0; j < n - 1...
#include <iostream> #include <string> #include <vector> using namespace std; int n, m, atari, d; bool check(vector<int> line, vector<vector<int>> sideline, int col = -1, int row = -1) { int i, j; if (col != -1 && row != -1) sideline[col][row] = 1; for (i = 0; i < d; i++) { for (j = 0; j < n - 1...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
545
2
// Drawing Lots ? #include <bits/stdc++.h> using namespace std; vector<int> mv(string s) { vector<int> tmp; for (int i = 0; i < s.length(); i++) tmp.push_back(s[i]); return tmp; } int main() { int n, m, g, d; vector<vector<int>> input; while (cin >> n) { if (n == 0) break; cin >> m >> g ...
// Drawing Lots ? #include <bits/stdc++.h> using namespace std; vector<int> mv(string s) { vector<int> tmp; for (int i = 0; i < s.length(); i++) tmp.push_back(s[i]); return tmp; } int main() { int n, m, g, d; vector<vector<int>> input; while (cin >> n) { if (n == 0) break; cin >> m >> g ...
[["+", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
494
2
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; #define REP(i, n) for (ll i = 0; i < n; ++i) #define REPR(i, n) for (ll i = 1; i < n; ++i) #define FOR(i, a, b) for (ll i = a; i < b; ++i) #define DEBUG(x) cout << #x << ": "...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; #define REP(i, n) for (ll i = 0; i < n; ++i) #define REPR(i, n) for (ll i = 1; i < n; ++i) #define FOR(i, a, b) for (ll i = a; i < b; ++i) #define DEBUG(x) cout << #x << ": "...
[["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13]]
1
501
2
#include <bits/stdc++.h> #define FOR(v, a, b) for (int v = (a); v < (b); ++v) #define FORE(v, a, b) for (int v = (a); v <= (b); ++v) #define REP(v, n) FOR(v, 0, n) #define UNWORDS(vec, str) \ for (int i = 0; i < (vec).size(); ++i) ...
#include <bits/stdc++.h> #define FOR(v, a, b) for (int v = (a); v < (b); ++v) #define FORE(v, a, b) for (int v = (a); v <= (b); ++v) #define REP(v, n) FOR(v, 0, n) #define UNWORDS(vec, str) \ for (int i = 0; i < (vec).size(); ++i) ...
[["+", 0, 9, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 57, 64, 93, 0, 94], ["+", 0, 14, 8, 9, 0, 57, 64, 93, 0, 35]]
1
393
6
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <ss...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <ss...
[["-", 15, 339, 51, 69, 341, 342, 0, 16, 31, 22], ["+", 15, 339, 51, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 69, 341, 342, 0, 22], ["+", 0, 57, 15, 339, 51, 69, 341, 342, 0, 22]]
1
466
4
#include <algorithm> #include <cstdio> #include <iostream> #include <queue> #include <string> #include <unordered_map> #include <vector> using namespace std; int k[10]; string s[30]; signed main() { int a; while (cin >> a, a) { for (int i = 0; i < a; i++) k[i] = i; int b, c, d; cin >> b >> c >> d...
#include <algorithm> #include <cstdio> #include <iostream> #include <queue> #include <string> #include <unordered_map> #include <vector> using namespace std; int k[10]; string s[30]; signed main() { int a; while (cin >> a, a) { for (int i = 0; i < a; i++) k[i] = i; int b, c, d; cin >> b >> c >> d...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
386
2
#include <algorithm> #include <cmath> #include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int n, m, g, d; char b; END: while (cin >> n >> m >> g >> d, n) { int hl[d][n - 1], rtr[d + 1], tr[d]; m--, g--; rtr[d] = g; rep(i, d) rep(j, n - 1) cin >> b, h...
#include <algorithm> #include <cmath> #include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int n, m, g, d; char b; END: while (cin >> n >> m >> g >> d, n) { int hl[d][n - 1], rtr[d + 1], tr[d]; m--, g--; rtr[d] = g; rep(i, d) rep(j, n - 1) cin >> b, h...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
444
4
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include ...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include ...
[["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
727
4
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { while (true) { int N; cin >> N; if (!N) break; int M, G, D; cin >> M >> G >> D; vector<string> lots(D); for (int i = 0; i < D; ++i) { cin >> lots[i]; lots[i] =...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { while (true) { int N; cin >> N; if (!N) break; int M, G, D; cin >> M >> G >> D; vector<string> lots(D); for (int i = 0; i < D; ++i) { cin >> lots[i]; lots[i] =...
[["-", 63, 118, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 63, 118, 28, 69, 341, 342, 0, 16, 12, 13]]
1
428
4
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #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; bool solve(v...
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #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; bool solve(v...
[["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72]]
1
419
4
#include <iostream> #include <vector> using namespace std; int n, m, goal, d; bool check(vector<int> line, vector<string> path) { int i, j; for (i = 0; i < d; i++) for (j = 0; j < n - 1; j++) if (path[i][j] == '1') swap(line[j], line[j + 1]); return line[goal - 1] == m; } int main() { int i...
#include <iostream> #include <vector> using namespace std; int n, m, goal, d; int check(vector<int> line, vector<string> path) { int i, j; for (i = 0; i < d; i++) for (j = 0; j < n - 1; j++) if (path[i][j] == '1') swap(line[j], line[j + 1]); return line[goal - 1] == m; } int main() { int f,...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 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
390
7
#include <cstring> #include <iostream> using namespace std; const int MAX = 12; bool cross[MAX][MAX]; int n, start, goal, d; void init() { memset(cross, false, sizeof(cross)); } bool move() { int pos = start; for (int i = 0; i < d; i++) { if (cross[i][pos]) pos++; else if (cross[i][pos - 1]) ...
#include <cstring> #include <iostream> using namespace std; const int MAX = 12; bool cross[MAX][MAX]; int n, start, goal, d; void init() { memset(cross, false, sizeof(cross)); } bool move() { int pos = start; for (int i = 1; i <= d; i++) { if (cross[i][pos]) pos++; else if (cross[i][pos - 1]) ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
367
6
#include <iostream> #include <string> #include <vector> using namespace std; int n, m, x, d; vector<string> field; bool solve() { int num[n]; for (int i = 0; i < n; i++) num[i] = i + 1; for (int i = 0; i < d; i++) { for (int j = 0; j < n - 1; j++) { if (field[i][j] == '1') { swap(num[j], n...
#include <iostream> #include <string> #include <vector> using namespace std; int n, m, x, d; vector<string> field; bool solve() { int num[n]; for (int i = 0; i < n; i++) num[i] = i + 1; for (int i = 0; i < d; i++) { for (int j = 0; j < n - 1; j++) { if (field[i][j] == '1') { swap(num[j], n...
[["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
366
4
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #includ...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #includ...
[["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 98]]
1
570
2
#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;...
[["-", 28, 69, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 28, 69, 28, 69, 341, 342, 0, 16, 12, 13], ["+", 12, 91, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 12, 91, 28, 69, 341, 342, 0, 16, 12, 13]]
1
594
4
def amida(n,m,s,l) a=Array.new(n) {|i| i+1} l.each do |i| i.each_with_index do |j,id| a[id],a[id+1]=a[id+1],a[id] if j==1 end end return a[s-1]==m ? true : false end loop do break if gets.chomp=="0" n,m,s,d,l=$_.to_i,gets.to_i,gets.to_i,gets.to_i,[] d.times do l<<gets.chomp.split("").ma...
def amida(n,m,s,l) a=Array.new(n) {|i| i+1} l.each do |i| i.each_with_index do |j,id| a[id],a[id+1]=a[id+1],a[id] if j==1 end end return a[s-1]==m ? true : false end loop do break if gets.chomp=="0" n,m,s,d,l=$_.to_i,gets.to_i,gets.to_i,gets.to_i,[] d.times do l<<gets.chomp.split("").ma...
[["-", 36, 36, 36, 36, 0, 42, 0, 768, 0, 769], ["+", 36, 36, 36, 36, 0, 42, 0, 768, 0, 769]]
4
159
2
def goal?(amida,m,s) s == 1 + (amida.inject(m-1) do |s,i| if s>1 && i[s-1]=="1" s-1 elsif i[s]=="1" s+1 else s end end) end loop do n = gets.to_i break if n==0 m,s,d = 3.times.map{ gets.to_i } amida = d.times.map{ gets.chomp } if goal?(amida,m,s) puts 0 next en...
def goal?(amida,m,s) s == 1 + (amida.inject(m-1) do |s,i| if s>=1 && i[s-1]=="1" s-1 elsif i[s]=="1" s+1 else s end end) end loop do n = gets.to_i break if n==0 m,s,d = 3.times.map{ gets.to_i } amida = d.times.map{ gets.chomp } if goal?(amida,m,s) puts 0 next e...
[["-", 8, 736, 0, 121, 15, 738, 31, 738, 17, 47], ["+", 8, 736, 0, 121, 15, 738, 31, 738, 17, 20]]
4
210
2
def check(n,m,star,d,f): ns=[i for i in range(n)] for i in range(d): for j in range(n-1): if f[i][j]: c=ns[j+1] ns[j+1]=ns[j] ns[j]=c return ns[star-1]==m-1 while True: n=int(input()) if(n==0):break m=int(input()) star=in...
def check(n,m,star,d,f): ns=[i for i in range(n)] for i in range(d): for j in range(n-1): if f[i][j]: c=ns[j+1] ns[j+1]=ns[j] ns[j]=c return ns[star-1]==m-1 while True: n=int(input()) if(n==0):break m=int(input()) star=in...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
343
4
import static java.lang.Math.*; import java.io.*; import java.util.*; class Main { public static void main(final String[] args) { final Scanner stdin = new Scanner(System.in); while (stdin.hasNextInt()) { final int n = stdin.nextInt(); final int s = stdin.nextInt(); final boolean[] vis...
import static java.lang.Math.*; import java.io.*; import java.util.*; class Main { public static void main(final String[] args) { final Scanner stdin = new Scanner(System.in); while (stdin.hasNextInt()) { final int n = stdin.nextInt(); final int s = stdin.nextInt(); final boolean[] vis...
[["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
3
312
6
#include <stdio.h> int data[10]; int ans[15][500]; void sub(int n, int x); int check(int a, int x); int main(void) { int n, i, s; for (n = 0; n < 15; n++) { for (i = 0; i < 500; i++) { ans[n][i] = 0; } } for (n = 1; n <= 10; n++) { sub(n, 0); } while (scanf("%d %d", &n, &s) != EOF) { ...
#include <stdio.h> int data[10]; int ans[15][500]; void sub(int n, int x); int check(int a, int x); int main(void) { int n, i, s; for (n = 0; n < 15; n++) { for (i = 0; i < 500; i++) { ans[n][i] = 0; } } for (n = 1; n <= 10; n++) { sub(n, 0); } while (scanf("%d %d", &n, &s) != EOF) { ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
328
1
#include <stdio.h> int memo[10][10][0x400][331]; int tansaku(int flags, int now, int max, int target) { int i; int result = 0; if (now >= max) return (target == 0) ? 1 : 0; if (target < 0 || target > 330) return 0; if (memo[max][now][flags][target] > 0) { return memo[max][now][flags][target] - 1...
#include <stdio.h> int memo[10][10][0x400][331]; int tansaku(int flags, int now, int max, int target) { int i; int result = 0; if (now >= max) return (target == 0) ? 1 : 0; if (target < 0 || target > 330) return 0; if (memo[max - 1][now][flags][target] > 0) { return memo[max - 1][now][flags][tar...
[["+", 28, 69, 28, 69, 28, 69, 71, 16, 17, 33], ["+", 28, 69, 28, 69, 28, 69, 71, 16, 12, 13]]
0
240
6
#include <stdio.h> #include <string.h> int u[10] = {0}, dp[10][331] = {{0}}, j, k; void f(int p, int r) { int i; dp[p][r]++; for (i = 0; i < 10; i++) if (!u[i]) { u[i] = 1; f(p + 1, r + i * (p + 1)); u[i] = 0; } } int main() { f(0, 0); for (; ~scanf("%d%d", &j, &k);) printf("%d...
#include <stdio.h> #include <string.h> int u[10] = {0}, dp[11][333] = {{0}}, j, k; void f(int p, int r) { int i; dp[p][r]++; for (i = 0; i < 10; i++) if (!u[i]) { u[i] = 1; f(p + 1, r + i * (p + 1)); u[i] = 0; } } int main() { f(0, 0); for (; ~scanf("%d%d", &j, &k);) printf("%d...
[["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["-", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13]]
0
171
4
used[9]; dfs(int step, int s) { int i, res; if (!step) return (s == 0); if (s < 0) return (0); if (s > (step * (step + 1)) * 4) return (0); res = 0; for (i = 0; i <= 9; ++i) { if (!used[i]) { used[i] = 1; res += dfs(step - 1, s - (i * step)); used[i] = 0; } } ret...
used[9]; dfs(int step, int s) { int i, res; if (!step) return (s == 0); if (s < 0) return (0); if (s > (step * (step + 1)) * 5) return (0); res = 0; for (i = 0; i <= 9; ++i) { if (!used[i]) { used[i] = 1; res += dfs(step - 1, s - (i * step)); used[i] = 0; } } ret...
[["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
0
177
2
a[99][999], c; f(i, d, s, b) { for (++a[d++][s]; i--;) b >> i & 1 || f(10, d, s + i * d, b | 1 << i); } main() { for (f(10L, 0L); scanf("%d%d", a, &c) / 2;) printf("%d\n", c < 400 ? a[**a][c] : 0); }
a[99][999], c; f(i, d, s, b) { for (++a[d++][s]; i--;) b >> i & 1 || f(10, d, s + i * d, b | 1 << i); } main() { for (f(10, 0, 0, 0); scanf("%d%d", a, &c) / 2;) printf("%d\n", c < 400 ? a[**a][c] : 0); }
[["-", 0, 9, 0, 7, 10, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 7, 10, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 7, 10, 2, 3, 4, 0, 21]]
0
118
8
#include <stdio.h> int main(void) { float x1, y1, x2, y2, xq, yq, a, b, x, y, xp, yp; while (scanf("%f,%f,%f,%f,%f,%f", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) { if (x1 == x2) { xp = 2 * x1 - xq; yp = yq; } else if (y1 == y2) { xp = xq; yp = 2 * y1 - yq; } else { a = (y2 - y...
#include <stdio.h> int main(void) { float x1, y1, x2, y2, xq, yq, a, b, x, y, xp, yp; while (scanf("%f,%f,%f,%f,%f,%f", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) { if (x1 == x2) { xp = 2 * x1 - xq; yp = yq; } else if (y1 == y2) { xp = xq; yp = 2 * y1 - yq; } else { a = (y2 - y...
[["+", 31, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22]]
0
251
4
#include <stdio.h> int main(int argc, char *argv[]) { double x1, y1, x2, y2, xq, yq; while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) { double a, b, qa, qb, tx, ty; if (x1 == x2) { if (x1 < xq) { printf("%lf %lf\n", x1 - (xq - x1), yq); } else { ...
#include <stdio.h> int main(int argc, char *argv[]) { double x1, y1, x2, y2, xq, yq; while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) { double a, b, qa, qb, tx, ty; if (x1 == x2) { if (x1 < xq) { printf("%lf %lf\n", x1 - (xq - x1), yq); } else { ...
[["-", 12, 16, 31, 91, 28, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 91, 28, 23, 0, 16, 17, 33], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 48], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33]]
0
273
4
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string...
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
369
2
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; #define EPS (1e-20) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x...
#include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; #define EPS (1e-20) class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x...
[["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
1
485
2
#include <cmath> #include <cstdio> #include <iomanip> #include <iostream> using namespace std; #define EPS 1e-10 #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: long double x, y; Point(long double x = 0, long double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y...
#include <cmath> #include <cstdio> #include <iomanip> #include <iostream> using namespace std; #define EPS 1e-10 #define equals(a, b) (fabs((a) - (b)) < EPS) class Point { public: long double x, y; Point(long double x = 0, long double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y...
[["+", 51, 16, 31, 2, 3, 4, 0, 66, 17, 67]]
1
559
5
#include <cmath> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> using namespace std; int main() { float x1, y1, x2, y2, xp, yp; double x0, y0, x, y, _x, _y, a, b; while (scanf("%f,%f,%f,%f,%f,%f", &x1, &y1, &x2, &y2, &xp, &yp) != EOF) { double angle = atan2(y2 - y1, x2 - x1); ...
#include <cmath> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> using namespace std; int main() { float x1, y1, x2, y2, xp, yp; double x0, y0, x, y, _x, _y, a, b; while (scanf("%f,%f,%f,%f,%f,%f", &x1, &y1, &x2, &y2, &xp, &yp) != EOF) { double angle = atan2(y2 - y1, x2 - x1); ...
[["+", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 17, 79], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 12, 13], ["+", 0, 11, 12, 23, 0, 41, 15, 16, 17, 106]]
1
266
4
#include <cmath> #include <complex> #include <cstdio> using namespace std; typedef complex<double> xy_t; double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } int main() { double x[3], y[3]; xy_t p[3], a, b, c, d; while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &y[0], &x[1], &y[1], &x[2], ...
#include <cmath> #include <complex> #include <cstdio> using namespace std; typedef complex<double> xy_t; double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } int main() { double x[3], y[3]; xy_t p[3], a, b, c, d; while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &y[0], &x[1], &y[1], &x[2], ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
249
3
#include <bits/stdc++.h> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) using namespace std; static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; struct Point { double x, y; ...
#include <bits/stdc++.h> #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS) using namespace std; static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; struct Point { double x, y; ...
[["-", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
1
2,381
2
#include <stdio.h> #include <string.h> int main() { double x1, y1, x2, y2, xq, yq, x, y; while (0 <= scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)) { x = ((x2 - x1) * (x2 - x1) * xq + (x2 - x1) * (y2 - y1) * (yq - y1) + (y2 - y1) * (y2 - y1) * x1) / ((y2 - y1) * (y2 - y1) + (x...
#include <stdio.h> #include <string.h> int main() { double x1, y1, x2, y2, xq, yq, x, y; while (0 <= scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)) { x = ((x2 - x1) * (x2 - x1) * xq + (x2 - x1) * (y2 - y1) * (yq - y1) + (y2 - y1) * (y2 - y1) * x1) / ((y2 - y1) * (y2 - y1) + (x...
[["-", 31, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
221
4
#include <cmath> #include <cstdio> #include <iostream> using namespace std; #define EPS 1e-6 int main(void) { double x1, y1, x2, y2, xq, yq; double a, b, c, d; double X, Y; double retx, rety; while (cin >> x1) { cin.ignore(); cin >> y1; cin.ignore(); cin >> x2; cin.ignore(); cin >> ...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; #define EPS 1e-6 int main(void) { double x1, y1, x2, y2, xq, yq; double a, b, c, d; double X, Y; double retx, rety; while (cin >> x1) { cin.ignore(); cin >> y1; cin.ignore(); cin >> x2; cin.ignore(); cin >> ...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
301
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
348
2
#include <cstdio> #include <iostream> int main() { double x0, y0, x1, y1, x2, y2, xq, yq, x, y, m, a; char c; while (std::cin >> x1 >> c >> y1 >> c >> x2 >> c >> y2 >> c >> xq >> c >> yq) { if (x1 == x2) { y = y1; x = x1; } else { m = (y2 - y1) / (x2 - x1); a = m * m + 1; ...
#include <cstdio> #include <iostream> int main() { double x0, y0, x1, y1, x2, y2, xq, yq, x, y, m, a; char c; while (std::cin >> x1 >> c >> y1 >> c >> x2 >> c >> y2 >> c >> xq >> c >> yq) { if (x1 == x2) { y = yq; x = x1; } else { m = (y2 - y1) / (x2 - x1); a = m * m + 1; ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
1
170
2
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <istream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> usin...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <istream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> usin...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
1,276
1
import sys from math import* for e in sys.stdin: a,b,c,d,x,y=map(float,e.split(',')) g=-2*(atan2(x-b,y-a)-atan2(d-b,c-a));s,t=sin(g),cos(g);x-=a;y-=b print(f'{t*x-s*y+a:.6f} {s*x+t*y+b:.6f}')
import sys from math import* for e in sys.stdin: a,b,c,d,x,y=map(float,e.split(',')) g=-2*(atan2(y-b,x-a)-atan2(d-b,c-a));s,t=sin(g),cos(g);x-=a;y-=b print(f'{t*x-s*y+a:.6f} {s*x+t*y+b:.6f}')
[["-", 0, 657, 31, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 657, 31, 652, 3, 4, 0, 657, 31, 22]]
5
120
4
import sys for line in sys.stdin.readlines(): x1,y1,x2,y2,xq,yq=list(map(float,line.strip().split(","))) if x1==x2: x,y=-xq+2*x1,yq elif y1==y2: x,y=xq,-yq+2*y1 else: m=(y1-y2)/(x1-x2) n=-m*x1+y1 x,y= (2*yq*m-2*m*n+xq-m*m*xq)/(m*m+1),(xq-x)/m+yq; print("{:.6f}...
import sys for line in sys.stdin.readlines(): x1,y1,x2,y2,xq,yq=list(map(float,line.strip().split(","))) if x1==x2: x,y=-xq+2*x1,yq elif y1==y2: x,y=xq,-yq+2*y1 else: m=(y1-y2)/(x1-x2) n=-m*x1+y1 x=(2*yq*m-2*m*n+xq-m*m*xq)/(m*m+1) y=(xq-x)/m+yq print("...
[["-", 8, 196, 0, 1, 0, 662, 31, 684, 0, 21], ["-", 8, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 432, 0, 21], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 8, 196, 0, 57, 75, 76, 8, 196, 0, 35]]
5
163
6
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public void run() { int[] merry = new int[] {1, 4, 1, 4, 1, 2, 1, 2}; while (sc.hasNext()) { int index = 0, max = -1, val = 0; int[] people = new int[] {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), ...
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public void run() { int[] merry = new int[] {1, 4, 1, 4, 1, 2, 1, 2}; while (sc.hasNext()) { int index = 0, max = -1, val = 0; int[] people = new int[] {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), ...
[["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
3
1,002
4
#include <stdio.h> int main(void) { int go_round[8] = {1, 2, 1, 2, 1, 4, 1, 4}; int client[8]; int minimum[8], min, temp; int seisuu; int i, j; int temp_s; while (scanf("%d%d%d%d%d%d%d%d", &client[0], &client[1], &client[2], &client[3], &client[4], &client[5], &client[6], &...
#include <stdio.h> int main(void) { int go_round[8] = {1, 2, 1, 2, 1, 4, 1, 4}; int client[8]; int minimum[8], min, temp; int seisuu; int i, j; int temp_s; while (scanf("%d%d%d%d%d%d%d%d", &client[0], &client[1], &client[2], &client[3], &client[4], &client[5], &client[6], &...
[["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]]
0
383
2
#include <stdio.h> #define N 8 int main(void) { int i, j; int d[N] = {1, 2, 1, 2, 1, 4, 1, 4}; int num[N]; int dt[N][N]; int p[N]; /* 配列から値へ */ for (i = 0; i < N; i++) { num[i] = 0; for (j = 0; j < N; j++) { num[i] *= 10; num[i] += d[(i + j) % N]; } } /* 値のソート */ for (i = ...
#include <stdio.h> #define N 8 int main(void) { int i, j; int d[N] = {1, 2, 1, 2, 1, 4, 1, 4}; int num[N]; int dt[N][N]; int p[N]; /* 配列から値へ */ for (i = 0; i < N; i++) { num[i] = 0; for (j = 0; j < N; j++) { num[i] *= 10; num[i] += d[(i + j) % N]; } } /* 値のソート */ for (i = ...
[["+", 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
508
4
#include <algorithm> #include <climits> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; const int latte[8] = {4, 1, 4, 1, 2, 1, 2, 1}, pri[8] = {0, 5, 1, 7, 3, 6, ...
#include <algorithm> #include <climits> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; const int latte[8] = {4, 1, 4, 1, 2, 1, 2, 1}, pri[8] = {0, 5, 1, 7, 3, 6, ...
[["-", 51, 16, 12, 23, 0, 16, 12, 16, 17, 47], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 17, 18]]
1
284
2
import re import sys for s in sys.stdin: print(re.sub(r"@(\d)(.)", lambda m: m.group(2)*int(m.group(1)), s))
import re import sys for s in sys.stdin: print(re.sub(r"@(\d)(.)", lambda m: m.group(2)*int(m.group(1)), s.rstrip()))
[["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
44
4
import sys for line in sys.stdin: line = line.strip() i = 0 ans = "" while i < len(line): if line[i] == "@": m = int(line[i+1]) c = line[i+2] i += 2 ans += m*c else: ans += line[i] i += 1 print(ans)
import sys for line in sys.stdin: line = line.strip() i = 0 ans = "" while i < len(line): if line[i] == "@": m = int(line[i+1]) c = line[i+2] i += 3 ans += m*c else: ans += line[i] i += 1 print(ans)
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612]]
5
83
2
import sys for e in sys.stdin: a='';b=n=0 for c in e: if'@'==c:b=1 elif b&1:n=int(c);b=2 elif b&2:a+=c*n;b=0 else:a+=c print(a)
import sys for e in sys.stdin: a='';b=n=0 for c in e[:-1]: if'@'==c:b=1 elif b&1:n=int(c);b=2 elif b&2:a+=c*n;b=0 else:a+=c print(a)
[["+", 0, 7, 8, 196, 0, 7, 12, 206, 0, 70], ["+", 0, 7, 12, 206, 206, 663, 0, 664, 17, 33], ["+", 0, 7, 12, 206, 206, 663, 0, 664, 28, 612], ["+", 0, 7, 8, 196, 0, 7, 12, 206, 0, 73], ["+", 0, 656, 0, 7, 8, 196, 0, 7, 0, 102]]
5
72
5
while True: try: inp = input() i, msg = 0, "" while i < len(inp)-1: if inp[i] == "@": msg += inp[i+2]*int(inp[i+1]) i += 3 else: msg += inp[i] i += 1 print(msg) except: break
while True: try: inp = input() i, msg = 0, "" while i < len(inp): if inp[i] == "@": msg += inp[i+2]*int(inp[i+1]) i += 3 else: msg += inp[i] i += 1 print(msg) except: break
[["-", 8, 196, 0, 52, 15, 666, 0, 657, 17, 33], ["-", 8, 196, 0, 52, 15, 666, 0, 657, 12, 612]]
5
77
2
while True: try: char = input() ans = "" while "@" in char: ans += char[0:char.index("@")] char = char[char.index("@"):] char = char[2] * int(char[1]) + char[3:] ans += char except: break
while True: try: char = input() ans = "" while "@" in char: ans += char[0:char.index("@")] char = char[char.index("@"):] char = char[2] * int(char[1]) + char[3:] ans += char print(ans) except: break
[["+", 0, 246, 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
76
4
<?php while (($line = trim(fgets(STDIN))) !== '0') { $n = (int)$line; //0埋め $arr = array_fill(0, $n, array_fill(0, $n, 0)); $x = (int)($n / 2); $y = $x + 1; //最初の入力 $arr[$y][$x] = 1; $m = pow($n, 2); $cnt = 2; $right = true; //全ての入力が終わるまで while ($cnt <= $m) { //...
<?php while (($line = trim(fgets(STDIN))) !== '0') { $n = (int)$line; //0埋め $arr = array_fill(0, $n, array_fill(0, $n, 0)); $x = (int)($n / 2); $y = $x + 1; //最初の入力 $arr[$y][$x] = 1; $m = pow($n, 2); $cnt = 2; $right = true; //全ての入力が終わるまで while ($cnt <= $m) { //...
[["-", 0, 493, 0, 52, 8, 9, 0, 608, 0, 621], ["-", 0, 493, 0, 52, 8, 9, 0, 608, 0, 141], ["-", 0, 493, 0, 52, 8, 9, 0, 608, 0, 35]]
6
359
3
import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); void run() { for (;;) { int n = sc.nextInt(); if (n == 0) break; int[][] ms = new int[n][n]; int posy = n / 2 + 1; int posx = n / 2; for (int...
import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); void run() { for (;;) { int n = sc.nextInt(); if (n == 0) break; int[][] ms = new int[n][n]; int posy = n / 2; int posx = n / 2 - 1; for (int...
[["-", 8, 196, 0, 503, 49, 200, 51, 16, 17, 72], ["-", 8, 196, 0, 503, 49, 200, 51, 16, 12, 499], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 17, 33], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 12, 499]]
3
310
4
#include <stdio.h> #define MAX 15 int main(void) { int n, i, j, nx, ny, sum; int magic[MAX][MAX]; while (1) { for (i = 0; i < MAX; i++) { for (j = 0; j < MAX; j++) { magic[i][j] = 0; } } scanf("%d", &n); if (n == 0) { break; } magic[n / 2 + 1][n / 2] = 1; ...
#include <stdio.h> #define MAX 15 int main(void) { int n, i, j, nx, ny, sum; int magic[MAX][MAX]; while (1) { for (i = 0; i < MAX; i++) { for (j = 0; j < MAX; j++) { magic[i][j] = 0; } } scanf("%d", &n); if (n == 0) { break; } magic[n / 2 + 1][n / 2] = 1; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
266
2
#include <stdio.h> int b[15][15]; void reset() { int i, j; for (i = 0; i < 15; i++) { for (j = 0; j < 15; j++) { b[i][j] = 0; } } } void magic_square(int x, int y, int n, int c) { if (c == n * n) return; if (b[x][y] == 0) { b[x][y] = ++c; if (++x == n) x = 0; if (++y == ...
#include <stdio.h> int b[15][15]; void reset() { int i, j; for (i = 0; i < 15; i++) { for (j = 0; j < 15; j++) { b[i][j] = 0; } } } void magic_square(int x, int y, int n, int c) { if (c == n * n) return; if (b[x][y] == 0) { b[x][y] = ++c; if (++x == n) x = 0; if (++y == ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
309
3
#include <stdio.h> int main() { int n, i, an[15][15], bn[15][15], a, b, n1, c = 2, d = 0, j; while (1) { for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { an[i][j] = bn[i][j] = 0; } } c = 2; d = 0; scanf("%d", &n); if (n == 0) break; an[n / 2 + 1][n / 2] = 1; ...
#include <stdio.h> int main() { int n, i, an[15][15], bn[15][15], a, b, n1, c = 2, d = 0, j; while (1) { for (i = 0; i < 15; i++) { for (j = 0; j < 15; j++) { an[i][j] = bn[i][j] = 0; } } c = 2; d = 0; scanf("%d", &n); if (n == 0) break; an[n / 2 + 1][n / 2] = 1...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
0
377
4
#include <stdio.h> int main(void) { int m[20][20], i, l, n, x, y; while (scanf("%d", &n) != 0) { if (n == 0) break; for (i = 0; i < 20; i++) { for (l = 0; l < 20; l++) { m[i][l] = 0; } } x = (n - 1) / 2; y = x + 1; m[x][y] = 1; for (i = 2; i <= n * n; i++) ...
#include <stdio.h> int main(void) { int m[20][20], i, l, n, x, y; while (scanf("%d", &n) != 0) { if (n == 0) break; for (i = 0; i < 20; i++) { for (l = 0; l < 20; l++) { m[i][l] = 0; } } x = (n - 1) / 2; y = x + 1; m[x][y] = 1; for (i = 2; i <= n * n; i++) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
300
2
#include <iostream> #include <string.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int field[16][16]; int n; while (cin >> n && n) { memset(field, 0, sizeof(field)); int x = n / 2; int y = n / 2 + 1; field[y][x] = 1; int count = 2; while (true) { ...
#include <iostream> #include <string.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { int field[16][16]; int n; while (cin >> n && n) { memset(field, 0, sizeof(field)); int x = n / 2; int y = n / 2 + 1; field[y][x] = 1; int count = 2; while (true) { ...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22]]
1
239
2
#include <cstdio> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n, n) { vector<vector<int>> d(n, vector<int>(n, 0)); int x = n / 2 + 1, y = n / 2; d[x][y] = 1; int m = 1; while (m < n * n) { m++; int dx = (x + 1) % n,...
#include <cstdio> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n, n) { vector<vector<int>> d(n, vector<int>(n, 0)); int x = n / 2 + 1, y = n / 2; d[x][y] = 1; int m = 1; while (m < n * n) { m++; int dx = (x + 1) % n,...
[["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
207
2
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n, n) { int x = n / 2, y = n / 2 + 1, fld[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { fld[i][j] = -1; } } fld[x][y] = 1; for (int i = 2; i <= n * n; i++) { x++; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n, n) { int x = n / 2, y = n / 2 + 1, fld[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { fld[i][j] = -1; } } fld[x][y] = 1; for (int i = 2; i <= n * n; i++) { x++; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 3, 4, 0, 69, 28, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
271
6
#include <iostream> using namespace std; int main() { // your code goes here int n; int a[20][20]; cin >> n; while (n != 0) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = 0; } } int k = 1 + n / 2; int l = n / 2; int m = 1; a[k][l] = 1; ...
#include <iostream> using namespace std; int main() { // your code goes here int n; int a[20][20]; cin >> n; while (n != 0) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = 0; } } int k = 1 + n / 2; int l = n / 2; int m = 1; a[k][l] = 1; ...
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 31, 13]]
1
353
2
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define PB push_back #define INF (1 << 29) #define ALL(a) (a).begin(), (a).end() #de...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define PB push_back #define INF (1 << 29) #define ALL(a) (a).begin(), (a).end() #de...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 31, 22], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
334
6
#include <cstdio> #include <iostream> using namespace std; int main() { int a[15][15]; int n, x, y, i = 1; cin >> n; while (n != 0) { for (int j = 0; j < n * n; j++) a[j / n][j % n] = -1; x = n / 2; y = n / 2 + 1; i = 1; while (i <= n * n) { if (x >= n) { x = 0; ...
#include <cstdio> #include <iostream> using namespace std; int main() { int a[15][15]; int n, x, y, i = 1; cin >> n; while (n != 0) { for (int j = 0; j < n * n; j++) a[j / n][j % n] = -1; x = n / 2; y = n / 2 + 1; i = 1; while (i <= n * n) { if (x >= n) { x = 0; ...
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
270
4
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using nam...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> using nam...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
391
2
#include <iostream> using namespace std; int main(int argc, char const *argv[]) { int i, j, k; int n; int a[15][15]; while (cin >> n && n != 0) { k = 0; for (i = 0; i < 15; i++) { for (j = 0; j < 15; j++) { a[i][j] = 0; } } for (i = -n / 2; i <= n / 2; i++) for (j = ...
#include <iostream> using namespace std; int main(int argc, char const *argv[]) { int i, j, k; int n; int a[15][15]; while (cin >> n && n != 0) { k = 0; for (i = 0; i < 15; i++) { for (j = 0; j < 15; j++) { a[i][j] = 0; } } for (i = -n / 2; i <= n / 2; i++) for (j = ...
[["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33]]
1
206
4
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace ::std; int main() { int number; int i, j; int center = 0; int h = 0; int w = 0; cin >> number; while (number != 0) { int magic[number][number]; for (i = 0; i < number; i++) { for...
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace ::std; int main() { int number; int i, j; int center = 0; int h = 0; int w = 0; cin >> number; while (number != 0) { int magic[number][number]; for (i = 0; i < number; i++) { for...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
281
2
#include <iomanip> #include <iostream> using namespace std; int n; int m[15][15]; void func(int x, int y, int l) { int nx, ny; if (!m[x][y]) { m[x][y] = l; if (l == n * n) return; if (x < n - 1) nx = x + 1; else nx = 0; if (y < n - 1) ny = y + 1; else ny = 0; ...
#include <iomanip> #include <iostream> using namespace std; int n; int m[15][15]; void func(int x, int y, int l) { int nx, ny; if (!m[x][y]) { m[x][y] = l; if (l == n * n) return; if (x < n - 1) nx = x + 1; else nx = 0; if (y < n - 1) ny = y + 1; else ny = 0; ...
[["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
310
2
#include <iomanip> #include <iostream> using namespace std; int main() { int n; int table[20][20]; while (cin >> n, n) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) table[i][j] = 0; int y = n / 2 + 1, x = n / 2; for (int i = 1; i <= n * n; i++) { table[y][x] = i; ...
#include <iomanip> #include <iostream> using namespace std; int main() { int n; int table[20][20]; while (cin >> n, n) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) table[i][j] = 0; int y = n / 2 + 1, x = n / 2; for (int i = 1; i <= n * n; i++) { table[y][x] = i; ...
[["-", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
247
2
arr, ans = gets.split.map{ |i| i.delete(",.") }, [] arr.each do |str| p str.length ans << str if (3..6).include?(str.length) end puts ans.join(" ")
arr, ans = gets.split.map{ |i| i.delete(",.") }, [] arr.each do |str| ans << str if (3..6).include?(str.length) end puts ans.join(" ")
[["-", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 486, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22]]
4
62
4
a =gets a.gsub!(","," ") a.gsub!("."," ") a = a.split(" ") r = a.map do |el| if el.length >= 3 && el.length <= 6 el end end puts r.compact!
a =gets a.gsub!(","," ") a.gsub!("."," ") a = a.split(" ") r = a.map do |el| if el.length >= 3 && el.length <= 6 el end end puts r.compact!.join(' ')
[["+", 0, 493, 0, 652, 3, 4, 0, 652, 17, 131], ["+", 0, 493, 0, 652, 3, 4, 0, 652, 735, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 62], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
4
65
7
import re s = re.split("[ .,]", input()) sl = len(s) ans = list() for i in range(sl) : if(2 < len(s[i]) and len(s[i]) < 7) : ans.append(s[i]) else : pass ansl = len(ans) for i in range(ansl - 1) : if(i == ansl) : print(ans[i]) else : print(ans[i], end = (" "))
import re s = re.split("[ .,]", input()) sl = len(s) ans = list() for i in range(sl) : if(2 < len(s[i]) and len(s[i]) < 7) : ans.append(s[i]) else : pass ansl = len(ans) for i in range(ansl) : if(i == ansl - 1) : print(ans[i]) else : print(ans[i], end = (" "))
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 57, 15, 23, 0, 666, 0, 657, 17, 33], ["+", 0, 57, 15, 23, 0, 666, 0, 657, 12, 612]]
5
117
4
l=list(map(str,input().split())) for i in l: tmp=i.replace(',','') tmp=i.replace('.','') if 2<len(tmp)<7: print(tmp, end=' ')
l=list(map(str,input().split())) for i in l: i=i.replace(',','') i=i.replace('.','') if 2<len(i)<7: print(i, end=' ')
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
68
8
print(' '.join([w for w in input().replace(',', '').replace('.', '').split(', ') if len(w) > 2 and len(w) < 7]))
print(' '.join([w for w in input().replace(',', '').replace('.', '').split(' ') if len(w) > 2 and len(w) < 7]))
[["-", 0, 659, 12, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 659, 12, 652, 3, 4, 0, 557, 0, 6]]
5
60
2
import re print(*[x for x in re.split(r'\s|"|,|\.',input())if 2<len(s)<7])
import re print(*[x for x in re.split(r'\s|"|,|\.',input())if 2<len(x)<7])
[["-", 0, 678, 0, 666, 0, 652, 3, 4, 0, 22], ["+", 0, 678, 0, 666, 0, 652, 3, 4, 0, 22]]
5
33
2
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { ArrayList<Integer> list = new ArrayList<Integer>(); int n = sc.nextInt(); int m = sc.nextInt(); if (n == 0 ...
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { ArrayList<Integer> list = new ArrayList<Integer>(); int n = sc.nextInt(); int m = sc.nextInt(); if (n == 0 ...
[["-", 8, 196, 0, 52, 15, 15, 0, 16, 17, 79], ["+", 8, 196, 0, 52, 15, 15, 0, 16, 17, 47], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
3
176
4
import java.util.*; public class Main { public static void main(String[] args) { new Main(); } public Main() { Scanner cin = new Scanner(System.in); while (true) { int n = cin.nextInt(); int m = cin.nextInt(); if (n == 0) break; boolean check[] = new boolean[1000]; i...
import java.util.*; public class Main { public static void main(String[] args) { new Main(); } public Main() { Scanner cin = new Scanner(System.in); while (true) { int n = cin.nextInt(); int m = cin.nextInt(); if (n == 0) break; boolean check[] = new boolean[1000]; i...
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
220
2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Deque; /** * Joseph's Potato */ public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamRead...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Deque; /** * Joseph's Potato */ public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamRead...
[["+", 0, 503, 49, 200, 51, 230, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
237
3
int joseph(int n, int diff, int initial) { int r = 0, i = 1; for (; i < n; i++) r = (r + diff) % i; return (r + 1 + initial) % n + 1; } int main() { int n, k; for (; scanf("%d%d", &n, &k), n;) printf("%d\n", joseph(n, k, k)); return 0; }
int joseph(int n, int diff, int initial) { int r = 0, i = 1; for (; i < n; i++) r = (r + diff) % i; return (r + 1 + initial) % n + 1; } int main() { int n, k; for (; scanf("%d%d", &n, &k), n;) printf("%d\n", joseph(n, k, k - 1)); return 0; }
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]]
0
106
2
/* AOJ 0085 * * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0085 * */ #include <stdio.h> #define DEBUG 0 int next[1001]; int main() { int m, n; int count; int i; int p, prev; while (scanf("%d %d", &n, &m) == 2) { if (m == 0 && n == 0) { break; } for (i = 1; i < n; i++)...
/* AOJ 0085 * * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0085 * */ #include <stdio.h> #define DEBUG 0 int next[1001]; int main() { int m, n; int count; int i; int p, prev; while (scanf("%d %d", &n, &m) == 2) { if (m == 0 && n == 0) { break; } for (i = 1; i < n; i++)...
[["+", 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
189
4
#include <iostream> #include <queue> using namespace std; main() { int n, m; queue<int> poteto; while (1) { cin >> n >> m; if (n == 0 && m == 0) break; for (int i = 1; i <= n; i++) { poteto.push(i); } while (poteto.size() > 1) { for (int j = 0; j < m - 1; j++) { potet...
#include <iostream> #include <queue> using namespace std; main() { int n, m; queue<int> poteto; while (1) { cin >> n >> m; if (n == 0 && m == 0) break; for (int i = 1; i <= n; i++) { poteto.push(i); } while (poteto.size() > 1) { for (int j = 0; j < m - 1; j++) { potet...
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
144
4
#define scanf_s scanf //#define gets_s gets #include <iostream> #include <math.h> #include <stdio.h> #include <string> using namespace std; #define MAX 1000 #define MIN 2 int main(void) { int n, m; while (scanf_s("%d %d", &n, &m) != EOF) { if (n == 0 && m == 0) break; int h[MAX + 1] = {0}, ans = 0, co...
#define scanf_s scanf //#define gets_s gets #include <iostream> #include <math.h> #include <stdio.h> #include <string> using namespace std; #define MAX 1000 #define MIN 2 int main(void) { int n, m; while (scanf_s("%d %d", &n, &m) != EOF) { if (n == 0 && m == 0) break; int h[MAX + 1] = {0}, ans = 0, co...
[["-", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
188
7
#include <iostream> #include <vector> using namespace std; int main() { int n, k, m, i; for (; cin >> n >> k, n;) { vector<int> vec(n); for (i = 0; i < n; i++) vec[i] = i + 1; i = (m - 1) % vec.size(); vec.erase(vec.begin() + i); for (; vec.size() > 1; vec.erase(vec.begin() + i)) if ...
#include <iostream> #include <vector> using namespace std; int main() { int n, k, i; for (; cin >> n >> k, n;) { vector<int> vec(n); for (i = 0; i < n; i++) vec[i] = i + 1; i = (k - 1) % vec.size(); vec.erase(vec.begin() + i); for (; vec.size() > 1; vec.erase(vec.begin() + i)) if (i ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22]]
1
160
4
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; const double EPS = 1e-9; cons...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; const double EPS = 1e-9; cons...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
200
2
#include <iostream> using namespace std; int potato(int x, int y) { int i; for (i = y - 1; i < (y - 1) * x; i = (i * y) / (y - 1) + 1) return (x * y - i); } int main() { int x, y; while (cin >> x >> y, x || y) { cout << potato(x, y) << endl; } }
#include <iostream> using namespace std; int potato(int x, int y) { int i; for (i = y - 1; i < (y - 1) * x; i = (y * i) / (y - 1) + 1) ; return (x * y - i); } int main() { int x, y; while (cin >> x >> y, x || y) { cout << potato(x, y) << endl; } }
[["-", 12, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 8, 1, 0, 35]]
1
99
5
#include <iostream> using namespace std; long long int func(int year, int month, int day) { return (year * 10000 + month * 100 + day); } int main() { long long int data[4]; data[0] = 1868 * 10000 + 9 * 100 + 8; data[1] = 1912 * 10000 + 7 * 100 + 29; data[2] = 1926 * 10000 + 12 * 100 + 24; data[3] = 1989 ...
#include <iostream> using namespace std; long long int func(int year, int month, int day) { return (year * 10000 + month * 100 + day); } int main() { long long int data[4]; data[0] = 1868 * 10000 + 9 * 100 + 8; data[1] = 1912 * 10000 + 7 * 100 + 29; data[2] = 1926 * 10000 + 12 * 100 + 24; data[3] = 1989 ...
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
335
8
#include <cstdio> #include <iostream> using namespace std; string G[] = {"meiji", "taisho", "showa", "heisei"}; int Gnum[] = {1868, 1912, 1926, 1989}; int YEAR(int year) { if (19890108 <= year) { return 3; } else if (19891225 <= year) { return 2; } else if (19120730 <= year) { return 1; } else if (...
#include <cstdio> #include <iostream> using namespace std; string G[] = {"meiji", "taisho", "showa", "heisei"}; int Gnum[] = {1868, 1912, 1926, 1989}; int YEAR(int year) { if (19890108 <= year) { return 3; } else if (19261225 <= year) { return 2; } else if (19120730 <= year) { return 1; } else if (...
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 31, 13], ["+", 0, 52, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
196
7
gengo = { "meiji" => 18680908..19120729, "taisho" => 19120730..19261224, "showa" => 19261225..19890107, "heisei" => 19890108..99999999, } while gets y, m, d = $_.split date = sprintf("%4d%02d%02d\n", y, m, d).to_i puts "pre-meiji" unless gengo.any? do |g, range| if range === ...
gengo = { "meiji" => 18680908..19120729, "taisho" => 19120730..19261224, "showa" => 19261225..19890107, "heisei" => 19890108..99999999, } while gets y, m, d = $_.split date = sprintf("%4d%02d%02d\n", y, m, d).to_i puts "pre-meiji" unless gengo.any? do |g, range| if range === d...
[["-", 0, 662, 12, 738, 31, 738, 31, 739, 0, 24], ["+", 0, 662, 12, 738, 31, 738, 31, 738, 17, 85], ["+", 0, 662, 12, 738, 31, 738, 31, 738, 12, 612], ["-", 0, 662, 12, 738, 31, 738, 31, 739, 0, 25]]
4
118
4
def solve(y,m,d): if y<1868 or (y==1868 and m<9) or (y==1868 and m==9 and d<8): print("pre-meiji") elif 1868<y<1912 or (y==1868 and 7<m) or (y==1868 and m==9 and 8<=d) or (y==1912 and m<7) or(y==1912 and m==7 and d<=29): print("meiji %d %d %d"%(y-1868+1,m,d)) elif 1912<y<1926 or (y==1912 and 7<m) or (y==1912 and...
def solve(y,m,d): if y<1868 or (y==1868 and m<9) or (y==1868 and m==9 and d<8): print("pre-meiji") elif 1868<y<1912 or (y==1868 and 9<m) or (y==1868 and m==9 and 8<=d) or (y==1912 and m<7) or(y==1912 and m==7 and d<=29): print("meiji %d %d %d"%(y-1868+1,m,d)) elif 1912<y<1926 or (y==1912 and 7<m) or (y==1912 and...
[["-", 31, 679, 12, 23, 0, 679, 12, 666, 0, 612], ["+", 31, 679, 12, 23, 0, 679, 12, 666, 0, 612], ["-", 0, 657, 12, 660, 0, 657, 31, 657, 12, 612], ["+", 0, 657, 12, 660, 0, 657, 31, 657, 12, 612]]
5
319
6
# Aizu Problem 0083: Era Transformation # import sys, math, os # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def era_transformation(y, m, d): if int(m) < 10: m = '0' + m if int(d) < 10: d = '0' + d date = int(y + m + d) ...
# Aizu Problem 0083: Era Transformation # import sys, math, os # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def era_transformation(y, m, d): if int(m) < 10: m = '0' + m if int(d) < 10: d = '0' + d date = int(y + m + d) ...
[["-", 0, 652, 3, 4, 0, 657, 31, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 12, 612]]
5
229
4
ans=[] while True: try: year,month,day=list(map(int,input().split())) except EOFError: break except ValueError: break wareki='' if (year < 1868) or (year == 1868 and month < 9) or (year == 1868 and month == 9 and day <= 7): ans.append('pre-meiji') continue ...
ans=[] while True: try: year,month,day=list(map(int,input().split())) except EOFError: break except ValueError: break wareki='' if (year < 1868) or (year == 1868 and month < 9) or (year == 1868 and month == 9 and day <= 7): ans.append('pre-meiji') continue ...
[["-", 0, 1, 0, 677, 12, 657, 31, 557, 0, 6], ["+", 0, 1, 0, 677, 12, 657, 31, 557, 0, 6]]
5
258
2
while True: try: y, m, d = list(map(int, input().split())) date = int("{}{}{}".format('%04d'%y,'%02d'%m,'%02d'%d)) if date < 18680908: print("pre-meiji") elif date < 19210730: y = y - 1868 + 1 print("meiji {} {} {}".format(y,m,d)) elif date < 19261225: y = y - 1912 + 1 print("taisho {} {} {}"....
while True: try: y, m, d = list(map(int, input().split())) date = int("{}{}{}".format('%04d'%y,'%02d'%m,'%02d'%d)) if date < 18680908: print("pre-meiji") elif date < 19120730: y = y - 1868 + 1 print("meiji {} {} {}".format(y,m,d)) elif date < 19261225: y = y - 1912 + 1 print("taisho {} {} {}"....
[["-", 8, 196, 0, 57, 75, 665, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 0, 612]]
5
174
2
import sys s=0 p=[list(map(float,e.split(',')))for e in sys.stdin] x,y=p[0] for i in range(len(p)-2): a,b=p[i+1];c,d=p[i+2] s-=((a-x)*(d-y)-(b-y)*(c-x))/2 print(s)
import sys s=0 p=[list(map(float,e.split(',')))for e in sys.stdin] x,y=p[0] for i in range(len(p)-2): a,b=p[i+1];c,d=p[i+2] s+=((a-x)*(d-y)-(b-y)*(c-x))/2 print(abs(s))
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
106
12
import sys s=0 p=[list(map(float,e.split(',')))for e in sys.stdin];n=len(p) for i in range(n):a,b=p[i];c,d=p[-~i%n];s+=a*d-b*c print(-s/2)
import sys s=0 p=[list(map(float,e.split(',')))for e in sys.stdin] n=len(p) for i in range(n):a,b=p[i];c,d=p[-~i%n];s+=a*d-b*c print(abs(s)/2)
[["-", 36, 36, 36, 36, 36, 36, 0, 656, 0, 35], ["-", 0, 652, 3, 4, 0, 657, 31, 664, 17, 33], ["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
84
5
import sys x=[list(map(float,s[:-1].split(","))) for s in sys.stdin] s=[x[i][0]*x[i+1][1]-x[i][1]*x[i+1][0] for i in range(len(x)-1)] print(abs(sum(s))/2)
import sys x=[list(map(float,s[:-1].split(","))) for s in sys.stdin] s=[x[i][0]*x[i-1][1]-x[i][1]*x[i-1][0] for i in range(len(x))] print(abs(sum(s))/2)
[["-", 31, 657, 12, 206, 51, 206, 206, 657, 17, 72], ["+", 31, 657, 12, 206, 51, 206, 206, 657, 17, 33], ["-", 12, 657, 12, 206, 51, 206, 206, 657, 17, 72], ["+", 12, 657, 12, 206, 51, 206, 206, 657, 17, 33], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
96
11
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n; Double n1, n2; n = sc.nextInt(); while (n != -1) { n1 = n * 1.0 / 2; n2 = n1 - (n1 * n1 * n1 - n) / (3 * n1 * n1); while (0.00001 * n <= Math.abs(n...
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n; Double n1, n2; n = sc.nextInt(); while (n != -1) { n1 = n * 1.0 / 2; n2 = n1 - (n1 * n1 * n1 - n) / (3 * n1 * n1); while (0.000001 * n <= Math.abs(...
[["-", 0, 52, 15, 15, 0, 16, 31, 16, 31, 515], ["+", 0, 52, 15, 15, 0, 16, 31, 16, 31, 515], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 44]]
3
158
3
import java.util.*; class Main { void run() { Scanner sc = new Scanner(System.in); while (true) { int z = sc.nextInt(); if (z == -1) break; double q = (double)z; double x = q / 2; while (true) { if (Math.abs(x * x * x - q) < 0.00001 * q) break; ...
import java.util.*; class Main { void run() { Scanner sc = new Scanner(System.in); while (true) { int z = sc.nextInt(); if (z == -1) break; double q = (double)z; double x = q / 2; while (true) { if (Math.abs(x * x * x - q) < 0.00001 * q) break; ...
[["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 44]]
3
151
1
#include <math.h> #include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) { break; } x = q / 2.0; while (fabs(x * x * x - q) >= 1e-5 * q) { x = x - (x * x * x - q) / (x * x); } printf("%f\n", x); } return (0); }
#include <math.h> #include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) { break; } x = q / 2.0; while (fabs(x * x * x - q) >= 1e-5 * q) { x = x - (x * x * x - q) / (3 * x * x); } printf("%f\n", x); } return (0); }
[["+", 12, 16, 12, 23, 0, 16, 31, 16, 31, 13], ["+", 12, 16, 12, 23, 0, 16, 31, 16, 17, 48]]
0
103
2
#include <math.h> #include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) break; x = q / 2; while (fabs(x * x * x - q) >= 0.00001 * q) x = x - (x * x * x - q) / (3 * x * x); printf("%f\n", x); } return 0; }
#include <math.h> #include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) break; x = (double)q / 2; while (fabs(x * x * x - q) >= 0.00001 * q) x = x - (x * x * x - q) / (3 * x * x); printf("%f\n", x); } return 0; }
[["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25]]
0
99
3