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
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var num = ToInt64(ReadLine());
var dig = num.ToString().Length;
var max = (dig - 1) * 9 + (ToInt32(num.ToString().Substring(0, 1)) - 1);
for (var i = 0; i <= 10; i++) {
var s = num.ToString();
var sum = 0;
for (var j = 0; j < s.Length; j++) {
sum += ToInt32(s.Substring(j, 1));
}
max = Max(max, sum);
num--;
}
WriteLine(max);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var num = ToInt64(ReadLine());
var dig = num.ToString().Length;
var max = (dig - 1) * 9 + (ToInt32(num.ToString().Substring(0, 1)) - 1);
for (var i = 0; i <= 10; i++) {
var s = num.ToString();
var sum = 0;
for (var j = 0; j < s.Length; j++) {
sum += ToInt32(s.Substring(j, 1));
}
max = Max(max, sum);
num--;
if (num == 0)
break;
}
WriteLine(max);
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 35]]
| 8
| 179
| 8
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = ReadLine();
WriteLine((int.Parse(N[0].ToString()) - 1) + ((N.Length - 1) * 9));
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = ReadLine();
var first = int.Parse(N[0].ToString());
first -= (N.Skip(1).Any(c => c != '9')) ? 1 : 0;
WriteLine(first + ((N.Length - 1) * 9));
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
[["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 1, 0, 11, 12, 41, 15, 23, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 12, 41, 15, 23, 0, 213, 63, 214, 0, 131], ["+", 12, 41, 15, 23, 0, 213, 63, 214, 141, 22], ["+", 12, 41, 15, 23, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 79], ["+", 0, 28, 0, 218, 8, 16, 12, 252, 0, 104], ["+", 0, 28, 0, 218, 8, 16, 12, 252, 0, 253], ["+", 12, 41, 15, 23, 0, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 41, 15, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 75, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22]]
| 8
| 459
| 35
|
using System;
using System.Collections.Generic;
namespace Competitive {
internal class Program {
public static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
List<int> digits = new List<int>();
while (N > 0) {
digits.Add(N % 10);
N /= 10;
}
bool flag = true;
for (int i = 0; i < digits.Count - 1; i++) {
if (digits[i] != 9)
flag = false;
}
int ret = 0;
for (int i = 0; i < digits.Count - 1; i++) {
ret += 9;
}
ret += digits[digits.Count - 1];
if (!flag)
ret -= 1;
Console.WriteLine(ret);
}
}
}
|
using System;
using System.Collections.Generic;
namespace Competitive {
internal class Program {
public static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
var digits = new List<int>();
while (N > 0) {
int n = (int)(N % 10);
digits.Add(n);
N /= 10;
}
bool flag = true;
for (int i = 0; i < digits.Count - 1; i++) {
if (digits[i] != 9)
flag = false;
}
int ret = 0;
for (int i = 0; i < digits.Count - 1; i++) {
ret += 9;
}
ret += digits[digits.Count - 1];
if (!flag)
ret -= 1;
Console.WriteLine(ret);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 74, 51, 23, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 174
| 25
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] x = new int[n], y = new int[n];
for (int i = 0; i < n; i++) {
string[] pos = Console.ReadLine().Split(' ');
x[i] = int.Parse(pos[0]);
y[i] = int.Parse(pos[1]);
}
for (int i = 0; i < n; i++) {
int[] v1 = new int[] { x[i] - x[(i + 1) % n], y[i] - y[(i + 1) % n] };
double max = 0, min = 0;
for (int j = 2; j < n; j++) {
int[] v2 = new int[] { x[i] - x[(i + j) % n], y[i] - y[(i + j) % n] };
double theta = Math.Acos((v1[0] * v2[0] + v1[1] * v2[1]) /
(Math.Sqrt(v1[0] * v1[0] + v1[1] * v1[1]) *
Math.Sqrt(v2[0] * v2[0] + v2[1] * v2[1])));
if (v1[0] * v2[1] - v1[1] * v2[0] < 0)
theta *= -1;
// Console.Error.WriteLine(v1[0] + " " + v1[1] + " " + v2[0] + " " +
// v2[1] + " " + theta);
if (theta > max)
max = theta;
if (theta < min)
min = theta;
}
if (max - min > Math.PI * 0.99999)
Console.WriteLine(0);
else
Console.WriteLine((Math.PI - max + min) / (2 * Math.PI));
}
}
}
// mcs Main.cs
// mono Main.exe
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
long[] x = new long[n], y = new long[n];
for (int i = 0; i < n; i++) {
string[] pos = Console.ReadLine().Split(' ');
x[i] = int.Parse(pos[0]);
y[i] = int.Parse(pos[1]);
}
for (int i = 0; i < n; i++) {
long[] v1 = new long[] { x[i] - x[(i + 1) % n], y[i] - y[(i + 1) % n] };
double max = 0, min = 0;
for (int j = 2; j < n; j++) {
long[] v2 = new long[] { x[i] - x[(i + j) % n], y[i] - y[(i + j) % n] };
double theta = Math.Acos((v1[0] * v2[0] + v1[1] * v2[1]) /
(Math.Sqrt(v1[0] * v1[0] + v1[1] * v1[1]) *
Math.Sqrt(v2[0] * v2[0] + v2[1] * v2[1])));
if (v1[0] * v2[1] - v1[1] * v2[0] < 0)
theta *= -1;
// Console.Error.WriteLine(v1[0] + " " + v1[1] + " " + v2[0] + " " +
// v2[1] + " " + theta);
if (theta > max)
max = theta;
if (theta < min)
min = theta;
}
if (max - min > Math.PI * 0.99999)
Console.WriteLine(0);
else
Console.WriteLine((Math.PI - max + min) / (2 * Math.PI));
}
}
}
// mcs Main.cs
// mono Main.exe
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199]]
| 8
| 427
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC021B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int num = 100000;
double[] max = new double[num];
double[] min = new double[num];
int[] maxNum = new int[num];
int[] minNum = new int[num];
double[] stdx = new double[num];
double[] stdy = new double[num];
int l = 0;
for (int i = 0; i < num; i++) {
stdx[i] = Math.Cos(i / (double)num * Math.PI);
stdy[i] = Math.Sin(i / (double)num * Math.PI);
}
int[] xs = new int[N];
int[] ys = new int[N];
for (int i = 0; i < N; i++) {
int[] input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
xs[i] = input[0];
ys[i] = input[1];
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < num; j++) {
double p = xs[i] * stdx[j] + ys[i] * stdy[j];
if (p < min[j]) {
min[j] = p;
minNum[j] = i;
} else if (p == min[j]) {
int k = minNum[j];
double dis1 = Math.Pow(xs[i], 2) + Math.Pow(ys[i], 2);
double dis2 = Math.Pow(xs[k], 2) + Math.Pow(ys[k], 2);
if (dis1 < dis2) {
minNum[j] = i;
}
}
if (p > max[j]) {
max[j] = p;
maxNum[j] = i;
} else if (p == max[j]) {
int k = maxNum[j];
double dis1 = Math.Pow(xs[i], 2) + Math.Pow(ys[i], 2);
double dis2 = Math.Pow(xs[k], 2) + Math.Pow(ys[k], 2);
if (dis1 < dis2) {
maxNum[j] = i;
}
}
}
}
double[] P = new double[N];
for (int i = 0; i < num; i++) {
P[maxNum[i]]++;
P[minNum[i]]++;
}
for (int i = 0; i < N; i++) {
P[i] = P[i] / (num * 2);
Console.WriteLine(P[i]);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC021B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int num = 50000;
// double[] max = new double[num];
// double[] min = new double[num];
double[] max = Enumerable.Repeat(-100000000.0, num).ToArray();
double[] min = Enumerable.Repeat(100000000.0, num).ToArray();
int[] maxNum = new int[num];
int[] minNum = new int[num];
double[] stdx = new double[num];
double[] stdy = new double[num];
int l = 0;
for (int i = 0; i < num; i++) {
stdx[i] = Math.Cos(i / (double)num * Math.PI);
stdy[i] = Math.Sin(i / (double)num * Math.PI);
}
int[] xs = new int[N];
int[] ys = new int[N];
for (int i = 0; i < N; i++) {
int[] input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
xs[i] = input[0];
ys[i] = input[1];
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < num; j++) {
double p = xs[i] * stdx[j] + ys[i] * stdy[j];
if (p < min[j]) {
min[j] = p;
minNum[j] = i;
} else if (p == min[j]) {
int k = minNum[j];
double dis1 = Math.Pow(xs[i], 2) + Math.Pow(ys[i], 2);
double dis2 = Math.Pow(xs[k], 2) + Math.Pow(ys[k], 2);
if (dis1 < dis2) {
minNum[j] = i;
}
}
if (p > max[j]) {
max[j] = p;
maxNum[j] = i;
} else if (p == max[j]) {
int k = maxNum[j];
double dis1 = Math.Pow(xs[i], 2) + Math.Pow(ys[i], 2);
double dis2 = Math.Pow(xs[k], 2) + Math.Pow(ys[k], 2);
if (dis1 < dis2) {
maxNum[j] = i;
}
}
}
}
double[] P = new double[N];
for (int i = 0; i < num; i++) {
P[maxNum[i]]++;
P[minNum[i]]++;
}
for (int i = 0; i < N; i++) {
P[i] = P[i] / (num * 2);
Console.WriteLine(P[i]);
}
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 3, 4, 0, 28, 0, 241, 0, 33], ["+", 205, 213, 3, 4, 0, 28, 0, 241, 0, 250], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 250]]
| 8
| 656
| 33
|
using System;
namespace practice {
class programpractice {
static void Main(string[] args) {
var A = int.Parse(Console.ReadLine());
var N = int.Parse(Console.ReadLine());
if (N % 500 <= A) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace practice {
class programpractice {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var A = int.Parse(Console.ReadLine());
if (N % 500 <= A) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22]]
| 8
| 81
| 4
|
using System;
namespace ProgrammingContest {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int a = int.Parse(Console.ReadLine());
n %= 500;
Console.WriteLine((n < a) ? "Yes" : "No");
}
}
}
|
using System;
namespace ProgrammingContest {
class Program {
static void Main(string[] args) {
// 1 <= n <= 10000
int n = int.Parse(Console.ReadLine());
// 0 <= a <= 1000
int a = int.Parse(Console.ReadLine());
Console.WriteLine((((n %= 500) <= a) ? "Yes" : "No"));
}
}
}
|
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 23, 0, 24], ["-", 0, 28, 0, 41, 15, 23, 0, 16, 17, 18], ["+", 0, 16, 31, 23, 0, 11, 0, 202, 0, 132], ["+", 15, 23, 0, 16, 31, 23, 0, 11, 12, 203], ["+", 0, 41, 15, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 23, 0, 41, 15, 23, 0, 16, 17, 19], ["+", 0, 213, 3, 4, 0, 28, 0, 23, 0, 25]]
| 8
| 73
| 12
|
using System;
class Program {
static void Main(string[] args) {
// 支払総額N円
string input = Console.ReadLine();
int payTotal = int.Parse(input);
// 1円硬貨枚数A
input = Console.ReadLine();
int one = int.Parse(input);
// 支払総額を500円で割った余りを計算
int surplus = payTotal % 500;
if (surplus <= one) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
// 支払総額N円
string input = Console.ReadLine();
int payTotal = int.Parse(input);
// 1円硬貨枚数A
input = Console.ReadLine();
int one = int.Parse(input);
// 支払総額を500円で割った余りを計算
if ((payTotal % 500) <= one) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 94
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace program {
class Program {
static void Main() {
int N = Input.ScanInt();
int A = Input.ScanInt() % 500;
Console.WriteLine(A <= N ? "Yes" : "No");
}
}
static class Input {
static public int ScanInt() { return int.Parse(Console.ReadLine()); }
static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
static public long ScanLong() { return long.Parse(Console.ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
static public int[] ScanIntArray() {
return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return Console.ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(' '); }
}
static class MyMath {
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong GCD(ulong a, ulong b) {
Func<ulong, ulong, ulong> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); }
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace program {
class Program {
static void Main() {
int N = Input.ScanInt() % 500;
int A = Input.ScanInt();
Console.WriteLine(N <= A ? "Yes" : "No");
}
}
static class Input {
static public int ScanInt() { return int.Parse(Console.ReadLine()); }
static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
static public long ScanLong() { return long.Parse(Console.ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
static public int[] ScanIntArray() {
return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return Console.ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(' '); }
}
static class MyMath {
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong GCD(ulong a, ulong b) {
Func<ulong, ulong, ulong> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); }
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 22]]
| 8
| 598
| 8
|
using System;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
int a = int.Parse(Console.ReadLine());
if (n % 500 <= a)
Console.WriteLine("YES"); // WriteLineをWriteとすると、改行なしで出力。
else
Console.WriteLine("NO");
}
}
|
using System;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
int a = int.Parse(Console.ReadLine());
if ((n % 500) <= a) {
Console.WriteLine("Yes"); // WriteLineをWriteとすると、改行なしで出力。
} else {
Console.WriteLine("No");
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 71
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderBS {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int n = int.Parse(Console.ReadLine());
if ((a % 500) < n) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
Console.Read();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderBS {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int n = int.Parse(Console.ReadLine());
if ((a % 500) <= n) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 113
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class A {
static void Main(string[] args) {
int A = int.Parse(Console.ReadLine());
int N = int.Parse(Console.ReadLine());
if (N % 500 > A || N == 0) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class A {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int A = int.Parse(Console.ReadLine());
if (N % 500 > A || N == 0) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22]]
| 8
| 109
| 4
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Array.Sort(a);
var answer = 0;
for (int i = 0; i < N; i++)
if (i % 2 == 0)
answer -= a[i];
else
answer += a[i];
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Array.Sort(a);
Array.Reverse(a);
var answer = 0;
for (int i = N - 1; i >= 0; i--)
if (i % 2 == 0)
answer += a[i];
else
answer -= a[i];
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68], ["-", 8, 57, 64, 1, 0, 11, 0, 202, 0, 110], ["+", 8, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["-", 8, 57, 75, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 57, 75, 1, 0, 11, 0, 202, 0, 110]]
| 8
| 148
| 21
|
using System;
namespace ChokudaiScanner {
class MainClass {
static void Main() {
Scanner cin = new Scanner();
int N = cin.NextInt();
int[] a = cin.ArrayInt(N);
int A = 0;
int B = 0;
Array.Sort(a);
Array.Reverse(a);
for (int i = 0; i < a.Length; i++) {
if (!(i % 2 == 0)) {
A += a[i];
} else {
B += a[i];
}
}
Console.WriteLine(A - B);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public string[] ArrayNext(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = Next();
}
return Array;
}
public int NextInt() { return int.Parse(Next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = NextInt() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
}
}
|
using System;
namespace ChokudaiScanner {
class MainClass {
static void Main() {
Scanner cin = new Scanner();
int N = cin.NextInt();
int[] a = cin.ArrayInt(N);
int A = 0;
int B = 0;
int C = 1;
Array.Sort(a);
Array.Reverse(a);
for (int i = 0; i < a.Length; i++) {
if (C % 2 == 0) {
B += a[i];
C++;
} else {
A += a[i];
C++;
}
}
Console.WriteLine(A - B);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public string[] ArrayNext(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = Next();
}
return Array;
}
public int NextInt() { return int.Parse(Next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = NextInt() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111], ["-", 15, 241, 0, 23, 0, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 241, 0, 23, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 528
| 20
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
// 自分の得意な言語で
// Let's チャレンジ!!
var line = System.Console.ReadLine();
int N = Convert.ToInt16(line);
int[] cards = new int[N];
line = Console.ReadLine();
var nums = line.Split(new char[] { ' ' });
for (int i = 0; i < N; i++) {
cards[i] = Convert.ToInt32(nums[i]);
}
Array.Reverse(cards);
int a = 0;
int b = 0;
for (int i = 0; i < N; i++) {
if (i % 2 != 0) {
b += cards[i];
} else {
a += cards[i];
}
}
int diffp = a - b;
Console.WriteLine(diffp);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var line = System.Console.ReadLine();
int N = Convert.ToInt16(line);
int[] cards = new int[N];
line = Console.ReadLine();
var nums = line.Split(new char[] { ' ' });
for (int i = 0; i < N; i++) {
cards[i] = Convert.ToInt32(nums[i]);
}
Array.Sort(cards);
Array.Reverse(cards);
int a = 0;
int b = 0;
for (int i = 0; i < N; i++) {
if (i % 2 != 0) {
b += cards[i];
} else {
a += cards[i];
}
}
int diffp = a - b;
Console.WriteLine(diffp);
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131]]
| 8
| 190
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace B {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var a = Console.ReadLine()
.Split()
.Select(int.Parse)
.OrderByDescending(x => x)
.ToArray();
var aliceScore = a.Where(x => x % 2 == 0).ToList().Sum();
var bobScore = a.Sum() - aliceScore;
Console.WriteLine(aliceScore - bobScore);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace B {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var a = Console.ReadLine()
.Split()
.Select(int.Parse)
.OrderByDescending(x => x)
.ToArray();
var aliceScore = a.Where((x, i) => i % 2 == 0).Sum();
var bobScore = a.Sum() - aliceScore;
Console.WriteLine(aliceScore - bobScore);
}
}
}
|
[["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 24], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 21], ["+", 0, 28, 0, 218, 54, 55, 0, 220, 141, 22], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 25], ["-", 0, 28, 0, 218, 8, 16, 31, 16, 31, 22], ["+", 0, 28, 0, 218, 8, 16, 31, 16, 31, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24]]
| 8
| 123
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Split().Select(int.Parse).ToList();
A.Reverse();
var alice = 0;
var bob = 0;
for (var i = 0; i < A.Count; i++) {
if (i % 2 == 0) {
alice += A[i];
} else {
bob += A[i];
}
}
Console.WriteLine(alice - bob);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var A =
Console.ReadLine().Split().Select(int.Parse).OrderBy(x => -x).ToList();
var alice = 0;
var bob = 0;
for (var i = 0; i < A.Count; i++) {
if (i % 2 == 0) {
alice += A[i];
} else {
bob += A[i];
}
}
Console.WriteLine(alice - bob);
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 241, 0, 33], ["+", 3, 4, 0, 28, 0, 218, 8, 241, 0, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 134
| 10
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var num = int.Parse(Console.ReadLine());
var input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
input.Sort((x, y) => y - x);
var result = 0;
for (int i = 0; i < input.Count; i++) {
if (i + 1 % 2 == 1) {
result += input[i];
} else {
result -= input[i];
}
}
Console.WriteLine(result);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var num = int.Parse(Console.ReadLine());
var input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
input.Sort((x, y) => y - x);
var result = 0;
for (int i = 0; i < input.Count; i++) {
if (i % 2 == 0 || i == 0) {
result += input[i];
} else {
result -= input[i];
}
}
Console.WriteLine(result);
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 146
| 8
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace ABC091.C
{
using static Util;
public class Solver : SolverBase
{
public void Run() {
var N = ReadInt();
List<XY> ListA = new List<XY>(N);
List<XY> ListB = new List<XY>(N);
for (int i = 0; i < N; i++) {
ListA.Add(new XY(ReadIntArray()));
}
for (int i = 0; i < N; i++) {
ListB.Add(new XY(ReadIntArray()));
}
ListA.Sort();
ListB.Sort();
//Dump(ListA);
//Dump(ListB);
int ans = 0;
foreach (var pb in ListB) {
// Bのx座標小さい順
// ペアになれるAのうちy座標最大のものをPick
int maxY = -1;
int maxPaIdx = -1;
for (int i = 0; i < ListA.Count; i++) {
var pa = ListA[i];
if (pb.X < pa.X)
break;
if (maxY < pa.Y) {
maxY = pa.Y;
maxPaIdx = i;
}
}
if (0 <= maxPaIdx) {
++ans;
ListA.RemoveAt(maxPaIdx);
}
}
WriteLine(ans);
}
#if !MYHOME
public static void Main(string[] args) {
new Solver().Run();
}
#endif
}
public class XY : IComparable<XY>, IFormattable
{
public readonly int X;
public readonly int Y;
public XY() { }
public XY(int x, int y) {
X = x;
Y = y;
}
public XY(int[] ary) {
X = ary[0];
Y = ary[1];
}
public int CompareTo(XY other) {
var dx = this.X - other.X;
if (0 < dx)
return 1;
else if (dx < 0)
return -1;
else {
var dy = this.Y - other.Y;
if (0 < dy)
return 1;
else if (dy < 0)
return -1;
else
return 0;
}
}
public override string ToString() {
return ToString(null, null);
}
// format等の引数は一切無視
public string ToString(string format, IFormatProvider formatProvider) {
return $"({X}, {Y})";
}
}
public static class Util
{
public static int Gcd(int a, int b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public readonly static long MOD = 1000000007;
public static string DumpToString<T>(IEnumerable<T> array) where T : IFormattable {
var sb = new StringBuilder();
foreach (var item in array) {
sb.Append(item);
sb.Append(", ");
}
return sb.ToString();
}
public static void InitArray<T>(T[] ary, T value) {
for (int i = 0; i < ary.Length; i++) {
ary[i] = value;
}
}
public static void InitDP2<T>(T[,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
dp[i, j] = value;
}
}
}
public static void InitDP3<T>(T[,,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
for (int k = 0; k < dp.GetLength(2); k++) {
dp[i, j, k] = value;
}
}
}
}
public static T Max<T>(params T[] nums) where T : IComparable {
if (nums.Length == 0) return default(T);
T max = nums[0];
for (int i = 1; i < nums.Length; i++) {
max = max.CompareTo(nums[i]) > 0 ? max : nums[i];
}
return max;
}
public static T Min<T>(params T[] nums) where T : IComparable {
if (nums.Length == 0) return default(T);
T min = nums[0];
for (int i = 1; i < nums.Length; i++) {
min = min.CompareTo(nums[i]) < 0 ? min : nums[i];
}
return min;
}
/// <summary>
/// ソート済み配列 ary に同じ値の要素が含まれている?
/// ※ソート順は昇順/降順どちらでもよい
/// </summary>
public static bool HasDuplicateInSortedArray<T>(T[] ary) where T : IComparable, IComparable<T> {
if (ary.Length <= 1) return false;
var lastNum = ary[ary.Length - 1];
foreach (var n in ary) {
if (lastNum.CompareTo(n) == 0) {
return true;
} else {
lastNum = n;
}
}
return false;
}
public static void ReplaceIfBigger<T>(ref T r, T v) where T : IComparable {
if (r.CompareTo(v) < 0) r = v;
}
public static void ReplaceIfSmaller<T>(ref T r, T v) where T : IComparable {
if (0 < r.CompareTo(v)) r = v;
}
/// <summary>
/// 二分探索
/// ※条件を満たす最小のidxを返す
/// ※満たすものがない場合は ary.Length を返す
/// ※『aryの先頭側が条件を満たさない、末尾側が条件を満たす』という前提
/// ただし、IsOK(...)の戻り値を逆転させれば、逆でも同じことが可能。
/// </summary>
/// <param name="ary">探索対象配列 ★ソート済みであること</param>
/// <param name="key">探索値 ※これ以上の値を持つ(IsOKがtrueを返す)最小のindexを返す</param>
public static int BinarySearch<T>(T[] ary, T key) where T : IComparable, IComparable<T> {
int left = -1;
int right = ary.Length;
while (1 < right - left) {
var mid = left + (right - left) / 2;
if (IsOK(ary, mid, key)) {
right = mid;
} else {
left = mid;
}
}
// left は条件を満たさない最大の値、right は条件を満たす最小の値になっている
return right;
}
public static bool IsOK<T>(T[] ary, int idx, T key) where T : IComparable, IComparable<T> {
// key <= ary[idx] と同じ意味
return key.CompareTo(ary[idx]) <= 0;
}
}
public class SolverBase
{
virtual protected string ReadLine() => Console.ReadLine();
virtual protected int ReadInt() => int.Parse(ReadLine());
//virtual protected void ReadInt2(out int x, out int y) {
// var aryS = ReadLine().Split(' ');
// x = int.Parse(aryS[0]);
// y = int.Parse(aryS[1]);
//}
virtual protected long ReadLong() => long.Parse(ReadLine());
virtual protected string[] ReadStringArray() => ReadLine().Split(' ');
virtual protected int[] ReadIntArray() => ReadLine().Split(' ').Select<string, int>(s => int.Parse(s)).ToArray();
virtual protected long[] ReadLongArray() => ReadLine().Split(' ').Select<string, long>(s => long.Parse(s)).ToArray();
virtual protected double[] ReadDoubleArray() => ReadLine().Split(' ').Select<string, double>(s => double.Parse(s)).ToArray();
virtual protected void WriteLine(string line) => Console.WriteLine(line);
virtual protected void WriteLine(double d) => Console.WriteLine($"{d:F9}");
virtual protected void WriteLine<T>(T value) where T : IFormattable => Console.WriteLine(value);
[Conditional("DEBUG")]
protected void Dump(string s) => Console.WriteLine(s);
[Conditional("DEBUG")]
protected void Dump(char c) => Console.WriteLine(c);
[Conditional("DEBUG")]
protected void Dump(double d) => Console.WriteLine($"{d:F9}");
[Conditional("DEBUG")]
protected void Dump<T>(IEnumerable<T> array) where T : IFormattable {
string s = Util.DumpToString(array);
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(s);
//_writer.WriteLine(s);
}
[Conditional("DEBUG")]
protected void DumpGrid<T>(IEnumerable<IEnumerable<T>> arrayOfArray) where T : IFormattable {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
sb.AppendLine(Util.DumpToString(a));
}
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(sb.ToString());
//_writer.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpDP<T>(T[,] dp) where T : IFormattable {
var sb = new StringBuilder();
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
sb.Append(dp[i, j]);
sb.Append(", ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace ABC091.C
{
using static Util;
public class Solver : SolverBase
{
public void Run() {
var N = ReadInt();
List<XY> ListA = new List<XY>(N);
List<XY> ListB = new List<XY>(N);
for (int i = 0; i < N; i++) {
ListA.Add(new XY(ReadIntArray()));
}
for (int i = 0; i < N; i++) {
ListB.Add(new XY(ReadIntArray()));
}
ListA.Sort();
ListB.Sort();
//Dump(ListA);
//Dump(ListB);
int ans = 0;
foreach (var pb in ListB) {
// Bのx座標小さい順
// ペアになれるAのうちy座標最大のものをPick
int maxY = -1;
int maxPaIdx = -1;
for (int i = 0; i < ListA.Count; i++) {
var pa = ListA[i];
if (pb.X < pa.X)
break;
if (pa.Y < pb.Y && maxY < pa.Y) {
maxY = pa.Y;
maxPaIdx = i;
}
}
if (0 <= maxPaIdx) {
++ans;
ListA.RemoveAt(maxPaIdx);
}
}
WriteLine(ans);
}
#if !MYHOME
public static void Main(string[] args) {
new Solver().Run();
}
#endif
}
public class XY : IComparable<XY>, IFormattable
{
public readonly int X;
public readonly int Y;
public XY() { }
public XY(int x, int y) {
X = x;
Y = y;
}
public XY(int[] ary) {
X = ary[0];
Y = ary[1];
}
public int CompareTo(XY other) {
var dx = this.X - other.X;
if (0 < dx)
return 1;
else if (dx < 0)
return -1;
else {
var dy = this.Y - other.Y;
if (0 < dy)
return 1;
else if (dy < 0)
return -1;
else
return 0;
}
}
public override string ToString() {
return ToString(null, null);
}
// format等の引数は一切無視
public string ToString(string format, IFormatProvider formatProvider) {
return $"({X}, {Y})";
}
}
public static class Util
{
public static int Gcd(int a, int b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public readonly static long MOD = 1000000007;
public static string DumpToString<T>(IEnumerable<T> array) where T : IFormattable {
var sb = new StringBuilder();
foreach (var item in array) {
sb.Append(item);
sb.Append(", ");
}
return sb.ToString();
}
public static void InitArray<T>(T[] ary, T value) {
for (int i = 0; i < ary.Length; i++) {
ary[i] = value;
}
}
public static void InitDP2<T>(T[,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
dp[i, j] = value;
}
}
}
public static void InitDP3<T>(T[,,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
for (int k = 0; k < dp.GetLength(2); k++) {
dp[i, j, k] = value;
}
}
}
}
public static T Max<T>(params T[] nums) where T : IComparable {
if (nums.Length == 0) return default(T);
T max = nums[0];
for (int i = 1; i < nums.Length; i++) {
max = max.CompareTo(nums[i]) > 0 ? max : nums[i];
}
return max;
}
public static T Min<T>(params T[] nums) where T : IComparable {
if (nums.Length == 0) return default(T);
T min = nums[0];
for (int i = 1; i < nums.Length; i++) {
min = min.CompareTo(nums[i]) < 0 ? min : nums[i];
}
return min;
}
/// <summary>
/// ソート済み配列 ary に同じ値の要素が含まれている?
/// ※ソート順は昇順/降順どちらでもよい
/// </summary>
public static bool HasDuplicateInSortedArray<T>(T[] ary) where T : IComparable, IComparable<T> {
if (ary.Length <= 1) return false;
var lastNum = ary[ary.Length - 1];
foreach (var n in ary) {
if (lastNum.CompareTo(n) == 0) {
return true;
} else {
lastNum = n;
}
}
return false;
}
public static void ReplaceIfBigger<T>(ref T r, T v) where T : IComparable {
if (r.CompareTo(v) < 0) r = v;
}
public static void ReplaceIfSmaller<T>(ref T r, T v) where T : IComparable {
if (0 < r.CompareTo(v)) r = v;
}
/// <summary>
/// 二分探索
/// ※条件を満たす最小のidxを返す
/// ※満たすものがない場合は ary.Length を返す
/// ※『aryの先頭側が条件を満たさない、末尾側が条件を満たす』という前提
/// ただし、IsOK(...)の戻り値を逆転させれば、逆でも同じことが可能。
/// </summary>
/// <param name="ary">探索対象配列 ★ソート済みであること</param>
/// <param name="key">探索値 ※これ以上の値を持つ(IsOKがtrueを返す)最小のindexを返す</param>
public static int BinarySearch<T>(T[] ary, T key) where T : IComparable, IComparable<T> {
int left = -1;
int right = ary.Length;
while (1 < right - left) {
var mid = left + (right - left) / 2;
if (IsOK(ary, mid, key)) {
right = mid;
} else {
left = mid;
}
}
// left は条件を満たさない最大の値、right は条件を満たす最小の値になっている
return right;
}
public static bool IsOK<T>(T[] ary, int idx, T key) where T : IComparable, IComparable<T> {
// key <= ary[idx] と同じ意味
return key.CompareTo(ary[idx]) <= 0;
}
}
public class SolverBase
{
virtual protected string ReadLine() => Console.ReadLine();
virtual protected int ReadInt() => int.Parse(ReadLine());
//virtual protected void ReadInt2(out int x, out int y) {
// var aryS = ReadLine().Split(' ');
// x = int.Parse(aryS[0]);
// y = int.Parse(aryS[1]);
//}
virtual protected long ReadLong() => long.Parse(ReadLine());
virtual protected string[] ReadStringArray() => ReadLine().Split(' ');
virtual protected int[] ReadIntArray() => ReadLine().Split(' ').Select<string, int>(s => int.Parse(s)).ToArray();
virtual protected long[] ReadLongArray() => ReadLine().Split(' ').Select<string, long>(s => long.Parse(s)).ToArray();
virtual protected double[] ReadDoubleArray() => ReadLine().Split(' ').Select<string, double>(s => double.Parse(s)).ToArray();
virtual protected void WriteLine(string line) => Console.WriteLine(line);
virtual protected void WriteLine(double d) => Console.WriteLine($"{d:F9}");
virtual protected void WriteLine<T>(T value) where T : IFormattable => Console.WriteLine(value);
[Conditional("DEBUG")]
protected void Dump(string s) => Console.WriteLine(s);
[Conditional("DEBUG")]
protected void Dump(char c) => Console.WriteLine(c);
[Conditional("DEBUG")]
protected void Dump(double d) => Console.WriteLine($"{d:F9}");
[Conditional("DEBUG")]
protected void Dump<T>(IEnumerable<T> array) where T : IFormattable {
string s = Util.DumpToString(array);
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(s);
//_writer.WriteLine(s);
}
[Conditional("DEBUG")]
protected void DumpGrid<T>(IEnumerable<IEnumerable<T>> arrayOfArray) where T : IFormattable {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
sb.AppendLine(Util.DumpToString(a));
}
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(sb.ToString());
//_writer.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpDP<T>(T[,] dp) where T : IFormattable {
var sb = new StringBuilder();
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
sb.Append(dp[i, j]);
sb.Append(", ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
}
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 1,857
| 8
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp1 {
class Program {
static void Main(string[] a_asArgs) {
int l_iN = int.Parse(Console.ReadLine());
List<Point> l_lpRed = new List<Point>();
List<Point> l_lpBlue = new List<Point>();
for (int l_iIndex = 0; l_iIndex < l_iN; l_iIndex++) {
int[] l_aiXY =
Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
l_lpRed.Add(new Point { X = l_aiXY[0], Y = l_aiXY[1] });
}
for (int l_iIndex = 0; l_iIndex < l_iN; l_iIndex++) {
int[] l_aiXY =
Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
l_lpBlue.Add(new Point { X = l_aiXY[0], Y = l_aiXY[1] });
}
l_lpBlue.Sort(new PointComparerX());
int l_iCount = 0;
foreach (Point l_pBlue in l_lpBlue) {
List<Point> l_List = l_lpRed.Where(a => a.X < l_pBlue.X).ToList();
if (l_List.Count > 0) {
l_List.Sort(new PointComparerDescY());
l_lpRed.Remove(l_List[0]);
l_iCount++;
}
}
Console.WriteLine(l_iCount);
}
private class Point {
public int X;
public int Y;
}
private class PointComparerX : IComparer<Point> {
public int Compare(Point a_Point1, Point a_Point2) {
return a_Point1.X - a_Point2.X;
}
}
private class PointComparerDescY : IComparer<Point> {
public int Compare(Point a_Point1, Point a_Point2) {
return a_Point2.Y - a_Point1.Y;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp1 {
class Program {
static void Main(string[] a_asArgs) {
int l_iN = int.Parse(Console.ReadLine());
List<Point> l_lpRed = new List<Point>();
List<Point> l_lpBlue = new List<Point>();
for (int l_iIndex = 0; l_iIndex < l_iN; l_iIndex++) {
int[] l_aiXY =
Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
l_lpRed.Add(new Point { X = l_aiXY[0], Y = l_aiXY[1] });
}
for (int l_iIndex = 0; l_iIndex < l_iN; l_iIndex++) {
int[] l_aiXY =
Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
l_lpBlue.Add(new Point { X = l_aiXY[0], Y = l_aiXY[1] });
}
l_lpBlue.Sort(new PointComparerX());
int l_iCount = 0;
foreach (Point l_pBlue in l_lpBlue) {
List<Point> l_List =
l_lpRed.Where(a => a.X < l_pBlue.X && a.Y < l_pBlue.Y).ToList();
if (l_List.Count > 0) {
l_List.Sort(new PointComparerDescY());
l_lpRed.Remove(l_List[0]);
l_iCount++;
}
}
Console.WriteLine(l_iCount);
}
private class Point {
public int X;
public int Y;
}
private class PointComparerX : IComparer<Point> {
public int Compare(Point a_Point1, Point a_Point2) {
return a_Point1.X - a_Point2.X;
}
}
private class PointComparerDescY : IComparer<Point> {
public int Compare(Point a_Point1, Point a_Point2) {
return a_Point2.Y - a_Point1.Y;
}
}
}
}
|
[["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 98], ["+", 0, 218, 8, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 218, 8, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 218, 8, 16, 12, 16, 31, 214, 141, 22], ["+", 0, 28, 0, 218, 8, 16, 12, 16, 17, 18], ["+", 0, 218, 8, 16, 12, 16, 12, 214, 205, 22], ["+", 0, 218, 8, 16, 12, 16, 12, 214, 0, 131], ["+", 0, 218, 8, 16, 12, 16, 12, 214, 141, 22]]
| 8
| 386
| 8
|
// Wrote after ended the contest
using System;
using System.Linq;
public class Program {
public static void Main() {
int N = int.Parse(Console.ReadLine());
int[][] red = new int [N][];
int[][] blue = new int [N][];
for (int i = 0; i < N; i++)
red[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
for (int i = 0; i < N; i++)
blue[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
red = red.OrderByDescending(a => a[1]).ToArray();
blue = blue.OrderBy(a => a[0]).ToArray();
int count = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (red[j] == null)
continue;
if (red[j][0] < blue[i][0]) {
count++;
red[j] = null;
break;
}
}
}
Console.WriteLine(count);
}
}
|
// Wrote after ended the contest
using System;
using System.Linq;
public class Program {
public static void Main() {
int N = int.Parse(Console.ReadLine());
int[][] red = new int [N][];
int[][] blue = new int [N][];
for (int i = 0; i < N; i++)
red[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
for (int i = 0; i < N; i++)
blue[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
red = red.OrderByDescending(a => a[1]).ToArray();
blue = blue.OrderBy(a => a[0]).ToArray();
int count = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (red[j] == null)
continue;
if (red[j][0] < blue[i][0] && red[j][1] < blue[i][1]) {
count++;
red[j] = null;
break;
}
}
}
Console.WriteLine(count);
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 204, 205, 204, 205, 22], ["+", 12, 16, 31, 204, 205, 204, 206, 207, 0, 70], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 15, 16, 12, 16, 12, 204, 205, 204, 205, 22], ["+", 12, 16, 12, 204, 205, 204, 206, 207, 0, 70], ["+", 12, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 12, 204, 205, 204, 206, 207, 0, 73], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 275
| 16
|
namespace AtCoder.ABC.C092 {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.IO;
using AtCoder.ABC.IO;
public class Quest {
public object Solve(Parser parser) {
int n = parser.Integer();
var red = parser.Take(n)
.Select(p => new Red() {
x = p.Integer(),
y = p.Integer(),
})
.ToArray();
Blue[] blue = parser.Take(n)
.Select(p => new Blue() {
x = p.Integer(),
y = p.Integer(),
})
.OrderBy(b => b.x)
.ToArray();
var got = Match(red, blue);
return got.Where(r => r >= 0).Count();
}
private int[] Match(Red[] red, Blue[] blue) {
int[] visited = Enumerable.Repeat(-1, red.Length).ToArray();
for (int b = 0; b < blue.Length; b++) {
for (int r = 0; r < red.Length; r++) {
if (visited[r] >= 0) {
continue;
}
if (IsFriend(red[r], blue[b])) {
visited[r] = b;
break;
}
}
}
return visited;
}
private static bool IsFriend(Red red, Blue blue) {
return red.x < blue.x && red.y < blue.y;
}
}
class Red {
public int x;
public int y;
}
class Blue {
public int x;
public int y;
}
static class Program {
static void Main(string[] args) {
var i = new Parser(Console.OpenStandardInput());
var o = new Printer(Console.OpenStandardOutput());
var got = new Quest().Solve(i);
o.WriteLine(got);
o.Flush();
}
}
}
namespace AtCoder.ABC.IO {
#region IO
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
public class Parser {
public Parser(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
public IEnumerable<Parser> Take(int n) {
return Enumerable.Range(1, n).Select(_ => this);
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture)
: double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
public class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
#endregion
}
|
namespace AtCoder.ABC.C092 {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.IO;
using AtCoder.ABC.IO;
public class Quest {
public object Solve(Parser parser) {
int n = parser.Integer();
var red = parser.Take(n)
.Select(p => new Red() {
x = p.Integer(),
y = p.Integer(),
})
.OrderByDescending(r => r.y)
.ToArray();
Blue[] blue = parser.Take(n)
.Select(p => new Blue() {
x = p.Integer(),
y = p.Integer(),
})
.OrderBy(b => b.x)
.ToArray();
var got = Match(red, blue);
return got.Where(r => r >= 0).Count();
}
private int[] Match(Red[] red, Blue[] blue) {
int[] visited = Enumerable.Repeat(-1, red.Length).ToArray();
for (int b = 0; b < blue.Length; b++) {
for (int r = 0; r < red.Length; r++) {
if (visited[r] >= 0) {
continue;
}
if (IsFriend(red[r], blue[b])) {
visited[r] = b;
break;
}
}
}
return visited;
}
private static bool IsFriend(Red red, Blue blue) {
return red.x < blue.x && red.y < blue.y;
}
}
class Edge<T, U> {
public T From;
public U[] To;
}
class Red {
public int x;
public int y;
}
class Blue {
public int x;
public int y;
}
static class Program {
static void Main(string[] args) {
var i = new Parser(Console.OpenStandardInput());
var o = new Printer(Console.OpenStandardOutput());
var got = new Quest().Solve(i);
o.WriteLine(got);
o.Flush();
}
}
}
namespace AtCoder.ABC.IO {
#region IO
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
public class Parser {
public Parser(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
public IEnumerable<Parser> Take(int n) {
return Enumerable.Range(1, n).Select(_ => this);
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture)
: double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
public class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
#endregion
}
|
[["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 209, 8, 201, 0, 235, 8, 201, 0, 46], ["+", 0, 208, 0, 209, 8, 201, 0, 235, 0, 269], ["+", 0, 208, 0, 209, 8, 201, 0, 235, 141, 22], ["+", 0, 209, 8, 201, 0, 235, 307, 308, 0, 18], ["+", 8, 201, 0, 235, 307, 308, 0, 309, 141, 22], ["+", 0, 209, 8, 201, 0, 235, 307, 308, 0, 21], ["+", 0, 209, 8, 201, 0, 235, 307, 308, 0, 47], ["+", 0, 209, 8, 201, 0, 235, 8, 201, 0, 45], ["+", 0, 235, 8, 201, 0, 124, 0, 251, 0, 259], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 22], ["+", 8, 201, 0, 124, 0, 198, 0, 200, 141, 22], ["+", 8, 201, 0, 235, 8, 201, 0, 124, 0, 35], ["+", 8, 201, 0, 124, 0, 198, 39, 224, 39, 22], ["+", 0, 124, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 124, 0, 198, 39, 224, 225, 226, 0, 73]]
| 8
| 1,266
| 28
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
long answer = 0;
long n = long.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
long[][] vertexesRed = new long [n][]; // x座標、y座標、使ったら1
long[][] vertexesBlue = new long [n][]; // x座標、y座標、使ったら1
for (long i = 0; i < n; i++) {
vertexesRed[i] = new long[3];
vertexesBlue[i] = new long[2];
}
for (long i = 0; i < n; i++) {
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
vertexesRed[i][0] = nums[0];
vertexesRed[i][1] = nums[1];
}
for (long i = 0; i < n; i++) {
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
vertexesBlue[i][0] = nums[0];
vertexesBlue[i][1] = nums[1];
}
Array.Sort(vertexesRed, (a, b) => a[0].CompareTo(b[0])); // x座標でソート
Array.Sort(vertexesBlue, (a, b) => a[0].CompareTo(b[0]));
long[] maxMemo = new long[2]; //番号とy座標
for (long blueNum = 0; blueNum < n; blueNum++) {
maxMemo[0] = -1;
maxMemo[1] = -1;
for (long redNum = 0; redNum < n; redNum++) {
if (vertexesRed[redNum][0] < vertexesBlue[blueNum][0] &&
vertexesRed[redNum][1] < vertexesBlue[blueNum][1] &&
vertexesRed[redNum][1] > maxMemo[1] &&
vertexesRed[redNum][2] == 0) {
maxMemo[1] = vertexesRed[redNum][1];
maxMemo[0] = vertexesRed[redNum][0];
}
if (maxMemo[0] != -1) {
vertexesRed[vertexesRed[redNum][2]][2] = 1;
answer++;
}
}
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
long answer = 0;
long n = long.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
long[][] vertexesRed = new long [n][]; // x座標、y座標、使ったら1
long[][] vertexesBlue = new long [n][]; // x座標、y座標、使ったら1
for (long i = 0; i < n; i++) {
vertexesRed[i] = new long[3];
vertexesBlue[i] = new long[2];
}
for (long i = 0; i < n; i++) {
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
vertexesRed[i][0] = nums[0];
vertexesRed[i][1] = nums[1];
}
for (long i = 0; i < n; i++) {
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
vertexesBlue[i][0] = nums[0];
vertexesBlue[i][1] = nums[1];
}
Array.Sort(vertexesRed, (a, b) => a[0].CompareTo(b[0])); // x座標でソート
Array.Sort(vertexesBlue, (a, b) => a[0].CompareTo(b[0]));
long[] maxMemo = new long[2]; //番号とy座標
for (long blueNum = 0; blueNum < n; blueNum++) {
maxMemo[0] = -1;
maxMemo[1] = -1;
for (long redNum = 0; redNum < n; redNum++) {
if (vertexesRed[redNum][0] < vertexesBlue[blueNum][0] &&
vertexesRed[redNum][1] < vertexesBlue[blueNum][1] &&
vertexesRed[redNum][1] > maxMemo[1] &&
vertexesRed[redNum][2] == 0) {
maxMemo[1] = vertexesRed[redNum][1];
maxMemo[0] = redNum;
}
}
// Console.WriteLine(maxMemo[0]+" "+maxMemo[1]);
if (maxMemo[0] != -1) {
vertexesRed[maxMemo[0]][2] = 1;
answer++;
// Console.WriteLine(maxMemo[0]+" "+maxMemo[1]);
}
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
[["-", 0, 1, 0, 11, 12, 204, 205, 204, 205, 22], ["-", 0, 11, 12, 204, 205, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 205, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 206, 207, 0, 28, 0, 204, 205, 204, 205, 22], ["+", 205, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["-", 0, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 28, 0, 204, 205, 204, 206, 207, 0, 73], ["-", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 492
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp36 {
class Program {
static void Main(string[] args) {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
string s3 = Console.ReadLine();
Console.WriteLine(s1[0] + s2[1] + s3[2]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp36 {
class Program {
static void Main(string[] args) {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
string s3 = Console.ReadLine();
Console.WriteLine(s1[0].ToString() + s2[1].ToString() + s3[2].ToString());
}
}
}
|
[["+", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 93
| 12
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace A {
class Program {
static void Main(string[] args) {
for (int i = 0; i < 3; i++) {
Console.WriteLine(Console.ReadLine().ToCharArray()[i]);
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace A {
class Program {
static void Main(string[] args) {
for (int i = 0; i < 3; i++) {
Console.Write(Console.ReadLine().ToCharArray()[i]);
}
Console.WriteLine();
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 68
| 8
|
using System;
namespace AtCoder.ABC090 {
public class A {
public static void Solve() {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
string s3 = Console.ReadLine();
Console.WriteLine(s1[0] + s2[1] + s3[2]);
}
}
}
namespace AtCoder {
class Program {
static void Main(string[] args) { ABC090.A.Solve(); }
}
}
|
using System;
namespace AtCoder.ABC090 {
public class A {
public static void Solve() {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
string s3 = Console.ReadLine();
Console.WriteLine(s1[0].ToString() + s2[1].ToString() + s3[2].ToString());
}
}
}
namespace AtCoder {
class Program {
static void Main(string[] args) { ABC090.A.Solve(); }
}
}
|
[["+", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 96
| 12
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
string s1 = Cin.Next();
string s2 = Cin.Next();
string s3 = Cin.Next();
Console.WriteLine(s1[0] + s2[1] + s3[2]);
}
}
public class Cin {
private static string[] s = new string[0];
private static int i = 0;
private static char[] cs = new char[] { ' ' };
public static string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return Next();
}
public static int Ni() { return int.Parse(Next()); }
public static long NextLong() { return long.Parse(Next()); }
public static double NextDouble() { return double.Parse(Next()); }
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
string s1 = Cin.Next();
string s2 = Cin.Next();
string s3 = Cin.Next();
Console.WriteLine(s1[0].ToString() + s2[1].ToString() + s3[2].ToString());
}
}
public class Cin {
private static string[] s = new string[0];
private static int i = 0;
private static char[] cs = new char[] { ' ' };
public static string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return Next();
}
public static int Ni() { return int.Parse(Next()); }
public static long NextLong() { return long.Parse(Next()); }
public static double NextDouble() { return double.Parse(Next()); }
}
|
[["+", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 235
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc090_b {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int sum = 0;
for (int i = a; i <= b; i++) {
string word = i.ToString();
if (word.Substring(0, 2) == word.Substring(3, 2)) {
sum++;
}
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc090_b {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int sum = 0;
for (int i = a; i <= b; i++) {
string word = i.ToString();
if (word.Substring(0, 1) == word.Substring(4, 1) &&
word.Substring(1, 1) == word.Substring(3, 1)) {
sum++;
}
}
Console.WriteLine(sum);
}
}
}
|
[["-", 15, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 31, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 31, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 21], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 205, 22], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 12, 16, 31, 213, 3, 4, 0, 24], ["+", 12, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 213, 3, 4, 0, 21], ["-", 15, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 12, 16, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 152
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcoder_問題5_B2問目 {
class Program {
static void Main(string[] args) {
//問題5
string[] input = Console.ReadLine().Split(' ');
int c = Convert.ToInt32(input[0]);
int d = Convert.ToInt32(input[1]);
int sum = 0;
for (int e = c; e < d; ++e) {
string f = Convert.ToString(e);
int num = e;
int rev = 0;
while (num > 0) {
rev = rev * 10 + num % 10;
num /= 10;
}
string revstr = rev.ToString();
bool check = f.Contains(revstr);
int ok = e - Convert.ToInt32(revstr);
if (check) {
if (ok == 0) {
sum = sum + 1;
}
}
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcoder_問題5_B2問目 {
class Program {
static void Main(string[] args) {
//問題5
//入力を受け取る
string[] input = Console.ReadLine().Split(' ');
int a = Convert.ToInt32(input[0]);
int b = Convert.ToInt32(input[1]);
int sum = 0;
for (int c = a; c <= b; ++c) {
string d = Convert.ToString(c);
int num = c;
int rev = 0;
while (num > 0) {
rev = rev * 10 + num % 10;
num /= 10;
}
string revstr = rev.ToString();
bool check = d.Contains(revstr);
int ok = c - Convert.ToInt32(revstr);
if (check) {
if (ok == 0) {
sum = sum + 1;
}
}
}
Console.WriteLine(sum);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22]]
| 8
| 216
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
var t = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }),
number => int.Parse(number));
var n = t[0] == 1 ? 1 : t[0] - 2;
var m = t[1] == 1 ? 1 : t[1] - 2;
Console.WriteLine(n * m);
//デバッグ実行での確認用。そのまま提出しても問題なし
Console.ReadKey();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
var t = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }),
number => long.Parse(number));
long n = t[0] == 1 ? 1 : t[0] - 2;
long m = t[1] == 1 ? 1 : t[1] - 2;
long ans = n * m;
Console.WriteLine(ans);
//デバッグ実行での確認用。そのまま提出しても問題なし
Console.ReadKey();
}
}
|
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 115
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionD {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var nm =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
var n = nm[0];
var m = nm[1];
/*
var cards = new bool[n + 2, m + 2];
for (int mm = 1; mm < m + 1; mm++) {
for (int nn = 1; nn < n + 1; nn++) {
for (int y = -1; y < 2; y++) {
for (int x = -1; x < 2; x++) {
cards[nn + x, mm + y] = !cards[nn + x, mm + y];
}
}
}
}
for (int mm = 1; mm < m + 1; mm++) {
for (int nn = 1; nn < n + 1; nn++) {
Console.Write(cards[nn, mm] ? "1" : "0");
}
Console.WriteLine();
}
*/
if (n == 2 || m == 2) {
Console.WriteLine(0);
Console.Out.Flush();
return;
}
if (n == 1 && m == 1) {
Console.WriteLine(1);
Console.Out.Flush();
return;
}
if (n == 1 || m == 1) {
Console.WriteLine((n * m) - 2);
Console.Out.Flush();
return;
}
var num = ((n + m) * 2) - 4;
Console.WriteLine((n * m) - num);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionD {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var nm =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
var n = nm[0];
var m = nm[1];
/*
var cards = new bool[n + 2, m + 2];
for (int mm = 1; mm < m + 1; mm++) {
for (int nn = 1; nn < n + 1; nn++) {
for (int y = -1; y < 2; y++) {
for (int x = -1; x < 2; x++) {
cards[nn + x, mm + y] = !cards[nn + x, mm + y];
}
}
}
}
for (int mm = 1; mm < m + 1; mm++) {
for (int nn = 1; nn < n + 1; nn++) {
Console.Write(cards[nn, mm] ? "1" : "0");
}
Console.WriteLine();
}
*/
if (n == 2 || m == 2) {
Console.WriteLine(0);
Console.Out.Flush();
return;
}
if (n == 1 && m == 1) {
Console.WriteLine(1);
Console.Out.Flush();
return;
}
if (n == 1 || m == 1) {
Console.WriteLine((n * m) - 2);
Console.Out.Flush();
return;
}
Console.WriteLine(((long)n - 2) * (m - 2));
Console.Out.Flush();
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 16, 31, 23, 0, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 74, 39, 199], ["+", 0, 16, 31, 23, 0, 16, 31, 74, 0, 25], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 257
| 26
|
// C - Flip,Flip, and Flip......
using System;
using System.Linq;
using System.Collections.Generic;
namespace C {
class Program {
static void Main(string[] args) {
var nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
var ans = 0L;
if (nm[0] > 1 && nm[1] > 1) {
ans = (nm[0] - 2) * (nm[1] - 2);
} else if ((nm[0] == 1 && nm[1] > 1) || (nm[0] > 1 && nm[1] == 0)) {
ans = Math.Max(nm[0], nm[1]) - 2;
} else {
ans = 1;
}
Console.WriteLine(ans);
}
}
}
|
// C - Flip,Flip, and Flip......
using System;
using System.Linq;
using System.Collections.Generic;
namespace C {
class Program {
static void Main(string[] args) {
var nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
var ans = 0L;
if (nm[0] > 1 && nm[1] > 1) {
ans = (nm[0] - 2) * (nm[1] - 2);
} else if (nm[0] == 1 && nm[1] == 1) {
ans = 1;
} else {
ans = Math.Max(nm[0], nm[1]) - 2;
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 57, 75, 57, 15, 16, 31, 23, 0, 24], ["-", 15, 16, 31, 23, 0, 16, 12, 16, 17, 47], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 60], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 106], ["-", 0, 57, 75, 57, 15, 16, 12, 23, 0, 24], ["-", 12, 23, 0, 16, 31, 16, 31, 204, 205, 22], ["-", 0, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 15, 16, 12, 23, 0, 16, 31, 16, 17, 47], ["-", 15, 16, 12, 23, 0, 16, 31, 16, 12, 203], ["-", 75, 57, 15, 16, 12, 23, 0, 16, 17, 98], ["-", 12, 23, 0, 16, 12, 16, 31, 204, 205, 22], ["-", 0, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 45], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 15, 16, 12, 23, 0, 16, 12, 16, 17, 60], ["-", 15, 16, 12, 23, 0, 16, 12, 16, 12, 203], ["-", 0, 57, 75, 57, 15, 16, 12, 23, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["-", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["-", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45], ["-", 75, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 75, 57, 75, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 172
| 32
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
public class C {
public static void Main() {
string[] args = Console.ReadLine().Split(' ');
long N = Int64.Parse(args[0]);
long M = Int64.Parse(args[1]);
long ans = 0;
if (N == 1)
ans = M - 2;
else if (M == 1)
ans = N - 2;
else
ans = (M - 2) * (N - 2);
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
public class C {
public static void Main() {
string[] args = Console.ReadLine().Split(' ');
long N = Int64.Parse(args[0]);
long M = Int64.Parse(args[1]);
long ans = 0;
if ((N == 1) && (M == 1))
ans = 1;
else if (N == 1)
ans = M - 2;
else if (M == 1)
ans = N - 2;
else
ans = (M - 2) * (N - 2);
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 31, 22]]
| 8
| 129
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) { Solve(); }
static void Solve() {
Scan sc = new Scan();
write wr = new write();
var s = sc.longarr;
long n = s[0];
long m = s[1];
long ans = 0;
if (n == 1) {
ans = m - 2;
} else if (m == 1) {
ans = n - 2;
} else {
ans = Math.Max(0, n - 2) * Math.Max(0, m - 2);
}
wr.wri(ans);
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => strarr.Select(char.Parse).ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) { Solve(); }
static void Solve() {
Scan sc = new Scan();
write wr = new write();
var s = sc.longarr;
long n = s[0];
long m = s[1];
long ans = 0;
if (m * n == 1) {
ans = 1;
} else if (n == 1) {
ans = m - 2;
} else if (m == 1) {
ans = n - 2;
} else {
ans = Math.Max(0, n - 2) * Math.Max(0, m - 2);
}
wr.wri(ans);
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => strarr.Select(char.Parse).ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 31, 22]]
| 8
| 269
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var eg = nm[0] + 2 * (nm[1] - 1) + nm[0] - 2;
if (nm[0] == 1 || nm[1] == 1)
WriteLine(Max(Max(nm[0], nm[1]) - 2, 0));
else
WriteLine((long)nm[0] * nm[1] - eg);
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var eg = (long)nm[0] + 2 * (nm[1] - 1) + nm[0] - 2;
if (nm[0] == 1 && nm[1] == 1)
WriteLine(1);
else if (nm[0] == 1 || nm[1] == 1)
WriteLine(Max(Max(nm[0], nm[1]) - 2, 0));
else
WriteLine((long)nm[0] * nm[1] - eg);
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
[["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 213, 63, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 171
| 25
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
#if DEBUG
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace competitive_programming {
public class Program {
static void Main(string[] args) {
#if DEBUG
var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open));
#else
var scanner = new IO.StreamScanner(Console.OpenStandardInput());
#endif
var n = scanner.Long();
var m = scanner.Long();
if (n > m) {
var tmp = n;
n = m;
m = tmp;
}
var ret = 0L;
if (n == 1)
ret = Math.Max(0, m - 2);
if (n == 2)
ret = 0;
if (n >= 3)
ret = Math.Max(0, (n - 2) * (m - 2));
IO.Printer.Out.WriteLine(ret);
IO.Printer.Out.Flush();
}
}
}
#if DEBUG
#endif
#region INOUT
namespace IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
#if DEBUG
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace competitive_programming {
public class Program {
static void Main(string[] args) {
#if DEBUG
var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open));
#else
var scanner = new IO.StreamScanner(Console.OpenStandardInput());
#endif
var n = scanner.Long();
var m = scanner.Long();
if (n > m) {
var tmp = n;
n = m;
m = tmp;
}
var ret = 0L;
if (n == 1 && m == 1)
ret = 1;
else if (n == 1)
ret = Math.Max(0, m - 2);
else if (n == 2)
ret = 0;
else if (n >= 3)
ret = Math.Max(0, (n - 2) * (m - 2));
IO.Printer.Out.WriteLine(ret);
IO.Printer.Out.Flush();
}
}
}
#if DEBUG
#endif
#region INOUT
namespace IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 31, 22], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 64, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 95]]
| 8
| 1,064
| 17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
static void Main(string[] args) {
SolveA(args);
// SolveB(args);
// SolveC(args);
// SolveD(args);
}
private const long MOD = 1000000007;
static void SolveA(string[] args) {
var nm = ReadAndParseIntArr();
long n = nm[0];
long m = nm[1];
if (n >= 3 && m >= 3) {
Console.WriteLine((n - 2) * (m - 2));
} else if (n >= 2 && m >= 2) {
long ans = n * m;
Console.WriteLine(0);
} else {
Console.WriteLine(n * m - 2);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
static void Main(string[] args) {
SolveA(args);
// SolveB(args);
// SolveC(args);
// SolveD(args);
}
private const long MOD = 1000000007;
static void SolveA(string[] args) {
var nm = ReadAndParseIntArr();
long n = nm[0];
long m = nm[1];
if (n == 1 && m == 1) {
Console.WriteLine(1);
} else if (n >= 3 && m >= 3) {
Console.WriteLine((n - 2) * (m - 2));
} else if (n >= 2 && m >= 2) {
long ans = n * m;
Console.WriteLine(0);
} else {
Console.WriteLine(n * m - 2);
}
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22]]
| 8
| 264
| 20
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
internal static void Main(string[] args) {
long[] inp = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long N = inp[0];
long M = inp[1];
if (N == 1 || M == 1) {
WriteLine((N * M) - 2);
return;
}
if (N == 2 || M == 2) {
WriteLine(0);
return;
}
WriteLine((N * M) - (N * 2) - ((M - 2) * 2));
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
internal static void Main(string[] args) {
long[] inp = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long N = inp[0];
long M = inp[1];
if (N == 1 && M == 1) {
WriteLine(1);
return;
}
if (N == 1 || M == 1) {
WriteLine((N * M) - 2);
return;
}
if (N == 2 || M == 2) {
WriteLine(0);
return;
}
WriteLine((N * M) - (N * 2) - ((M - 2) * 2));
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203]]
| 8
| 154
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;
public class Hello {
public static void Main() {
string[] n = SpRead(' ');
long N = long.Parse(n[0]);
long M = long.Parse(n[1]);
/*
000 110 001 010
0000 1100 0010 0101 0110 N = 1 M > 1 M-2
000 110 001 010 100 011 000
000 110 001 010 100 011 000
*/
if (N == 1 && M == 1)
Console.WriteLine(1);
else if (N == 1)
Console.WriteLine(M - 2);
else
Console.WriteLine((N - 2) * (M - 2));
}
}
public class Atcoder {
static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static int LCM(int a, int b) {
int c = a * b;
if (a < b)
Swap(ref a, ref b);
int d = a % b;
while (d != 0) {
a = b;
b = d;
d = a % b;
}
return c / b;
}
public static string strReverce(string s) {
return new string(s.Reverse().ToArray());
}
public static int intRead() { return int.Parse(Console.ReadLine()); }
public static bool IsPrime(int n) {
if (n < 2)
return false;
if (n == 2)
return true;
if (n % 2 == 0)
return false;
// double sqrtNum = Math.Sqrt(n);
for (int i = 3; i < n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
public static string[] SpRead(char c) { return Console.ReadLine().Split(c); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;
public class Hello {
public static void Main() {
string[] n = SpRead(' ');
long N = long.Parse(n[0]);
long M = long.Parse(n[1]);
/*
000 110 001 010
0000 1100 0010 0101 0110 N = 1 M > 1 M-2
0 1 0 0
0 1 0 1
0 0 1 0
000 110 001 010 100 011 000
000 110 001 010 100 011 000
*/
if (N == 1 && M == 1)
Console.WriteLine(1);
else if (N == 1)
Console.WriteLine(M - 2);
else if (M == 1)
Console.WriteLine(N - 2);
else
Console.WriteLine((N - 2) * (M - 2));
}
}
public class Atcoder {
static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static int LCM(int a, int b) {
int c = a * b;
if (a < b)
Swap(ref a, ref b);
int d = a % b;
while (d != 0) {
a = b;
b = d;
d = a % b;
}
return c / b;
}
public static string strReverce(string s) {
return new string(s.Reverse().ToArray());
}
public static int intRead() { return int.Parse(Console.ReadLine()); }
public static bool IsPrime(int n) {
if (n < 2)
return false;
if (n == 2)
return true;
if (n % 2 == 0)
return false;
// double sqrtNum = Math.Sqrt(n);
for (int i = 3; i < n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
public static string[] SpRead(char c) { return Console.ReadLine().Split(c); }
}
|
[["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 17, 60], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 25], ["+", 75, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 75, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 57, 75, 57, 75, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 95]]
| 8
| 378
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// var N = int.Parse(Console.ReadLine());
// var inputList = new List<int>();
// foreach (var i in Enumerable.Range(0, N))
// inputList.Add(int.Parse(Console.ReadLine()));
var NM = Console.ReadLine().Split(' ');
var N = int.Parse(NM.First());
var M = int.Parse(NM.Last());
var result = 0;
if (N == 1 && M == 1)
result = 1;
if ((N == 1 && M != 1) || (N != 1 && M == 1))
result = N * M - 2;
else if (N >= 2 && M >= 2)
result = (N - 2) * (M - 2);
if (result < 0)
result = 0;
Console.WriteLine(result);
// var NK = Console.ReadLine().Split(' ');
// var N = int.Parse(NK.First());
// var K = int.Parse(NK.Last());
// long count = 0;
////count += (N - K - 1) * (N - K);
// count += Factorial(N - K);
// if (K == 0)
// count += N;
// else
// for (int a = K; a < N; a++) {
// for (int b = K; b < a; b++) {
// if (a % b == 0) {
// // Console.WriteLine("{0} {1}", a, b);
// count++;
// }
// }
// }
// Console.WriteLine(count);
return;
}
// public static BigInteger Factorial(int n) {
// if ((n & 1) == 0) return Factorial(n / 2).Square() * Combination(n, n /
// 2); else return Factorial(n / 2).Square() * Combination(n, n / 2) * (n -
// n / 2);
//}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// var N = int.Parse(Console.ReadLine());
// var inputList = new List<int>();
// foreach (var i in Enumerable.Range(0, N))
// inputList.Add(int.Parse(Console.ReadLine()));
var NM = Console.ReadLine().Split(' ');
var N = long.Parse(NM.First());
var M = long.Parse(NM.Last());
long result = 0;
if (N == 1 && M == 1)
result = 1;
else if ((N == 1 && M != 1))
result = M - 2;
else if (N != 1 && M == 1)
result = N - 2;
else if (N >= 2 && M >= 2)
result = (N - 2) * (M - 2);
Console.WriteLine(result);
// var NK = Console.ReadLine().Split(' ');
// var N = int.Parse(NK.First());
// var K = int.Parse(NK.Last());
// long count = 0;
////count += (N - K - 1) * (N - K);
// count += Factorial(N - K);
// if (K == 0)
// count += N;
// else
// for (int a = K; a < N; a++) {
// for (int b = K; b < a; b++) {
// if (a % b == 0) {
// // Console.WriteLine("{0} {1}", a, b);
// count++;
// }
// }
// }
// Console.WriteLine(count);
return;
}
// public static BigInteger Factorial(int n) {
// if ((n & 1) == 0) return Factorial(n / 2).Square() * Combination(n, n /
// 2); else return Factorial(n / 2).Square() * Combination(n, n / 2) * (n -
// n / 2);
//}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 64, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 57, 64, 1, 0, 11, 12, 16, 31, 22], ["+", 75, 57, 64, 1, 0, 11, 12, 16, 17, 33], ["+", 75, 57, 64, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 64, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["-", 64, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["-", 8, 196, 0, 57, 75, 57, 64, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203]]
| 8
| 215
| 30
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC090.C {
class Program {
static void Main() {
int[] inputs = Console.ReadLine()
.Split(' ')
.Select(elem => int.Parse(elem))
.ToArray();
int N = inputs[0];
int M = inputs[1];
long result = 0;
if (N < 2 && M < 2) {
} else if (M == 1)
result = N - 2;
else if (N == 1)
result = M - 2;
else {
result = (long)(N - 2) * (long)(M - 2);
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC090.C {
class Program {
static void Main() {
decimal[] inputs = Console.ReadLine()
.Split(' ')
.Select(elem => decimal.Parse(elem))
.ToArray();
decimal N = inputs[0];
decimal M = inputs[1];
decimal result = 0;
if (N < 2 && M < 2) {
result = 1;
} else if (M == 1)
result = N - 2;
else if (N == 1)
result = M - 2;
else {
result = (N - 2) * (M - 2);
}
Console.WriteLine(result);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 1, 0, 11, 12, 16, 31, 74, 39, 199], ["-", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25], ["-", 0, 11, 12, 16, 31, 74, 51, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25]]
| 8
| 179
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc_090c {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
long result;
int min = Math.Min(N, M);
int max = Math.Max(N, M);
if (min == 1) {
if (max == 1) {
result = 1;
} else {
result = max - 2;
}
} else {
result = (min - 2) * (max - 2);
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc_090c {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
long result;
int min = Math.Min(N, M);
int max = Math.Max(N, M);
if (min == 1) {
if (max == 1) {
result = 1;
} else {
result = max - 2;
}
} else {
result = ((long)min - 2) * (max - 2);
}
Console.WriteLine(result);
Console.Read();
}
}
}
|
[["+", 12, 16, 31, 23, 0, 16, 31, 74, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 74, 39, 199], ["+", 12, 16, 31, 23, 0, 16, 31, 74, 0, 25], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
| 8
| 170
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder2 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
long n = int.Parse(str[0]);
long m = int.Parse(str[1]);
long ans;
if (n == 1 || m == 1) {
ans = n * m - 2;
} else {
ans = (n - 2) * (m - 2);
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder2 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
long n = int.Parse(str[0]);
long m = int.Parse(str[1]);
long ans;
if (n == 1 && m == 1) {
ans = 1;
} else if (n == 1 || m == 1) {
ans = (n * m - 2);
} else {
ans = (n - 2) * (m - 2);
}
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 25]]
| 8
| 137
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC_D {
class D090 {
static void Main(string[] args) {
int[] h = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
int N = h[0], K = h[1];
long counter = 0;
for (int i = K + 1; i <= N; i++) {
int turn = N / i;
long q = (long)turn * (i - K);
int p = Math.Max(0, N % i - K + 1);
if (i > 1)
q += p;
counter += q;
}
Console.WriteLine(counter);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC_D {
class D090 {
static void Main(string[] args) {
int[] h = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
int N = h[0], K = h[1];
long counter = 0;
for (int i = K + 1; i <= N; i++) {
int turn = N / i;
long q = (long)turn * (i - K);
int m = N % i;
int d = K == 0 ? 0 : K - 1;
int p = m - d;
if (p > 0)
q += p;
counter += q;
}
Console.WriteLine(counter);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 17, 33], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 178
| 33
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var k = int.Parse(line[1]);
var ret = 0L;
for (int i = 1; i <= n; i++)
ret += getAns(n, i, k);
Console.WriteLine(ret);
}
public static int getAns(int n, int b, int k) {
var c = n / b;
var d = n % b;
return Math.Max(0, b - k) * c + Math.Max(0, d - k + 1);
}
}
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var k = int.Parse(line[1]);
var ret = 0L;
for (int i = 1; i <= n; i++)
ret += getAns(n, i, k);
Console.WriteLine(ret);
}
public static int getAns(int n, int b, int k) {
var c = n / b;
var d = n % b;
var w = Math.Max(0, b - k);
if (k == 0)
return b * c + d;
else
return w * c + Math.Max(0, d - k + 1);
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 57, 64, 37, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 64, 37, 0, 16, 31, 16, 17, 48], ["+", 0, 57, 64, 37, 0, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 37, 0, 16, 17, 72], ["+", 8, 196, 0, 57, 64, 37, 0, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 37, 0, 38], ["+", 0, 57, 75, 37, 0, 16, 31, 16, 31, 22]]
| 8
| 158
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// var N = int.Parse(Console.ReadLine());
// var inputList = new List<int>();
// foreach (var i in Enumerable.Range(0, N))
// inputList.Add(int.Parse(Console.ReadLine()));
var NK = Console.ReadLine().Split(' ');
var N = int.Parse(NK.First());
var K = int.Parse(NK.Last());
long count = 0;
for (int b = 1; b < N; b++)
count += max(b - K, 0) * (N / b) + max((N % b) - K, 0);
Console.WriteLine(count);
return;
}
static long max(long left, long right) {
if (left >= right)
return left;
return right;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// var N = int.Parse(Console.ReadLine());
// var inputList = new List<int>();
// foreach (var i in Enumerable.Range(0, N))
// inputList.Add(int.Parse(Console.ReadLine()));
var NK = Console.ReadLine().Split(' ');
var N = int.Parse(NK.First());
var K = int.Parse(NK.Last());
long count = 0;
for (int b = 1; b <= N; b++) {
count += (max(b - K, 0) * (N / b) + max((N % b) - K + 1, 0));
if (K == 0)
count -= 1;
}
Console.WriteLine(count);
return;
}
static long max(long left, long right) {
if (left >= right)
return left;
return right;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 8, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 23, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 110], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 181
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var nm = ReadLib.ReadAsIntArray();
var n = nm[0];
var m = nm[1];
var val = CalcVal(n, m);
Console.WriteLine(val.ToString("D"));
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
private static long CalcVal(int n, int m) {
if (n == 1) {
return m - 2;
}
if (m == 1) {
return n - 2;
}
return Math.BigMul(n - 1, m - 1);
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
/// <summary>nCr, 組み合わせ</summary>
public static long Combination(int n, int r) {
if (r == 0) {
return 1;
}
// 分子
var moleculeArr =
Enumerable.Range(0, Math.Min(n - r, r)).Select(i => n - i).ToArray();
var moleculeArrLength = moleculeArr.Length;
// 分母
var denominatorArr = Enumerable.Range(1, Math.Max(n - r, r)).ToArray();
for (var m = 0; m < moleculeArrLength; m++) {
while (true) {
var mVal = moleculeArr[m];
var gcds = denominatorArr.Select(b => Gcd(mVal, b));
var maxGcd = gcds.Max();
var maxI = gcds.ToList().IndexOf(maxGcd);
if (maxGcd == 1) {
break;
}
denominatorArr[maxI] /= maxGcd;
moleculeArr[m] /= maxGcd;
}
}
return FullPower(moleculeArr);
}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static int Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
var mod = a % b;
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return (int)b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)value % mod;
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
long value = item1.Value + item2;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
long value = Math.BigMul(item1.Value, item2);
return new ModInt(value, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var nm = ReadLib.ReadAsIntArray();
var n = nm[0];
var m = nm[1];
var val = CalcVal(n, m);
Console.WriteLine(val.ToString("D"));
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
private static long CalcVal(int n, int m) {
if (m == 1 && n == 1) {
return 1;
}
if (n == 1) {
return m - 2;
}
if (m == 1) {
return n - 2;
}
return Math.BigMul(n - 2, m - 2);
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
/// <summary>nCr, 組み合わせ</summary>
public static long Combination(int n, int r) {
if (r == 0) {
return 1;
}
// 分子
var moleculeArr =
Enumerable.Range(0, Math.Min(n - r, r)).Select(i => n - i).ToArray();
var moleculeArrLength = moleculeArr.Length;
// 分母
var denominatorArr = Enumerable.Range(1, Math.Max(n - r, r)).ToArray();
for (var m = 0; m < moleculeArrLength; m++) {
while (true) {
var mVal = moleculeArr[m];
var gcds = denominatorArr.Select(b => Gcd(mVal, b));
var maxGcd = gcds.Max();
var maxI = gcds.ToList().IndexOf(maxGcd);
if (maxGcd == 1) {
break;
}
denominatorArr[maxI] /= maxGcd;
moleculeArr[m] /= maxGcd;
}
}
return FullPower(moleculeArr);
}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static int Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
var mod = a % b;
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return (int)b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)value % mod;
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
long value = item1.Value + item2;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
long value = Math.BigMul(item1.Value, item2);
return new ModInt(value, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 1,698
| 19
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long n = long.Parse(input[0]);
long k = long.Parse(input[1]);
long answer = 0;
for (long i = 1; i <= n; i++) {
if (i <= k)
continue;
else {
answer += (n + 1) / i * (i - k);
answer += Math.Max(0, ((n + 1) % i) - k);
}
}
Console.WriteLine(answer);
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long n = long.Parse(input[0]);
long k = long.Parse(input[1]);
long answer = 0;
for (long i = 1; i <= n; i++) {
if (i <= k)
continue;
else {
answer += (n + 1) / i * (i - k);
answer += Math.Max(0, ((n + 1) % i) - k);
}
}
if (k != 0)
Console.WriteLine(answer);
else
Console.WriteLine(n * n);
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 148
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Competitive {
internal class Solution {
private int N, K;
public void Run() {
int[] ary = Input.ReadIntArray();
N = ary[0];
K = ary[1];
long ret = 0;
for (int b = K + 1; b <= N; b++) {
ret += (N / b) * (b - K) + Math.Max(0, N % b - K + 1);
}
Console.WriteLine(ret);
}
}
internal static class Input {
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Competitive {
internal class Solution {
private int N, K;
public void Run() {
int[] ary = Input.ReadIntArray();
N = ary[0];
K = ary[1];
long ret = 0;
for (int b = K + 1; b <= N; b++) {
int res = K == 0 ? N % b : Math.Max(0, N % b - K + 1);
ret += (N / b) * (b - K) + res;
}
Console.WriteLine(ret);
}
}
internal static class Input {
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 11, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 17, 85], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 41, 64, 16, 17, 109], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 11, 12, 16, 31, 16, 12, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 0, 212, 0, 41, 75, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 85], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 223
| 37
|
using System;
using System.Collections.Generic;
public class Program {
private int N, A, B;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
A = sc.NextInt();
B = sc.NextInt();
if (A + B - 1 > N) {
Console.WriteLine(-1);
return;
}
if ((long)A * B < N) {
Console.WriteLine(-1);
return;
}
List<int> l = new List<int>();
l.Add(A);
int i = A;
// N-A個をB-1個に分ける
int d = (N - A) / (B - 1);
int m = (N - A) % (B - 1);
for (int j = 0; j < B - 1; j++) {
int tmp = d;
if (j < m)
tmp++;
l.Add(tmp);
}
var ans = new int[N];
int t = N;
int index = 0;
foreach (int i1 in l) {
for (int j = i1 - 1; j >= 0; j--) {
ans[index] = t - j;
index++;
}
t -= i1;
}
Console.WriteLine(String.Join(" ", ans));
}
public static void Main(string[] args) { new Program().Solve(); }
}
class Scanner {
public Scanner() {
_pos = 0;
_line = new string[0];
}
const char Separator = ' ';
private int _pos;
private string[] _line;
#region スペース区切りで取得
public string Next() {
if (_pos >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_pos = 0;
}
return _line[_pos++];
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
#endregion
#region 型変換
private int[] ToIntArray(string[] array) {
var result = new int[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = int.Parse(array[i]);
}
return result;
}
private long[] ToLongArray(string[] array) {
var result = new long[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = long.Parse(array[i]);
}
return result;
}
private double[] ToDoubleArray(string[] array) {
var result = new double[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = double.Parse(array[i]);
}
return result;
}
#endregion
#region 配列取得
public string[] Array() {
if (_pos >= _line.Length)
_line = Console.ReadLine().Split(Separator);
_pos = _line.Length;
return _line;
}
public int[] IntArray() { return ToIntArray(Array()); }
public long[] LongArray() { return ToLongArray(Array()); }
public double[] DoubleArray() { return ToDoubleArray(Array()); }
#endregion
}
|
using System;
using System.Collections.Generic;
public class Program {
private int N, A, B;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
A = sc.NextInt();
B = sc.NextInt();
if (A + B - 1 > N) {
Console.WriteLine(-1);
return;
}
if ((long)A * B < N) {
Console.WriteLine(-1);
return;
}
List<int> l = new List<int>();
l.Add(A);
int i = A;
// N-A個をB-1個に分ける
if (B > 1) {
int d = (N - A) / (B - 1);
int m = (N - A) % (B - 1);
for (int j = 0; j < B - 1; j++) {
int tmp = d;
if (j < m)
tmp++;
l.Add(tmp);
}
}
var ans = new int[N];
int t = N;
int index = 0;
foreach (int i1 in l) {
for (int j = i1 - 1; j >= 0; j--) {
ans[index] = t - j;
index++;
}
t -= i1;
}
Console.WriteLine(String.Join(" ", ans));
}
public static void Main(string[] args) { new Program().Solve(); }
}
class Scanner {
public Scanner() {
_pos = 0;
_line = new string[0];
}
const char Separator = ' ';
private int _pos;
private string[] _line;
#region スペース区切りで取得
public string Next() {
if (_pos >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_pos = 0;
}
return _line[_pos++];
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
#endregion
#region 型変換
private int[] ToIntArray(string[] array) {
var result = new int[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = int.Parse(array[i]);
}
return result;
}
private long[] ToLongArray(string[] array) {
var result = new long[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = long.Parse(array[i]);
}
return result;
}
private double[] ToDoubleArray(string[] array) {
var result = new double[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = double.Parse(array[i]);
}
return result;
}
#endregion
#region 配列取得
public string[] Array() {
if (_pos >= _line.Length)
_line = Console.ReadLine().Split(Separator);
_pos = _line.Length;
return _line;
}
public int[] IntArray() { return ToIntArray(Array()); }
public long[] LongArray() { return ToLongArray(Array()); }
public double[] DoubleArray() { return ToDoubleArray(Array()); }
#endregion
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 719
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;
class Program
{
static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
// const int M = 998244353;
const long LM = (long)1e18;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
static void Main(string[] args)
{
int n = sc.Int;
int ans = 0;
for (int i = 0; i < n; i++)
{
int a, k;
sc.Multi(out a, out k);
ans ^= calc(a, k);
}
Prt(ans != 0 ? "Takahashi" : "Aoki");
sw.Flush();
}
static int calc(int a, int k) {
if (a < k) {
return 0;
}
if (a % k == 0) {
return a / k;
}
if (a / k < k && (a % k) % (a / k) + a / k * k < a) {
return calc((a % k) % (a / k) + a / k * k, k);
}
return calc(a - (a / k + 1), k);
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
public override string ToString() => v1 + " " + v2;
}
static class util
{
public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]);
public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2);
public static T sqr<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++) ret[i] = a[i];
return ret;
}
}
static class Operator<T>
{
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan
{
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => Console.ReadLine().Trim();
public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U>
{ T a; U b; Multi(out a, out b); return new pair<T, U>(a, b); }
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
public void Multi<T, U, V>(out T a, out U b, out V c)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); }
}
static class mymath
{
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2) return false;
for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++) p[i] = true;
for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long[n][];
for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
return ret;
}
public static double[][] dE(int n) {
var ret = new double[n][];
for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; }
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0) return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0) return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static double _dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0, r = 0;
for (int i = 0; i < n; i++) {
double s = ret + (x[i] * y[i] + r);
r = (x[i] * y[i] + r) - (s - ret);
ret = s;
}
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
return ret;
}
public static double[] mul(double a, double[] x) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i];
return ret;
}
public static long[] mul(long a, long[] x) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod;
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static double[][] mul(double a, double[][] A) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static long[][] mul(long a, long[][] A) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod) return pow(a % Mod, b);
if (a == 0) return 0;
if (b == 0) return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0) return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) => pow(a, Mod - 2);
public static long gcd(long a, long b) {
while (b > 0) { var t = a % b; a = b; b = t; } return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a; x = 1; y = 0;
if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
return g;
}
public static long lcm(long a, long b) => a / gcd(a, b) * b;
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n) return 0;
if (n - r < r) r = n - r;
if (r == 0) return 1;
if (r == 1) return n;
if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }
}
}
long ret = 1;
for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long[n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;
class Program
{
static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
// const int M = 998244353;
const long LM = (long)1e18;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
static void Main(string[] args)
{
int n = sc.Int;
int ans = 0;
for (int i = 0; i < n; i++)
{
int a, k;
sc.Multi(out a, out k);
ans ^= calc(a, k);
}
Prt(ans != 0 ? "Takahashi" : "Aoki");
sw.Flush();
}
static int calc(int a, int k) {
if (a < k) {
return 0;
}
if (a % k == 0) {
return a / k;
}
if ((a % k) % (a / k + 1) + a / k * k < a) {
return calc((a % k) % (a / k + 1) + a / k * k, k);
}
return calc(a - (a / k + 1), k);
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
public override string ToString() => v1 + " " + v2;
}
static class util
{
public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]);
public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2);
public static T sqr<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++) ret[i] = a[i];
return ret;
}
}
static class Operator<T>
{
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan
{
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => Console.ReadLine().Trim();
public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U>
{ T a; U b; Multi(out a, out b); return new pair<T, U>(a, b); }
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
public void Multi<T, U, V>(out T a, out U b, out V c)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); }
}
static class mymath
{
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2) return false;
for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++) p[i] = true;
for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long[n][];
for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
return ret;
}
public static double[][] dE(int n) {
var ret = new double[n][];
for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; }
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0) return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0) return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static double _dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0, r = 0;
for (int i = 0; i < n; i++) {
double s = ret + (x[i] * y[i] + r);
r = (x[i] * y[i] + r) - (s - ret);
ret = s;
}
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
return ret;
}
public static double[] mul(double a, double[] x) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i];
return ret;
}
public static long[] mul(long a, long[] x) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod;
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static double[][] mul(double a, double[][] A) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static long[][] mul(long a, long[][] A) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod) return pow(a % Mod, b);
if (a == 0) return 0;
if (b == 0) return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0) return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) => pow(a, Mod - 2);
public static long gcd(long a, long b) {
while (b > 0) { var t = a % b; a = b; b = t; } return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a; x = 1; y = 0;
if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
return g;
}
public static long lcm(long a, long b) => a / gcd(a, b) * b;
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n) return 0;
if (n - r < r) r = n - r;
if (r == 0) return 1;
if (r == 1) return n;
if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }
}
}
long ret = 1;
for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long[n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
[["-", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 85], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 203]]
| 8
| 4,375
| 10
|
#pragma warning disable
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Diagnostics;
using System.Collections;
static class MainClass {
public static void Main() {
var a = Console.ReadLine().ToInt32();
Console.WriteLine(a % 3 == 0 ? a / 3 : a / 3 + 1);
}
#region ライブラリ
#region 二分探索
public static int LowerBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int LowerBound<T>(this IEnumerable<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
public static int UpperBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(this IEnumerable<T> arr, T value) {
return UpperBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
#endregion
#region bit全探索
/// <summary>
/// Bit全探索用のライブラリ
/// </summary>
/// <param name="len">作る配列の長さ(lenが0以下だと(ry)</param>
/// <returns>できた配列</returns>
public static List<List<bool>> CreateBits(int len) {
return CreateBitsPri(new List<List<bool>>(), len, 0);
}
private static List<List<bool>> CreateBitsPri(List<List<bool>> bits, int len,
int count) {
if (count == 0) {
var lss = new List<bool>();
lss.Add(true);
bits.Add(lss);
var lx = new List<bool>();
lx.Add(false);
bits.Add(lx);
count++;
return CreateBitsPri(bits, len, count);
}
if (len - count == 0)
return bits;
count++;
var ls = new List<List<bool>>();
foreach (var item in bits) {
var x = item.ToList();
x.Add(true);
item.Add(false);
ls.Add(item);
ls.Add(x);
}
return CreateBitsPri(ls, len, count);
}
#endregion
#region 文字列処理
public static int ToInt32(this string str) { return int.Parse(str); }
public static List<string> SplittedStringToList(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.ToList();
}
public static List<int> SplittedStringToInt32List(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x))
.ToList();
}
#endregion
#region エラトステネスの篩
/**
* MIT License
Copyright (c) 2018 gushwell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**/
public class BoundedBoolArray {
private BitArray _array;
private int _lower;
public BoundedBoolArray(int lower, int upper) {
_array = new BitArray(upper - lower + 1);
_lower = lower;
}
public bool this[int index] {
get { return _array[index - _lower]; }
set { _array[index - _lower] = value; }
}
}
public static IEnumerable<int> GeneratePrimes() {
var primes = new List<int>() { 2, 3 };
foreach (var p in primes)
yield return p;
int ix = 0;
while (true) {
int prime1st = primes[ix];
int prime2nd = primes[++ix];
var lower = prime1st * prime1st;
var upper = prime2nd * prime2nd - 1;
var sieve = new BoundedBoolArray(lower, upper);
foreach (var prime in primes.Take(ix)) {
var start = (int)Math.Ceiling((double)lower / prime) * prime;
for (int index = start; index <= upper; index += prime)
sieve[index] = true;
}
for (int i = lower; i <= upper; i++) {
if (sieve[i] == false) {
primes.Add(i);
yield return i;
}
}
}
}
#endregion
#region DeepClone
public static T DeepClone<T>(this T src) {
using (var memoryStream = new MemoryStream()) {
var binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src);
memoryStream.Seek(0, SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream);
}
}
#endregion
#region 順列を作るやつ
public static List<List<int>> GeneratePermutations(int n) {
if (n > 14)
throw new ArgumentOutOfRangeException();
var ls = new List<List<int>>();
ls.Add(new List<int>() { 1 });
for (int i = 0; i < n - 1; i++) {
var newls = new List<List<int>>();
ls.ForEach(x => {
var len = x.Count;
for (int j = 0; j <= len; j++) {
var item = x.DeepClone();
item.Insert(j, i + 2);
newls.Add(item);
}
});
ls = newls;
}
return ls;
}
#endregion
#endregion
}
|
#pragma warning disable
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Diagnostics;
using System.Collections;
static class MainClass {
public static void Main() {
var a = Console.ReadLine().ToInt32();
Console.WriteLine(a / 3);
}
#region ライブラリ
#region 二分探索
public static int LowerBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int LowerBound<T>(this IEnumerable<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
public static int UpperBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(this IEnumerable<T> arr, T value) {
return UpperBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
#endregion
#region bit全探索
/// <summary>
/// Bit全探索用のライブラリ
/// </summary>
/// <param name="len">作る配列の長さ(lenが0以下だと(ry)</param>
/// <returns>できた配列</returns>
public static List<List<bool>> CreateBits(int len) {
return CreateBitsPri(new List<List<bool>>(), len, 0);
}
private static List<List<bool>> CreateBitsPri(List<List<bool>> bits, int len,
int count) {
if (count == 0) {
var lss = new List<bool>();
lss.Add(true);
bits.Add(lss);
var lx = new List<bool>();
lx.Add(false);
bits.Add(lx);
count++;
return CreateBitsPri(bits, len, count);
}
if (len - count == 0)
return bits;
count++;
var ls = new List<List<bool>>();
foreach (var item in bits) {
var x = item.ToList();
x.Add(true);
item.Add(false);
ls.Add(item);
ls.Add(x);
}
return CreateBitsPri(ls, len, count);
}
#endregion
#region 文字列処理
public static int ToInt32(this string str) { return int.Parse(str); }
public static List<string> SplittedStringToList(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.ToList();
}
public static List<int> SplittedStringToInt32List(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x))
.ToList();
}
#endregion
#region エラトステネスの篩
/**
* MIT License
Copyright (c) 2018 gushwell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**/
public class BoundedBoolArray {
private BitArray _array;
private int _lower;
public BoundedBoolArray(int lower, int upper) {
_array = new BitArray(upper - lower + 1);
_lower = lower;
}
public bool this[int index] {
get { return _array[index - _lower]; }
set { _array[index - _lower] = value; }
}
}
public static IEnumerable<int> GeneratePrimes() {
var primes = new List<int>() { 2, 3 };
foreach (var p in primes)
yield return p;
int ix = 0;
while (true) {
int prime1st = primes[ix];
int prime2nd = primes[++ix];
var lower = prime1st * prime1st;
var upper = prime2nd * prime2nd - 1;
var sieve = new BoundedBoolArray(lower, upper);
foreach (var prime in primes.Take(ix)) {
var start = (int)Math.Ceiling((double)lower / prime) * prime;
for (int index = start; index <= upper; index += prime)
sieve[index] = true;
}
for (int i = lower; i <= upper; i++) {
if (sieve[i] == false) {
primes.Add(i);
yield return i;
}
}
}
}
#endregion
#region DeepClone
public static T DeepClone<T>(this T src) {
using (var memoryStream = new MemoryStream()) {
var binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src);
memoryStream.Seek(0, SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream);
}
}
#endregion
#region 順列を作るやつ
public static List<List<int>> GeneratePermutations(int n) {
if (n > 14)
throw new ArgumentOutOfRangeException();
var ls = new List<List<int>>();
ls.Add(new List<int>() { 1 });
for (int i = 0; i < n - 1; i++) {
var newls = new List<List<int>>();
ls.ForEach(x => {
var len = x.Count;
for (int j = 0; j <= len; j++) {
var item = x.DeepClone();
item.Insert(j, i + 2);
newls.Add(item);
}
});
ls = newls;
}
return ls;
}
#endregion
#endregion
}
|
[["-", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109], ["-", 0, 28, 0, 41, 15, 16, 31, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["-", 3, 4, 0, 28, 0, 41, 64, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 41, 64, 16, 17, 85], ["-", 3, 4, 0, 28, 0, 41, 64, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["-", 0, 28, 0, 41, 75, 16, 31, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 41, 75, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 41, 75, 16, 12, 203]]
| 8
| 1,244
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_ABC089_A {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
Console.WriteLine(n % 3);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_ABC089_A {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
Console.WriteLine(((int)(n / 3)).ToString());
}
}
}
|
[["+", 0, 28, 0, 213, 63, 214, 205, 23, 0, 24], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 0, 24], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 39, 199], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 0, 25], ["+", 63, 214, 205, 23, 0, 74, 51, 23, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["+", 205, 23, 0, 74, 51, 23, 0, 16, 17, 85], ["+", 63, 214, 205, 23, 0, 74, 51, 23, 0, 25], ["+", 0, 28, 0, 213, 63, 214, 205, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 69
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;
class Program
{
static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
// const int M = 998244353;
const long LM = (long)1e18;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
static void Main(string[] args)
{
Prt(sc.Str.Contains('Y') ? "Four" : "Three");
sw.Flush();
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
public override string ToString() => v1 + " " + v2;
}
static class util
{
public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]);
public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2);
public static T sqr<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++) ret[i] = a[i];
return ret;
}
}
static class Operator<T>
{
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan
{
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => Console.ReadLine().Trim();
public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U>
{ T a; U b; Multi(out a, out b); return make_pair(a, b); }
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
public void Multi<T, U, V>(out T a, out U b, out V c)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); }
}
static class mymath
{
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2) return false;
for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++) p[i] = true;
for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long[n][];
for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
return ret;
}
public static double[][] dE(int n) {
var ret = new double[n][];
for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; }
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0) return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0) return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static double _dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0, r = 0;
for (int i = 0; i < n; i++) {
double s = ret + (x[i] * y[i] + r);
r = (x[i] * y[i] + r) - (s - ret);
ret = s;
}
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
return ret;
}
public static double[] mul(double a, double[] x) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i];
return ret;
}
public static long[] mul(long a, long[] x) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod;
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static double[][] mul(double a, double[][] A) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static long[][] mul(long a, long[][] A) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod) return pow(a % Mod, b);
if (a == 0) return 0;
if (b == 0) return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0) return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) => pow(a, Mod - 2);
public static long gcd(long a, long b) {
while (b > 0) { var t = a % b; a = b; b = t; } return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a; x = 1; y = 0;
if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
return g;
}
public static long lcm(long a, long b) => a / gcd(a, b) * b;
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n) return 0;
if (n - r < r) r = n - r;
if (r == 0) return 1;
if (r == 1) return n;
if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }
}
}
long ret = 1;
for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long[n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;
class Program
{
static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
// const int M = 998244353;
const long LM = (long)1e18;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
static void Main(string[] args)
{
int n = sc.Int;
Prt(sc.StrArr.Contains("Y") ? "Four" : "Three");
sw.Flush();
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
public override string ToString() => v1 + " " + v2;
}
static class util
{
public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]);
public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2);
public static T sqr<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; }
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++) ret[i] = a[i];
return ret;
}
}
static class Operator<T>
{
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan
{
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => Console.ReadLine().Trim();
public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U>
{ T a; U b; Multi(out a, out b); return make_pair(a, b); }
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
public void Multi<T, U, V>(out T a, out U b, out V c)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
{ var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); }
}
static class mymath
{
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2) return false;
for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++) p[i] = true;
for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long[n][];
for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
return ret;
}
public static double[][] dE(int n) {
var ret = new double[n][];
for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; }
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0) return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0) return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static double _dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0, r = 0;
for (int i = 0; i < n; i++) {
double s = ret + (x[i] * y[i] + r);
r = (x[i] * y[i] + r) - (s - ret);
ret = s;
}
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
return ret;
}
public static double[] mul(double a, double[] x) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i];
return ret;
}
public static long[] mul(long a, long[] x) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod;
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static double[][] mul(double a, double[][] A) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static long[][] mul(long a, long[][] A) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod) return pow(a % Mod, b);
if (a == 0) return 0;
if (b == 0) return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0) return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) => pow(a, Mod - 2);
public static long gcd(long a, long b) {
while (b > 0) { var t = a % b; a = b; b = t; } return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a; x = 1; y = 0;
if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
return g;
}
public static long lcm(long a, long b) => a / gcd(a, b) * b;
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n) return 0;
if (n - r < r) r = n - r;
if (r == 0) return 1;
if (r == 1) return n;
if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }
}
}
long ret = 1;
for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long[n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 41, 15, 213, 63, 214, 205, 214, 141, 22], ["+", 0, 41, 15, 213, 63, 214, 205, 214, 141, 22], ["-", 15, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["+", 15, 213, 3, 4, 0, 28, 0, 5, 0, 62]]
| 8
| 4,215
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderB {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
char[] s = sc.NextCharArray();
int count = s.Distinct().Count();
string answer = count == 3 ? "Three" : "Four";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderB {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
List<char> s = new List<char>();
for (int i = 0; i < n; i++) {
s.Add(sc.NextChar());
}
int count = s.Distinct().Count();
string answer = count == 3 ? "Three" : "Four";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 389
| 36
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
var n = ScanInt();
var nameList = new Dictionary<char, List<string>>() {
{ 'M', new List<string>() }, { 'A', new List<string>() },
{ 'R', new List<string>() }, { 'C', new List<string>() },
{ 'H', new List<string>() },
};
for (int i = 0; i < n; i++) {
var s = ReadLine();
if (!"MARCH".Contains(s[0]))
continue;
nameList[s[0]].Add(s);
}
long res = 0;
long m = nameList['M'].Count;
long a = nameList['A'].Count;
long r = nameList['R'].Count;
long c = nameList['C'].Count;
long h = nameList['H'].Count;
res += m * a * r;
res += m * a * c;
res += m * a * h;
res += m * r * c;
res += m * r * h;
res += a * r * c;
res += a * r * h;
res += a * c * h;
res += r * c * h;
WriteLine(res);
// ReadKey();
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
var n = ScanInt();
var nameList = new Dictionary<char, List<string>>() {
{ 'M', new List<string>() }, { 'A', new List<string>() },
{ 'R', new List<string>() }, { 'C', new List<string>() },
{ 'H', new List<string>() },
};
for (int i = 0; i < n; i++) {
var s = ReadLine();
if (!"MARCH".Contains(s[0]))
continue;
nameList[s[0]].Add(s);
}
long res = 0;
long m = nameList['M'].Count;
long a = nameList['A'].Count;
long r = nameList['R'].Count;
long c = nameList['C'].Count;
long h = nameList['H'].Count;
res += m * a * r;
res += m * a * c;
res += m * a * h;
res += m * r * c;
res += m * r * h;
res += m * c * h;
res += a * r * c;
res += a * r * h;
res += a * c * h;
res += r * c * h;
WriteLine(res);
// ReadKey();
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107]]
| 8
| 2,245
| 8
|
using System;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
long m = 0;
long a = 0;
long r = 0;
long c = 0;
long h = 0;
string s;
for (int i = 0; i < N; i++) {
s = Console.ReadLine();
if (s[0] == 'M')
m++;
else if (s[0] == 'A')
a++;
else if (s[0] == 'R')
r++;
else if (s[0] == 'C')
c++;
else if (s[0] == 'H')
h++;
}
// the posibilities are "mar mac mah mrc mrh mch arc arh ach rch" just
// aggregate wont do it. so per m, there is a amount of posibilities, meaning
// *a and then r posibilities meaning *r, aggregate this for answer
long aggregation = (m * a * r) + (m * a * c) + (m * a * h) + (m * r * c) +
(m * r * h) + (a * r * c) + (a * r * h) + (a * c * h) +
(r * c * h);
Console.WriteLine(aggregation);
}
}
}
|
using System;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
long m = 0;
long a = 0;
long r = 0;
long c = 0;
long h = 0;
string s;
for (int i = 0; i < N; i++) {
s = Console.ReadLine();
if (s[0] == 'M')
m++;
else if (s[0] == 'A')
a++;
else if (s[0] == 'R')
r++;
else if (s[0] == 'C')
c++;
else if (s[0] == 'H')
h++;
}
// the posibilities are "mar mac mah mrc mrh mch arc arh ach rch" just
// aggregate wont do it. m *a posibilitiesof m *r posibilities of ma
long aggregation = (m * a * r) + (m * a * c) + (m * a * h) + (m * r * c) +
(m * r * h) + (m * c * h) + (a * r * c) + (a * r * h) +
(a * c * h) + (r * c * h);
Console.WriteLine(aggregation);
}
}
}
|
[["+", 31, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 17, 48], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 16, 12, 23, 0, 24]]
| 8
| 247
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtCodeeeer {
class AtCOOOOOOOOOOOder {
static void Main(string[] args) {
//組み合わせを自らの手によって全列挙してしまえば難しいアルゴリズムなどは必要なくなる
int[] P = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
int[] Q = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
int[] R = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };
int n = int.Parse(ReadLine());
int[] s = Enumerable.Repeat(0, 5).ToArray();
for (int i = 0; i < n; i++) {
var tmp = ReadLine()[0];
if (tmp == 'M')
s[0]++;
if (tmp == 'A')
s[1]++;
if (tmp == 'R')
s[2]++;
if (tmp == 'C')
s[3]++;
if (tmp == 'H')
s[4]++;
}
long ans = 0;
for (int i = 0; i < 10; i++) {
ans += s[P[i]] * s[Q[i]] * s[R[i]];
}
WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtCodeeeer {
class AtCOOOOOOOOOOOder {
static void Main(string[] args) {
//組み合わせを自らの手によって全列挙してしまえば難しいアルゴリズムなどは必要なくなる
int[] P = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
int[] Q = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
int[] R = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };
int n = int.Parse(ReadLine());
int[] s = Enumerable.Repeat(0, 5).ToArray();
for (int i = 0; i < n; i++) {
var tmp = ReadLine()[0];
if (tmp == 'M')
s[0]++;
if (tmp == 'A')
s[1]++;
if (tmp == 'R')
s[2]++;
if (tmp == 'C')
s[3]++;
if (tmp == 'H')
s[4]++;
}
long ans = 0;
for (int i = 0; i < 10; i++) {
ans += (long)(s[P[i]]) * (long)(s[Q[i]]) * (long)(s[R[i]]);
}
WriteLine(ans);
}
}
}
|
[["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 25], ["+", 12, 16, 31, 16, 31, 74, 51, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 74, 51, 23, 0, 25], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 0, 25], ["+", 12, 16, 31, 16, 12, 74, 51, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 74, 51, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25], ["+", 0, 11, 12, 16, 12, 74, 51, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 74, 51, 23, 0, 25]]
| 8
| 316
| 15
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoder {
class Program {
static void Main(string[] args) { MainStream(); }
static void MainStream() {
Scan sc = new Scan();
write wr = new write();
int[] march = new int[5];
int[] P = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
int[] Q = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
int[] R = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };
int n = sc.intarr[0];
for (int i = 0; i < n; i++) {
string name = sc.str;
char init = name[0];
if (init == 'M') {
march[0]++;
} else if (init == 'A') {
march[1]++;
} else if (init == 'R') {
march[2]++;
} else if (init == 'C') {
march[3]++;
} else if (init == 'H') {
march[4]++;
}
}
long result = 0;
for (int i = 0; i < 10; i++) {
result += march[P[i]] * march[Q[i]] * march[R[i]];
}
wr.wri(result);
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => str.ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
class Method {
static public int max(params int[] nums) {
int maxx = nums[0];
for (int i = 1; i < nums.Length; i++) {
maxx = Math.Max(maxx, nums[i]);
}
return maxx;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoder {
class Program {
static void Main(string[] args) { MainStream(); }
static void MainStream() {
Scan sc = new Scan();
write wr = new write();
int[] march = new int[5];
int[] P = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
int[] Q = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
int[] R = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };
int n = sc.intarr[0];
for (int i = 0; i < n; i++) {
string name = sc.str;
char init = name[0];
if (init == 'M') {
march[0]++;
}
if (init == 'A') {
march[1]++;
}
if (init == 'R') {
march[2]++;
}
if (init == 'C') {
march[3]++;
}
if (init == 'H') {
march[4]++;
}
}
long result = 0;
for (int i = 0; i < 10; i++) {
result += (long)march[P[i]] * march[Q[i]] * march[R[i]];
}
Console.WriteLine(result);
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => str.ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
class Method {
static public int max(params int[] nums) {
int maxx = nums[0];
for (int i = 1; i < nums.Length; i++) {
maxx = Math.Max(maxx, nums[i]);
}
return maxx;
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 57, 0, 95], ["-", 8, 196, 0, 57, 75, 57, 75, 57, 0, 95], ["-", 0, 57, 75, 57, 75, 57, 75, 57, 0, 95], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22]]
| 8
| 494
| 11
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] l = new int[5] { 0, 0, 0, 0, 0 };
for (int i = 0; i < n; i++) {
string s = Console.ReadLine();
if (s[0] == 'M')
l[0]++;
if (s[0] == 'A')
l[1]++;
if (s[0] == 'R')
l[2]++;
if (s[0] == 'C')
l[3]++;
if (s[0] == 'H')
l[4]++;
}
Console.WriteLine(solve(l));
}
static int solve(int[] l) {
int count = 0;
count += l[0] * l[1] * (l[2] + l[3] + l[4]);
count += l[0] * l[2] * (l[3] + l[4]);
count += l[0] * l[3] * l[4];
count += l[1] * l[2] * (l[3] + l[4]);
count += l[1] * l[3] * l[4];
count += l[2] * l[3] * l[4];
return count;
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long[] l = new long[5] { 0, 0, 0, 0, 0 };
for (long i = 0; i < n; i++) {
string s = Console.ReadLine();
if (s[0] == 'M')
l[0]++;
if (s[0] == 'A')
l[1]++;
if (s[0] == 'R')
l[2]++;
if (s[0] == 'C')
l[3]++;
if (s[0] == 'H')
l[4]++;
}
Console.WriteLine(solve(l));
}
static long solve(long[] l) {
long count = 0;
count += l[0] * l[1] * (l[2] + l[3] + l[4]);
count += l[0] * l[2] * (l[3] + l[4]);
count += l[0] * l[3] * l[4];
count += l[1] * l[2] * (l[3] + l[4]);
count += l[1] * l[3] * l[4];
count += l[2] * l[3] * l[4];
return count;
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 0, 195, 54, 55, 0, 220, 39, 224, 39, 199], ["+", 0, 195, 54, 55, 0, 220, 39, 224, 39, 199]]
| 8
| 326
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class ABC {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int m = 0, a = 0, r = 0, c = 0, h = 0;
for (int i = 0; i < N; i++) {
string S = Console.ReadLine();
if (S[0] == 'M')
m++;
else if (S[0] == 'A')
a++;
else if (S[0] == 'R')
r++;
else if (S[0] == 'C')
c++;
else if (S[0] == 'H')
h++;
}
int[] list = { m, a, r, c, h };
int[] A = { 0, 0, 0, 1, 1, 2, 1, 0, 0, 0 };
int[] B = { 1, 1, 1, 2, 2, 3, 3, 2, 2, 3 };
int[] C = { 2, 3, 4, 3, 4, 4, 4, 3, 4, 4 };
long ans = 0;
for (int i = 0; i < 10; i++) {
ans += list[A[i]] * list[B[i]] * list[C[i]];
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class ABC {
static void Main(string[] args) {
long N = int.Parse(Console.ReadLine());
long m = 0, a = 0, r = 0, c = 0, h = 0;
for (long i = 0; i < N; i++) {
string S = Console.ReadLine();
if (S[0] == 'M')
m++;
else if (S[0] == 'A')
a++;
else if (S[0] == 'R')
r++;
else if (S[0] == 'C')
c++;
else if (S[0] == 'H')
h++;
}
long[] list = { m, a, r, c, h };
long[] A = { 0, 0, 0, 1, 1, 2, 1, 0, 0, 0 };
long[] B = { 1, 1, 1, 2, 2, 3, 3, 2, 2, 3 };
long[] C = { 2, 3, 4, 3, 4, 4, 4, 3, 4, 4 };
long ans = 0;
for (long i = 0; i < 10; i++) {
ans += list[A[i]] * list[B[i]] * list[C[i]];
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199]]
| 8
| 338
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
#if DEBUG
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace competitive_programming {
public class Program {
static void Main(string[] args) {
#if DEBUG
var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open));
#else
var scanner = new IO.StreamScanner(Console.OpenStandardInput());
#endif
var n = scanner.Integer();
var ss = new List<string>();
for (int i = 0; i < n; i++)
ss.Add(scanner.ScanLine());
var strsDict = new Dictionary<char, int>();
foreach (var s in ss) {
if (!"MARCH".Contains(s[0]))
continue;
if (!strsDict.ContainsKey(s[0]))
strsDict.Add(s[0], 0);
strsDict[s[0]]++;
}
var ret = 0L;
var combi = new List<char[]>();
var array = "MARCH".ToCharArray();
GetPermutation(ref combi, array, 0, array.Length - 1);
var allCombi = new HashSet<string>();
foreach (var c in combi) {
allCombi.Add(new string(c.Take(3).OrderBy(d => d).ToArray()));
}
foreach (var ptn in allCombi.ToList()) {
if (!strsDict.ContainsKey(ptn[0]) || !strsDict.ContainsKey(ptn[1]) ||
!strsDict.ContainsKey(ptn[2]))
continue;
ret += (strsDict[ptn[0]] * strsDict[ptn[1]] * strsDict[ptn[2]]);
}
IO.Printer.Out.WriteLine(ret);
IO.Printer.Out.Flush();
}
static public void GetPermutation<T>(ref List<T[]> ret, T[] arry, int i,
int n) {
int j;
if (i == n)
ret.Add(new List<T>(arry).ToArray());
else {
for (j = i; j <= n; j++) {
Swap(ref arry[i], ref arry[j]);
GetPermutation(ref ret, arry, i + 1, n);
Swap(ref arry[i], ref arry[j]); // backtrack
}
}
}
static public void Swap<T>(ref T a, ref T b) {
T tmp;
tmp = a;
a = b;
b = tmp;
}
// m種類から重複なくn個を選ぶ組み合わせ
public static Int64 GetMcn(int m, int n) {
Int64 val;
if (m < n)
return 0;
n = Math.Min(n, m - n);
if (n == 0)
val = 1;
else
val = GetMcn(m - 1, n - 1) * m / n;
return val;
}
}
}
#if DEBUG
#endif
#region INOUT
namespace IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
#if DEBUG
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace competitive_programming {
public class Program {
static void Main(string[] args) {
#if DEBUG
var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open));
#else
var scanner = new IO.StreamScanner(Console.OpenStandardInput());
#endif
var n = scanner.Integer();
var ss = new List<string>();
for (int i = 0; i < n; i++)
ss.Add(scanner.ScanLine());
var strsDict = new Dictionary<char, int>();
foreach (var s in ss) {
if (!"MARCH".Contains(s[0]))
continue;
if (!strsDict.ContainsKey(s[0]))
strsDict.Add(s[0], 0);
strsDict[s[0]]++;
}
var ret = 0L;
var combi = new List<char[]>();
var array = "MARCH".ToCharArray();
GetPermutation(ref combi, array, 0, array.Length - 1);
var allCombi = new HashSet<string>();
foreach (var c in combi) {
allCombi.Add(new string(c.Take(3).OrderBy(d => d).ToArray()));
}
foreach (var ptn in allCombi.ToList()) {
if (!strsDict.ContainsKey(ptn[0]) || !strsDict.ContainsKey(ptn[1]) ||
!strsDict.ContainsKey(ptn[2]))
continue;
ret += ((long)strsDict[ptn[0]] * (long)strsDict[ptn[1]] *
(long)strsDict[ptn[2]]);
}
IO.Printer.Out.WriteLine(ret);
IO.Printer.Out.Flush();
}
static public void GetPermutation<T>(ref List<T[]> ret, T[] arry, int i,
int n) {
int j;
if (i == n)
ret.Add(new List<T>(arry).ToArray());
else {
for (j = i; j <= n; j++) {
Swap(ref arry[i], ref arry[j]);
GetPermutation(ref ret, arry, i + 1, n);
Swap(ref arry[i], ref arry[j]); // backtrack
}
}
}
static public void Swap<T>(ref T a, ref T b) {
T tmp;
tmp = a;
a = b;
b = tmp;
}
// m種類から重複なくn個を選ぶ組み合わせ
public static Int64 GetMcn(int m, int n) {
Int64 val;
if (m < n)
return 0;
n = Math.Min(n, m - n);
if (n == 0)
val = 1;
else
val = GetMcn(m - 1, n - 1) * m / n;
return val;
}
}
}
#if DEBUG
#endif
#region INOUT
namespace IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
|
[["+", 12, 23, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 12, 23, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 12, 23, 0, 16, 31, 16, 31, 74, 0, 25], ["+", 12, 23, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 12, 23, 0, 16, 31, 16, 12, 74, 39, 199], ["+", 12, 23, 0, 16, 31, 16, 12, 74, 0, 25], ["+", 0, 11, 12, 23, 0, 16, 12, 74, 0, 24], ["+", 0, 11, 12, 23, 0, 16, 12, 74, 39, 199], ["+", 0, 11, 12, 23, 0, 16, 12, 74, 0, 25]]
| 8
| 1,475
| 9
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.C_Challenge {
class ABC_088 {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
var marchCnt = new ulong[5];
for (int i = 0; i < n; i++) {
string s = Console.ReadLine();
switch (s[0]) {
case 'M':
marchCnt[0]++;
break;
case 'A':
marchCnt[1]++;
break;
case 'R':
marchCnt[2]++;
break;
case 'C':
marchCnt[3]++;
break;
case 'H':
marchCnt[4]++;
break;
}
}
ulong allCnt = 0;
for (int i = 0; i < n - 2; i++) {
for (int j = i + 1; j < n - 1; j++) {
for (int k = j + 1; k < n; k++) {
/*Console.WriteLine(string.Format("{0},{1},{2}",
i, j, k));*/
allCnt += marchCnt[i] * marchCnt[j] * marchCnt[k];
}
}
}
Console.WriteLine(allCnt);
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.C_Challenge {
class ABC_088 {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
var marchCnt = new ulong[5];
for (int i = 0; i < n; i++) {
string s = Console.ReadLine();
switch (s[0]) {
case 'M':
marchCnt[0]++;
break;
case 'A':
marchCnt[1]++;
break;
case 'R':
marchCnt[2]++;
break;
case 'C':
marchCnt[3]++;
break;
case 'H':
marchCnt[4]++;
break;
}
}
ulong allCnt = 0;
for (int i = 0; i < 3; i++) {
for (int j = i + 1; j < 4; j++) {
for (int k = j + 1; k < 5; k++) {
allCnt += marchCnt[i] * marchCnt[j] * marchCnt[k];
}
}
}
Console.WriteLine(allCnt);
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 412
| 10
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
internal static void Main(string[] args) {
var N = int.Parse(ReadLine());
var S = new Dictionary<String, int>() {
{ "M", 0 }, { "A", 0 }, { "R", 0 }, { "C", 0 }, { "H", 0 }
};
for (int i = 0; i < N; i++) {
var str = ReadLine().Substring(0, 1);
switch (str) {
case "M":
case "A":
case "R":
case "C":
case "H":
if (S.ContainsKey(str)) {
S[str]++;
}
break;
}
}
string[] p = { "M", "M", "M", "M", "M", "M", "A", "A", "A", "R" };
string[] q = { "A", "A", "A", "R", "R", "C", "R", "R", "C", "C" };
string[] r = { "R", "C", "H", "C", "H", "H", "C", "H", "H", "H" };
long ans = 0;
for (int i = 0; i < 10; i++) {
ans += S[p[i]] * S[q[i]] * S[r[i]];
}
WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
internal static void Main(string[] args) {
var N = int.Parse(ReadLine());
var S = new Dictionary<String, long>() {
{ "M", 0 }, { "A", 0 }, { "R", 0 }, { "C", 0 }, { "H", 0 }
};
for (int i = 0; i < N; i++) {
var str = ReadLine().Substring(0, 1);
if (S.ContainsKey(str)) {
S[str]++;
}
}
string[] p = { "M", "M", "M", "M", "M", "M", "A", "A", "A", "R" };
string[] q = { "A", "A", "A", "R", "R", "C", "R", "R", "C", "C" };
string[] r = { "R", "C", "H", "C", "H", "H", "C", "H", "H", "H" };
long ans = 0;
for (int i = 0; i < 10; i++) {
ans += S[p[i]] * S[q[i]] * S[r[i]];
}
WriteLine(ans);
}
}
|
[["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 8, 196, 0, 7, 8, 196, 0, 99, 0, 155], ["-", 8, 196, 0, 7, 8, 196, 0, 99, 0, 24], ["-", 8, 196, 0, 7, 8, 196, 0, 99, 51, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 99, 0, 25], ["-", 0, 7, 8, 196, 0, 99, 8, 254, 0, 45], ["-", 0, 99, 8, 254, 0, 239, 0, 264, 0, 173], ["-", 8, 254, 0, 239, 0, 264, 0, 5, 0, 62], ["-", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["-", 0, 99, 8, 254, 0, 239, 0, 264, 0, 102], ["-", 0, 239, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 254, 0, 239, 0, 57, 64, 196, 0, 46], ["-", 0, 99, 8, 254, 0, 239, 0, 93, 0, 94]]
| 8
| 376
| 35
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc90_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
long M = 0;
long A = 0;
long R = 0;
long C = 0;
long H = 0;
for (int i = 0; i < n; i++) {
var s = ReadLine().Substring(0, 1);
switch (s) {
case ("M"):
M++;
break;
case ("A"):
A++;
break;
case ("R"):
R++;
break;
case ("C"):
C++;
break;
case ("H"):
H++;
break;
default:
break;
}
}
long sum = M * A * R + M * A * C + M * A + H + M * R * C + M * R * H +
M * C * H + A * R * C + A * R * H + A * C * H + R * C * H;
WriteLine(sum);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc90_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
long M = 0;
long A = 0;
long R = 0;
long C = 0;
long H = 0;
for (int i = 0; i < n; i++) {
var s = ReadLine().Substring(0, 1);
switch (s) {
case ("M"):
M++;
break;
case ("A"):
A++;
break;
case ("R"):
R++;
break;
case ("C"):
C++;
break;
case ("H"):
H++;
break;
default:
break;
}
}
long sum = (M * A * R) + (M * A * C) + (M * A * H) + (M * R * C) +
(M * R * H) + (M * C * H) + (A * R * C) + (A * R * H) +
(A * C * H) + (R * C * H);
WriteLine(sum);
}
}
}
|
[["+", 31, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 16, 31, 16, 31, 16, 31, 23, 0, 25], ["+", 31, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 0, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 212, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25]]
| 8
| 278
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc089c {
class Abc089c {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
double m = 0, a = 0, r = 0, c = 0, h = 0;
for (var i = 0; i != n; ++i) {
var name = Console.ReadLine();
switch (name[0]) {
case 'M':
++m;
break;
case 'A':
++a;
break;
case 'R':
++r;
break;
case 'C':
++c;
break;
case 'H':
++h;
break;
}
}
double ans = 0;
ans += m * a * r;
ans += m * a * c;
ans += m * a * h;
ans += m * r * c;
ans += m * r * h;
ans += m * c * h;
ans += a * r * c;
ans += a * r * h;
ans += r * c * h;
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc089c {
class Abc089c {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
double m = 0, a = 0, r = 0, c = 0, h = 0;
for (var i = 0; i != n; ++i) {
var name = Console.ReadLine();
switch (name[0]) {
case 'M':
++m;
break;
case 'A':
++a;
break;
case 'R':
++r;
break;
case 'C':
++c;
break;
case 'H':
++h;
break;
}
}
double ans = 0;
ans += m * a * r;
ans += m * a * c;
ans += m * a * h;
ans += m * r * c;
ans += m * r * h;
ans += m * c * h;
ans += a * r * c;
ans += a * r * h;
ans += a * c * h;
ans += r * c * h;
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107]]
| 8
| 249
| 8
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] a_asArgs) {
int l_iN =
Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray()[0];
char[] l_acHead = new char[] { 'M', 'A', 'R', 'C', 'H' };
int[] l_aiCount = new int[5];
for (int l_iIndex = 0; l_iIndex < l_iN; l_iIndex++) {
string l_sName = Console.ReadLine();
int l_iPos = Array.IndexOf<char>(l_acHead, l_sName[0]);
if (l_iPos > -1) {
l_aiCount[l_iPos]++;
}
}
int[][] l_aaiCombination = new int[][] {
new int[] { 0, 1, 2 }, new int[] { 0, 1, 3 }, new int[] { 0, 1, 4 },
new int[] { 0, 2, 3 }, new int[] { 0, 2, 4 }, new int[] { 0, 3, 4 },
new int[] { 1, 2, 3 }, new int[] { 1, 2, 4 }, new int[] { 1, 3, 4 },
new int[] { 2, 3, 4 },
};
long l_iResult = 0;
for (int l_iBuf = 0; l_iBuf < l_aaiCombination.Length; l_iBuf++) {
l_iResult += l_aiCount[l_aaiCombination[l_iBuf][0]] *
l_aiCount[l_aaiCombination[l_iBuf][1]] *
l_aiCount[l_aaiCombination[l_iBuf][2]];
}
Console.WriteLine(l_iResult);
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] a_asArgs) {
long l_iN =
Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray()[0];
char[] l_acHead = new char[] { 'M', 'A', 'R', 'C', 'H' };
long[] l_aiCount = new long[5];
for (long l_iIndex = 0; l_iIndex < l_iN; l_iIndex++) {
string l_sName = Console.ReadLine();
long l_iPos = Array.IndexOf<char>(l_acHead, l_sName[0]);
if (l_iPos > -1) {
l_aiCount[l_iPos]++;
}
}
long[][] l_aaiCombination = new long[][] {
new long[] { 0, 1, 2 }, new long[] { 0, 1, 3 }, new long[] { 0, 1, 4 },
new long[] { 0, 2, 3 }, new long[] { 0, 2, 4 }, new long[] { 0, 3, 4 },
new long[] { 1, 2, 3 }, new long[] { 1, 2, 4 }, new long[] { 1, 3, 4 },
new long[] { 2, 3, 4 },
};
long l_iResult = 0;
for (long l_iBuf = 0; l_iBuf < l_aaiCombination.Length; l_iBuf++) {
l_iResult += l_aiCount[l_aaiCombination[l_iBuf][0]] *
l_aiCount[l_aaiCombination[l_iBuf][1]] *
l_aiCount[l_aaiCombination[l_iBuf][2]];
}
Console.WriteLine(l_iResult);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 39, 224, 39, 199], ["+", 0, 197, 0, 198, 39, 224, 39, 224, 39, 199], ["-", 0, 212, 0, 227, 39, 224, 39, 224, 39, 199], ["+", 0, 212, 0, 227, 39, 224, 39, 224, 39, 199], ["-", 0, 227, 0, 229, 0, 227, 39, 224, 39, 199], ["+", 0, 227, 0, 229, 0, 227, 39, 224, 39, 199]]
| 8
| 363
| 38
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
// using System.Text;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
// using System.Numerics;
// using static System.Math;
// using pair = Pair<int, int>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
readonly int mod = 1000000007;
void solve() {
int N = cin.nextint;
var A = new long[5];
var D = new Dictionary<int, int> { ['M'] = 0, ['A'] = 1, ['R'] = 2,
['C'] = 3, ['H'] = 4 };
for (int i = 0; i < N; i++) {
var c = cin.next[0];
if (D.ContainsKey(c)) {
A[D[c]]++;
}
}
long ans = 0;
for (int i = 0; i < 5; i++) {
for (int j = i + 1; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
ans += A[i] * A[j] % mod * A[k] % mod;
ans %= mod;
}
}
}
WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan {
get { return ReadLine().Split(); }
}
public int[] scanint {
get { return Array.ConvertAll(scan, int.Parse); }
}
public long[] scanlong {
get { return Array.ConvertAll(scan, long.Parse); }
}
public double[] scandouble {
get { return Array.ConvertAll(scan, double.Parse); }
}
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint {
get { return int.Parse(next); }
}
public long nextlong {
get { return long.Parse(next); }
}
public double nextdouble {
get { return double.Parse(next); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
// using System.Text;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
// using System.Numerics;
// using static System.Math;
// using pair = Pair<int, int>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
readonly int mod = 1000000007;
void solve() {
int N = cin.nextint;
var A = new long[5];
var D = new Dictionary<int, int> { ['M'] = 0, ['A'] = 1, ['R'] = 2,
['C'] = 3, ['H'] = 4 };
for (int i = 0; i < N; i++) {
var c = cin.next[0];
if (D.ContainsKey(c)) {
A[D[c]]++;
}
}
long ans = 0;
for (int i = 0; i < 5; i++) {
for (int j = i + 1; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
ans += A[i] * A[j] * A[k];
}
}
}
WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan {
get { return ReadLine().Split(); }
}
public int[] scanint {
get { return Array.ConvertAll(scan, int.Parse); }
}
public long[] scanlong {
get { return Array.ConvertAll(scan, long.Parse); }
}
public double[] scandouble {
get { return Array.ConvertAll(scan, double.Parse); }
}
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint {
get { return int.Parse(next); }
}
public long nextlong {
get { return long.Parse(next); }
}
public double nextdouble {
get { return double.Parse(next); }
}
}
|
[["-", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["-", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 542
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var A = GetInt();
var B = GetInt();
var X = GetInt();
var ans = (X - A) % B;
Console.Write(ans);
}
static public string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var X = GetInt();
var A = GetInt();
var B = GetInt();
var ans = (X - A) % B;
Console.Write(ans);
}
static public string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22]]
| 8
| 633
| 6
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
// 整数の入力
long x = long.Parse(Console.ReadLine());
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long remain = x - a;
while (remain > b) {
remain -= b;
}
Console.WriteLine(remain.ToString());
Console.Out.Flush();
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
// 整数の入力
long x = long.Parse(Console.ReadLine());
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long remain = x - a;
while (remain >= b) {
remain -= b;
}
Console.WriteLine(remain.ToString());
Console.Out.Flush();
Console.ReadLine();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22]]
| 8
| 103
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC087A {
class Program {
static void Main(string[] args) {
int n, a, b, c;
var word = Console.ReadLine().Split(' ');
c = int.Parse(Console.ReadLine());
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
n = (c - a) % b;
Console.WriteLine(c);
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC087A {
class Program {
static void Main(string[] args) {
int n, a, b, c;
c = int.Parse(Console.ReadLine());
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
n = (c - a) % b;
Console.WriteLine(n);
Console.ReadKey();
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 133
| 18
|
using System;
namespace AtCoder_20190705 {
class Program {
static int Solve() {
int money = int.Parse(Console.ReadLine());
int balance = money - int.Parse(Console.ReadLine());
int someCake = int.Parse(Console.ReadLine());
while (balance > someCake) {
balance -= someCake;
}
return balance;
}
static void Main(string[] args) { Console.WriteLine(Solve()); }
}
}
|
using System;
namespace AtCoder_20190705 {
class Program {
static int Solve() {
int money = int.Parse(Console.ReadLine());
int balance = money - int.Parse(Console.ReadLine());
int someCake = int.Parse(Console.ReadLine());
while (balance >= someCake) {
balance -= someCake;
}
if (true) {
}
return balance;
}
static void Main(string[] args) { Console.WriteLine(Solve()); }
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 211, 0, 146], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45]]
| 8
| 97
| 2
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
static void Main(string[] args) {
long a = Read();
long b = Read();
long c = Read();
long x = Read();
long ans = 0;
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
for (int k = 0; k < c; k++) {
long n = (i + 1) * 500 + (j + 1) * 100 + (k + 1) * 50;
if (x == n) {
ans++;
}
}
}
}
Write(ans);
Exit();
}
public static void Write(string str) { Console.WriteLine(str); }
public static void Write(int i) { Console.WriteLine(i); }
public static void Write(double d) { Console.WriteLine(d); }
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long Read() { return long.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static void Exit() {}
}
}
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
static void Main(string[] args) {
long a = Read();
long b = Read();
long c = Read();
long x = Read();
long ans = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
long n = i * 500 + j * 100 + k * 50;
if (x == n) {
ans++;
}
}
}
}
Write(ans);
Exit();
}
public static void Write(string str) { Console.WriteLine(str); }
public static void Write(int i) { Console.WriteLine(i); }
public static void Write(double d) { Console.WriteLine(d); }
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long Read() { return long.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static void Exit() {}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["-", 31, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 31, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 16, 31, 16, 31, 16, 31, 23, 0, 25], ["-", 0, 16, 31, 16, 12, 16, 31, 23, 0, 24], ["-", 31, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["-", 31, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 16, 31, 16, 12, 16, 31, 23, 0, 25], ["-", 0, 212, 0, 16, 12, 16, 31, 23, 0, 24], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 212, 0, 16, 12, 16, 31, 23, 0, 25]]
| 8
| 291
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
int target = int.Parse(Console.ReadLine());
int a = int.Parse(Console.ReadLine()); // 500
int s = int.Parse(Console.ReadLine()); // 100
int d = int.Parse(Console.ReadLine()); // 50
int kazu = 0;
int i, j, k;
for (i = 0; i <= a; i++) {
for (j = 0; j <= s; j++) {
for (k = 0; k <= d; k++) {
if (i * 500 + j * 100 + 50 * k == target) {
kazu++;
}
}
}
}
Console.WriteLine(kazu);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine()); // 500
int s = int.Parse(Console.ReadLine()); // 100
int d = int.Parse(Console.ReadLine()); // 50
int target = int.Parse(Console.ReadLine());
int kazu = 0;
int i, j, k;
for (i = 0; i <= a; i++) {
for (j = 0; j <= s; j++) {
for (k = 0; k <= d; k++) {
if ((i * 500 + j * 100 + 50 * k) == target) {
kazu++;
}
}
}
}
Console.WriteLine(kazu);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25]]
| 8
| 190
| 10
|
using System;
namespace ABC087_B {
class Program {
static void Main(string[] args) {
var a = int.Parse(Console.ReadLine());
var b = int.Parse(Console.ReadLine());
var c = int.Parse(Console.ReadLine());
var x = int.Parse(Console.ReadLine());
var count = 0;
for (var i = 0; i <= b; i++)
for (var j = 0; j <= c; j++) {
if ((x - (100 * i + 50 * j)) % 500 == 0)
count++;
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace ABC087_B {
class Program {
static void Main(string[] args) {
var a = int.Parse(Console.ReadLine());
var b = int.Parse(Console.ReadLine());
var c = int.Parse(Console.ReadLine());
var x = int.Parse(Console.ReadLine());
var count = 0;
for (var i = 0; i <= b; i++)
for (var j = 0; j <= c; j++)
for (var k = 0; k <= a; k++) {
if (500 * k + 100 * i + 50 * j == x)
count++;
}
Console.WriteLine(count);
}
}
}
|
[["+", 8, 196, 0, 7, 8, 7, 8, 7, 0, 88], ["+", 8, 196, 0, 7, 8, 7, 8, 7, 0, 24], ["+", 8, 7, 8, 7, 10, 198, 39, 216, 0, 217], ["+", 8, 7, 8, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 7, 8, 7, 0, 35], ["+", 0, 7, 8, 7, 8, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 7, 8, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 7, 8, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 7, 8, 7, 26, 223, 0, 22], ["+", 0, 7, 8, 7, 8, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 7, 8, 7, 0, 25], ["-", 0, 7, 8, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 31, 203], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 72], ["-", 31, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 8, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 143
| 28
|
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass {
static void Main(string[] args) { AnswerB(); }
public static void AnswerB() {
int A = int.Parse(Console.ReadLine());
int B = int.Parse(Console.ReadLine());
int C = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int PatternCnt = 0;
for (int i50 = 0; i50 <= C; i50++)
for (int j100 = 0; j100 <= B; j100++)
for (int k500 = 0; k500 <= A; k500++) {
int mul = (i50 * 50) + (j100 * 100) + (k500 * 500);
if (X == mul) {
PatternCnt++;
Console.WriteLine($"{i50} {j100} {k500}");
}
}
Console.WriteLine(PatternCnt.ToString());
Console.ReadKey();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass {
static void Main(string[] args) { AnswerB(); }
public static void AnswerB() {
int A = int.Parse(Console.ReadLine());
int B = int.Parse(Console.ReadLine());
int C = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int PatternCnt = 0;
for (int i50 = 0; i50 <= C; i50++)
for (int j100 = 0; j100 <= B; j100++)
for (int k500 = 0; k500 <= A; k500++) {
int mul = (i50 * 50) + (j100 * 100) + (k500 * 500);
if (X == mul) {
PatternCnt++;
// Console.WriteLine($"{i50} {j100} {k500}");
}
}
Console.WriteLine(PatternCnt.ToString());
Console.ReadKey();
}
}
|
[["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 215
| 19
|
using System;
using System.Text.RegularExpressions;
namespace algorithm {
class Program {
static void Main(string[] args) {
int i, j, k, l;
i = int.Parse(Console.ReadLine());
j = int.Parse(Console.ReadLine());
k = int.Parse(Console.ReadLine());
l = int.Parse(Console.ReadLine());
int cnt = 0;
for (int a = 0; a <= i; a++) {
if (a * 500 > l)
break;
for (int b = 0; b <= j; b++) {
if (b * 100 > l)
break;
for (int c = 0; c <= k; c++) {
//脳死で総当たり
if (a * 500 + b * 100 + c * 50 == l)
cnt++;
}
}
Console.WriteLine(cnt);
}
}
}
}
|
using System;
using System.Text.RegularExpressions;
namespace algorithm {
class Program {
static void Main(string[] args) {
int i, j, k, l;
i = int.Parse(Console.ReadLine());
j = int.Parse(Console.ReadLine());
k = int.Parse(Console.ReadLine());
l = int.Parse(Console.ReadLine());
int cnt = 0;
for (int a = 0; a <= k; a++) {
for (int b = 0; b <= j; b++) {
for (int c = 0; c <= i; c++) {
//脳死で総当たり
if (a * 50 + b * 100 + c * 500 == l)
cnt++;
}
}
}
Console.WriteLine(cnt);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["-", 0, 7, 8, 196, 0, 57, 64, 93, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 190
| 30
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var A = cin.ReadInt;
var B = cin.ReadInt;
var C = cin.ReadInt;
var X = cin.ReadInt;
var ans = 0;
var a = 0;
var b = 0;
var c = 0;
while (a * 500 <= X) {
while (b * 100 <= X - a * 500) {
while (c + 50 <= X - a * 500 - b * 100) {
ans++;
c++;
}
c = 0;
b++;
}
b = 0;
a++;
}
WriteLine(ans);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var A = cin.ReadInt;
var B = cin.ReadInt;
var C = cin.ReadInt;
var X = cin.ReadInt;
var ans = 0;
var a = 0;
var b = 0;
var c = 0;
while (a * 500 <= X && a <= A) {
while (b * 100 <= X - a * 500 && b <= B) {
while (c * 50 <= X - a * 500 - b * 100 && c <= C) {
if (a * 500 + b * 100 + c * 50 == X) {
ans += 1;
}
c += 1;
}
c = 0;
b += 1;
}
b = 0;
a += 1;
}
WriteLine(ans);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 98], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 12, 22], ["+", 0, 52, 8, 196, 0, 52, 15, 16, 17, 98], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 17, 72], ["+", 0, 52, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 15, 16, 31, 16, 12, 16, 12, 16, 31, 22], ["+", 15, 16, 31, 16, 12, 16, 12, 16, 17, 48], ["+", 15, 16, 31, 16, 12, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 52, 0, 25], ["+", 0, 52, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 540
| 44
|
using System;
namespace AtCoder {
class B_Coins_087 {
public static void Main() {
var coin500Num = int.Parse(Console.ReadLine());
var coin100Num = int.Parse(Console.ReadLine());
var coin50Num = int.Parse(Console.ReadLine());
var totalPrice = int.Parse(Console.ReadLine());
Console.WriteLine(Count(coin500Num, coin100Num, coin50Num, totalPrice));
}
private static int Count(int _coin500Num, int _coin100Num, int _coin50Num,
int _totalPrice) {
var count = 0;
for (var a = 0; a <= _coin500Num; ++a) {
var A = a * 500;
if (_totalPrice < A) {
return count;
}
for (var b = 0; b <= _coin100Num; ++b) {
var B = b * 100;
if (_totalPrice < B) {
return count;
}
for (var c = 0; c <= _coin50Num; ++c) {
var C = c * 50;
if (_totalPrice < C) {
return count;
}
var result = A + B + C;
if (result == _totalPrice) {
++count;
}
}
}
}
return count;
}
}
}
|
using System;
namespace AtCoder {
class B_Coins_087 {
public static void Main() {
var coin500Num = int.Parse(Console.ReadLine());
var coin100Num = int.Parse(Console.ReadLine());
var coin50Num = int.Parse(Console.ReadLine());
var totalPrice = int.Parse(Console.ReadLine());
Console.WriteLine(Count(coin500Num, coin100Num, coin50Num, totalPrice));
}
private static int Count(int _coin500Num, int _coin100Num, int _coin50Num,
int _totalPrice) {
var count = 0;
for (var a = 0; a <= _coin500Num; ++a) {
var A = a * 500;
// if (_totalPrice < A) { return count; }
for (var b = 0; b <= _coin100Num; ++b) {
var B = b * 100;
// if (_totalPrice < B) { return count; }
for (var c = 0; c <= _coin50Num; ++c) {
var C = c * 50;
// if (_totalPrice < C) { return count; }
var result = A + B + C;
if (result == _totalPrice) {
++count;
}
}
}
}
return count;
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35]]
| 8
| 240
| 33
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int total = int.Parse(Console.ReadLine());
string[] buff_1 = Console.ReadLine().Split(' ');
string[] buff_2 = Console.ReadLine().Split(' ');
int[] line_1 = new int[total];
int[] line_2 = new int[total];
int cnt = 0;
int cnadySum = 0;
int maxSum = 0;
int line_1_sum = 0;
int line_2_sum = 0;
int underOffset = 0;
for (cnt = 0; cnt < total; cnt++) {
line_1[cnt] = int.Parse(buff_1[cnt]);
line_2[cnt] = int.Parse(buff_2[cnt]);
}
line_2_sum = line_2.Sum();
for (cnt = 0; cnt < total; cnt++) {
line_1_sum += line_1[cnt];
if (maxSum < (line_1_sum + line_2_sum)) {
maxSum = (line_1_sum + line_2_sum);
}
line_2_sum = line_2[cnt];
}
Console.WriteLine(maxSum);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int total = int.Parse(Console.ReadLine());
string[] buff_1 = Console.ReadLine().Split(' ');
string[] buff_2 = Console.ReadLine().Split(' ');
int[] line_1 = new int[total];
int[] line_2 = new int[total];
int cnt = 0;
int maxSum = 0;
int line_1_sum = 0;
int line_2_sum = 0;
for (cnt = 0; cnt < total; cnt++) {
line_1[cnt] = int.Parse(buff_1[cnt]);
line_2[cnt] = int.Parse(buff_2[cnt]);
}
line_2_sum = line_2.Sum();
for (cnt = 0; cnt < total; cnt++) {
line_1_sum += line_1[cnt];
if (maxSum < (line_1_sum + line_2_sum)) {
maxSum = (line_1_sum + line_2_sum);
}
line_2_sum -= line_2[cnt];
}
Console.WriteLine(maxSum);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110]]
| 8
| 234
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var line2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int ans = 0;
ans = line1.First() + line2.Sum();
int temp = ans;
for (int i = 1; i < n; i++) {
temp = temp + line1[i] - line2[i - 1];
ans = Math.Max(ans, temp);
Console.WriteLine(ans);
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var line2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int ans = 0;
ans = line1.First() + line2.Sum();
int temp = ans;
for (int i = 1; i < n; i++) {
temp = temp + line1[i] - line2[i - 1];
ans = Math.Max(ans, temp);
}
Console.WriteLine(ans);
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 184
| 13
|
using static System.Console;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int N = int.Parse(ReadLine());
var ue = ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var shita = ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var list = new List<int>();
for (int i = 0; i < N; i++) {
var u = 0;
var s = 0;
u += ue[i];
for (int j = i; j < N; j++)
s += shita[j];
list.Add(u + s);
}
WriteLine(list.Max());
}
}
|
using static System.Console;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int N = int.Parse(ReadLine());
var ue = ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var shita = ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var list = new List<int>();
int c = 0;
for (int i = 0; i < N; i++) {
var u = 0;
var s = 0;
for (int k = 0; k <= c; k++)
u += ue[k];
for (int j = c; j < N; j++)
s += shita[j];
list.Add(u + s);
c++;
}
WriteLine(list.Max());
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 188
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
void calc() {
cin = new Scanner();
cin2 = new Func();
char[] s = cin.next().ToCharArray();
s[3] = '8';
string ans = s.ToString();
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Answer {
public void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
public void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
void calc() {
cin = new Scanner();
cin2 = new Func();
char[] s = cin.next().ToCharArray();
s[3] = '8';
for (int i = 0; i < s.Length; i++)
Console.Write(s[i]);
Console.WriteLine();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Answer {
public void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
public void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 7, 8, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 7, 8, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 7, 8, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 723
| 24
|
using System;
using System.Linq;
namespace kozaiyApp {
public class KagamiMochi {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] d = new int[N];
int[] Mochi = Enumerable.Repeat<int>(1000, N).ToArray();
for (int i = 0; i < N; i++) {
d[i] = int.Parse(Console.ReadLine());
}
Array.Sort(d);
for (int i = 0; i < N; i++) {
if (0 > Array.BinarySearch(Mochi, d[i])) {
int index = Array.IndexOf(Mochi, 1000);
Mochi[index] = d[i];
}
}
Console.WriteLine(Array.IndexOf(Mochi, 1000));
}
}
}
|
using System;
using System.Linq;
namespace kozaiyApp {
public class KagamiMochi {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] d = new int[N];
int[] Mochi = Enumerable.Repeat<int>(1000, N).ToArray();
for (int i = 0; i < N; i++) {
d[i] = int.Parse(Console.ReadLine());
}
Array.Sort(d);
for (int i = 0; i < N; i++) {
if (0 > Array.BinarySearch(Mochi, d[i])) {
int index = Array.IndexOf(Mochi, 1000);
Mochi[index] = d[i];
}
}
if (0 > Array.IndexOf(Mochi, 1000)) {
Console.WriteLine(d.Length);
return;
}
Console.WriteLine(Array.IndexOf(Mochi, 1000));
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 179
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace easy_Atcoder {
class Program {
static void Main(string[] args) {
int[] NY = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int thousand = -1;
int five_thousand = -1;
int ten_thousand = -1;
for (int i = 0; i <= NY[0]; i++) {
for (int j = 0; j <= NY[0] - i; j++) {
int sum = 1000 * i + 5000 * j + 10000 * (NY[0] - i - j);
if (sum == NY[1] && (NY[0] - i - j) >= 0) {
thousand = i;
five_thousand = j;
ten_thousand = NY[0] - i - j;
break;
}
}
}
Console.WriteLine("{0} {1} {2}", thousand, five_thousand, ten_thousand);
}
// float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
// long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
// long N = NK[0];
// long K = NK[1];
// long K = long.Parse(Console.ReadLine());
// int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
// string S = Console.ReadLine();
// int x = int.Parse(Console.ReadLine());
// int b = int.Parse(Console.ReadLine());
// int N = int.Parse(Console.ReadLine());
// float N = float.Parse(Console.ReadLine());
// string c = Console.ReadLine();
// string B = Console.ReadLine();
// string[] s = Console.ReadLine().Split();
// var s = (new string[] { Console.ReadLine(), Console.ReadLine(),
// Console.ReadLine() }).Select(float.Parse); float[] a =
// Array.ConvertAll(Console.ReadLine().Split(),float.Parse); var X =
// Console.ReadLine(); int[,] abcd = new int[NMQ[2],4]; int[] A = new
// int[NMQ[0]]; int[] A_num = new int[NMQ[0]]; long[]
// s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse); var hs=new
// Dictionary<long,long>(); for(int i=0;i<s[0];i++){
// long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
// if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
// else{hs.Add(q[0],q[1]);}
// }
// //最小公倍数
// static long Lcm(long a, long b)
// {
// return a/Gcd(a,b)*b;
// }
// //最大公約数
// static long Gcd(long m, long n)
// {
// if(n==0)return m;
// return Gcd(n,m%n);
// }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace easy_Atcoder {
class Program {
static void Main(string[] args) {
int[] NY = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int thousand = -1;
int five_thousand = -1;
int ten_thousand = -1;
for (int i = 0; i <= NY[0]; i++) {
for (int j = 0; j <= NY[0] - i; j++) {
int sum = 1000 * i + 5000 * j + 10000 * (NY[0] - j - i);
if (sum == NY[1] && (NY[0] - j - i) >= 0) {
thousand = i;
five_thousand = j;
ten_thousand = NY[0] - j - i;
break;
}
}
}
Console.WriteLine("{0} {1} {2}", ten_thousand, five_thousand, thousand);
}
// float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
// long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
// long N = NK[0];
// long K = NK[1];
// long K = long.Parse(Console.ReadLine());
// int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
// string S = Console.ReadLine();
// int x = int.Parse(Console.ReadLine());
// int b = int.Parse(Console.ReadLine());
// int N = int.Parse(Console.ReadLine());
// float N = float.Parse(Console.ReadLine());
// string c = Console.ReadLine();
// string B = Console.ReadLine();
// string[] s = Console.ReadLine().Split();
// var s = (new string[] { Console.ReadLine(), Console.ReadLine(),
// Console.ReadLine() }).Select(float.Parse); float[] a =
// Array.ConvertAll(Console.ReadLine().Split(),float.Parse); var X =
// Console.ReadLine(); int[,] abcd = new int[NMQ[2],4]; int[] A = new
// int[NMQ[0]]; int[] A_num = new int[NMQ[0]]; long[]
// s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse); var hs=new
// Dictionary<long,long>(); for(int i=0;i<s[0];i++){
// long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
// if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
// else{hs.Add(q[0],q[1]);}
// }
// //最小公倍数
// static long Lcm(long a, long b)
// {
// return a/Gcd(a,b)*b;
// }
// //最大公約数
// static long Gcd(long m, long n)
// {
// if(n==0)return m;
// return Gcd(n,m%n);
// }
}
}
|
[["-", 12, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["-", 12, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["-", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 15, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 236
| 16
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var ny = IO.RSInt;
for (int i = 0; i <= ny[0]; i++) {
for (int j = ny[0] - i; j <= ny[0]; j++) {
if ((10000 * i + 5000 * j - ny[1]) % 1000 == 0) {
WriteLine(i + " " + j + " " + (10000 * i + 5000 * j - ny[1]) / 1000);
return;
}
}
}
WriteLine("-1 -1 -1");
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var ny = IO.RSInt;
for (int i = 0; i <= ny[0]; i++) {
for (int j = 0; j + i <= ny[0]; j++) {
if (-(10000 * i + 5000 * j - ny[1]) % 1000 == 0 &&
-(10000 * i + 5000 * j - ny[1]) / 1000 == ny[0] - i - j) {
WriteLine(i + " " + j + " " + -(10000 * i + 5000 * j - ny[1]) / 1000);
return;
}
}
}
WriteLine("-1 -1 -1");
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 204, 205, 22], ["-", 0, 212, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 212, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["+", 15, 16, 31, 16, 31, 16, 31, 241, 0, 33], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 16, 31, 241, 0, 33], ["+", 12, 16, 31, 16, 31, 241, 0, 23, 0, 24], ["+", 0, 23, 0, 16, 31, 16, 31, 16, 31, 203], ["+", 0, 23, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 31, 241, 0, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 23, 0, 16, 31, 16, 12, 16, 31, 203], ["+", 0, 23, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 23, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 31, 16, 31, 241, 0, 23, 0, 16, 17, 33], ["+", 31, 241, 0, 23, 0, 16, 12, 204, 205, 22], ["+", 0, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 12, 16, 31, 16, 31, 241, 0, 23, 0, 25], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 85], ["+", 12, 16, 12, 16, 31, 16, 31, 204, 205, 22], ["+", 12, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 15, 16, 12, 16, 12, 16, 31, 16, 17, 33], ["+", 15, 16, 12, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 16, 31, 241, 0, 33]]
| 8
| 578
| 36
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var Instance = new Otoshidama();
Instance.Exec();
}
}
public class Otoshidama {
public void Exec() {
var array =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long n = array[0];
long y = array[1];
long ten = -1;
long five = -1;
long one = -1;
long yy = y / 1000;
for (var i = 0; i <= yy; ++i) {
for (var j = 0; j <= yy; ++j) {
var k = n - i - j;
if (k < 0) {
break;
}
long total = 1000 * i + 5000 * j + 10000 * k;
if (total == y && n - i - j > 0) {
ten = n - i - j;
five = j;
one = i;
}
}
}
string str = $"{ten} {five} {one}";
Console.WriteLine(str);
Console.Out.Flush();
Console.ReadLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var Instance = new Otoshidama();
Instance.Exec();
}
}
public class Otoshidama {
public void Exec() {
var array =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long n = array[0];
long y = array[1];
long ten = -1;
long five = -1;
long one = -1;
long max = y / 1000;
for (var i = 0; i <= n; ++i) {
for (var j = 0; j <= n; ++j) {
var k = n - i - j;
if (k < 0) {
break;
}
long total = 1000 * i + 5000 * j + 10000 * k;
if (total == y) {
ten = k;
five = j;
one = i;
}
}
}
string str = $"{ten} {five} {one}";
Console.WriteLine(str);
Console.Out.Flush();
Console.ReadLine();
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 15, 16, 12, 16, 31, 16, 31, 16, 31, 22], ["-", 15, 16, 12, 16, 31, 16, 31, 16, 17, 33], ["-", 15, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 269
| 20
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
namespace cswork {
class Program {
public Program() {}
Scanner cin;
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
void Omame() {
cin = new Scanner();
int n = cin.nextInt();
long y = cin.nextLong();
int ans = 0;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n - i; j++) {
int l = n - i - j;
if (10000 * i + 5000 * j + 1000 * l == y) {
Console.WriteLine(i + " " + j + " " + l);
return;
}
}
}
}
static void Main(string[] args) { new Program().Omame(); }
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
}
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
namespace cswork {
class Program {
public Program() {}
Scanner cin;
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
void Omame() {
cin = new Scanner();
int n = cin.nextInt();
long y = cin.nextLong();
int ans = 0;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n - i; j++) {
int l = n - i - j;
if (10000 * i + 5000 * j + 1000 * l == y) {
Console.WriteLine(i + " " + j + " " + l);
return;
}
}
}
Console.WriteLine("-1 -1 -1");
}
static void Main(string[] args) { new Program().Omame(); }
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 484
| 9
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
public Program() {}
Scanner cin;
void Omame() {
cin = new Scanner();
long n = cin.nextLong();
long y = cin.nextLong();
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n - i; j++) {
for (int k = 0; k <= n - i - j; k++) {
if (10000 * i + 5000 * j + 1000 * k == y) {
Console.WriteLine(i + " " + j + " " + k);
return;
}
}
}
}
Console.WriteLine("-1 -1 -1");
}
static void Main(string[] args) { new Program().Omame(); }
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
}
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
public Program() {}
Scanner cin;
void Omame() {
cin = new Scanner();
int n = cin.nextInt();
long y = cin.nextLong();
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n - i; j++) {
int k = n - i - j;
if (10000 * i + 5000 * j + 1000 * k == y) {
Console.WriteLine(i + " " + j + " " + k);
return;
}
}
}
Console.WriteLine("-1 -1 -1");
}
static void Main(string[] args) { new Program().Omame(); }
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 344
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var inputLine = Console.ReadLine();
var splitInput = inputLine.Split(' ');
var billNum = int.Parse(splitInput[0]);
var targetTotalAmount = int.Parse(splitInput[1]);
int resultN10000;
int resultN5000;
int resultN1000;
Search(billNum, targetTotalAmount, out resultN10000, out resultN5000,
out resultN1000);
Console.WriteLine("{0} {1} {2}", resultN10000, resultN5000, resultN1000);
}
private static int GetTotalAmount(int n10000, int n5000, int n1000) {
return n10000 * 10000 + n5000 * 5000 + n1000 * 1000;
}
private static bool Search(int billNum, int targetTotalAmount,
out int resultN10000, out int resultN5000,
out int resultN1000) {
resultN10000 = -1;
resultN5000 = -1;
resultN1000 = -1;
for (var n1000 = 0; n1000 <= billNum; n1000++) {
for (var n5000 = 0; n5000 <= billNum - n1000; n5000++) {
var n10000 = billNum - n1000 - n5000;
if (GetTotalAmount(n10000, n5000, n1000) > targetTotalAmount) {
break;
}
if (GetTotalAmount(n10000, n5000, n1000) == targetTotalAmount) {
resultN10000 = n10000;
resultN5000 = n5000;
resultN1000 = n1000;
return true;
}
}
}
return false;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var inputLine = Console.ReadLine();
var splitInput = inputLine.Split(' ');
var billNum = int.Parse(splitInput[0]);
var targetTotalAmount = int.Parse(splitInput[1]);
int resultN10000;
int resultN5000;
int resultN1000;
Search(billNum, targetTotalAmount, out resultN10000, out resultN5000,
out resultN1000);
Console.WriteLine("{0} {1} {2}", resultN10000, resultN5000, resultN1000);
}
private static int GetTotalAmount(int n10000, int n5000, int n1000) {
return n10000 * 10000 + n5000 * 5000 + n1000 * 1000;
}
private static bool Search(int billNum, int targetTotalAmount,
out int resultN10000, out int resultN5000,
out int resultN1000) {
resultN10000 = -1;
resultN5000 = -1;
resultN1000 = -1;
for (var n1000 = 0; n1000 <= billNum; n1000++) {
for (var n5000 = 0; n5000 <= billNum - n1000; n5000++) {
var n10000 = billNum - n1000 - n5000;
if (GetTotalAmount(n10000, n5000, n1000) == targetTotalAmount) {
resultN10000 = n10000;
resultN5000 = n5000;
resultN1000 = n1000;
return true;
}
}
}
return false;
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 213, 63, 22], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["-", 15, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 21], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 291
| 17
|
using System;
using System.Linq;
public class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int Y = int.Parse(input[1]);
int x = -1;
int y = -1;
int z = -1;
int c;
for (int a = 0; a <= N; a++) {
for (int b = 0; b <= N; b++) {
c = N - a - b;
if (10000 * a + 5000 * b + 1000 * c == Y && a + b + c == N) {
x = a;
y = b;
z = c;
}
}
}
Console.WriteLine($"{x} {y} {z}");
}
}
|
using System;
using System.Linq;
public class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int Y = int.Parse(input[1]);
int x = -1, y = -1, z = -1;
int c;
for (int a = 0; a <= N; a++) {
for (int b = 0; a + b <= N; b++) {
c = N - a - b;
if (10000 * a + 5000 * b + 1000 * c == Y) {
x = a;
y = b;
z = c;
}
}
}
Console.WriteLine($"{x} {y} {z}");
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 17, 72], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 15, 16, 12, 16, 31, 16, 31, 16, 31, 22], ["-", 15, 16, 12, 16, 31, 16, 31, 16, 17, 72], ["-", 15, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 72], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 182
| 16
|
using System;
using System.Collections;
using System.Collections.Generic;
namespace 練習問題 {
class Program {
static void Main(string[] args) {
List<int> pattern = new List<int>();
var sw = new System.Diagnostics.Stopwatch();
long n = 0;
long y = 0;
List<int> result = new List<int>();
debug Debug = new debug();
if (args.Length == 0) {
Debug.FlagFalse();
string[] input = Console.ReadLine().Split(' ');
n = int.Parse(input[0]);
y = int.Parse(input[1]);
} else {
Debug.FlagTrue();
if (args[0] == "1") {
pattern.Add(9);
pattern.Add(45000);
n = pattern[0];
y = pattern[1];
} else if (args[0] == "2") {
pattern.Add(20);
pattern.Add(196000);
n = pattern[0];
y = pattern[1];
} else if (args[0] == "3") {
pattern.Add(1000);
pattern.Add(1234000);
n = pattern[0];
y = pattern[1];
} else if (args[0] == "4") {
pattern.Add(2000);
pattern.Add(20000000);
n = pattern[0];
y = pattern[1];
}
}
sw.Start(); //スタート
for (int i = 0; i < n; i++) {
if (i * 10000 >= y) {
continue;
} else {
for (int j = 0; j < n; j++) {
long k = n - i - j;
long total = i * 10000 + j * 5000 + k * 1000;
if (total == y) {
if (i > -1 && j > -1 && k > -1) {
Console.WriteLine(i + " " + j + " " + k);
sw.Stop();
TimeSpan ifts = sw.Elapsed;
// Console.WriteLine($"{ifts}");
return;
}
}
}
}
}
Console.WriteLine(-1 + " " + -1 + " " + -1);
sw.Stop();
TimeSpan ts = sw.Elapsed;
// Console.WriteLine($"{ts}");
}
static int intPow(int target, int kaisu) {
int startTarget = target;
for (int i = 1; i < kaisu; i++) {
target *= startTarget;
}
return target;
}
static void bubble_sort(List<List<int>> a) {
int count = 0;
for (int i = 0; i < a.Count; i++) {
for (int j = 0; j < a.Count - i - 1; j++) {
// if (a[j] == a[a.Count - 1]){
// continue;
// }
count++;
if (a[j][1] > a[j + 1][1]) {
int localsave = 0;
localsave = a[j + 1][1];
a[j + 1][1] = a[j][1];
a[j][1] = localsave;
localsave = a[j][0];
a[j][0] = a[j + 1][0];
a[j + 1][0] = localsave;
}
}
}
for (int i = 0; i < a.Count; i++) {
Console.WriteLine(a[i][0] + " " + a[i][1]);
}
}
/* 標準入力と標準出力が使えるかのチェック
static void echo() {
string echotest = Console.ReadLine();
Console.WriteLine(echotest);
}
static void HelloWorld(){
Console.WriteLine("Hello World!");
}
*/
}
public class debug { //宣言時は、「 debug Debug = new debug(); 」推奨
bool debug_flag = true;
public void Log(string str) {
if (debug_flag == true) {
Console.WriteLine(str);
}
}
public void Log(int str) {
if (debug_flag == true) {
Console.WriteLine(str);
}
}
public void Log(float str) {
if (debug_flag == true) {
Console.WriteLine(str);
}
}
public void Log(object obj) {
if (debug_flag == true) {
Console.WriteLine(obj);
}
}
public void Log(int[] arr) {
if (debug_flag == true) {
Console.WriteLine(string.Join(",", arr));
}
}
public void Log(string[] arr) {
if (debug_flag == true) {
Console.WriteLine(string.Join(",", arr));
}
}
public void Log(List<int> arr) {
if (debug_flag == true) {
string shuturyoku = "";
for (int i = 0; i < arr.Count; i++) {
shuturyoku += arr[i] + ",";
}
Console.WriteLine(shuturyoku.TrimEnd(','));
}
}
public void Log(List<string> arr) {
if (debug_flag == true) {
string shuturyoku = "";
for (int i = 0; i < arr.Count; i++) {
shuturyoku += arr[i] + ",";
}
Console.WriteLine(shuturyoku.TrimEnd(','));
}
}
public void Log(List<float> arr) {
if (debug_flag == true) {
string shuturyoku = "";
for (int i = 0; i < arr.Count; i++) {
shuturyoku += arr[i] + ",";
}
Console.WriteLine(shuturyoku.TrimEnd(','));
}
}
public void Log() {
if (debug_flag == true) {
Console.WriteLine("アタイイレナサイ");
}
}
public void FlagFalse() { debug_flag = false; }
public void FlagTrue() { debug_flag = true; }
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
namespace 練習問題 {
class Program {
static void Main(string[] args) {
List<int> pattern = new List<int>();
var sw = new System.Diagnostics.Stopwatch();
long n = 0;
long y = 0;
List<int> result = new List<int>();
debug Debug = new debug();
if (args.Length == 0) {
Debug.FlagFalse();
string[] input = Console.ReadLine().Split(' ');
n = int.Parse(input[0]);
y = int.Parse(input[1]);
} else {
Debug.FlagTrue();
if (args[0] == "1") {
pattern.Add(9);
pattern.Add(45000);
n = pattern[0];
y = pattern[1];
} else if (args[0] == "2") {
pattern.Add(20);
pattern.Add(196000);
n = pattern[0];
y = pattern[1];
} else if (args[0] == "3") {
pattern.Add(1000);
pattern.Add(1234000);
n = pattern[0];
y = pattern[1];
} else if (args[0] == "4") {
pattern.Add(2000);
pattern.Add(20000000);
n = pattern[0];
y = pattern[1];
}
}
sw.Start(); //スタート
for (long i = 0; i <= n; i++) {
for (long j = 0; j + i <= n; j++) {
long k = n - i - j;
long total = i * 10000 + j * 5000 + k * 1000;
if (total == y) {
if (i >= 0 && j >= 0 && k >= 0) {
Console.WriteLine(i + " " + j + " " + k);
sw.Stop();
TimeSpan ifts = sw.Elapsed;
// Console.WriteLine($"{ifts}");
return;
}
}
}
}
Console.WriteLine(-1 + " " + -1 + " " + -1);
sw.Stop();
TimeSpan ts = sw.Elapsed;
// Console.WriteLine($"{ts}");
}
static int intPow(int target, int kaisu) {
int startTarget = target;
for (int i = 1; i < kaisu; i++) {
target *= startTarget;
}
return target;
}
static void bubble_sort(List<List<int>> a) {
int count = 0;
for (int i = 0; i < a.Count; i++) {
for (int j = 0; j < a.Count - i - 1; j++) {
// if (a[j] == a[a.Count - 1]){
// continue;
// }
count++;
if (a[j][1] > a[j + 1][1]) {
int localsave = 0;
localsave = a[j + 1][1];
a[j + 1][1] = a[j][1];
a[j][1] = localsave;
localsave = a[j][0];
a[j][0] = a[j + 1][0];
a[j + 1][0] = localsave;
}
}
}
for (int i = 0; i < a.Count; i++) {
Console.WriteLine(a[i][0] + " " + a[i][1]);
}
}
/* 標準入力と標準出力が使えるかのチェック
static void echo() {
string echotest = Console.ReadLine();
Console.WriteLine(echotest);
}
static void HelloWorld(){
Console.WriteLine("Hello World!");
}
*/
}
public class debug { //宣言時は、「 debug Debug = new debug(); 」推奨
bool debug_flag = true;
public void Log(string str) {
if (debug_flag == true) {
Console.WriteLine(str);
}
}
public void Log(int str) {
if (debug_flag == true) {
Console.WriteLine(str);
}
}
public void Log(float str) {
if (debug_flag == true) {
Console.WriteLine(str);
}
}
public void Log(object obj) {
if (debug_flag == true) {
Console.WriteLine(obj);
}
}
public void Log(int[] arr) {
if (debug_flag == true) {
Console.WriteLine(string.Join(",", arr));
}
}
public void Log(string[] arr) {
if (debug_flag == true) {
Console.WriteLine(string.Join(",", arr));
}
}
public void Log(List<int> arr) {
if (debug_flag == true) {
string shuturyoku = "";
for (int i = 0; i < arr.Count; i++) {
shuturyoku += arr[i] + ",";
}
Console.WriteLine(shuturyoku.TrimEnd(','));
}
}
public void Log(List<string> arr) {
if (debug_flag == true) {
string shuturyoku = "";
for (int i = 0; i < arr.Count; i++) {
shuturyoku += arr[i] + ",";
}
Console.WriteLine(shuturyoku.TrimEnd(','));
}
}
public void Log(List<float> arr) {
if (debug_flag == true) {
string shuturyoku = "";
for (int i = 0; i < arr.Count; i++) {
shuturyoku += arr[i] + ",";
}
Console.WriteLine(shuturyoku.TrimEnd(','));
}
}
public void Log() {
if (debug_flag == true) {
Console.WriteLine("アタイイレナサイ");
}
}
public void FlagFalse() { debug_flag = false; }
public void FlagTrue() { debug_flag = true; }
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 57, 75, 196, 0, 7, 15, 16, 17, 18], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 47], ["-", 15, 16, 31, 16, 31, 16, 12, 241, 0, 33], ["-", 15, 16, 31, 16, 31, 16, 12, 241, 0, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 47], ["-", 15, 16, 31, 16, 12, 16, 12, 241, 0, 33], ["-", 15, 16, 31, 16, 12, 16, 12, 241, 0, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["-", 0, 57, 15, 16, 12, 16, 12, 241, 0, 33], ["-", 0, 57, 15, 16, 12, 16, 12, 241, 0, 203], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,189
| 40
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
bool flag = false;
for (int x = 0; x <= input[0]; x++) {
if (flag)
break;
for (int y = 0; y <= input[0] - x; y++) {
if ((1000 * x) + (5000 * y) + (10000 * (input[0] - x - y)) ==
input[1]) {
Console.WriteLine((input[0] - x - y).ToString() + " " + x.ToString() +
" " + y.ToString());
flag = true;
break;
}
}
}
if (!flag) {
Console.WriteLine("-1 -1 -1");
}
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
bool flag = false;
for (int x = 0; x <= input[0]; x++) {
if (flag)
break;
for (int y = 0; y <= input[0] - x; y++) {
var a = (1000 * x) + (5000 * y) + (10000 * (input[0] - x - y));
if (a == input[1]) {
Console.WriteLine((input[0] - x - y).ToString() + " " + y.ToString() +
" " + x.ToString());
flag = true;
break;
} else if (a < input[1]) {
break;
}
}
}
if (!flag) {
Console.WriteLine("-1 -1 -1");
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 31, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 31, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 31, 22], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 57, 15, 16, 12, 204, 205, 22], ["+", 75, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 75, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 45]]
| 8
| 199
| 27
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace competitive_programming {
class Program {
static void Main(string[] args) {
var main = new Program();
main.solve();
}
void solve() {
long[] ny =
Console.ReadLine().Split(' ').Select(val => long.Parse(val)).ToArray();
var n = ny[0];
var y = ny[1];
for (int i = 0; i < n && i <= n; i++) {
for (int j = 0; j + i <= n; j++) {
int k = (int)n - j - i;
if (10000 * i + 5000 * j + 1000 * k == y) {
Console.WriteLine(i + " " + j + " " + k);
return;
}
}
}
Console.WriteLine(-1 + " " + -1 + " " + -1);
}
}
struct Vector2 {
public Vector2(long x, long y) {
this.x = x;
this.y = y;
}
public long x;
public long y;
}
struct Vector3 {
public int x;
public int y;
public int z;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace competitive_programming {
class Program {
static void Main(string[] args) {
var main = new Program();
main.solve();
}
void solve() {
long[] ny =
Console.ReadLine().Split(' ').Select(val => long.Parse(val)).ToArray();
var n = ny[0];
var y = ny[1];
for (long i = 0; i <= y / 10000 && i <= n; i++) {
for (long j = 0; j + i <= n; j++) {
long k = n - j - i;
// Console.WriteLine(i + " " + j + " " + k + " " + (10000 * i + 5000 * j
// + 1000 * k));
if (10000 * i + 5000 * j + 1000 * k == y) {
Console.WriteLine(i + " " + j + " " +
k /*+ " " + (10000 * i + 5000 * j + 1000 * k)*/);
return;
}
}
}
Console.WriteLine(-1 + " " + -1 + " " + -1);
}
}
struct Vector2 {
public Vector2(long x, long y) {
this.x = x;
this.y = y;
}
public long x;
public long y;
}
struct Vector3 {
public int x;
public int y;
public int z;
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 17, 19], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 17, 85], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 212, 0, 16, 31, 16, 31, 74, 0, 24], ["-", 0, 212, 0, 16, 31, 16, 31, 74, 39, 199], ["-", 0, 212, 0, 16, 31, 16, 31, 74, 0, 25]]
| 8
| 271
| 15
|
using System;
class at {
static void Main() {
var line = Console.ReadLine().Split(' ');
int n = int.Parse(line[0]);
int say = int.Parse(line[1]);
bool lay = false;
int x = -1;
int y = -1;
int z = -1;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n - i; j++) {
for (int k = 0; k <= n - i - j; k++) {
int sum = i * 10000 + 5000 * j + k * 1000;
if (sum == say) {
x = i;
y = j;
z = k;
}
}
}
}
Console.WriteLine(x + " " + y + " " + z);
}
}
|
using System;
class at {
static void Main() {
var line = Console.ReadLine().Split(' ');
int n = int.Parse(line[0]);
int say = int.Parse(line[1]);
bool lay = false;
int x = -1;
int y = -1;
int z = -1;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n - i; j++) {
int sum = i * 10000 + 5000 * j + (n - i - j) * 1000;
if (sum == say) {
x = i;
y = j;
z = n - i - j;
}
}
}
Console.WriteLine(x + " " + y + " " + z);
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 33], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 200, 0, 212, 0, 16, 12, 16, 31, 22], ["+", 0, 212, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 212, 0, 16, 12, 16, 31, 23, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 187
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc085_c {
class Program {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int billCount = input[0];
int sum = input[1];
for (int x = 0; x <= billCount; x++) {
for (int y = 0; y <= billCount - x; y++) {
for (int z = 0; z <= billCount - x - y; z++) {
if (10000 * x + 5000 * y + 1000 * z == sum) {
Console.WriteLine($"{x} {y} {z}");
return;
}
}
}
}
Console.WriteLine("-1 -1 -1");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc085_c {
class Program {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int billCount = input[0];
int sum = input[1];
for (int x = 0; x <= billCount; x++) {
for (int y = 0; y <= billCount - x; y++) {
int z = billCount - x - y;
if (10000 * x + 5000 * y + 1000 * z == sum) {
Console.WriteLine($"{x} {y} {z}");
return;
}
}
}
Console.WriteLine("-1 -1 -1");
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 181
| 11
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace PastQuestions {
class Program {
static void Main(string[] args) {
new Program().Solve(new Input(Console.In));
}
public void Solve(Input input) {
var answer = Solve2(input);
Console.Write($"{answer[0]} {answer[1]} {answer[2]}");
}
public int[] Solve2(Input input) {
var n = input.ReadInt;
var y = input.ReadInt;
var answer = new int[3] { -1, -1, -1 };
for (var i = 0; i <= n; i++) {
var total = 10000 * i;
for (var j = 0; j <= n - i; j++) {
total += 5000 * j;
var temp = total;
for (var k = 0; k <= n - i - j; k++) {
total = temp;
total += 1000 * k;
if (y == total) {
answer[0] = i;
answer[1] = j;
answer[2] = k;
return answer;
}
}
}
}
return answer;
}
}
public class Input {
private TextReader Stream { get; }
private char Separator { get; }
private Queue<string> InputStream { get; }
public Input(TextReader stream, char separator = ' ') {
Stream = stream;
Separator = separator;
InputStream = new Queue<string>();
}
public string Read {
get {
if (InputStream.Count != 0)
return InputStream.Dequeue();
string[] tmp = Stream.ReadLine().Split(Separator);
for (int i = 0; i < tmp.Length; ++i)
InputStream.Enqueue(tmp[i]);
return InputStream.Dequeue();
}
}
public string ReadLine => Stream.ReadLine();
public int ReadInt => int.Parse(Read);
public long ReadLong => long.Parse(Read);
public double ReadDouble => double.Parse(Read);
public int[] ReadIntArray =>
Stream.ReadLine().Split(Separator).Select(i => int.Parse(i)).ToArray();
public long[] ReadLongArray =>
Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace PastQuestions {
class Program {
static void Main(string[] args) {
new Program().Solve(new Input(Console.In));
}
public void Solve(Input input) {
var answer = Solve2(input);
Console.Write($"{answer[0]} {answer[1]} {answer[2]}");
}
public int[] Solve2(Input input) {
var n = input.ReadInt;
var y = input.ReadInt;
var answer = new int[3] { -1, -1, -1 };
for (var i = 0; i <= n; i++) {
var total = 10000 * i;
var temp = total;
for (var j = 0; j <= n - i; j++) {
total = temp;
total += 5000 * j;
var k = n - i - j;
total += 1000 * k;
if (y == total) {
answer[0] = i;
answer[1] = j;
answer[2] = k;
return answer;
}
}
}
return answer;
}
}
public class Input {
private TextReader Stream { get; }
private char Separator { get; }
private Queue<string> InputStream { get; }
public Input(TextReader stream, char separator = ' ') {
Stream = stream;
Separator = separator;
InputStream = new Queue<string>();
}
public string Read {
get {
if (InputStream.Count != 0)
return InputStream.Dequeue();
string[] tmp = Stream.ReadLine().Split(Separator);
for (int i = 0; i < tmp.Length; ++i)
InputStream.Enqueue(tmp[i]);
return InputStream.Dequeue();
}
}
public string ReadLine => Stream.ReadLine();
public int ReadInt => int.Parse(Read);
public long ReadLong => long.Parse(Read);
public double ReadDouble => double.Parse(Read);
public int[] ReadIntArray =>
Stream.ReadLine().Split(Separator).Select(i => int.Parse(i)).ToArray();
public long[] ReadLongArray =>
Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 8, 196, 0, 7, 10, 198, 39, 216, 0, 217], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 504
| 29
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive {
internal class Solution {
public int N, M;
public int[] L, R;
public long[] D;
public Graph G;
public void Run() {
// インプット
{
var line = Input.ReadIntArray();
N = line[0];
M = line[1];
}
// グラフの構築
G = new Graph(N);
for (int i = 0; i < M; i++) {
var line = Input.ReadIntArray();
int l = line[0];
int r = line[1];
int d = line[2];
l--;
r--;
var e1 = new Edge(l, r, d);
var e2 = new Edge(r, l, -d);
e1.ReverseEdge = e2;
e2.ReverseEdge = e1;
G.Nodes[l].Edges.Add(e1);
G.Nodes[r].Edges.Add(e2);
}
bool ret = true;
for (int i = 0; i < N; i++) {
G[i].Dist = 0;
bool success = DFS(new Edge(i, i, 0));
if (!success) {
ret = false;
break;
}
}
Console.WriteLine(ret ? "Yes" : "No");
}
public bool DFS(Edge e) {
Node n = G[e.To];
long fromDist = G[e.From].Dist;
e.Used = true;
if (e.ReverseEdge != null)
e.ReverseEdge.Used = true;
// 距離のセット
if (n.Dist == long.MaxValue) {
n.Dist = fromDist + e.D;
// 次のステップ
foreach (var ee in n.Edges) {
if (!ee.Used) {
bool success = DFS(ee);
if (!success)
return false;
}
}
} else {
if (n.Dist != fromDist + e.D) {
return false;
}
}
return true;
}
}
// libs ----------
// 通常はIComparableのみが必要
class EdgeData : IComparable<EdgeData>, IComparable {
public int Dist;
public Edge Edge;
public EdgeData(int dist, Edge edge) {
Dist = dist;
Edge = edge;
}
public int CompareTo(EdgeData other) { return Dist.CompareTo(other.Dist); }
public int CompareTo(object obj) {
if (obj == null)
return 1;
if (GetType() != obj.GetType())
throw new ArgumentException();
return CompareTo((EdgeData)obj);
}
}
internal class Graph {
public List<Node> Nodes;
public Node this[int i] {
set { Nodes[i] = value; }
get { return Nodes[i]; }
}
public Graph(int N) {
Nodes = new List<Node>();
for (int i = 0; i < N; i++) {
Nodes.Add(new Node(i));
}
}
}
internal class Node {
public List<Edge> Edges;
public long Dist;
public int No;
public Node(int no) {
this.No = no;
Dist = long.MaxValue;
Edges = new List<Edge>();
}
}
internal class Edge {
public int From;
public int To;
public int D;
public bool Used;
public Edge ReverseEdge;
public Edge(int fr, int to, int d = 0) {
From = fr;
To = to;
D = d;
Used = false;
}
}
// common ----------
internal static class Input {
public static string ReadString() {
string line = Console.ReadLine();
return line;
}
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() {
string line = Console.ReadLine();
return long.Parse(line);
}
public static long[] ReadLongArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(double.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive {
internal class Solution {
public int N, M;
public int[] L, R;
public long[] D;
public Graph G;
public void Run() {
// インプット
{
var line = Input.ReadIntArray();
N = line[0];
M = line[1];
}
// グラフの構築
G = new Graph(N);
for (int i = 0; i < M; i++) {
var line = Input.ReadIntArray();
int l = line[0];
int r = line[1];
int d = line[2];
l--;
r--;
var e1 = new Edge(l, r, d);
var e2 = new Edge(r, l, -d);
e1.ReverseEdge = e2;
e2.ReverseEdge = e1;
G.Nodes[l].Edges.Add(e1);
G.Nodes[r].Edges.Add(e2);
}
bool ret = true;
for (int i = 0; i < N; i++) {
G[i].Dist = 0;
bool success = DFS(new Edge(i, i, 0));
if (!success) {
ret = false;
break;
}
}
Console.WriteLine(ret ? "Yes" : "No");
}
public bool DFS(Edge e) {
Node n = G[e.To];
long fromDist = G[e.From].Dist;
e.Used = true;
if (e.ReverseEdge != null)
e.ReverseEdge.Used = true;
// 距離のセット
if (n.Dist == long.MaxValue || e.From == e.To) {
n.Dist = fromDist + e.D;
// 次のステップ
foreach (var ee in n.Edges) {
if (!ee.Used) {
bool success = DFS(ee);
if (!success)
return false;
}
}
} else {
if (n.Dist != fromDist + e.D) {
return false;
}
}
return true;
}
}
// libs ----------
// 通常はIComparableのみが必要
class EdgeData : IComparable<EdgeData>, IComparable {
public int Dist;
public Edge Edge;
public EdgeData(int dist, Edge edge) {
Dist = dist;
Edge = edge;
}
public int CompareTo(EdgeData other) { return Dist.CompareTo(other.Dist); }
public int CompareTo(object obj) {
if (obj == null)
return 1;
if (GetType() != obj.GetType())
throw new ArgumentException();
return CompareTo((EdgeData)obj);
}
}
internal class Graph {
public List<Node> Nodes;
public Node this[int i] {
set { Nodes[i] = value; }
get { return Nodes[i]; }
}
public Graph(int N) {
Nodes = new List<Node>();
for (int i = 0; i < N; i++) {
Nodes.Add(new Node(i));
}
}
}
internal class Node {
public List<Edge> Edges;
public long Dist;
public int No;
public Node(int no) {
this.No = no;
Dist = long.MaxValue;
Edges = new List<Edge>();
}
}
internal class Edge {
public int From;
public int To;
public int D;
public bool Used;
public Edge ReverseEdge;
public Edge(int fr, int to, int d = 0) {
From = fr;
To = to;
D = d;
Used = false;
}
}
// common ----------
internal static class Input {
public static string ReadString() {
string line = Console.ReadLine();
return line;
}
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() {
string line = Console.ReadLine();
return long.Parse(line);
}
public static long[] ReadLongArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(double.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 141, 22]]
| 8
| 951
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var ks = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = ks[0];
var Y = ks[1];
var count = 0;
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= N - i; j++) {
if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {
Console.WriteLine($"{i} {j} {N-i-j}");
count++;
}
break;
}
}
if (count == 0) {
Console.WriteLine("-1 -1 -1");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var ks = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = ks[0];
var Y = ks[1];
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= N - i; j++) {
if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {
Console.WriteLine($"{i} {j} {N-i-j}");
return;
}
}
}
Console.WriteLine("-1 -1 -1");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 94], ["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 195
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var NY = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var N = NY[0];
var Y = NY[1];
var count = 0;
if (Y > 10000 * N) {
Console.WriteLine("-1 -1 -1");
} else {
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= N - i; j++) {
for (int k = 0; k <= N - i - j; k++) {
if (i * 10000 + j * 5000 + k * 1000 == Y) {
Console.WriteLine(i + " " + j + " " + k);
return;
}
}
}
}
Console.WriteLine("-1 -1 -1");
return;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var NY = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var N = NY[0];
var Y = NY[1];
var count = 0;
if (Y > 10000 * N) {
Console.WriteLine("-1 -1 -1");
} else {
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= N - i; j++) {
int k = N - i - j;
if (i * 10000 + j * 5000 + k * 1000 == Y) {
Console.WriteLine(i + " " + j + " " + k);
return;
}
}
}
Console.WriteLine("-1 -1 -1");
return;
}
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 215
| 11
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.