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 <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)
int cal(vector<double> &v, string op) {
int right = v[v.size() - 1];
int left = v[v.size() - 2];
v.pop_back();
v.pop_back();
if (op == "+")
return left + right;
if (op == "-")
return left - right;
if (op == "*")
return left * right;
if (op == "/")
return left / right;
}
int main() {
string str;
while (getline(cin, str)) {
stringstream ss(str);
vector<double> v;
while (ss >> str) {
if (str.length() != 1 && str[0] == '-')
v.push_back(-1.0 * atoi(str.substr(1).c_str()));
else if (isdigit(str[0]))
v.push_back((double)(atoi(str.c_str())));
else
v.push_back(cal(v, str));
}
printf("%.7lf\n", v[0]);
}
return 0;
}
|
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)
double cal(vector<double> &v, string op) {
double right = v[v.size() - 1];
double left = v[v.size() - 2];
v.pop_back();
v.pop_back();
if (op == "+")
return left + right;
if (op == "-")
return left - right;
if (op == "*")
return left * right;
if (op == "/")
return left / right;
}
int main() {
string str;
while (getline(cin, str)) {
stringstream ss(str);
vector<double> v;
while (ss >> str) {
if (str.length() != 1 && str[0] == '-')
v.push_back(-1.0 * atoi(str.substr(1).c_str()));
else if (isdigit(str[0]))
v.push_back((double)(atoi(str.c_str())));
else
v.push_back(cal(v, str));
}
printf("%.7lf\n", v[0]);
}
return 0;
}
|
[["-", 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, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
| 1
| 272
| 6
|
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stack>
using namespace std;
stack<double> st;
int solve(char s) {
double a, b;
b = st.top();
st.pop();
a = st.top();
st.pop();
if (s == '+')
return (a + b);
else if (s == '-')
return (a - b);
else if (s == '*')
return (a * b);
else if (s == '/')
return (a / b);
return 1;
}
int main() {
int cnt = 0;
char s[80];
while (1) {
exit:
cin >> s;
cnt++;
if (cin.eof())
break;
if (getchar() == '\n') {
if (cnt == 1) {
cout << s << endl;
cnt = 0;
goto exit;
}
st.push(solve(s[0]));
printf("%.6f\n", st.top());
st.pop();
cnt = 0;
} else if (!isalnum(s[0]) && !isalnum(s[1]))
st.push(solve(s[0]));
else
st.push(atof(s));
}
return 0;
}
|
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stack>
using namespace std;
stack<double> st;
double solve(char s) {
double a, b;
b = st.top();
st.pop();
a = st.top();
st.pop();
if (s == '+')
return (a + b);
else if (s == '-')
return (a - b);
else if (s == '*')
return (a * b);
else if (s == '/')
return (a / b);
return 1;
}
int main() {
int cnt = 0;
char s[80];
while (1) {
exit:
cin >> s;
cnt++;
if (cin.eof())
break;
if (getchar() == '\n') {
if (cnt == 1) {
cout << s << endl;
cnt = 0;
goto exit;
}
st.push(solve(s[0]));
printf("%.6f\n", st.top());
st.pop();
cnt = 0;
} else if (!isalnum(s[0]) && !isalnum(s[1]))
st.push(solve(s[0]));
else
st.push(atof(s));
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
| 1
| 287
| 2
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
stack<double> s;
int calc(string str) {
int x = s.top();
s.pop();
int y = s.top();
s.pop();
switch (str[0]) {
case '+':
return x + y;
case '-':
return y - x;
case '*':
return x * y;
}
return y / x;
}
void judge() {
string str, a;
while (getline(cin, str)) {
stringstream ss(str);
while (ss >> a) {
if (a == "+" || a == "-" || a == "*" || a == "/") {
s.push(calc(a));
} else {
s.push(atof(a.c_str()));
}
}
printf("%.6f\n", s.top());
}
}
int main() {
judge();
return 0;
}
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
stack<double> s;
double calc(string str) {
double x = s.top();
s.pop();
double y = s.top();
s.pop();
switch (str[0]) {
case '+':
return x + y;
case '-':
return y - x;
case '*':
return x * y;
}
return y / x;
}
void judge() {
string str, a;
while (getline(cin, str)) {
stringstream ss(str);
while (ss >> a) {
if (a == "+" || a == "-" || a == "*" || a == "/") {
s.push(calc(a));
} else {
s.push(atof(a.c_str()));
}
}
printf("%.6f\n", s.top());
}
}
int main() {
judge();
return 0;
}
|
[["-", 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, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
| 1
| 222
| 6
|
while _ = $stdin.gets
stack = []
terms = _.chomp.split(/ /)
terms.each do |t|
case t
when /^\A\d+\z/
stack << t.to_i
when '+'
stack << stack.pop(2).inject(:+)
when '-'
stack << stack.pop(2).inject(:-)
when '/'
stack << stack.pop(2).inject(:/)
when '*'
stack << stack.pop(2).inject(:*)
end
end
puts('%.6f' % stack[0])
end
|
while _ = $stdin.gets
stack = []
terms = _.chomp.split(/ /)
terms.each do |t|
case t
when /^\A-?\d+\z/
stack << t.to_f
when '+'
stack << stack.pop(2).inject(:+)
when '-'
stack << stack.pop(2).inject(:-)
when '/'
stack << stack.pop(2).inject(:/)
when '*'
stack << stack.pop(2).inject(:*)
end
end
puts('%.6f' % stack[0])
end
|
[["+", 0, 173, 0, 763, 374, 374, 0, 575, 0, 6], ["-", 0, 763, 8, 749, 0, 738, 12, 652, 735, 22], ["+", 0, 763, 8, 749, 0, 738, 12, 652, 735, 22]]
| 4
| 126
| 3
|
$<.each do |line|
stack = line.chomp.split
#逆ポーランド記法
n = stack.inject([]) do |s, x|
x =~ /[0-9]/ ? s << x : s << eval(s.pop(2).join(x))
end
puts sprintf("%.6f", n.first + 0)
end
|
$<.each do |line|
stack = line.chomp.split
#逆ポーランド記法
n = stack.inject([]) do |s, x|
x =~ /[0-9]/ ? s << x.to_f : s << eval(s.pop(2).join(x))
end
puts sprintf("%.6f", n.first + 0)
end
|
[["+", 8, 736, 0, 754, 64, 738, 12, 652, 17, 131], ["+", 8, 736, 0, 754, 64, 738, 12, 652, 735, 22]]
| 4
| 71
| 14
|
while str = gets do
a = str.split(" ")
b = Array.new
a.each do |_a|
begin
b.push Integer(_a)
rescue
n1,n2 = b.pop,b.pop
if _a == '+'
b.push n2+n1
elsif _a == '-'
b.push n2-n1
elsif _a == '*'
b.push n2*n1
elsif _a == '/'
b.push n2/n1
end
end
end
puts b.pop.to_f
end
|
while str = gets do
a = str.split(" ")
b = Array.new
a.each do |_a|
begin
b.push Float(_a)
rescue
n1,n2 = b.pop,b.pop
if _a == '+'
b.push n2+n1
elsif _a == '-'
b.push n2-n1
elsif _a == '*'
b.push n2*n1
elsif _a == '/'
b.push n2/n1
end
end
end
puts b.pop
end
|
[["-", 0, 756, 0, 652, 3, 4, 0, 652, 735, 743], ["+", 0, 756, 0, 652, 3, 4, 0, 652, 735, 743], ["-", 8, 170, 0, 652, 3, 4, 0, 652, 17, 131], ["-", 8, 170, 0, 652, 3, 4, 0, 652, 735, 22]]
| 4
| 105
| 4
|
#!/usr/bin/env python3
import sys
def calc_inverse_polish_notation_string(s):
tokens = [token for token in s.split(' ') if token != '']
stack = []
for token in tokens:
if token in ['+', '-', '*', '/']:
val2 = stack.pop()
val1 = stack.pop()
result = eval("%s %s %s" % (val1, token, val2))
stack.append(result)
else:
stack.append(token)
return stack[0] # if len(stack) != 1, it should throw an exception
def main():
for line in sys.stdin.readlines():
print(calc_inverse_polish_notation_string(line))
if __name__ == "__main__":
main()
|
import sys
def calc_inverse_polish_notation_string(s):
tokens = [token for token in s.split(' ') if token != '']
stack = []
for token in tokens:
if token in ['+', '-', '*', '/']:
val2 = stack.pop()
val1 = stack.pop()
result = eval("%s %s %s" % (val1, token, val2))
stack.append(result)
else:
stack.append(token)
return stack[0] # if len(stack) != 1, it should throw an exception
def main():
for line in sys.stdin.readlines():
print(calc_inverse_polish_notation_string(line.strip()))
if __name__ == "__main__":
main()
|
[["+", 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
| 143
| 4
|
import sys
for line in sys.stdin.readlines():
stack=[]
for a in line.strip().split():
if a=="+":
a=stack.pop()+stack.pop()
elif a=="-":
a=-(stack.pop()-stack.pop())
elif a=="*":
a=stack.pop()*stack.pop()
elif a=="/":
a=stack.pop()/stack.pop()
stack.append(float(a))
print("{:.6f}".format(stack[0]+0))
|
import sys
for line in sys.stdin.readlines():
stack=[]
for a in line.strip().split():
if a=="+":
a=stack.pop()+stack.pop()
elif a=="-":
a=-(stack.pop()-stack.pop())
elif a=="*":
a=stack.pop()*stack.pop()
elif a=="/":
a=1.0/stack.pop()*stack.pop()
stack.append(float(a))
print("{:.6f}".format(stack[0]+0))
|
[["+", 0, 1, 0, 662, 12, 657, 31, 657, 31, 531], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 17, 85], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 48]]
| 5
| 138
| 4
|
while True:
stack = []
for s in input().split():
if s in ('+', '-', '*', '/'):
stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
else:
stack.append(float(s))
print('%.6f' % stack.pop())
|
while True:
try:
stack = []
for s in input().split():
if s in ('+', '-', '*', '/'):
stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
else:
stack.append(float(s))
print('%.6f' % stack.pop())
except EOFError:
break
|
[["+", 0, 656, 0, 52, 8, 196, 0, 246, 0, 247], ["+", 0, 656, 0, 52, 8, 196, 0, 246, 0, 102], ["+", 0, 52, 8, 196, 0, 246, 0, 671, 0, 672], ["+", 0, 52, 8, 196, 0, 246, 0, 671, 0, 22], ["+", 0, 52, 8, 196, 0, 246, 0, 671, 0, 102], ["+", 0, 246, 0, 671, 0, 196, 0, 93, 0, 94]]
| 5
| 90
| 6
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main {
static int nowLoca = 1;
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
while ((line = br.readLine()) != null) {
if (line.isEmpty())
break;
char[] chrs = line.toCharArray();
String bits = "";
for (char c : chrs) {
bits += code(c);
}
int len = bits.length();
if (len % 5 != 0) {
for (int i = 1; i <= 5 - (len % 5); i++) {
bits += "0";
}
}
String res = "";
for (int i = 0; i < bits.length() / 5; i++) {
String substr = bits.substring(0 * i, 0 * i + 4);
res += code2(substr);
}
System.out.println(res);
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
static String code2(String bits) {
if (bits.equals("00000"))
return "A";
else if (bits.equals("00001"))
return "B";
else if (bits.equals("00010"))
return "C";
else if (bits.equals("00011"))
return "D";
else if (bits.equals("00100"))
return "E";
else if (bits.equals("00101"))
return "F";
else if (bits.equals("00110"))
return "G";
else if (bits.equals("00111"))
return "H";
else if (bits.equals("01000"))
return "I";
else if (bits.equals("01001"))
return "J";
else if (bits.equals("01010"))
return "K";
else if (bits.equals("01011"))
return "L";
else if (bits.equals("01100"))
return "M";
else if (bits.equals("01101"))
return "N";
else if (bits.equals("01110"))
return "O";
else if (bits.equals("01111"))
return "P";
else if (bits.equals("10000"))
return "Q";
else if (bits.equals("10001"))
return "R";
else if (bits.equals("10010"))
return "S";
else if (bits.equals("10011"))
return "T";
else if (bits.equals("10100"))
return "U";
else if (bits.equals("10101"))
return "V";
else if (bits.equals("10110"))
return "W";
else if (bits.equals("10111"))
return "X";
else if (bits.equals("11000"))
return "Y";
else if (bits.equals("11001"))
return "Z";
else if (bits.equals("11010"))
return " ";
else if (bits.equals("11011"))
return ".";
else if (bits.equals("11100"))
return ",";
else if (bits.equals("11101"))
return "-";
else if (bits.equals("11110"))
return "\'";
else if (bits.equals("11111"))
return "?";
else
return "_INV_";
}
static String code(char c) {
switch (c) {
case ' ':
return "101";
case '\'':
return "000000";
case ',':
return "000011";
case '-':
return "10010001";
case '.':
return "010001";
case '?':
return "000001";
case 'A':
return "100101";
case 'B':
return "10011010";
case 'C':
return "0101";
case 'D':
return "0001";
case 'E':
return "110";
case 'F':
return "01001";
case 'G':
return "10011011";
case 'H':
return "010000";
case 'I':
return "0111";
case 'J':
return "10011000";
case 'K':
return "0110";
case 'L':
return "00100";
case 'M':
return "10011001";
case 'N':
return "10011110";
case 'O':
return "00101";
case 'P':
return "111";
case 'Q':
return "10011111";
case 'R':
return "1000";
case 'S':
return "00110";
case 'T':
return "00111";
case 'U':
return "10011100";
case 'V':
return "10011101";
case 'W':
return "000010";
case 'X':
return "10010010";
case 'Y':
return "10010011";
case 'Z':
return "10010000";
}
return "Err";
}
}
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main {
static int nowLoca = 1;
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
while ((line = br.readLine()) != null) {
if (line.isEmpty())
break;
char[] chrs = line.toCharArray();
String bits = "";
for (char c : chrs) {
bits += code(c);
}
int len = bits.length();
if (len % 5 != 0) {
for (int i = 1; i <= 5 - (len % 5); i++) {
bits += "0";
}
}
String res = "";
for (int i = 0; i < bits.length() / 5; i++) {
String substr = bits.substring(5 * i, 5 * i + 5);
res += code2(substr);
}
System.out.println(res);
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
static String code2(String bits) {
if (bits.equals("00000"))
return "A";
else if (bits.equals("00001"))
return "B";
else if (bits.equals("00010"))
return "C";
else if (bits.equals("00011"))
return "D";
else if (bits.equals("00100"))
return "E";
else if (bits.equals("00101"))
return "F";
else if (bits.equals("00110"))
return "G";
else if (bits.equals("00111"))
return "H";
else if (bits.equals("01000"))
return "I";
else if (bits.equals("01001"))
return "J";
else if (bits.equals("01010"))
return "K";
else if (bits.equals("01011"))
return "L";
else if (bits.equals("01100"))
return "M";
else if (bits.equals("01101"))
return "N";
else if (bits.equals("01110"))
return "O";
else if (bits.equals("01111"))
return "P";
else if (bits.equals("10000"))
return "Q";
else if (bits.equals("10001"))
return "R";
else if (bits.equals("10010"))
return "S";
else if (bits.equals("10011"))
return "T";
else if (bits.equals("10100"))
return "U";
else if (bits.equals("10101"))
return "V";
else if (bits.equals("10110"))
return "W";
else if (bits.equals("10111"))
return "X";
else if (bits.equals("11000"))
return "Y";
else if (bits.equals("11001"))
return "Z";
else if (bits.equals("11010"))
return " ";
else if (bits.equals("11011"))
return ".";
else if (bits.equals("11100"))
return ",";
else if (bits.equals("11101"))
return "-";
else if (bits.equals("11110"))
return "\'";
else if (bits.equals("11111"))
return "?";
else
return "_INV_";
}
static String code(char c) {
switch (c) {
case ' ':
return "101";
case '\'':
return "000000";
case ',':
return "000011";
case '-':
return "10010001";
case '.':
return "010001";
case '?':
return "000001";
case 'A':
return "100101";
case 'B':
return "10011010";
case 'C':
return "0101";
case 'D':
return "0001";
case 'E':
return "110";
case 'F':
return "01001";
case 'G':
return "10011011";
case 'H':
return "010000";
case 'I':
return "0111";
case 'J':
return "10011000";
case 'K':
return "0110";
case 'L':
return "00100";
case 'M':
return "10011001";
case 'N':
return "10011110";
case 'O':
return "00101";
case 'P':
return "111";
case 'Q':
return "10011111";
case 'R':
return "1000";
case 'S':
return "00110";
case 'T':
return "00111";
case 'U':
return "10011100";
case 'V':
return "10011101";
case 'W':
return "000010";
case 'X':
return "10010010";
case 'Y':
return "10010011";
case 'Z':
return "10010000";
}
return "Err";
}
}
|
[["-", 49, 200, 51, 492, 3, 4, 0, 16, 31, 499], ["+", 49, 200, 51, 492, 3, 4, 0, 16, 31, 499], ["-", 51, 492, 3, 4, 0, 16, 31, 16, 31, 499], ["+", 51, 492, 3, 4, 0, 16, 31, 16, 31, 499], ["-", 49, 200, 51, 492, 3, 4, 0, 16, 12, 499], ["+", 49, 200, 51, 492, 3, 4, 0, 16, 12, 499]]
| 3
| 1,086
| 6
|
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
static final HashMap<Character, String> map1 =
new HashMap<Character, String>() {
{
put(' ', "101");
put('\'', "000000");
put(',', "000011");
put('-', "10010001");
put('.', "010001");
put('?', "000001");
put('A', "100101");
put('B', "10011010");
put('C', "0101");
put('D', "0001");
put('E', "110");
put('F', "01001");
put('G', "10011011");
put('H', "010000");
put('I', "0111");
put('J', "10011000");
put('K', "0110");
put('L', "00100");
put('M', "10011001");
put('N', "10011110");
put('O', "00101");
put('P', "111");
put('Q', "10011111");
put('R', "1000");
put('S', "00110");
put('T', "00111");
put('U', "10011100");
put('V', "10011101");
put('W', "000010");
put('X', "10010010");
put('Y', "10010011");
put('Z', "10010000");
}
};
static final HashMap<String, Character> map2 =
new HashMap<String, Character>() {
{
put("00000", 'A');
put("00001", 'B');
put("00010", 'C');
put("00011", 'D');
put("00100", 'E');
put("00101", 'F');
put("00110", 'G');
put("00111", 'H');
put("01000", 'I');
put("01001", 'J');
put("01010", 'K');
put("01011", 'L');
put("01100", 'M');
put("01101", 'N');
put("01110", 'O');
put("01111", 'P');
put("10000", 'Q');
put("10001", 'R');
put("10010", 'S');
put("10011", 'T');
put("10100", 'U');
put("10101", 'V');
put("10110", 'W');
put("10111", 'X');
put("11000", 'Y');
put("11001", 'Z');
put("11010", ' ');
put("11011", '.');
put("11100", ',');
put("11101", '-');
put("11110", '\'');
put("11111", '?');
}
};
public static void main(String[] args) {
FastScanner sc = new FastScanner();
Scanner stdIn = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (stdIn.hasNext()) {
StringBuffer buf = new StringBuffer();
buf.append(stdIn.nextLine());
StringBuffer buf2 = new StringBuffer();
for (int i = 0; i < buf.length(); i++) {
buf2.append(map1.get(buf.charAt(i)));
}
if (buf2.length() % 5 != 5) {
for (int i = buf2.length() % 5; i <= 5; i++) {
buf2.append("0");
}
}
buf = new StringBuffer();
for (int i = 0; i < buf2.length() / 5; i++) {
buf.append(map2.get(buf2.substring(i * 5, (i + 1) * 5)));
}
out.println(buf.toString());
}
out.flush();
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
static final HashMap<Character, String> map1 =
new HashMap<Character, String>() {
{
put(' ', "101");
put('\'', "000000");
put(',', "000011");
put('-', "10010001");
put('.', "010001");
put('?', "000001");
put('A', "100101");
put('B', "10011010");
put('C', "0101");
put('D', "0001");
put('E', "110");
put('F', "01001");
put('G', "10011011");
put('H', "010000");
put('I', "0111");
put('J', "10011000");
put('K', "0110");
put('L', "00100");
put('M', "10011001");
put('N', "10011110");
put('O', "00101");
put('P', "111");
put('Q', "10011111");
put('R', "1000");
put('S', "00110");
put('T', "00111");
put('U', "10011100");
put('V', "10011101");
put('W', "000010");
put('X', "10010010");
put('Y', "10010011");
put('Z', "10010000");
}
};
static final HashMap<String, Character> map2 =
new HashMap<String, Character>() {
{
put("00000", 'A');
put("00001", 'B');
put("00010", 'C');
put("00011", 'D');
put("00100", 'E');
put("00101", 'F');
put("00110", 'G');
put("00111", 'H');
put("01000", 'I');
put("01001", 'J');
put("01010", 'K');
put("01011", 'L');
put("01100", 'M');
put("01101", 'N');
put("01110", 'O');
put("01111", 'P');
put("10000", 'Q');
put("10001", 'R');
put("10010", 'S');
put("10011", 'T');
put("10100", 'U');
put("10101", 'V');
put("10110", 'W');
put("10111", 'X');
put("11000", 'Y');
put("11001", 'Z');
put("11010", ' ');
put("11011", '.');
put("11100", ',');
put("11101", '-');
put("11110", '\'');
put("11111", '?');
}
};
public static void main(String[] args) {
FastScanner sc = new FastScanner();
Scanner stdIn = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (stdIn.hasNext()) {
StringBuffer buf = new StringBuffer();
buf.append(stdIn.nextLine());
StringBuffer buf2 = new StringBuffer();
for (int i = 0; i < buf.length(); i++) {
buf2.append(map1.get(buf.charAt(i)));
}
if (buf2.length() % 5 != 0) {
for (int i = buf2.length() % 5; i <= 5; i++) {
buf2.append("0");
}
}
buf = new StringBuffer();
for (int i = 0; i < buf2.length() / 5; i++) {
buf.append(map2.get(buf2.substring(i * 5, (i + 1) * 5)));
}
out.println(buf.toString());
}
out.flush();
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499]]
| 3
| 1,348
| 2
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
static final HashMap<Character, String> InMap =
new HashMap<Character, String>() {
{
put(' ', "101");
put('\'', "000000");
put(',', "000011");
put('-', "10010001");
put('.', "010001");
put('?', "000001");
put('A', "100101");
put('B', "10011010");
put('C', "0101");
put('D', "0001");
put('E', "110");
put('F', "01001");
put('G', "10011011");
put('H', "010000");
put('I', "0111");
put('J', "10011000");
put('K', "0110");
put('L', "00100");
put('M', "10011001");
put('N', "10011110");
put('O', "00101");
put('P', "111");
put('Q', "10011111");
put('R', "1000");
put('S', "00110");
put('T', "00111");
put('U', "10011100");
put('V', "10011101");
put('W', "000010");
put('X', "10010010");
put('Y', "10010011");
put('Z', "10010000");
}
};
static final HashMap<String, Character> OutMap =
new HashMap<String, Character>() {
{
put("00000", 'A');
put("00001", 'B');
put("00010", 'C');
put("00011", 'D');
put("00100", 'E');
put("00101", 'F');
put("00110", 'G');
put("00111", 'H');
put("01000", 'I');
put("01001", 'J');
put("01010", 'K');
put("01011", 'L');
put("01100", 'M');
put("01101", 'N');
put("01110", 'O');
put("01111", 'P');
put("10000", 'Q');
put("10001", 'R');
put("10010", 'S');
put("10011", 'T');
put("10100", 'U');
put("10101", 'V');
put("10110", 'W');
put("10111", 'X');
put("11000", 'Y');
put("11001", 'Z');
put("11010", ' ');
put("11011", '.');
put("11100", ',');
put("11101", '-');
put("11110", '\'');
put("11111", '?');
}
};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String temp = sc.nextLine(), str = "", ans = "";
char character[] = temp.toCharArray();
for (int i = 0; i < character.length; i++) {
str += InMap.get(character[i]);
}
str += "00000";
// System.out.println(str);
for (int i = 0; i < str.length() - 1; i += 5) {
ans += OutMap.get(str.substring(i, i + 5));
}
System.out.println(ans);
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
static final HashMap<Character, String> InMap =
new HashMap<Character, String>() {
{
put(' ', "101");
put('\'', "000000");
put(',', "000011");
put('-', "10010001");
put('.', "010001");
put('?', "000001");
put('A', "100101");
put('B', "10011010");
put('C', "0101");
put('D', "0001");
put('E', "110");
put('F', "01001");
put('G', "10011011");
put('H', "010000");
put('I', "0111");
put('J', "10011000");
put('K', "0110");
put('L', "00100");
put('M', "10011001");
put('N', "10011110");
put('O', "00101");
put('P', "111");
put('Q', "10011111");
put('R', "1000");
put('S', "00110");
put('T', "00111");
put('U', "10011100");
put('V', "10011101");
put('W', "000010");
put('X', "10010010");
put('Y', "10010011");
put('Z', "10010000");
}
};
static final HashMap<String, Character> OutMap =
new HashMap<String, Character>() {
{
put("00000", 'A');
put("00001", 'B');
put("00010", 'C');
put("00011", 'D');
put("00100", 'E');
put("00101", 'F');
put("00110", 'G');
put("00111", 'H');
put("01000", 'I');
put("01001", 'J');
put("01010", 'K');
put("01011", 'L');
put("01100", 'M');
put("01101", 'N');
put("01110", 'O');
put("01111", 'P');
put("10000", 'Q');
put("10001", 'R');
put("10010", 'S');
put("10011", 'T');
put("10100", 'U');
put("10101", 'V');
put("10110", 'W');
put("10111", 'X');
put("11000", 'Y');
put("11001", 'Z');
put("11010", ' ');
put("11011", '.');
put("11100", ',');
put("11101", '-');
put("11110", '\'');
put("11111", '?');
}
};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String temp = sc.nextLine(), str = "", ans = "";
char character[] = temp.toCharArray();
for (int i = 0; i < character.length; i++) {
str += InMap.get(character[i]);
}
str += "00000";
// System.out.println(str);
for (int i = 0; i < str.length() - 5; i += 5) {
ans += OutMap.get(str.substring(i, i + 5));
}
System.out.println(ans);
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
| 3
| 814
| 2
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
int main() {
ll a, b;
while (cin >> a >> b) {
ll sum = a * b;
printf("15.10lf%\n", sum / 3.305785);
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
int main() {
ll a, b;
while (cin >> a >> b) {
ll sum = a * b;
printf("%15.10lf\n", sum / 3.305785);
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 83
| 2
|
#include <stdio.h>
int main(void) {
int a, b, S;
scanf("%d", &a);
scanf("%d", &b);
S = a * b / 3.305785;
printf("%d\n", S);
return 0;
}
|
#include <stdio.h>
int main(void) {
double a, b, S;
scanf("%lf", &a);
scanf("%lf", &b);
S = a * b / 3.305785;
printf("%lf\n", S);
return 0;
}
|
[["-", 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]]
| 1
| 57
| 8
|
#include <stdio.h>
int main() {
int a, b;
double S;
scanf("%d %d", &a, &b);
S = (double)(a * b / 3.305785);
printf("%lf, S");
return 0;
}
|
#include <stdio.h>
int main() {
int a, b;
double S;
scanf("%d %d", &a, &b);
S = (double)(a * b / 3.305785);
printf("%lf", S);
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
| 1
| 52
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define LL long long
#define ULL unsigned long long
#define ull unsigned long long
#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--)
using namespace std;
int main() {
long double a, b, tmp, ans;
cin >> a >> b;
ans = a * b;
ans /= 3.305785;
printf("%f\n", ans);
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define LL long long
#define ULL unsigned long long
#define ull unsigned long long
#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--)
using namespace std;
int main() {
double a, b, tmp, ans;
cin >> a >> b;
ans = a * b;
ans /= 3.305785;
printf("%f\n", ans);
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 109
| 1
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
// adjust problem by problem
const double EPS = 1e-8;
const double PI = acos(-1.0);
#ifdef __GNUC__
int popcount(int n) { return __builtin_popcount(n); }
int popcount(ll n) { return __builtin_popcountll(n); }
#endif
#ifndef __GNUC__
template <class T> int popcount(T n) {
int cnt = 0;
while (n) {
if (n % 2)
cnt++;
n /= 2;
}
return cnt;
}
#endif
template <class T> int SIZE(T a) { return a.size(); }
template <class T> string IntToString(T num) {
string res;
stringstream ss;
ss << num;
return ss.str();
}
template <class T> T StringToInt(string str) {
T res = 0;
for (int i = 0; i < SIZE(str); i++)
res = (res * 10 + str[i] - '0');
return res;
}
template <class T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void PrintSeq(T &a, int sz) {
for (int i = 0; i < sz; i++) {
cout << a[i];
if (sz == i + 1)
cout << endl;
else
cout << ' ';
}
}
bool EQ(double a, double b) { return abs(a - b) < EPS; }
void fastStream() {
cin.tie(0);
std::ios_base::sync_with_stdio(0);
}
vector<string> split(string str, char del) {
vector<string> res;
for (int i = 0, s = 0; i < SIZE(str); i++) {
if (str[i] == del) {
if (i - s != 0)
res.push_back(str.substr(s, i - s));
s = i + 1;
} else if (i == SIZE(str) - 1) {
res.push_back(str.substr(s));
}
}
return res;
}
int main() {
double a, b;
cin >> a >> b;
printf("%.10f\n", a * b / 3.306785);
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
// adjust problem by problem
const double EPS = 1e-8;
const double PI = acos(-1.0);
#ifdef __GNUC__
int popcount(int n) { return __builtin_popcount(n); }
int popcount(ll n) { return __builtin_popcountll(n); }
#endif
#ifndef __GNUC__
template <class T> int popcount(T n) {
int cnt = 0;
while (n) {
if (n % 2)
cnt++;
n /= 2;
}
return cnt;
}
#endif
template <class T> int SIZE(T a) { return a.size(); }
template <class T> string IntToString(T num) {
string res;
stringstream ss;
ss << num;
return ss.str();
}
template <class T> T StringToInt(string str) {
T res = 0;
for (int i = 0; i < SIZE(str); i++)
res = (res * 10 + str[i] - '0');
return res;
}
template <class T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void PrintSeq(T &a, int sz) {
for (int i = 0; i < sz; i++) {
cout << a[i];
if (sz == i + 1)
cout << endl;
else
cout << ' ';
}
}
bool EQ(double a, double b) { return abs(a - b) < EPS; }
void fastStream() {
cin.tie(0);
std::ios_base::sync_with_stdio(0);
}
vector<string> split(string str, char del) {
vector<string> res;
for (int i = 0, s = 0; i < SIZE(str); i++) {
if (str[i] == del) {
if (i - s != 0)
res.push_back(str.substr(s, i - s));
s = i + 1;
} else if (i == SIZE(str) - 1) {
res.push_back(str.substr(s));
}
}
return res;
}
int main() {
double a, b;
cin >> a >> b;
printf("%.10f\n", a * b / 3.305785);
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 599
| 2
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
printf("%.10lf\n", a * b / 113.437508);
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
printf("%.10f\n", a * b / 3.305785);
return 0;
}
|
[["-", 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, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 42
| 4
|
p eval(gets.split*?*)/3.30578
|
p eval(gets.split*?*)/3.305785
|
[["-", 0, 493, 0, 652, 3, 4, 0, 738, 12, 531], ["+", 0, 493, 0, 652, 3, 4, 0, 738, 12, 531]]
| 4
| 11
| 2
|
a,b = map(float,raw_input().split(' '))
print((a * b) / 3.305785)
|
a,b = map(float,input().split(' '))
print((a * b) / 3.305785)
|
[["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22]]
| 5
| 29
| 2
|
#include <iostream>
using namespace std;
void solve() {
int a, b;
bool init = true;
while (cin >> a >> b, a || b) {
if (!init) {
cout << endl;
}
init = false;
bool ok = false;
for (int i = a; i < b; ++i) {
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
cout << i << endl;
ok = true;
}
}
if (!ok) {
cout << "NA" << endl;
}
}
}
int main() {
solve();
return (0);
}
|
#include <iostream>
using namespace std;
void solve() {
int a, b;
bool init = true;
while (cin >> a >> b, a || b) {
if (!init) {
cout << endl;
}
init = false;
bool ok = false;
for (int i = a; i <= b; ++i) {
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
cout << i << endl;
ok = true;
}
}
if (!ok) {
cout << "NA" << endl;
}
}
}
int main() {
solve();
return (0);
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 136
| 2
|
#include <cstdio>
main() {
int a, b, d = 0, c;
while (scanf("%d%d", &a, &b), a) {
if (d++)
puts("");
c = 0;
for (; a <= b; a++)
if (a % 4 < 1)
if (a % 25)
c++, printf("%d\n", a);
else if (a % 8 < 1)
c++, printf("%d\n", a);
if (!c)
puts("NA");
}
}
|
#include <cstdio>
main() {
int a, b, d = 0, c;
while (scanf("%d%d", &a, &b), a) {
if (d++)
puts("");
c = 0;
for (; a <= b; a++)
if (a % 4 < 1)
if (a % 25)
c++, printf("%d\n", a);
else if (a % 16 < 1)
c++, printf("%d\n", a);
if (!c)
puts("NA");
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
| 1
| 123
| 2
|
#include <cstdio>
main() {
int a, b, d = 0, c;
while (scanf("%d%d", &a, &b), a) {
if (d++)
puts("");
c = 0;
for (; a <= b; a++)
if (a % 4 < 1)
if (a % 25 || a % 16)
c++, printf("%d\n", a);
if (!c)
puts("NA");
}
}
|
#include <cstdio>
main() {
int a, b, d = 0, c;
while (scanf("%d%d", &a, &b), a) {
if (d++)
puts("");
c = 0;
for (; a <= b; a++)
if (a % 4 < 1)
if (a % 25 || a % 16 < 1)
c++, printf("%d\n", a);
if (!c)
puts("NA");
}
}
|
[["+", 64, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 64, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 105
| 20
|
#include <cstdio>
main() {
int a, b, c, d = 0;
while (scanf("%d%d", &a, &b), a) {
d++ &&puts("");
for (c = 0; a <= b; a++)
if (a % 4 < 1 && a % 25 | a % 16)
printf("%d\n", c = a);
!c &&puts("NA");
}
}
|
#include <cstdio>
main() {
int a, b, c, d = 0;
while (scanf("%d%d", &a, &b), a) {
d++ &&puts("");
for (c = 0; a <= b; a++)
if (a % 4 < 1 && a % 25 | a % 16 < 1)
printf("%d\n", c = a);
!c &&puts("NA");
}
}
|
[["+", 15, 339, 51, 16, 12, 16, 12, 16, 17, 18], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 12, 13]]
| 1
| 97
| 2
|
#include <stdio.h>
int main() {
int a, b;
scanf("%d%d", &a, &b);
while (1) {
int i, sum = 0;
for (i = a; i <= b; i++) {
if (i % 400 == 0) {
printf("%d\n", i);
sum++;
} else if (i % 100 == 0) {
continue;
} else if (i % 4 == 0) {
printf("%d\n", i);
sum++;
}
}
if (sum == 0)
printf("NA\n");
sum = 0;
scanf("%d%d", &a, &b);
if (a == 0 && b == 0)
break;
}
return 0;
}
|
#include <stdio.h>
int main() {
int a, b;
scanf("%d%d", &a, &b);
while (1) {
int i, sum = 0;
for (i = a; i <= b; i++) {
if (i % 400 == 0) {
printf("%d\n", i);
sum++;
} else if (i % 100 == 0) {
continue;
} else if (i % 4 == 0) {
printf("%d\n", i);
sum++;
}
}
if (sum == 0)
printf("NA\n");
sum = 0;
scanf("%d%d", &a, &b);
if (a == 0 && b == 0)
break;
printf("\n");
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 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], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 160
| 7
|
#include <iostream>
using namespace std;
void solve() {
int a, b;
bool firstFlag = true;
while (cin >> a >> b) {
if (a == 0 && b == 0) {
break;
}
if (!firstFlag) {
cout << endl;
}
bool existFlag = false;
for (int i = a; i < b; ++i) {
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
cout << i << endl;
existFlag = true;
}
}
if (!existFlag) {
cout << "NA" << endl;
}
firstFlag = false;
}
}
int main() {
solve();
return (0);
}
|
#include <iostream>
using namespace std;
void solve() {
int a, b;
bool firstFlag = true;
while (cin >> a >> b) {
if (a == 0 && b == 0) {
break;
}
if (!firstFlag) {
cout << endl;
}
bool existFlag = false;
for (int i = a; i <= b; ++i) {
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
cout << i << endl;
existFlag = true;
}
}
if (!existFlag) {
cout << "NA" << endl;
}
firstFlag = false;
}
}
int main() {
solve();
return (0);
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 144
| 2
|
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
using namespace std;
int main() {
int a;
int b;
bool first = true;
while (cin >> a >> b, a * b) {
if (first != true) {
cout << endl;
} else {
first = false;
}
bool j = false;
for (int i = a; i < b; i++) {
if (i % 4 == 0) {
if (i % 400 == 0) {
j = true;
cout << i << endl;
} else if (i % 100 == 0) {
} else {
j = true;
cout << i << endl;
}
} else {
}
}
if (j == false)
cout << "NA" << endl;
}
return 0;
}
|
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
using namespace std;
int main() {
int a;
int b;
bool first = true;
while (cin >> a >> b, a * b) {
if (first != true) {
cout << endl;
} else {
first = false;
}
bool j = false;
for (int i = a; i < b + 1; i++) {
if (i % 4 == 0) {
if (i % 400 == 0) {
j = true;
cout << i << endl;
} else if (i % 100 == 0) {
} else {
j = true;
cout << i << endl;
}
} else {
}
}
if (j == false)
cout << "NA" << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 163
| 2
|
#include <iostream>
using namespace std;
int main() {
int a, b;
bool flag = false;
while (cin >> a >> b, a || b) {
int ans = 0;
if (flag)
cout << endl;
for (; a < b; a++) {
if (a % 4 == 0 && (a % 100 != 0 || a % 400 == 0)) {
cout << a << endl;
ans++;
}
}
if (ans == 0)
cout << "NA" << endl;
flag = true;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b;
bool flag = false;
while (cin >> a >> b, a || b) {
int ans = 0;
if (flag)
cout << endl;
for (; a <= b; a++) {
if (a % 4 == 0 && (a % 100 != 0 || a % 400 == 0)) {
cout << a << endl;
ans++;
}
}
if (ans == 0)
cout << "NA" << endl;
flag = true;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 115
| 2
|
#include <stdio.h>
int main() {
int a, b, i, count = 0, s = 0;
while (scanf("%d %d", &a, &b) != 0) {
if (a == 0 || b == 0)
break;
if (s == 1)
printf("\n");
for (i = a; i <= b; i++) {
if (i % 400 == 0) {
printf("%d\n", i);
count = 1;
} else if (i % 100 == 0)
continue;
else if (i % 4 == 0) {
printf("%d\n", i);
count = 1;
}
}
if (count == 0)
printf("NA\n");
s = 1;
}
return 0;
}
|
#include <stdio.h>
int main() {
int a, b, i, count = 0, s = 0;
while (scanf("%d %d", &a, &b) != 0) {
if (a == 0 || b == 0)
break;
if (s == 1)
printf("\n");
for (i = a; i <= b; i++) {
if (i % 400 == 0) {
printf("%d\n", i);
count = 1;
} else if (i % 100 == 0)
continue;
else if (i % 4 == 0) {
printf("%d\n", i);
count = 1;
}
}
if (count == 0)
printf("NA\n");
count = 0;
s = 1;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 163
| 4
|
// include
//------------------------------------------
#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 <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
int main() {
int a, b;
VI y;
cin >> a >> b;
while (1) {
for (int i = a; i < b; i++) {
if (i % 400 == 0)
y.PB(i);
else if (i % 100 == 0)
continue;
else if (i % 4 == 0)
y.PB(i);
}
if (y.empty())
cout << "NA" << endl;
else {
VI::iterator it = y.begin();
while (it != y.end()) {
cout << *it << endl;
it++;
}
}
y.clear();
cin >> a >> b;
if (a + b == 0)
break;
cout << '\n';
}
}
|
// include
//------------------------------------------
#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 <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
int main() {
int a, b;
VI y;
cin >> a >> b;
while (1) {
for (int i = a; i <= b; i++) {
if (i % 400 == 0)
y.PB(i);
else if (i % 100 == 0)
continue;
else if (i % 4 == 0)
y.PB(i);
}
if (y.empty())
cout << "NA" << endl;
else {
VI::iterator it = y.begin();
while (it != y.end()) {
cout << *it << endl;
it++;
}
}
y.clear();
cin >> a >> b;
if (a + b == 0)
break;
cout << '\n';
}
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 438
| 2
|
require 'date'
f=nil;while(a,b=gets.split.map(&:to_i))!=[0,0]do
if f then puts end;f=1
z=a.step(b).select{|i|Date.new(i).leap?}
if z.size==0 then puts'NA'else z.each{|e|p e}end
end
|
require 'date'
f=nil;while(a,b=gets.split.map(&:to_i))!=[0,0]do
if f then puts end;f=1
z=a.step(b).select{|i|Date.leap?(i)}
if z.size==0 then puts'NA'else z.each{|e|p e}end
end
|
[["-", 196, 196, 8, 734, 0, 652, 486, 652, 735, 22], ["+", 12, 652, 196, 196, 8, 734, 0, 652, 735, 22], ["-", 12, 652, 196, 196, 8, 734, 0, 652, 17, 131], ["-", 12, 652, 196, 196, 8, 734, 0, 652, 735, 22]]
| 4
| 87
| 4
|
def isLeap(y):
return y % 4 == 0 and (y != 100 or y == 400)
flag2 = False
while True:
a,b = map(int,input().split())
if a == 0: break
if flag2:print()
flag2 = True
flag = True
for y in range(a,b + 1):
if isLeap(y):
print(y)
flag = False
if(flag):print("NA")
|
def isLeap(y):
return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)
flag2 = False
while True:
a,b = map(int,input().split())
if a == 0: break
if flag2:print()
flag2 = True
flag = True
for y in range(a,b + 1):
if isLeap(y):
print(y)
flag = False
if(flag):print("NA")
|
[["-", 0, 679, 12, 23, 0, 679, 31, 666, 667, 79], ["+", 12, 23, 0, 679, 31, 666, 0, 657, 17, 109], ["+", 0, 679, 12, 23, 0, 679, 31, 666, 667, 79], ["+", 0, 679, 12, 23, 0, 679, 31, 666, 0, 612], ["-", 0, 679, 12, 23, 0, 679, 12, 666, 667, 60], ["+", 12, 23, 0, 679, 12, 666, 0, 657, 17, 109], ["+", 0, 679, 12, 23, 0, 679, 12, 666, 667, 60], ["+", 0, 679, 12, 23, 0, 679, 12, 666, 0, 612]]
| 5
| 98
| 8
|
b=0
for e in iter(input,'0 0'):
if b:print();b=1
s,t=map(int,e.split())
u=[y for y in range(s,t+1)if y%4==0 and y%100!=0 or y%400==0]
if u:
for y in u:print(y)
else:print('NA')
|
b=0
for e in iter(input,'0 0'):
if b:print()
b=1
s,t=map(int,e.split())
u=[y for y in range(s,t+1)if y%4==0 and y%100!=0 or y%400==0]
if u:
for y in u:print(y)
else:print('NA')
|
[["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 35]]
| 5
| 93
| 1
|
b=0
for e in iter(input,'0 0'):
if b:print()
b=u=1
s,t=map(int,e.split())
for y in range(s,t+1):y%4==0 and y%100!=0 or y%400==0 and print(y);u=0
if u:print('NA')
|
b=0
for e in iter(input,'0 0'):
if b:print()
b=u=1
s,t=map(int,e.split())
for y in range(s,t+1):
if y%4==0 and y%100!=0 or y%400==0:print(y);u=0
if u:print('NA')
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 1, 0, 679, 12, 679, 17, 355], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
| 5
| 87
| 9
|
p=print
b=0
for e in iter(input,'0 0'):
if b:p()
b=f=1;s,t=map(int,e.split())
for y in range(s,t+1):
if(y%4==0)*(y%100)or y%400==0:p(y);f=0
if u:p('NA')
|
p=print
b=0
for e in iter(input,'0 0'):
if b:p()
b=f=1;s,t=map(int,e.split())
for y in range(s,t+1):
if(y%4==0)*(y%100)or y%400==0:p(y);f=0
if f:p('NA')
|
[["-", 0, 656, 0, 7, 8, 196, 0, 57, 15, 22], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 15, 22]]
| 5
| 94
| 14
|
p=print
b=0
for e in iter(input,'0 0'):
if b:p()
b=f=1;s,t=map(int,e.split())
for y in range(s,t+1):
if(y%4==0)*(y%100)or y%400==0:p(y);f=0
if u:p('NA')
|
p=print
b=0
for e in iter(input,'0 0'):
if b:p()
b=f=1;s,t=map(int,e.split())
for y in range(s,t+1):
if(y%4==0)*(y%100)or y%400==0:p(y);f=0
f and p('NA')
|
[["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 0, 656, 0, 7, 8, 196, 0, 57, 15, 22], ["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102], ["+", 0, 7, 8, 196, 0, 1, 0, 679, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 679, 17, 355]]
| 5
| 94
| 14
|
ans = []
while True:
a, b = list(map(int, input().split()))
if a + b == 0: break
tmp = []
for i in range(a, b+1):
if i % 4 == 0:
if i % 400 == 0:
tmp.append(i)
elif i % 100 == 0:
continue
else:
tmp.append(i)
if len(tmp) == 0: tmp.append("NA")
ans.append(tmp)
print(ans)
for i in range(len(ans)):
for s in ans[i]:
print(s)
if i != len(ans)-1:
print()
|
ans = []
while True:
a, b = list(map(int, input().split()))
if a + b == 0: break
tmp = []
for i in range(a, b+1):
if i % 4 == 0:
if i % 400 == 0:
tmp.append(i)
elif i % 100 == 0:
continue
else:
tmp.append(i)
if len(tmp) == 0: tmp.append("NA")
ans.append(tmp)
for i in range(len(ans)):
for s in ans[i]:
print(s)
if i != len(ans)-1:
print()
|
[["-", 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
| 148
| 4
|
<?php
fscanf(STDIN, "%f%f", $a, $b);
sprint("%.6f",($a * $b) / 3.305785);
?>
|
<?php
fscanf(STDIN, "%f%f", $a, $b);
print(($a * $b) / 3.305785);
?>
|
[["-", 36, 36, 0, 493, 0, 1, 0, 613, 63, 141], ["+", 36, 36, 0, 493, 0, 1, 0, 619, 0, 620], ["-", 0, 613, 3, 3, 0, 28, 0, 609, 0, 62], ["-", 0, 613, 3, 3, 0, 28, 0, 609, 0, 610], ["-", 0, 493, 0, 1, 0, 613, 3, 3, 0, 21]]
| 6
| 34
| 6
|
#include <stdio.h>
int main(void) {
int a, b;
double S;
scanf("%d %d", &a, &b);
S = a * b * 3.305785;
printf("%lf", S);
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, b;
double S;
scanf("%d %d", &a, &b);
S = a * b / 3.305785;
printf("%lf", S);
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85]]
| 0
| 50
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int[] v = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
v[i] = sc.nextInt();
}
for (int i = 0; i < n - 1; i++) {
for (int j = n - 1; j > i; j--) {
if (a[j - 1] < a[j]) {
int box = v[j - 1];
v[j - 1] = v[j];
v[j] = box;
box = a[j];
a[j] = a[j - 1];
a[j - 1] = box;
}
}
}
for (int i = 0; i < n - 1; i++) {
for (int j = n - 1; j > i; j--) {
if (v[j - 1] < v[j]) {
int box = v[j - 1];
v[j - 1] = v[j];
v[j] = box;
box = a[j];
a[j] = a[j - 1];
a[j - 1] = box;
}
}
}
System.out.println(a[0] + " " + v[0]);
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int[] v = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
v[i] = sc.nextInt();
}
for (int i = 0; i < n - 1; i++) {
for (int j = n - 1; j > i; j--) {
if (a[j - 1] > a[j]) {
int box = v[j - 1];
v[j - 1] = v[j];
v[j] = box;
box = a[j];
a[j] = a[j - 1];
a[j - 1] = box;
}
}
}
for (int i = 0; i < n - 1; i++) {
for (int j = n - 1; j > i; j--) {
if (v[j - 1] < v[j]) {
int box = v[j - 1];
v[j - 1] = v[j];
v[j] = box;
box = a[j];
a[j] = a[j - 1];
a[j - 1] = box;
}
}
}
System.out.println(a[0] + " " + v[0]);
}
}
|
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47]]
| 3
| 343
| 2
|
import java.util.Scanner;
class Main {
Scanner scan = new Scanner(System.in);
public static void main(String args[]) {
Main app = new Main();
while (app.scan.hasNext()) {
int n = Integer.parseInt(app.scan.nextLine());
int[][] entrant = new int[n][2];
app.input(n, entrant);
int index = app.max(n, entrant);
System.out.println(entrant[index][0] + " " + entrant[index][1]);
}
}
public void input(int n, int[][] e) {
String[] splitLine;
for (int i = 0; i < n; i++) {
splitLine = scan.nextLine().split(" ");
e[i][0] = Integer.parseInt(splitLine[0]);
e[i][1] = Integer.parseInt(splitLine[1]);
}
}
public int max(int n, int[][] e) {
int index = 0;
int max = 0;
for (int i = 0; i < n; i++) {
if (e[i][1] > max) {
max = e[i][1];
}
}
for (int i = 0; i < n; i++) {
if (e[i][1] == max) {
if (e[i][0] < e[index][0]) {
index = i;
}
}
}
return index;
}
}
|
import java.util.Scanner;
class Main {
Scanner scan = new Scanner(System.in);
public static void main(String args[]) {
Main app = new Main();
while (app.scan.hasNext()) {
int n = Integer.parseInt(app.scan.nextLine());
int[][] entrant = new int[n][2];
app.input(n, entrant);
int index = app.max(n, entrant);
System.out.println(entrant[index][0] + " " + entrant[index][1]);
}
}
public void input(int n, int[][] e) {
String[] splitLine;
for (int i = 0; i < n; i++) {
splitLine = scan.nextLine().split(" ");
e[i][0] = Integer.parseInt(splitLine[0]);
e[i][1] = Integer.parseInt(splitLine[1]);
}
}
public int max(int n, int[][] e) {
int max = 0;
int index = 0;
for (int i = 0; i < n; i++) {
if (e[i][1] > max) {
max = e[i][1];
index = i;
}
}
for (int i = 0; i < n; i++) {
if (e[i][1] == max) {
if (e[i][0] < e[index][0]) {
index = i;
}
}
}
return index;
}
}
|
[["-", 0, 195, 8, 196, 0, 503, 49, 200, 141, 22], ["+", 0, 195, 8, 196, 0, 503, 49, 200, 141, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
| 3
| 345
| 8
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int max = 101;
int c = 0;
while (n-- > 0) {
int m = sc.nextInt();
int w = sc.nextInt();
if (max < w || max == w && c > m) {
max = w;
c = m;
}
}
System.out.println(c + " " + max);
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int max = -1;
int c = 0;
while (n-- > 0) {
int m = sc.nextInt();
int w = sc.nextInt();
if (max < w || max == w && c > m) {
max = w;
c = m;
}
}
System.out.println(c + " " + max);
}
}
|
[["-", 0, 195, 8, 196, 0, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 503, 49, 200, 51, 91, 17, 33], ["+", 8, 196, 0, 503, 49, 200, 51, 91, 439, 499]]
| 3
| 120
| 3
|
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static int[][] fishingData;
static int n;
public static void main(String[] args) {
while (read()) {
solve();
}
}
static boolean read() {
if (!sc.hasNext())
return false;
n = sc.nextInt();
fishingData = new int[n][2];
for (int i = 0; i < fishingData.length; i++) {
fishingData[i][0] = sc.nextInt();
fishingData[i][1] = sc.nextInt();
}
return true;
}
static void solve() {
int max = -1;
for (int i = 0; i < fishingData.length; i++) {
max = Math.max(max, fishingData[i][1]);
}
int res = -1;
for (int i = 0; i < fishingData.length; i++) {
if (fishingData[i][1] == max) {
res = Math.min(res, fishingData[i][0]);
}
}
System.out.println(res + " " + max);
}
}
|
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static int[][] fishingData;
static int n;
public static void main(String[] args) {
while (read()) {
solve();
}
}
static boolean read() {
if (!sc.hasNext())
return false;
n = sc.nextInt();
fishingData = new int[n][2];
for (int i = 0; i < fishingData.length; i++) {
fishingData[i][0] = sc.nextInt();
fishingData[i][1] = sc.nextInt();
}
return true;
}
static void solve() {
int max = -1;
for (int i = 0; i < fishingData.length; i++) {
max = Math.max(max, fishingData[i][1]);
}
int res = 1 << 29;
for (int i = 0; i < fishingData.length; i++) {
if (fishingData[i][1] == max) {
res = Math.min(res, fishingData[i][0]);
}
}
System.out.println(res + " " + max);
}
}
|
[["-", 8, 196, 0, 503, 49, 200, 51, 91, 17, 33], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 17, 151], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 12, 499]]
| 3
| 265
| 3
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = "";
int[] top = new int[] {21, -1};
// int n = Integer.parseInt(br.readLine());
// int i = 0;
while ((s = br.readLine()) != null) {
// if (i == n)
// break;
Scanner sc = new Scanner(s);
int _angler = sc.nextInt();
int _catch = sc.nextInt();
// if (_angler < 0 || _angler > 20)
// continue;
// if (_catch < 0 || _angler > 100)
// continue;
if (top[1] < _catch || (top[1] == _catch && top[0] > _angler)) {
top[0] = _angler;
top[1] = _catch;
}
// i++;
}
System.out.println(top[0] + " " + top[1]);
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = "";
int[] top = new int[] {21, -1};
br.readLine();
// int n = Integer.parseInt(br.readLine());
// int i = 0;
while ((s = br.readLine()) != null) {
// if (i == n)
// break;
Scanner sc = new Scanner(s);
int _angler = sc.nextInt();
int _catch = sc.nextInt();
// if (_angler < 0 || _angler > 20)
// continue;
// if (_catch < 0 || _angler > 100)
// continue;
if (top[1] < _catch || (top[1] == _catch && top[0] > _angler)) {
top[0] = _angler;
top[1] = _catch;
}
// i++;
}
System.out.println(top[0] + " " + top[1]);
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 492, 500, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 492, 0, 131], ["+", 0, 195, 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, 498, 0, 195, 8, 196, 0, 1, 0, 35]]
| 3
| 198
| 6
|
#include <stdio.h>
int main(void) {
int n;
int i;
int a;
int v;
int a_max = 0;
int v_max = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d %d", &a, &v);
if (v_max <= v) {
v_max = v;
a_max = a;
} else if (v_max == v && a_max > a) {
a_max = a;
}
}
printf("%d %d\n", a_max, v_max);
return (0);
}
|
#include <stdio.h>
int main(void) {
int n;
int i;
int a;
int v;
int a_max = 21;
int v_max = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d %d", &a, &v);
if (v_max < v) {
v_max = v;
a_max = a;
} else if (v_max == v && a_max > a) {
a_max = a;
}
}
printf("%d %d\n", a_max, v_max);
return (0);
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
| 0
| 119
| 4
|
#include <stdio.h>
int main() {
int i, n, ans = 0, num, j;
scanf("%d", &n);
int a, v;
for (i = 0; i < n; i++) {
scanf("%d %d", &a, &v);
if (ans < v) {
ans = v;
num = a;
} else if (ans == v && num < a)
num = a;
}
printf("%d %d\n", num, ans);
return 0;
}
|
#include <stdio.h>
int main() {
int i, n, ans = 0, num, j;
scanf("%d", &n);
int a, v;
for (i = 0; i < n; i++) {
scanf("%d %d", &a, &v);
if (ans < v) {
ans = v;
num = a;
} else if (ans == v && num > a)
num = a;
}
printf("%d %d\n", num, ans);
return 0;
}
|
[["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 47]]
| 0
| 110
| 2
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int max = -1;
int kouho = 0;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
if (max = b && kouho > a) {
kouho = a;
}
if (max < b) {
max = b;
kouho = a;
}
}
cout << kouho << " " << max << endl;
}
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int max = -1;
int kouho = 0;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
if (max == b && kouho > a) {
kouho = a;
}
if (max < b) {
max = b;
kouho = a;
}
}
cout << kouho << " " << max << endl;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60]]
| 1
| 100
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, men, fish, num, fishmax;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> men >> fish;
if (i == 0) {
num = men;
fishmax = fish;
} else {
if (fish > fishmax) {
fishmax = fish;
num = men;
} else if (num > men)
num = men;
}
}
cout << num << " " << fishmax << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, men, fish, num, fishmax;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> men >> fish;
if (i == 0) {
num = men;
fishmax = fish;
} else {
if (fish > fishmax) {
fishmax = fish;
num = men;
} else if (num > men && fish == fishmax)
num = men;
}
}
cout << num << " " << fishmax << endl;
}
|
[["+", 75, 76, 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, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
| 1
| 107
| 4
|
#include <iostream>
using namespace std;
int main() {
int n, max = -1, num = -1, a[20], v[20];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> v[i];
if (max < v[i] && max != v[i]) {
num = a[i];
max = v[i];
} else if (max == v[i] && num > a[i]) {
num = a[i];
}
}
cout << num + 1 << " " << max << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n, max = -1, num = -1, a[20], v[20];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> v[i];
if (max < v[i] && max != v[i]) {
num = a[i];
max = v[i];
} else if (max == v[i] && num > a[i]) {
num = a[i];
}
}
cout << num << " " << max << endl;
return 0;
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 140
| 2
|
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int ansA, ansV;
ansA = 100, ansV = 0;
for (int i = 0; i < n; ++i) {
int a, v;
cin >> a >> v;
if (ansV < v) {
ansA = a;
ansV = v;
} else if (ansA > a) {
ansA = a;
}
}
cout << ansA << " " << ansV << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int ansA, ansV;
ansA = 100, ansV = 0;
for (int i = 0; i < n; ++i) {
int a, v;
cin >> a >> v;
if (ansV < v) {
ansA = a;
ansV = v;
} else if (ansV == v && ansA > a) {
ansA = a;
}
}
cout << ansA << " " << ansV << endl;
}
return 0;
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98]]
| 1
| 107
| 4
|
#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<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PA;
using namespace std;
#define MAX 1000
int main() {
int n;
cin >> n;
PA hoge;
hoge.second = -INF;
int a, b;
rep(i, n) {
cin >> a >> b;
if (b > hoge.second) {
hoge.second = b;
hoge.first = a;
} else if (hoge.second == b || hoge.first > a)
hoge.first = a;
};
cout << hoge.first << " " << hoge.second << endl;
}
|
#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<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PA;
using namespace std;
#define MAX 1000
int main() {
int n;
cin >> n;
PA hoge;
hoge.second = -INF;
int a, b;
rep(i, n) {
cin >> a >> b;
if (b > hoge.second) {
hoge.second = b;
hoge.first = a;
} else if (hoge.second == b && hoge.first > a)
hoge.first = a;
};
cout << hoge.first << " " << hoge.second << endl;
}
|
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98]]
| 1
| 197
| 2
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n;
int x[20];
int y[20] = {};
cin >> n;
for (int i = 0; i < n; i++) {
int a, v;
cin >> a >> v;
x[a - 1] = v;
y[a - 1] = x[a - 1];
}
sort(y, y + 20);
for (int i = 0; i < 20; i++) {
if (y[19] == x[i]) {
cout << (i + 1) << ' ' << x[i] << endl;
}
}
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n;
int x[20];
int y[20] = {};
cin >> n;
for (int i = 0; i < n; i++) {
int a, v;
cin >> a >> v;
x[a - 1] = v;
y[a - 1] = x[a - 1];
}
sort(y, y + n);
for (int i = 0; i < 20; i++) {
if (y[n - 1] == x[i]) {
cout << (i + 1) << ' ' << x[i] << endl;
break;
}
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
| 1
| 147
| 8
|
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, j, k) for (int i = (int)j; i < (int)k; i++)
#define itrep(i, x) for (auto i = (x).begin(); i != (x).end(); i++)
#define Sort(x) sort((x).begin(), (x).end())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int, int> P;
int D = 1;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
using namespace std;
bool comb(pair<int, int> a, pair<int, int> b) {
if (a.first == b.first) {
return a.second > b.second;
} else
return a > b;
}
int main() {
int n;
cin >> n;
vector<pair<int, int>> v(n);
rep(i, 0, n) { cin >> v[i].se >> v[i].fi; }
rep(i, 0, n - 1) {
rep(j, i + 1, n) {
if (v[i].fi > v[j].fi) {
pair<int, int> temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
} else if (v[i].fi == v[j].fi) {
if (v[i].se < v[i].se) {
pair<int, int> temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
}
}
}
}
cout << v[n - 1].se << " " << v[n - 1].fi << endl;
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, j, k) for (int i = (int)j; i < (int)k; i++)
#define itrep(i, x) for (auto i = (x).begin(); i != (x).end(); i++)
#define Sort(x) sort((x).begin(), (x).end())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int, int> P;
int D = 1;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
using namespace std;
bool comb(pair<int, int> a, pair<int, int> b) {
if (a.first == b.first) {
return a.second > b.second;
} else
return a > b;
}
int main() {
int n;
cin >> n;
vector<pair<int, int>> v(n);
rep(i, 0, n) { cin >> v[i].se >> v[i].fi; }
rep(i, 0, n - 1) {
rep(j, i + 1, n) {
if (v[i].fi > v[j].fi) {
pair<int, int> temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
} else if (v[i].fi == v[j].fi) {
if (v[i].se < v[j].se) {
pair<int, int> temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
}
}
}
}
cout << v[n - 1].se << " " << v[n - 1].fi << endl;
return 0;
}
|
[["-", 51, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 118, 28, 69, 341, 342, 0, 22]]
| 1
| 412
| 2
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a = 0, v = 0;
for (int i = 0; i < n; ++i) {
int aa, vv;
cin >> aa >> vv;
if (v < vv) {
a = aa;
v = vv;
} else {
if (aa < a) {
a = aa;
}
}
}
cout << a << " " << v << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a = 1000, v = 0;
for (int i = 0; i < n; ++i) {
int aa, vv;
cin >> aa >> vv;
if (v < vv) {
a = aa;
v = vv;
} else {
if (v == vv && aa < a) {
a = aa;
}
}
}
cout << a << " " << v << endl;
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
| 1
| 101
| 6
|
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
int n, num, w;
pair<int, int> p[20];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> num >> w;
p[i] = make_pair(-w, num);
}
sort(p, p + n);
cout << p[0].second << ' ' << p[0].first << endl;
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
int n, num, w;
pair<int, int> p[20];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> num >> w;
p[i] = make_pair(-w, num);
}
sort(p, p + n);
cout << p[0].second << ' ' << (-1) * p[0].first << endl;
return 0;
}
|
[["+", 0, 16, 31, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 16, 31, 23, 0, 13], ["+", 0, 16, 31, 16, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48]]
| 1
| 106
| 4
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
int p[20] = {};
int a, v;
int max = 0;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a >> v;
p[a] = v;
if (v > max)
max = v;
}
for (int i = 0; i < n; ++i) {
if (p[i] == max) {
cout << i << " " << p[i] << endl;
break;
}
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
int p[20] = {};
int a, v;
int max = 0;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a >> v;
p[a - 1] = v;
if (v > max)
max = v;
}
for (int i = 0; i < n; ++i) {
if (p[i] == max) {
cout << i + 1 << " " << p[i] << endl;
break;
}
}
return 0;
}
|
[["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 126
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#define pb(in, tmp) in.push_back(tmp)
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, b) loop(i, 0, b)
#define all(in) in.begin(), in.end()
using namespace std;
int main() {
int n;
cin >> n;
vector<int> in;
vector<int> no;
rep(i, n) {
int a, b;
cin >> a >> b;
pb(in, b);
pb(no, a);
}
rep(i, 100 * n) {
rep(j, n - 1) {
if (in[j] < in[j + 1]) {
swap(in[j], in[j + 1]);
swap(no[j], no[j + 1]);
}
if (in[j] == in[j + 1] && no[j] < no[j + 1])
swap(no[j], no[j + 1]);
}
}
cout << no[0] << " " << in[0] << endl;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#define pb(in, tmp) in.push_back(tmp)
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, b) loop(i, 0, b)
#define all(in) in.begin(), in.end()
using namespace std;
int main() {
int n;
cin >> n;
vector<int> in;
vector<int> no;
rep(i, n) {
int a, b;
cin >> a >> b;
pb(in, b);
pb(no, a);
}
rep(i, 100 * n) {
rep(j, n - 1) {
if (in[j] < in[j + 1]) {
swap(in[j], in[j + 1]);
swap(no[j], no[j + 1]);
}
if (in[j] == in[j + 1] && no[j] > no[j + 1])
swap(no[j], no[j + 1]);
}
}
cout << no[0] << " " << in[0] << endl;
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47]]
| 1
| 235
| 2
|
gets;p [*$<].max_by{|s|a,b=s.split.map &:to_i;b*100+100-a}
|
gets;puts [*$<].max_by{|s|a,b=s.split.map &:to_i;b*100+100-a}
|
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22]]
| 4
| 33
| 2
|
$<.gets
data = $<.readlines.map {|l| l.split.map(&:to_i)}.sort_by(&:last)
max = data.last.last
num = data.select {|a| a.last == max}.sort(&:first).first.first
puts "#{num} #{max}"
|
$<.gets
data = $<.readlines.map {|l| l.split.map(&:to_i)}.sort_by(&:last)
max = data.last.last
num = data.select {|a| a.last == max}.sort_by(&:first).first.first
puts "#{num} #{max}"
|
[["-", 0, 662, 12, 652, 486, 652, 486, 652, 735, 22], ["+", 0, 662, 12, 652, 486, 652, 486, 652, 735, 22]]
| 4
| 72
| 2
|
a=0;v=-1;
gets.to_i.times do
line=gets
x,y=line.split.map(&:to_i)
if y>v then
a=x;v=y
elsif y=v then
if x<a then
a=x
end
end
end
print a," ",v,"\n"
|
a=0;v=-1;
gets.to_i.times do
line=gets
x,y=line.split.map(&:to_i)
if y>v then
a=x;v=y
elsif y==v then
if x<a then
a=x
end
end
end
print a," ",v,"\n"
|
[["-", 8, 736, 0, 121, 75, 759, 15, 662, 0, 32], ["+", 8, 736, 0, 121, 75, 759, 15, 738, 17, 60]]
| 4
| 71
| 2
|
def main(input = STDIN)
maxv = 0
maxa = 1 / 0.0
input.gets.to_i.times do
a, v = input.gets.split(" ").map(&:to_i)
maxv, maxa = v, a if maxv < v or (maxv == v and maxa <= a)
end
puts "#{maxa} #{maxv}"
end
main
|
def main(input = STDIN)
maxv = 0
maxa = 1 / 0.0
input.gets.to_i.times do
a, v = input.gets.split(" ").map(&:to_i)
maxv, maxa = v, a if maxv < v or (maxv == v and maxa > a)
end
puts "#{maxa} #{maxv}"
end
main
|
[["-", 15, 738, 12, 739, 0, 738, 12, 738, 17, 19], ["+", 15, 738, 12, 739, 0, 738, 12, 738, 17, 47]]
| 4
| 77
| 2
|
l = []
gets.to_i.times { l << gets.split.map(&:to_i) }
puts l.sort_by{ |v| [-v[1], v[0]] }.join(" ")
|
l = []
gets.to_i.times { l << gets.split.map(&:to_i) }
puts l.sort_by{ |v| [-v[1], v[0]] }[0].join(" ")
|
[["+", 0, 652, 3, 4, 0, 652, 486, 742, 0, 70], ["+", 0, 652, 3, 4, 0, 652, 486, 742, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 486, 742, 0, 73]]
| 4
| 50
| 3
|
n=eval(input())
a0,v0=n,0
for i in range(n):
a,v=list(map(int,input().split()))
if v>v0: a0,v0=a,v
elif v==v0: a0=min(a0,a)
print(a,v)
|
n=eval(input())
a0,v0=n,0
for i in range(n):
a,v=list(map(int,input().split()))
if v>v0: a0,v0=a,v
elif v==v0: a0=min(a0,a)
print(a0,v0)
|
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
| 5
| 73
| 4
|
n=eval(input())
x=[0]*n
for i in range(n):
a,v=list(map(int,input().split()))
x[a-1]=v
m=max(x)
print(x.index(m),m)
|
n=eval(input())
x=[0]*n
for i in range(n):
a,v=list(map(int,input().split()))
x[a-1]=v
m=max(x)
print(x.index(m)+1,m)
|
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
| 5
| 67
| 2
|
a = [0] * 20
v = [0] * 20
a_v = []
for i in range(int(input())):
a[i],v[i] = list(map(int, input().split()))
a_v.append([a[i], v[i]])
a_v.sort()
ans2 = max(v)
for i in a_v:
if i[1] == ans2:
ans1 = i[0]
print("{} {}".format(ans1, ans2))
|
a = [0] * 20
v = [0] * 20
a_v = []
for i in range(int(input())):
a[i],v[i] = list(map(int, input().split()))
a_v.append([a[i], v[i]])
a_v.sort()
ans2 = max(v)
for i in a_v:
if i[1] == ans2:
ans1 = i[0]
break
print("{} {}".format(ans1, ans2))
|
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
| 5
| 115
| 1
|
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main(void) {
ll dp[4][4001];
fill_n(*dp, 4 * 4001, 0);
//????????????
rep(i, 4001) dp[0][i] = 1;
for (int i = 1; i <= 3; i++) {
for (int j = 4000; j >= 0; j--) {
for (int k = 0; k <= 1000; k++) {
if (j - k < 0)
break;
dp[i][j] += dp[i - 1][j - k];
}
}
}
int n;
while (cin >> n)
FIN(dp[3][n]);
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main(void) {
ll dp[4][4001];
fill_n(*dp, 4 * 4001, 0);
//????????????
rep(i, 1001) dp[0][i] = 1;
for (int i = 1; i <= 3; i++) {
for (int j = 4000; j >= 0; j--) {
for (int k = 0; k <= 1000; k++) {
if (j - k < 0)
break;
dp[i][j] += dp[i - 1][j - k];
}
}
}
int n;
while (cin >> n)
FIN(dp[3][n]);
return 0;
}
|
[["-", 31, 69, 28, 69, 28, 2, 3, 4, 0, 13], ["+", 31, 69, 28, 69, 28, 2, 3, 4, 0, 13]]
| 1
| 273
| 27
|
#include <iostream>
using namespace std;
int x[100][4000], n;
int main() {
x[0][0] = 1;
for (int i = 1; i < 10; i++) {
for (int j = 0; j < 4000; j++) {
for (int k = 0; k <= 1000; k++) {
x[i][j + k] += x[i - 1][j];
}
}
}
int n;
while (cin >> n) {
cout << x[4][n];
}
}
|
#include <iostream>
using namespace std;
int x[100][4001], n;
int main() {
x[0][0] = 1;
for (int i = 1; i < 10; i++) {
for (int j = 0; j < 4000; j++) {
for (int k = 0; k <= 1000; k++) {
x[i][j + k] += x[i - 1][j];
}
}
}
int n;
while (cin >> n) {
cout << x[4][n] << endl;
}
}
|
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 122
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
long long int dp[5][4001];
int main(void) {
for (int i = 0; i <= 1000; i++)
dp[1][i] = 1;
for (int i = 2; i < 5; i++) {
for (int j = 0; j <= 1000 * i; j++) {
for (int k = 0; k <= 1000 * i; k++) {
if (j + k > 4000)
continue;
dp[i][j + k] += dp[i - 1][j];
}
}
}
int n;
while (cin >> n) {
cout << dp[4][n] << endl;
}
return 0;
}
// EOF
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
long long int dp[5][4001];
int main(void) {
for (int i = 0; i <= 1000; i++)
dp[1][i] = 1;
for (int i = 2; i < 5; i++) {
for (int j = 0; j <= 1000 * i; j++) {
for (int k = 0; k <= 1000; k++) {
if (j + k > 4000)
continue;
dp[i][j + k] += dp[i - 1][j];
}
}
}
int n;
while (cin >> n) {
cout << dp[4][n] << endl;
}
return 0;
}
// EOF
|
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 48], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
| 1
| 186
| 2
|
#include <iostream>
using namespace std;
int main() {
int dp[4][5000] = {};
for (int i = 0; i <= 1000; i++)
dp[1][i] = 1;
for (int i = 1; i <= 2; i++)
for (int j = 0; j <= 1000 * i; j++)
for (int k = 0; k <= 1000 * i; k++)
dp[i * 2][j + k] += dp[i][j] * dp[i][k];
for (int n; cin >> n;)
cout << dp[4][n] << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int dp[8][5000] = {};
for (int i = 0; i <= 1000; i++)
dp[1][i] = 1;
for (int i = 1; i <= 2; i++)
for (int j = 0; j <= 1000 * i; j++)
for (int k = 0; k <= 1000 * i; k++)
dp[i * 2][j + k] += dp[i][j] * dp[i][k];
for (int n; cin >> n;)
cout << dp[4][n] << endl;
return 0;
}
|
[["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13]]
| 1
| 147
| 2
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define COUNT(i, n) for (int i = 1; i <= n; i++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for (ITER(c) it = (c).begin(); it != (c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
const int INF = 1 << 24;
const int N = 4001;
const int M = 1001;
int dp[5][N];
int main(void) {
rep(i, 5) fill(dp[i], dp[i] + N, 0);
dp[0][0] = 1;
COUNT(i, 4)
rep(j, N) if (dp[i - 1][j]) rep(k, M) dp[i][j + k] += dp[i - 1][j];
for (int n; cin >> n; cout << dp[n] << endl)
;
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define COUNT(i, n) for (int i = 1; i <= n; i++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for (ITER(c) it = (c).begin(); it != (c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
const int INF = 1 << 24;
const int N = 4001;
const int M = 1001;
int dp[5][N];
int main(void) {
rep(i, 5) fill(dp[i], dp[i] + N, 0);
dp[0][0] = 1;
COUNT(i, 4)
rep(j, N) if (dp[i - 1][j]) rep(k, M) dp[i][j + k] += dp[i - 1][j];
for (int n; cin >> n; cout << dp[4][n] << endl)
;
return 0;
}
|
[["+", 31, 16, 12, 69, 28, 69, 341, 342, 0, 13], ["+", 31, 16, 12, 69, 28, 69, 341, 342, 0, 73], ["+", 26, 16, 31, 16, 12, 69, 341, 342, 0, 70]]
| 1
| 253
| 3
|
n=1001
a=list(range(1,n))
a+=[n]+a[::-1]
for n in map(int,sys.stdin):
x=0
for i in range(max(0,n-2000),min(n,2000)+1):
x+=a[i]*a[n-i]
print(x)
|
import sys
n=1001
a=list(range(1,n))
a+=[n]+a[::-1]
for n in map(int,sys.stdin):
x=0
for i in range(max(0,n-2000),min(n,2000)+1):
x+=a[i]*a[n-i]
print(x)
|
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
| 5
| 83
| 2
|
import sys
def N(n):
return (n+1)*(n+2)*(n+3)/6
for n in sys.stdin:
n = int(input())
if n > 2000:
n = 4000 - n
if n < 1001:
print(N(n))
else:
m = n - 1000
print(N(n) - (N(2*m) - m - 1)/2)
|
import sys
def N(n):
return (n+1)*(n+2)*(n+3)/6
for n in sys.stdin:
n = int(n)
if n > 2000:
n = 4000 - n
if n < 1001:
print(N(n))
else:
m = n - 1000
print(N(n) - (N(2*m) - m - 1)/2)
|
[["-", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
| 5
| 94
| 4
|
#include <cstdio>
using namespace std;
typedef long long lint;
int main() {
int n, s;
lint dp[10][1000] = {0};
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 1000; j >= 0; j--) {
for (int k = 9; k >= 1; k--) {
if (j - i >= 0)
dp[k][j] += dp[k - 1][j - i];
}
}
}
while (scanf("%d %d", &n, &s) && s) {
printf("%lld\n", dp[n][s]);
}
return (0);
}
|
#include <cstdio>
using namespace std;
typedef long long lint;
int main() {
int n, s;
lint dp[10][1000] = {0};
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 1000; j >= 0; j--) {
for (int k = 9; k >= 1; k--) {
if (j - i >= 0)
dp[k][j] += dp[k - 1][j - i];
}
}
}
while (scanf("%d %d", &n, &s) && n) {
printf("%lld\n", dp[n][s]);
}
return (0);
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
| 1
| 161
| 2
|
#include <cstring>
#include <iostream>
using namespace std;
int main() {
long long int dp[11][1001];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 9; j >= 0; j--) {
for (int k = 0; i + k <= 1000; k++) {
dp[j + 1][i + k] += dp[j][k];
}
}
}
int n, s;
while (cin >> n >> s, n && s)
cout << dp[n][s] << endl;
}
|
#include <cstring>
#include <iostream>
using namespace std;
int main() {
long long int dp[11][1001];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 9; j >= 0; j--) {
for (int k = 0; i + k <= 1000; k++) {
dp[j + 1][i + k] += dp[j][k];
}
}
}
int n, s;
while (cin >> n >> s, n || s)
cout << dp[n][s] << endl;
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
| 1
| 146
| 2
|
#include <bits/stdc++.h>
using namespace std;
#define reps(i, f, n) for (int i = f; i < int(n); i++)
#define rep(i, n) reps(i, 0, n)
typedef long long ll;
int n, s;
bool input() {
cin >> n >> s;
return n != 0;
}
const int N = 101;
const int M = 10;
const int K = 1001;
ll memo[N][M][K];
ll saiki(int st, int rn, int rs) {
if (memo[st][rn][rs] != -1)
return memo[st][rn][rs];
if (rn == 0) {
if (rs == 0)
return 1;
return 0;
}
ll ret = 0;
reps(i, st, N) {
if (rs - i < 0)
break;
ret += saiki(i + 1, rn - 1, rs - i);
}
// printf("st=%d rn=%d rs=%d ret=%d\n",st,rn,rs,ret);
return memo[st][rn][rs] = ret;
}
ll solve() {
rep(i, N) rep(j, M) rep(k, K) memo[i][j][k] = -1;
return saiki(0, n, s);
}
int main() {
while (input()) {
cout << solve() << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define reps(i, f, n) for (int i = f; i < int(n); i++)
#define rep(i, n) reps(i, 0, n)
typedef long long ll;
int n, s;
bool input() {
cin >> n >> s;
return n != 0;
}
const int N = 101;
const int M = 10;
const int K = 1001;
ll memo[N + 10][M][K];
ll saiki(int st, int rn, int rs) {
if (memo[st][rn][rs] != -1)
return memo[st][rn][rs];
if (rn == 0) {
if (rs == 0)
return 1;
return 0;
}
ll ret = 0;
reps(i, st, N) {
if (rs - i < 0)
break;
ret += saiki(i + 1, rn - 1, rs - i);
}
// printf("st=%d rn=%d rs=%d ret=%d\n",st,rn,rs,ret);
return memo[st][rn][rs] = ret;
}
ll solve() {
rep(i, N + 10) rep(j, M) rep(k, K) memo[i][j][k] = -1;
return saiki(0, n, s);
}
int main() {
while (input()) {
cout << solve() << endl;
}
}
|
[["+", 49, 80, 49, 80, 49, 80, 81, 16, 17, 72], ["+", 49, 80, 49, 80, 49, 80, 81, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
| 1
| 268
| 6
|
#include <cmath>
#include <iostream>
#define N 100
#define S 1000
using namespace std;
int main() {
int n, s;
long long int soi[N][S + 1] = {};
soi[1][0] = 1;
for (int i = 1; i <= 9; i++) {
for (int j = i; j > 0; j--) {
for (int k = 0; k <= S; k++) {
if (soi[j][k] != 0) {
soi[j + 1][k + i] += soi[j][k];
}
}
}
soi[1][i] = 1;
}
while (1) {
cin >> n >> s;
if (n == 0 && s == 0)
break;
cout << soi[n][s] << endl;
}
return 0;
}
|
#include <cmath>
#include <iostream>
#define N 100
#define S 1000
using namespace std;
int main() {
int n, s;
long long int soi[10][S + 1] = {};
soi[1][0] = 1;
for (int i = 1; i <= N; i++) {
for (int j = 8; j > 0; j--) {
for (int k = 0; k <= S; k++) {
if (soi[j][k] != 0) {
soi[j + 1][k + i] += soi[j][k];
}
}
}
soi[1][i] = 1;
}
while (1) {
cin >> n >> s;
if (n == 0 && s == 0)
break;
cout << soi[n][s] << endl;
}
return 0;
}
|
[["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 22], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
| 1
| 182
| 6
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
int main() {
lld dp[10][1001];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 8; j >= 0; j--) {
for (int k = 0; k <= 1000; k++) {
if (k + i > 1000)
continue;
dp[j + 1][k + i] += dp[j][k];
}
}
}
int n, s;
while (cin >> n >> s, n, s) {
cout << dp[n][s] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
int main() {
lld dp[10][1001];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 8; j >= 0; j--) {
for (int k = 0; k <= 1000; k++) {
if (k + i > 1000)
continue;
dp[j + 1][k + i] += dp[j][k];
}
}
}
int n, s;
while (cin >> n >> s, n || s) {
cout << dp[n][s] << endl;
}
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
| 1
| 158
| 2
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
int n, s;
lld dp[10][111][1111];
lld solve(int idx, int now, int sum) {
if (idx == n) {
if (sum == s)
return 1;
else
return 0;
}
if (dp[idx][now][sum] != -1)
return dp[idx][now][sum];
lld ret = 0;
for (int i = now; i <= 100; i++) {
if (sum + i > s)
break;
ret += solve(idx + 1, i + 1, sum + i);
}
return dp[idx][now][sum] = ret;
}
int main() {
while (cin >> n >> s, n, s) {
memset(dp, -1, sizeof(dp));
cout << solve(0, 0, 0) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
int n, s;
lld dp[10][111][1111];
lld solve(int idx, int now, int sum) {
if (idx == n) {
if (sum == s)
return 1;
else
return 0;
}
if (dp[idx][now][sum] != -1)
return dp[idx][now][sum];
lld ret = 0;
for (int i = now; i <= 100; i++) {
if (sum + i > s)
break;
ret += solve(idx + 1, i + 1, sum + i);
}
return dp[idx][now][sum] = ret;
}
int main() {
while (cin >> n >> s, n || s) {
memset(dp, -1, sizeof(dp));
cout << solve(0, 0, 0) << endl;
}
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
| 1
| 198
| 2
|
#include "bits/stdc++.h"
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define INF 999999999
int main() {
int dp[11][1100] = {};
dp[0][0] = 1;
for (int i = 1; i <= 10; i++) { //????????????????????\??????
for (int j = 10; j >= 1; j--) {
rep(k, 1000 + 1) {
if (k - (i - 1) >= 0) {
dp[j][k] += dp[j - 1][k - (i - 1)];
// cout<<"dp["<<j<<"]["<<k<<"]="<<dp[j][k]<<endl;
}
}
}
}
int n, s;
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
cout << dp[n][s] << endl;
}
}
|
#include "bits/stdc++.h"
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define INF 999999999
int main() {
ll dp[11][1100] = {};
dp[0][0] = 1;
for (
int i = 1; i <= 101;
i++) { //テ」ツδォテ」ツδシテ」ツδ療」ツ?ョテ、ツクツュテ」ツ?ォテ・ツ?・テ」ツつ古」ツつ?
for (int j = 10; j >= 1; j--) {
rep(k, 1000 + 1) {
if (k - (i - 1) >= 0) {
dp[j][k] += dp[j - 1][k - (i - 1)];
// cout<<"dp["<<j<<"]["<<k<<"]="<<dp[j][k]<<endl;
}
}
}
}
int n, s;
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
cout << dp[n][s] << endl;
}
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 205
| 4
|
#include <iostream>
#include <map>
#include <string>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;
long long dp[20][1200][200];
long long f(int n, int s, int next) {
if (n == 0 && s == 0)
return 1;
if (n < 0 || s < 0)
return 0;
if (next > s)
return 0;
if (dp[n][s][next] != -1) {
return dp[n][s][next];
}
long long res = 0;
loop(i, next, s + 1) { res += f(n - 1, s - i, i + 1); }
return dp[n][s][next] = res;
}
int main() {
int n, k;
while (cin >> n >> k, n || k) {
rep(i, 20) rep(j, 1200) rep(l, 200) dp[i][j][l] = -1;
cout << f(n, k, 0) << endl;
}
return 0;
}
|
#include <iostream>
#include <map>
#include <string>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;
long long dp[20][1200][200];
long long f(int n, int s, int next) {
if (n == 0 && s == 0)
return 1;
if (n < 0 || s < 0)
return 0;
if (next > s)
return 0;
if (dp[n][s][next] != -1) {
return dp[n][s][next];
}
long long res = 0;
loop(i, next, 101) { res += f(n - 1, s - i, i + 1); }
return dp[n][s][next] = res;
}
int main() {
int n, k;
while (cin >> n >> k, n || k) {
rep(i, 20) rep(j, 1200) rep(l, 200) dp[i][j][l] = -1;
cout << f(n, k, 0) << endl;
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
| 1
| 242
| 4
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = a; i >= n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).X, (b).X) && EQ((a).Y, (b).Y))
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int const MOD = 1000000007;
namespace std {
bool operator<(const P a, const P b) {
return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}
} // namespace std
int main() {
int dp[10][1010];
dp[0][0] = 1;
rep(k, 0, 101) repr(i, 8, 0) rep(j, 0, 1001 - k) {
dp[i + 1][j + k] += dp[i][j];
}
int n, s;
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
cout << dp[n][s] << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = a; i >= n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).X, (b).X) && EQ((a).Y, (b).Y))
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int const MOD = 1000000007;
namespace std {
bool operator<(const P a, const P b) {
return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}
} // namespace std
int main() {
ll dp[11][1010];
dp[0][0] = 1;
rep(k, 0, 101) repr(i, 9, 0) rep(j, 0, 1001 - k) {
dp[i + 1][j + k] += dp[i][j];
}
int n, s;
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
cout << dp[n][s] << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
| 1
| 366
| 6
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[110][10][1010];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, s;
while (cin >> n >> s, n + s) {
memset(dp, 0, sizeof dp);
dp[0][0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; k <= s; k++) {
if (dp[i][j][k] == 0)
continue;
dp[i + 1][j][k] += dp[i][j][k];
if (k + i <= s) {
dp[i + 1][j + 1][k + i] += dp[i][j][k];
}
}
}
}
cout << dp[101][n][s] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[110][15][1010];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, s;
while (cin >> n >> s, n | s) {
memset(dp, 0, sizeof dp);
dp[0][0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; k <= s; k++) {
if (dp[i][j][k] == 0)
continue;
dp[i + 1][j][k] += dp[i][j][k];
if (k + i <= s) {
dp[i + 1][j + 1][k + i] += dp[i][j][k];
}
}
}
}
cout << dp[101][n][s] << endl;
}
}
|
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 72], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 139]]
| 1
| 227
| 4
|
#include <iostream>
using namespace std;
typedef long long int ll;
ll dp[102][10][1001];
int main() {
int n, s;
while (cin >> n >> s, n || s) {
for (int i = 0; i < 102; i++) {
for (int j = 0; j < 10; j++) {
for (int k = 0; k < 1001; k++) {
dp[i][j][k] = 0;
}
}
}
dp[0][0][0] = 1;
for (int i = 0; i < 102; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; k <= s; k++) {
dp[i + 1][j][k] += dp[i][j][k];
if (k + i > s)
continue;
dp[i + 1][j + 1][k + i] += dp[i][j][k];
}
}
}
cout << dp[101][n][s] << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
typedef long long int ll;
ll dp[102][11][1001];
int main() {
int n, s;
while (cin >> n >> s, n || s) {
for (int i = 0; i < 102; i++) {
for (int j = 0; j < 11; j++) {
for (int k = 0; k < 1001; k++) {
dp[i][j][k] = 0;
}
}
}
dp[0][0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; k <= s; k++) {
dp[i + 1][j][k] += dp[i][j][k];
if (k + i > s)
continue;
dp[i + 1][j + 1][k + i] += dp[i][j][k];
}
}
}
cout << dp[101][n][s] << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 251
| 8
|
#include <iostream>
using namespace std;
typedef long long ll;
// dp[n][s] := n個の数字を使って合計がsのときの組合せ数
ll dp[10][1010] = {0};
int main() {
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 1000; j >= 0; j--) {
for (int k = 9; k >= 1; k--) {
if (j - i >= 0) {
dp[k][j] += dp[k - 1][j - i];
}
}
}
}
int n, s;
while (cin >> n >> s) {
cout << dp[n][s] << endl;
}
}
|
#include <iostream>
using namespace std;
typedef long long ll;
// dp[n][s] := n個の数字を使って合計がsのときの組合せ数
ll dp[10][1010] = {0};
int main() {
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 1000; j >= 0; j--) {
for (int k = 9; k >= 1; k--) {
if (j - i >= 0) {
dp[k][j] += dp[k - 1][j - i];
}
}
}
}
int n, s;
while (cin >> n >> s, n || s) {
cout << dp[n][s] << endl;
}
}
|
[["+", 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, 106], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]]
| 1
| 146
| 4
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int dp[11][1010]; // dp[i][j] := i個からjを作る組み合わせの数
int main() {
for (int i = 0; i < 10; i++)
for (int j = 0; j <= 1000; j++)
dp[i][j] = 0;
dp[1][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 9; j >= 0; j--) {
for (int k = 0; k <= 1000; k++) {
if (dp[j][k] == 0)
continue;
if (k + i > 1000)
continue;
dp[j + 1][k + i] += dp[j][k];
}
}
}
int n, s;
while (cin >> n >> s, n | s)
cout << dp[n][s] << endl;
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
long long dp[11][1010]; // dp[i][j] := i個からjを作る組み合わせの数
int main() {
for (int i = 0; i < 10; i++)
for (int j = 0; j <= 1000; j++)
dp[i][j] = 0;
dp[0][0] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 9; j >= 0; j--) {
for (int k = 0; k <= 1000; k++) {
if (dp[j][k] == 0)
continue;
if (k + i > 1000)
continue;
dp[j + 1][k + i] += dp[j][k];
}
}
}
int n, s;
while (cin >> n >> s, n | s)
cout << dp[n][s] << endl;
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 13]]
| 1
| 200
| 5
|
#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>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))
template <typename T> void FILL_(void *ptr, size_t size, T value) {
std::fill((T *)ptr, (T *)ptr + size, value);
}
// 4方向ベクトル→↑←↓
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int n; //使う個数
int s; //求める和
int ans;
int dp[10][1010]; // dp[n][s]sをn個の整数で表すときの組み合わせ
int main() {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i < 101; i++) {
for (int j = 1000; j > -1; j--) {
for (int k = 9; k > 0; k--) {
if (j - i >= 0) {
dp[k][j] += dp[k - 1][j - i];
}
}
}
}
while (cin >> n >> s) {
cout << dp[n][s] << endl;
}
return 0;
}
|
#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>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))
template <typename T> void FILL_(void *ptr, size_t size, T value) {
std::fill((T *)ptr, (T *)ptr + size, value);
}
// 4方向ベクトル→↑←↓
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int n; //使う個数
int s; //求める和
int ans;
long long int dp[10][1010]; // dp[n][s]sをn個の整数で表すときの組み合わせ
int main() {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i < 101; i++) {
for (int j = 1000; j > -1; j--) {
for (int k = 9; k > 0; k--) {
if (j - i >= 0) {
dp[k][j] += dp[k - 1][j - i];
}
}
}
}
while (cin >> n >> s, n || s) {
cout << dp[n][s] << endl;
}
return 0;
}
|
[["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 0, 52, 15, 339, 51, 34, 31, 16, 12, 22], ["+", 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, 106]]
| 1
| 310
| 6
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
typedef pair<int, int> Pii;
typedef vector<int> vi;
int main() {
ll dp[10][10000] = {{0}};
dp[0][0] = 1;
rep(i, 101) {
for (int j = 1000; j >= 0; j--) {
for (int k = 9; k > 0; k--) {
dp[k][j] += dp[k - 1][j - i];
}
}
}
int n, s;
while (scanf("%d%d", &n, &s), (n | s)) {
printf("%d\n", dp[n][s]);
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
typedef pair<int, int> Pii;
typedef vector<int> vi;
int main() {
ll dp[10][10000] = {{0}};
dp[0][0] = 1;
rep(i, 101) {
for (int j = 1000; j >= i; j--) {
for (int k = 9; k > 0; k--) {
dp[k][j] += dp[k - 1][j - i];
}
}
}
int n, s;
while (scanf("%d%d", &n, &s), (n | s)) {
printf("%lld\n", dp[n][s]);
}
return 0;
}
|
[["-", 8, 9, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 265
| 4
|
#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>
using namespace std;
#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));
#define for_(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define for_d(i, a, b) for (int i = (int)a - 1; i >= b; i--)
#define for_r(i, a, b, c) for (int i = (int)a; i < (int)b; i += c)
#define for_dr(i, a, b, c) for (int i = (int)a - 1; i >= b; i -= c)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
template <class T> int __builtin_popcount(T n) {
return n ? 1 + __builtin_popcount(n & (n - 1)) : 0;
}
typedef long long ll;
typedef double D;
const int iINF = 2147483647;
const ll lINF = 9223372036854775807;
template <class T> inline void dbg(T t) { cout << t << endl; }
ll dp[110][15][2000];
void make() {
dp[0][0][0] = 1;
for_(t, 0, 101) {
for_(i, 0, 9) {
for_(s, 0, 1000) {
dp[t + 1][i][s] += dp[t][i][s];
dp[t + 1][i + 1][s + t] += dp[t][i][s];
}
}
}
}
int main() {
int n, s;
minit(dp, 0);
make();
while (1) {
cin >> n >> s;
if (n == 0 && s == 0)
break;
cout << dp[101][n][s] << endl;
}
return 0;
}
|
#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>
using namespace std;
#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));
#define for_(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define for_d(i, a, b) for (int i = (int)a - 1; i >= b; i--)
#define for_r(i, a, b, c) for (int i = (int)a; i < (int)b; i += c)
#define for_dr(i, a, b, c) for (int i = (int)a - 1; i >= b; i -= c)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
template <class T> int __builtin_popcount(T n) {
return n ? 1 + __builtin_popcount(n & (n - 1)) : 0;
}
typedef long long ll;
typedef double D;
const int iINF = 2147483647;
const ll lINF = 9223372036854775807;
template <class T> inline void dbg(T t) { cout << t << endl; }
ll dp[110][15][2000];
void make() {
dp[0][0][0] = 1;
for_(t, 0, 101) {
for_(i, 0, 10) {
for_(s, 0, 1000) {
dp[t + 1][i][s] += dp[t][i][s];
dp[t + 1][i + 1][s + t] += dp[t][i][s];
}
}
}
}
int main() {
int n, s;
minit(dp, 0);
make();
while (1) {
cin >> n >> s;
if (n == 0 && s == 0)
break;
cout << dp[101][n][s] << endl;
}
return 0;
}
|
[["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
| 1
| 378
| 2
|
L = 100
@memo = Array.new(9) {Array.new(101) {[]}}
def solve(num, start, sum)
return 0 if sum <= 0 or start > L
return (sum <= L) ? 1 : 0 if num == 1
a = @memo[num - 1][start][sum]
return a if a
co = 0
lim = [L, (2 * sum - num ** 2 + num) / (2 * num)].min
(start..lim).each do |i|
co += solve(num - 1, i + 1, sum - i)
end
@memo[num - 1][start][sum] = co
end
until (a = $<.gets.split.map(&:to_i)) == [0, 0]
puts solve(a.first, 0, a.last)
end
|
L = 100
@memo = Array.new(9) {Array.new(101) {[]}}
def solve(num, start, sum)
return 0 if sum < 0 or start > L
return (start <= sum and sum <= L) ? 1 : 0 if num == 1
a = @memo[num - 1][start][sum]
return a if a
co = 0
lim = [L, (2 * sum - num ** 2 + num) / (2 * num)].min
(start..lim).each do |i|
co += solve(num - 1, i + 1, sum - i)
end
@memo[num - 1][start][sum] = co
end
until (a = $<.gets.split.map(&:to_i)) == [0, 0]
puts solve(a.first, 0, a.last)
end
|
[["-", 8, 736, 0, 751, 15, 738, 31, 738, 17, 19], ["+", 8, 736, 0, 751, 15, 738, 31, 738, 17, 18], ["+", 0, 754, 15, 739, 0, 738, 31, 738, 31, 22], ["+", 0, 754, 15, 739, 0, 738, 31, 738, 17, 19], ["+", 0, 754, 15, 739, 0, 738, 31, 738, 12, 22], ["+", 0, 4, 0, 754, 15, 739, 0, 738, 17, 355]]
| 4
| 181
| 6
|
dp = 11.times.map{ [0]*1001 }
dp[0][0] = 1
(1..100).each do |i|
9.downto(0) do |j|
(0..1000).each do |k|
break if k+i > 1000
dp[j+1][k+i] += dp[j][k]
end
end
end
loop do
n, s = gets.split.map(&:to_i)
break if n == 0
p dp[n][s]
end
|
dp = 11.times.map{ [0]*1001 }
dp[0][0] = 1
(0..100).each do |i|
9.downto(0) do |j|
(0..1000).each do |k|
break if k+i > 1000
dp[j+1][k+i] += dp[j][k]
end
end
end
loop do
n, s = gets.split.map(&:to_i)
break if n == 0
p dp[n][s]
end
|
[["-", 0, 493, 0, 652, 486, 739, 0, 475, 756, 612], ["+", 0, 493, 0, 652, 486, 739, 0, 475, 756, 612]]
| 4
| 113
| 2
|
dp = Array.new(10){ Array.new(1001) {0} }
dp[0][0] = 1
0.upto(100) do |i|
1000.downto(0) do |j|
9.downto(1) do |k|
dp[k][j] += dp[k-1][j-i] if j-i>=0
end
end
end
while gets do
n, s = $_.split(' ').map(&:to_i)
break if n == 0 or s == 0
puts dp[n][s]
end
|
dp = Array.new(10){ Array.new(1001) {0} }
dp[0][0] = 1
0.upto(100) do |i|
1000.downto(0) do |j|
9.downto(1) do |k|
dp[k][j] += dp[k-1][j-i] if j-i>=0
end
end
end
while gets do
n, s = $_.split(' ').map(&:to_i)
break if n == 0 and s == 0
puts dp[n][s]
end
|
[["-", 0, 89, 8, 170, 0, 751, 15, 738, 17, 354], ["+", 0, 89, 8, 170, 0, 751, 15, 738, 17, 355]]
| 4
| 125
| 2
|
m=1001
A=list(range(9))
d=[[0]*m for i in A]
for i in range(101):
for j in A[:-1][::-1]:
for k in range(m-i): d[j][k+i]+=d[j-1][k]
d[0][i]=1
while True:
n,s=list(map(int,input().split()))
if n==s==0: break
print(d[n-1][s])
|
m=1001
A=list(range(9))
d=[[0]*m for i in A]
for i in range(101):
for j in A[1:][::-1]:
for k in range(m-i): d[j][k+i]+=d[j-1][k]
d[0][i]=1
while True:
n,s=list(map(int,input().split()))
if n==s==0: break
print(d[n-1][s])
|
[["-", 0, 7, 12, 206, 51, 206, 206, 663, 0, 102], ["-", 12, 206, 51, 206, 206, 663, 0, 664, 17, 33], ["+", 0, 7, 12, 206, 51, 206, 206, 663, 0, 102]]
| 5
| 129
| 3
|
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n = arr.shift() - 0;
var yx = [];
var zero = [];
for (var i = 0; i < n + 1; i++)
zero.push(0);
yx.push(zero);
for (var i = 0; i < n; i++)
yx.push(("0 " + arr.shift()).split(" ").map(Number));
n = n + 1;
var sum = [];
for (var i = 0; i < n; i++) {
sum[i] = [];
sum[i][0] = yx[i][0];
}
for (var i = 0; i < n; i++) {
for (var j = 1; j < n; j++) {
sum[i][j] = sum[i][j - 1] + yx[i][j];
}
}
for (var i = 1; i < n; i++) {
for (var j = 0; j < n; j++) {
sum[i][j] = sum[i - 1][j] + sum[i][j];
}
}
var max = -Infinity;
for (var i = 0; i < n; i++) {
for (var j = 0; j < n; j++) {
for (var y = i + 1; y < n; y++) {
for (var x = j + 1; x < n; x++) {
var S = sum[y][x] - sum[i][x] - sum[y][j] + sum[i][j];
if (max > S)
max = S;
}
}
}
}
console.log(max);
|
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n = arr.shift() - 0;
var yx = [];
var zero = [];
for (var i = 0; i < n + 1; i++)
zero.push(0);
yx.push(zero);
for (var i = 0; i < n; i++)
yx.push(("0 " + arr.shift()).split(" ").map(Number));
n = n + 1;
var sum = [];
for (var i = 0; i < n; i++) {
sum[i] = [];
sum[i][0] = yx[i][0];
}
for (var i = 0; i < n; i++) {
for (var j = 1; j < n; j++) {
sum[i][j] = sum[i][j - 1] + yx[i][j];
}
}
for (var i = 1; i < n; i++) {
for (var j = 0; j < n; j++) {
sum[i][j] = sum[i - 1][j] + sum[i][j];
}
}
var max = -Infinity;
for (var i = 0; i < n; i++) {
for (var j = 0; j < n; j++) {
for (var y = i + 1; y < n; y++) {
for (var x = j + 1; x < n; x++) {
var S = sum[y][x] - sum[i][x] - sum[y][j] + sum[i][j];
if (max < S)
max = S;
}
}
}
}
console.log(max);
|
[["-", 8, 556, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 556, 0, 57, 15, 23, 0, 16, 17, 18]]
| 2
| 427
| 2
|
import java.util.Scanner;
// Maximum Sum Sequence II
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] a = new int[n + 1][n + 1];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
int x = sc.nextInt();
a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + x;
}
int res = Integer.MIN_VALUE;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
for (int y = 1; y <= n; y++)
for (int x = 1; x <= n; x++)
res = Math.max(res, a[i][j] - a[y - 1][j] - a[i][x - 1] +
a[y - 1][x - 1]);
System.out.println(res);
}
public static void main(String[] args) { new Main().run(); }
}
|
import java.util.Scanner;
// Maximum Sum Sequence II
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] a = new int[n + 1][n + 1];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
int x = sc.nextInt();
a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + x;
}
int res = Integer.MIN_VALUE;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
for (int y = 1; y <= i; y++)
for (int x = 1; x <= j; x++)
res = Math.max(res, a[i][j] - a[y - 1][j] - a[i][x - 1] +
a[y - 1][x - 1]);
System.out.println(res);
}
public static void main(String[] args) { new Main().run(); }
}
|
[["-", 0, 7, 8, 7, 8, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 7, 8, 7, 15, 16, 12, 22], ["-", 8, 7, 8, 7, 8, 7, 15, 16, 12, 22], ["+", 8, 7, 8, 7, 8, 7, 15, 16, 12, 22]]
| 3
| 282
| 4
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] map = new int[n + 1][n + 1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
map[i][j] =
sc.nextInt() + map[i - 1][j] + map[i][j - 1] - map[i - 1][j - 1];
}
}
int max = map[1][1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
for (int l = 1; l <= n; l++) {
max = Math.max(max, map[k][l] + map[i - 1][j - 1] - map[i - 1][l] -
map[k][j - 1]);
}
}
}
}
System.out.println(max);
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] map = new int[n + 1][n + 1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
map[i][j] =
sc.nextInt() + map[i - 1][j] + map[i][j - 1] - map[i - 1][j - 1];
}
}
int max = map[1][1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
for (int k = i; k <= n; k++) {
for (int l = j; l <= n; l++) {
max = Math.max(max, map[k][l] + map[i - 1][j - 1] - map[i - 1][l] -
map[k][j - 1]);
}
}
}
}
System.out.println(max);
}
}
|
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 22]]
| 3
| 275
| 4
|
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int res = Integer.MIN_VALUE;
int[][] mat = new int[n][n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
mat[i][j] = sc.nextInt();
}
}
int[][] sum = new int[n][n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int k = 0; k <= i; ++k) {
for (int l = 0; l <= j; ++l) {
sum[i][j] += mat[k][l];
}
}
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int k = i + 1; k < n; ++k) {
for (int l = j + 1; l < n; ++l) {
int A = 0, B = 0, C = sum[k][l], D = 0;
if (i - 1 >= 0) {
A = sum[i - 1][l];
if (j > 0)
D = sum[i - 1][j - 1];
}
if (j - 1 >= 0) {
B = sum[k][j - 1];
if (i > 0)
D = sum[i - 1][j - 1];
}
int csum = C + D - A - B;
if (csum > res)
res = csum;
}
}
}
}
System.out.println(res);
}
}
|
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int res = Integer.MIN_VALUE;
int[][] mat = new int[n][n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
mat[i][j] = sc.nextInt();
}
}
int[][] sum = new int[n][n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int k = 0; k <= i; ++k) {
for (int l = 0; l <= j; ++l) {
sum[i][j] += mat[k][l];
}
}
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int k = i; k < n; ++k) {
for (int l = j; l < n; ++l) {
int A = 0, B = 0, C = sum[k][l], D = 0;
if (i - 1 >= 0) {
A = sum[i - 1][l];
if (j > 0)
D = sum[i - 1][j - 1];
}
if (j - 1 >= 0) {
B = sum[k][j - 1];
if (i > 0)
D = sum[i - 1][j - 1];
}
int csum = C + D - A - B;
if (csum > res)
res = csum;
}
}
}
}
System.out.println(res);
}
}
|
[["-", 0, 7, 502, 503, 49, 200, 51, 16, 17, 72], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499]]
| 3
| 413
| 4
|
#include <climits>
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
// 要素
int a[100][100] = {};
// 要素の横方向の累積和を取る
int sum[101][101] = {};
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
sum[i][j + 1] += sum[i][j] + a[i][j];
}
}
// 横方向の区間[i,j]を固定し、縦方向に動かして部分行列の和の最大値を取る
int ans = INT_MIN;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
int tmp = 0;
// 行kを0~nまで動かして最大値を探す
// tmpが負になった時点でtmpをリセットしてしまって良い
// (1つ前のループでtmpをmax関数に通しているので問題ない)
for (int k = 0; k < n; k++) {
if (tmp < 0) {
tmp = sum[k][j] - sum[k][i];
} else {
tmp += sum[k][j] - sum[k][i];
}
ans = max(ans, tmp);
}
}
}
cout << ans << endl;
return 0;
}
|
#include <climits>
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
// 要素
int a[100][100] = {};
// 要素の横方向の累積和を取る
int sum[101][101] = {};
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
sum[i][j + 1] += sum[i][j] + a[i][j];
}
}
// 横方向の区間[i,j]を固定し、縦方向に動かして部分行列の和の最大値を取る
int ans = INT_MIN;
for (int i = 0; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
int tmp = 0;
// 行kを0~nまで動かして最大値を探す
// tmpが負になった時点でtmpをリセットしてしまって良い
// (1つ前のループでtmpをmax関数に通しているので問題ない)
for (int k = 0; k < n; k++) {
if (tmp < 0) {
tmp = sum[k][j] - sum[k][i];
} else {
tmp += sum[k][j] - sum[k][i];
}
ans = max(ans, tmp);
}
}
}
cout << ans << endl;
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
| 1
| 274
| 4
|
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < ((int)b); ++i)
#define RFOR(i, a) for (int i = (a); i >= 0; --i)
#define FOE(i, a) for (auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef long long LL;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = std::vector<std::vector<T>>;
template <typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template <class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template <class T> inline void print(T x) { std::cout << x << std::endl; }
template <class T> inline void print_vec(const std::vector<T> &v) {
for (int i = 0; i < v.size(); ++i) {
if (i != 0) {
std::cout << " ";
}
std::cout << v[i];
}
std::cout << "\n";
}
template <class T> inline bool inside(T y, T x, T H, T W) {
return 0 <= y and y < H and 0 <= x and x < W;
}
template <class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
template <class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) {
return abs(x1 - x2) + abs(y1 - y2);
}
const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = {0, 1, 0, -1},
dx4 = {1, 0, -1, 0}; // 4近傍(右, 下, 左, 上)
const std::vector<int> dy8 = {0, -1, 0, 1, 1, -1, -1, 1},
dx8 = {1, 0, -1, 0, 1, 1, -1, -1};
using namespace std;
class CumulativeSum {
public:
std::vector<long long> memo1; // 1次元用の累積和表
std::vector<std::vector<long long>> memo2; // 2次元用の累積和表
CumulativeSum() {}
void build(const std::vector<long long> &line) {
this->memo1.assign(line.size() + 1, 0);
for (long long i = 0; i < line.size(); ++i) {
this->memo1[i + 1] = this->memo1[i] + line[i];
}
}
// 2次元の累積和表を作成
void build(const std::vector<std::vector<long long>> &board) {
int height = board.size();
int width = board[0].size();
this->memo2.assign(height + 1, std::vector<long long>(width + 1, 0));
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
memo2[y + 1][x + 1] = board[y][x] + memo2[y + 1][x];
}
for (int x = 0; x < width; ++x) {
memo2[y + 1][x + 1] += memo2[y][x + 1];
}
}
}
long long sum(int left, int right) {
return this->memo1[right] - this->memo1[left];
}
/*
(y1, x1)から(y2, x2)の合計を返す.(y2, x2)は含まない
座標はmemoを作成したboard準拠
(ex, sum(0, 0, 2, 2)なら(0, 0), (0, 1), (1, 0), (1, 1)の合計を返す)
*/
long long sum(int y1, int x1, int y2, int x2) {
return this->memo2[y2][x2] - this->memo2[y2][x1] - this->memo2[y1][x2] +
this->memo2[y1][x1];
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<vector<LL>> f(N, vector<LL>(N));
FOR(i, 0, N) {
FOR(j, 0, N) { cin >> f[i][j]; }
}
CumulativeSum cs;
cs.build(f);
LL ans = -INF;
FOR(y1, 0, N) {
FOR(y2, y1 + 1, N) {
FOR(x1, 0, N) {
FOR(x2, x1 + 1, N) { ans = max(ans, cs.sum(y1, x1, y2 + 1, x2 + 1)); }
}
}
}
print(ans);
return 0;
}
|
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < ((int)b); ++i)
#define RFOR(i, a) for (int i = (a); i >= 0; --i)
#define FOE(i, a) for (auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef long long LL;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = std::vector<std::vector<T>>;
template <typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template <class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template <class T> inline void print(T x) { std::cout << x << std::endl; }
template <class T> inline void print_vec(const std::vector<T> &v) {
for (int i = 0; i < v.size(); ++i) {
if (i != 0) {
std::cout << " ";
}
std::cout << v[i];
}
std::cout << "\n";
}
template <class T> inline bool inside(T y, T x, T H, T W) {
return 0 <= y and y < H and 0 <= x and x < W;
}
template <class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
template <class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) {
return abs(x1 - x2) + abs(y1 - y2);
}
const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = {0, 1, 0, -1},
dx4 = {1, 0, -1, 0}; // 4近傍(右, 下, 左, 上)
const std::vector<int> dy8 = {0, -1, 0, 1, 1, -1, -1, 1},
dx8 = {1, 0, -1, 0, 1, 1, -1, -1};
using namespace std;
class CumulativeSum {
public:
std::vector<long long> memo1; // 1次元用の累積和表
std::vector<std::vector<long long>> memo2; // 2次元用の累積和表
CumulativeSum() {}
void build(const std::vector<long long> &line) {
this->memo1.assign(line.size() + 1, 0);
for (long long i = 0; i < line.size(); ++i) {
this->memo1[i + 1] = this->memo1[i] + line[i];
}
}
// 2次元の累積和表を作成
void build(const std::vector<std::vector<long long>> &board) {
int height = board.size();
int width = board[0].size();
this->memo2.assign(height + 1, std::vector<long long>(width + 1, 0));
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
memo2[y + 1][x + 1] = board[y][x] + memo2[y + 1][x];
}
for (int x = 0; x < width; ++x) {
memo2[y + 1][x + 1] += memo2[y][x + 1];
}
}
}
long long sum(int left, int right) {
return this->memo1[right] - this->memo1[left];
}
/*
(y1, x1)から(y2, x2)の合計を返す.(y2, x2)は含まない
座標はmemoを作成したboard準拠
(ex, sum(0, 0, 2, 2)なら(0, 0), (0, 1), (1, 0), (1, 1)の合計を返す)
*/
long long sum(int y1, int x1, int y2, int x2) {
return this->memo2[y2][x2] - this->memo2[y2][x1] - this->memo2[y1][x2] +
this->memo2[y1][x1];
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<vector<LL>> f(N, vector<LL>(N));
FOR(i, 0, N) {
FOR(j, 0, N) { cin >> f[i][j]; }
}
CumulativeSum cs;
cs.build(f);
LL ans = -INF;
FOR(y1, 0, N) {
FOR(y2, y1, N) {
FOR(x1, 0, N) {
FOR(x2, x1, N) { ans = max(ans, cs.sum(y1, x1, y2 + 1, x2 + 1)); }
}
}
}
print(ans);
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
| 1
| 1,072
| 6
|
/*
∧_∧ やあ
(´・ω・`) / ようこそ、バーボンハウスへ。
/∇y:::::\
[ ̄] このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
|:⊃:|:::::| |──|
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄| うん、「また」なんだ。済まない。
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄| ̄
仏の顔もって言うしね、謝って許してもらおうとも思っていない。
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄/|
∇ ∇ ∇ ∇ /./| でも、この提出を見たとき、君は、きっと言葉では言い表せない
┴ ┴ ┴ ┴ / /
| 「ときめき」みたいなものを感じてくれたと思う。
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|/
| 殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | そう思って、この提出を投げたんだ。
(⊆⊇) (⊆⊇) (⊆⊇) |
|| || || | じゃあ、判定を聞こうか。
./|\ /|\ /|\
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) \
cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) \
cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y \
<< ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
lint a[n + 1][n + 1];
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= n; ++j) {
a[i][j] = 0;
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
a[i][j] = a[i][j - 1] + a[i][j];
}
}
for (int j = 1; j <= n; ++j) {
for (int i = 1; i <= n; ++i) {
a[i][j] = a[i - 1][j] + a[i][j];
}
}
lint ans = -INF;
lint sum;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
for (int ii = 1; ii <= n; ++ii) {
for (int jj = 1; jj <= n; ++jj) {
sum = a[ii][jj] - a[ii][j - 1] - a[i - 1][jj] + a[i - 1][j - 1];
ans = max(ans, sum);
}
}
}
}
cout << ans << endl;
return 0;
}
|
/*
∧_∧ やあ
(´・ω・`) / ようこそ、バーボンハウスへ。
/∇y:::::\
[ ̄] このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
|:⊃:|:::::| |──|
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄| うん、「また」なんだ。済まない。
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄| ̄
仏の顔もって言うしね、謝って許してもらおうとも思っていない。
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄/|
∇ ∇ ∇ ∇ /./| でも、この提出を見たとき、君は、きっと言葉では言い表せない
┴ ┴ ┴ ┴ / /
| 「ときめき」みたいなものを感じてくれたと思う。
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|/
| 殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | そう思って、この提出を投げたんだ。
(⊆⊇) (⊆⊇) (⊆⊇) |
|| || || | じゃあ、判定を聞こうか。
./|\ /|\ /|\
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) \
cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) \
cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y \
<< ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
lint a[n + 1][n + 1];
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= n; ++j) {
a[i][j] = 0;
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
a[i][j] = a[i][j - 1] + a[i][j];
}
}
for (int j = 1; j <= n; ++j) {
for (int i = 1; i <= n; ++i) {
a[i][j] = a[i - 1][j] + a[i][j];
}
}
lint ans = -INF;
lint sum;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
for (int ii = i; ii <= n; ++ii) {
for (int jj = j; jj <= n; ++jj) {
sum = a[ii][jj] - a[ii][j - 1] - a[i - 1][jj] + a[i - 1][j - 1];
ans = max(ans, sum);
}
}
}
}
cout << ans << endl;
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22]]
| 1
| 548
| 4
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[110][110];
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
cin >> a[i][j];
}
long long sum[110][110];
for (int i = 0; i < n; i++) {
sum[i + 1][0] = 0;
for (int j = 0; j < n; j++)
sum[i + 1][j + 1] = sum[i + 1][j] + a[i][j];
}
for (int i = 0; i <= n; i++) {
sum[0][i] = 0;
for (int j = 0; j < n; j++)
sum[j + 1][i] += sum[j][i];
}
long long res = -1e15;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int ii = 0; ii < i; ii++) {
for (int jj = 0; jj < j; jj++) {
res = max(res, sum[i + 1][j + 1] - sum[i + 1][jj] - sum[ii][j + 1] +
sum[ii][jj]);
}
}
}
}
cout << res << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[110][110];
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
cin >> a[i][j];
}
long long sum[110][110];
for (int i = 0; i < n; i++) {
sum[i + 1][0] = 0;
for (int j = 0; j < n; j++)
sum[i + 1][j + 1] = sum[i + 1][j] + a[i][j];
}
for (int i = 0; i <= n; i++) {
sum[0][i] = 0;
for (int j = 0; j < n; j++)
sum[j + 1][i] += sum[j][i];
}
long long res = -1e15;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int ii = 0; ii <= i; ii++) {
for (int jj = 0; jj <= j; jj++) {
res = max(res, sum[i + 1][j + 1] - sum[i + 1][jj] - sum[ii][j + 1] +
sum[ii][jj]);
}
}
}
}
cout << res << endl;
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 330
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.