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 System.Text;
using System.Threading.Tasks;
namespace AtCoderBS {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string checkFirst = "MARCH";
int[] count = new int[5];
long pair = 0;
for (int i = 0; i < n; i++) {
string check = null;
check = Console.ReadLine();
if (checkFirst.IndexOf(check[0]) != -1) {
count[checkFirst.IndexOf(check[0])]++;
}
}
for (int j = 0; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
for (int l = k + 1; l < 5; l++) {
pair += count[j] * count[k] * count[l];
}
}
}
Console.WriteLine(pair);
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 n = int.Parse(Console.ReadLine());
string checkFirst = "MARCH";
long[] count = new long[5];
long pair = 0;
for (int i = 0; i < n; i++) {
string check = null;
check = Console.ReadLine();
if (checkFirst.IndexOf(check[0]) != -1) {
count[checkFirst.IndexOf(check[0])]++;
}
}
for (int j = 0; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
for (int l = k + 1; l < 5; l++) {
pair += count[j] * count[k] * count[l];
}
}
}
Console.WriteLine(pair);
Console.Read();
}
}
}
|
[["-", 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
| 225
| 4
|
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 dic = new Dictionary<char, int>();
string s = string.Empty;
var march = new char[] { 'M', 'A', 'R', 'C', 'H' };
foreach (char c in march) {
dic[c] = 0;
}
for (int i = 0; i < n; i++) {
s = Console.ReadLine();
if (!march.Contains(s.First()))
continue;
dic[s.First()]++;
}
var check = new int[] { 7, 11, 13, 14, 19, 21, 22, 25, 26, 28 };
int comb = 1;
int sum = 0;
for (int i = 7; i <= 28; i++) {
if (!check.Contains(i))
continue;
comb = 1;
for (int j = 0; j < 5; j++) {
if ((i >> j & 1) == 1) {
comb *= dic[march[j]];
}
}
sum += comb;
}
Console.WriteLine(sum);
}
}
}
|
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 dic = new Dictionary<char, int>();
string s = string.Empty;
var march = new char[] { 'M', 'A', 'R', 'C', 'H' };
foreach (char c in march) {
dic[c] = 0;
}
for (int i = 0; i < n; i++) {
s = Console.ReadLine();
if (!march.Contains(s.First()))
continue;
dic[s.First()]++;
}
var check = new int[] { 7, 11, 13, 14, 19, 21, 22, 25, 26, 28 };
long comb = 1;
long sum = 0;
for (int i = 7; i <= 28; i++) {
if (!check.Contains(i))
continue;
comb = 1;
for (int j = 0; j < 5; j++) {
if ((i >> j & 1) == 1) {
comb *= dic[march[j]];
}
}
sum += comb;
}
Console.WriteLine(sum);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 290
| 4
|
using System;
using System.Linq;
class Problem_C {
public static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
int mNum = 0, aNum = 0, rNum = 0, cNum = 0, hNum = 0;
for (var i = 0; i < n; i++) {
var name = Console.ReadLine();
if (name.First() == 'M') {
mNum++;
} else if (name.First() == 'A') {
aNum++;
} else if (name.First() == 'R') {
rNum++;
} else if (name.First() == 'C') {
cNum++;
} else if (name.First() == 'H') {
hNum++;
}
}
long ans = (mNum * aNum * rNum) + (mNum * aNum * cNum) +
(mNum * aNum * hNum) + (mNum * rNum * cNum) +
(mNum * rNum * hNum) + (mNum * cNum * hNum) +
(aNum * rNum * cNum) + (aNum * rNum * hNum) +
(aNum * cNum * hNum) + (rNum * cNum * hNum);
Console.WriteLine($"{ans}");
}
}
|
using System;
using System.Linq;
class Problem_C {
public static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
long mNum = 0, aNum = 0, rNum = 0, cNum = 0, hNum = 0;
for (var i = 0; i < n; i++) {
var name = Console.ReadLine();
if (name.First() == 'M') {
mNum++;
} else if (name.First() == 'A') {
aNum++;
} else if (name.First() == 'R') {
rNum++;
} else if (name.First() == 'C') {
cNum++;
} else if (name.First() == 'H') {
hNum++;
}
}
long ans = (mNum * aNum * rNum) + (mNum * aNum * cNum) +
(mNum * aNum * hNum) + (mNum * rNum * cNum) +
(mNum * rNum * hNum) + (mNum * cNum * hNum) +
(aNum * rNum * cNum) + (aNum * rNum * hNum) +
(aNum * cNum * hNum) + (rNum * cNum * hNum);
Console.WriteLine($"{ans}");
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 267
| 2
|
using System;
using System.Linq;
namespace abc089_c {
class Program {
static void Main(string[] args) {
char[] name = new char[] { 'M', 'A', 'R', 'C', 'H' };
int[] people = new int[5];
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++) {
string s = Console.ReadLine();
if (name.Contains(s[0])) {
people[Array.IndexOf(name, s[0])]++;
}
}
long ret = 0;
for (int i = 0; i < 5; i++) {
for (int j = i + 1; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
ret += people[i] * people[j] * people[k];
}
}
}
Console.WriteLine(ret);
}
}
}
|
using System;
using System.Linq;
namespace abc089_c {
class Program {
static void Main(string[] args) {
char[] name = new char[] { 'M', 'A', 'R', 'C', 'H' };
long[] people = new long[5];
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++) {
string s = Console.ReadLine();
if (name.Contains(s[0])) {
people[Array.IndexOf(name, s[0])]++;
}
}
long ret = 0;
for (int i = 0; i < 5; i++) {
for (int j = i + 1; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
ret += people[i] * people[j] * people[k];
}
}
}
Console.WriteLine(ret);
}
}
}
|
[["-", 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
| 219
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
public static void Main() {
// 終了後回答
int N = int.Parse(Console.ReadLine());
string[] names = new string[N];
for (int i = 0; i < N; i++) {
names[i] = Console.ReadLine();
}
int[] MARCH = new[] { 'M', 'A', 'R', 'C', 'H' }
.Select(c => names.Count(s => s[0] == c))
.ToArray();
int M = MARCH[0], A = MARCH[1], R = MARCH[2], C = MARCH[3], H = MARCH[4];
// MARCH(5C3=10): MAR, MAC, MAH, MRC, MRH, MCH, ARC, ARH, ACH, RCH;
long res = 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(res);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
public static void Main() {
// 終了後回答
int N = int.Parse(Console.ReadLine());
string[] names = new string[N];
for (int i = 0; i < N; i++) {
names[i] = Console.ReadLine();
}
long[] MARCH = new[] { 'M', 'A', 'R', 'C', 'H' }
.Select(c => (long)names.Count(s => s[0] == c))
.ToArray();
long M = MARCH[0], A = MARCH[1], R = MARCH[2], C = MARCH[3], H = MARCH[4];
// MARCH(5C3=10): MAR, MAC, MAH, MRC, MRH, MCH, ARC, ARH, ACH, RCH;
long res = 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(res);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 25], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 246
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
var N = int.Parse(ReadLine());
var S = new string[N];
for (int i = 0; i < N; i++) {
S[i] = ReadLine();
}
long M = S.Count(x => x.First() == 'M');
long A = S.Count(x => x.First() == 'A');
long R = S.Count(x => x.First() == 'R');
long C = S.Count(x => x.First() == 'C');
long H = S.Count(x => x.First() == 'H');
var L = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H +
M * C * H + A * R * C + A * R * H + R * C * H;
WriteLine(L);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
var N = int.Parse(ReadLine());
var S = new string[N];
for (int i = 0; i < N; i++) {
S[i] = ReadLine();
}
long M = S.Count(x => x.First() == 'M');
long A = S.Count(x => x.First() == 'A');
long R = S.Count(x => x.First() == 'R');
long C = S.Count(x => x.First() == 'C');
long H = S.Count(x => x.First() == 'H');
var L = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H +
M * C * H + A * R * C + A * R * H + R * C * H + A * C * H;
WriteLine(L);
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 212, 0, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 212, 0, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 212, 0, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 12, 22]]
| 8
| 240
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC089C {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int mNum = 0;
int aNum = 0;
int rNum = 0;
int cNum = 0;
int hNum = 0;
for (int i = 0; i < N; i++) {
string input = Console.ReadLine();
string inputChar = input.Substring(0, 1);
switch (inputChar) {
case "M":
mNum++;
break;
case "A":
aNum++;
break;
case "R":
rNum++;
break;
case "C":
cNum++;
break;
case "H":
hNum++;
break;
default:
break;
}
}
long ans = mNum * aNum * rNum + mNum * aNum * cNum + mNum * aNum * hNum +
mNum * rNum * cNum + mNum * rNum * hNum + mNum * cNum * hNum +
aNum * rNum * cNum + aNum * rNum * hNum + aNum * cNum * hNum +
rNum * cNum * hNum;
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC089C {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
long mNum = 0;
long aNum = 0;
long rNum = 0;
long cNum = 0;
long hNum = 0;
for (int i = 0; i < N; i++) {
string input = Console.ReadLine();
string inputChar = input.Substring(0, 1);
switch (inputChar) {
case "M":
mNum++;
break;
case "A":
aNum++;
break;
case "R":
rNum++;
break;
case "C":
cNum++;
break;
case "H":
hNum++;
break;
default:
break;
}
}
long ans = mNum * aNum * rNum + mNum * aNum * cNum + mNum * aNum * hNum +
mNum * rNum * cNum + mNum * rNum * hNum + mNum * cNum * hNum +
aNum * rNum * cNum + aNum * rNum * hNum + aNum * cNum * hNum +
rNum * cNum * hNum;
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 252
| 10
|
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() {
int N = Cin();
String[] Name = new string[N];
int M = 0;
int A = 0;
int R = 0;
int C = 0;
int H = 0;
for (int i = 0; i < N; i++) {
Name[i] = Console.ReadLine();
if (Name[i][0] == 'M')
M += 1;
if (Name[i][0] == 'A')
A += 1;
if (Name[i][0] == 'R')
R += 1;
if (Name[i][0] == 'C')
C += 1;
if (Name[i][0] == 'H')
H += 1;
}
long 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);
}
}
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 Cin() { 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() {
int N = Cin();
String[] Name = new string[N];
ulong M = 0;
ulong A = 0;
ulong R = 0;
ulong C = 0;
ulong H = 0;
for (int i = 0; i < N; i++) {
Name[i] = Console.ReadLine();
if (Name[i][0] == 'M')
M += 1;
if (Name[i][0] == 'A')
A += 1;
if (Name[i][0] == 'R')
R += 1;
if (Name[i][0] == 'C')
C += 1;
if (Name[i][0] == 'H')
H += 1;
}
ulong 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);
}
}
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 Cin() { 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); }
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 540
| 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());
int[] march = new int[5];
for (int i = 0; i < n; ++i) {
string name = Console.ReadLine();
switch (name[0]) {
case 'M':
++march[0];
break;
case 'A':
++march[1];
break;
case 'R':
++march[2];
break;
case 'C':
++march[3];
break;
case 'H':
++march[4];
break;
}
}
List<int> marchList = new List<int>();
for (int i = 0; i < 5; ++i) {
if (march[i] > 0) {
marchList.Add(march[i]);
}
}
if (marchList.Count < 3) {
Console.WriteLine(0);
return;
}
if (marchList.Count == 3) {
Console.WriteLine(marchList[0] * marchList[1] * marchList[2]);
return;
}
List<int> marchCounts = new List<int>();
System.Int64 marchCount = 0;
for (int i = 0; i < 3; ++i) {
int tmpMarchCountI = marchList[i];
for (int j = i + 1; (j < i + 4 || j < marchList.Count); ++j) {
if (j >= marchList.Count) {
break;
}
int tmpMarchCountJ = tmpMarchCountI * marchList[j];
for (int k = j + 1; k < marchList.Count; ++k) {
if (k >= marchList.Count) {
break;
}
marchCount += tmpMarchCountJ * marchList[k];
}
}
}
Console.WriteLine(marchCount);
}
}
}
|
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());
int[] march = new int[5];
for (int i = 0; i < n; ++i) {
string name = Console.ReadLine();
switch (name[0]) {
case 'M':
++march[0];
break;
case 'A':
++march[1];
break;
case 'R':
++march[2];
break;
case 'C':
++march[3];
break;
case 'H':
++march[4];
break;
}
}
List<int> marchList = new List<int>();
for (int i = 0; i < 5; ++i) {
if (march[i] > 0) {
marchList.Add(march[i]);
}
}
if (marchList.Count < 3) {
Console.WriteLine(0);
return;
}
if (marchList.Count == 3) {
Console.WriteLine(marchList[0] * marchList[1] * marchList[2]);
return;
}
List<int> marchCounts = new List<int>();
System.Int64 marchCount = 0;
for (int i = 0; i < 3; ++i) {
System.Int64 tmpMarchCountI = marchList[i];
for (int j = i + 1; (j < i + 4 || j < marchList.Count); ++j) {
if (j >= marchList.Count) {
break;
}
System.Int64 tmpMarchCountJ = tmpMarchCountI * marchList[j];
for (int k = j + 1; k < marchList.Count; ++k) {
if (k >= marchList.Count) {
break;
}
marchCount += tmpMarchCountJ * marchList[k];
}
}
}
Console.WriteLine(marchCount);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 232, 234, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 232, 0, 131], ["+", 8, 196, 0, 197, 0, 198, 39, 232, 141, 22]]
| 8
| 415
| 8
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace ABC089 {
public class Program {
void Solve(StreamScanner ss, StreamWriter sw) {
//---------------------------------
var N = ss.Next(Int);
var S = ss.Next(s => s[0], N);
var gc =
S.Where(c => c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H')
.GroupBy(c => c)
.Select(g => g.Count())
.ToArray();
if (gc.Length <= 2) {
sw.WriteLine(0);
return;
}
var res = 0L;
for (var i = 0; i <= gc.Length - 3; i++) {
for (var j = i + 1; j <= gc.Length - 2; j++) {
for (var k = j + 1; k <= gc.Length - 1; k++) {
res += gc[i] * gc[j] * gc[k];
}
}
}
sw.WriteLine(res);
//---------------------------------
}
static void Main() {
var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
new Program().Solve(ss, sw);
sw.Flush();
}
static readonly Func<string, string> String = s => s;
static readonly Func<string, int> Int = int.Parse;
static readonly Func<string, long> Long = long.Parse;
static readonly Func<string, double> Double = double.Parse;
}
public class StreamScanner {
static readonly char[] Sep = { ' ' };
readonly Queue<string> buffer = new Queue<string>();
readonly TextReader textReader;
public StreamScanner(TextReader textReader) { this.textReader = textReader; }
public T Next<T>(Func<string, T> parser) {
if (buffer.Count != 0)
return parser(buffer.Dequeue());
var nextStrings =
textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
foreach (var nextString in nextStrings)
buffer.Enqueue(nextString);
return Next(parser);
}
public T[] Next<T>(Func<string, T> parser, int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next(parser);
return ret;
}
public T[][] Next<T>(Func<string, T> parser, int x, int y) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next(parser, x);
return ret;
}
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace ABC089 {
public class Program {
void Solve(StreamScanner ss, StreamWriter sw) {
//---------------------------------
var N = ss.Next(Int);
var S = ss.Next(s => s[0], N);
var gc =
S.Where(c => c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H')
.GroupBy(c => c)
.Select(g => g.Count())
.ToArray();
if (gc.Length <= 2) {
sw.WriteLine(0);
return;
}
var res = 0L;
for (var i = 0; i <= gc.Length - 3; i++) {
for (var j = i + 1; j <= gc.Length - 2; j++) {
for (var k = j + 1; k <= gc.Length - 1; k++) {
res += (long)gc[i] * gc[j] * gc[k];
}
}
}
sw.WriteLine(res);
//---------------------------------
}
static void Main() {
var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
new Program().Solve(ss, sw);
sw.Flush();
}
static readonly Func<string, string> String = s => s;
static readonly Func<string, int> Int = int.Parse;
static readonly Func<string, long> Long = long.Parse;
static readonly Func<string, double> Double = double.Parse;
}
public class StreamScanner {
static readonly char[] Sep = { ' ' };
readonly Queue<string> buffer = new Queue<string>();
readonly TextReader textReader;
public StreamScanner(TextReader textReader) { this.textReader = textReader; }
public T Next<T>(Func<string, T> parser) {
if (buffer.Count != 0)
return parser(buffer.Dequeue());
var nextStrings =
textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
foreach (var nextString in nextStrings)
buffer.Enqueue(nextString);
return Next(parser);
}
public T[] Next<T>(Func<string, T> parser, int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next(parser);
return ret;
}
public T[][] Next<T>(Func<string, T> parser, int x, int y) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next(parser, x);
return ret;
}
}
}
|
[["+", 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
| 608
| 3
|
using System;
namespace abc089_c {
class program {
static void Main(string[] args) {
ChangeLocalDebugInput();
int N = int.Parse(Console.ReadLine());
int[] march = new int[5];
for (int i = 0; i < N; i++) {
string input = Console.ReadLine();
if (input[0] == 'M') {
march[0]++;
} else if (input[0] == 'A') {
march[1]++;
} else if (input[0] == 'R') {
march[2]++;
} else if (input[0] == 'C') {
march[3]++;
} else if (input[0] == 'H') {
march[4]++;
}
}
long answer =
march[0] * march[1] * march[2] + march[0] * march[1] * march[3] +
march[0] * march[1] * march[4] + march[0] * march[2] * march[3] +
march[0] * march[2] * march[4] + march[0] * march[3] * march[4] +
march[1] * march[2] * march[3] + march[1] * march[2] * march[4] +
march[1] * march[3] * march[4] + march[2] * march[3] * march[4];
Console.WriteLine(answer);
}
[System.Diagnostics.Conditional("LOCAL_DEBUG")]
static void ChangeLocalDebugInput() {
Console.SetIn(new System.IO.StreamReader("../../stdin.txt"));
}
}
}
|
using System;
namespace abc089_c {
class program {
static void Main(string[] args) {
ChangeLocalDebugInput();
int N = int.Parse(Console.ReadLine());
long[] march = new long[5];
for (int i = 0; i < N; i++) {
string input = Console.ReadLine();
if (input[0] == 'M') {
march[0]++;
} else if (input[0] == 'A') {
march[1]++;
} else if (input[0] == 'R') {
march[2]++;
} else if (input[0] == 'C') {
march[3]++;
} else if (input[0] == 'H') {
march[4]++;
}
}
long answer =
march[0] * march[1] * march[2] + march[0] * march[1] * march[3] +
march[0] * march[1] * march[4] + march[0] * march[2] * march[3] +
march[0] * march[2] * march[4] + march[0] * march[3] * march[4] +
march[1] * march[2] * march[3] + march[1] * march[2] * march[4] +
march[1] * march[3] * march[4] + march[2] * march[3] * march[4];
Console.WriteLine(answer);
}
[System.Diagnostics.Conditional("LOCAL_DEBUG")]
static void ChangeLocalDebugInput() {
Console.SetIn(new System.IO.StreamReader("../../stdin.txt"));
}
}
}
|
[["-", 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
| 371
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoder.Beginner068 {
public class ABC089C {
public static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] count = new int[5];
HashSet<string> names = new HashSet<string>();
for (int i = 0; i < n; i++) {
string s = Console.ReadLine();
switch (s.Substring(0, 1)) {
case "M":
count[0]++;
break;
case "A":
count[1]++;
break;
case "R":
count[2]++;
break;
case "C":
count[3]++;
break;
case "H":
count[4]++;
break;
}
}
int allcount = 0;
for (int i = 0; i < 5; i++) {
for (int j = i + 1; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
allcount += count[i] * count[j] * count[k];
}
}
}
Console.WriteLine(allcount);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoder.Beginner068 {
public class ABC089C {
public static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
long[] count = new long[5];
HashSet<string> names = new HashSet<string>();
for (int i = 0; i < n; i++) {
string s = Console.ReadLine();
switch (s.Substring(0, 1)) {
case "M":
count[0]++;
break;
case "A":
count[1]++;
break;
case "R":
count[2]++;
break;
case "C":
count[3]++;
break;
case "H":
count[4]++;
break;
}
}
long allcount = 0;
for (int i = 0; i < 5; i++) {
for (int j = i + 1; j < 5; j++) {
for (int k = j + 1; k < 5; k++) {
allcount += count[i] * count[j] * count[k];
}
}
}
Console.WriteLine(allcount);
}
}
}
|
[["-", 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, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 261
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder1_A {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string[] name = new string[n];
for (int i = 0; i < n; i++) {
name[i] = Console.ReadLine();
}
int M = 0;
int A = 0;
int R = 0;
int C = 0;
int H = 0;
foreach (string item in name) {
switch (item[0]) {
case 'M':
M++;
break;
case 'A':
A++;
break;
case 'R':
R++;
break;
case 'C':
C++;
break;
case 'H':
H++;
break;
}
}
long ans = (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(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder1_A {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string[] name = new string[n];
for (int i = 0; i < n; i++) {
name[i] = Console.ReadLine();
}
long M = 0;
long A = 0;
long R = 0;
long C = 0;
long H = 0;
foreach (string item in name) {
switch (item[0]) {
case 'M':
M++;
break;
case 'A':
A++;
break;
case 'R':
R++;
break;
case 'C':
C++;
break;
case 'H':
H++;
break;
}
}
long ans = (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(ans);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 281
| 10
|
using System;
using System.Linq;
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++;
}
// スペース区切りの整数の入力
long ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h +
m * c * h + a * r * c + a * r * h + r * c * h;
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
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++;
}
// スペース区切りの整数の入力
long ans = 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(ans);
}
}
|
[["+", 0, 16, 31, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 212, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 212, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72]]
| 8
| 228
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC089C {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
string[] names = new string[N];
for (int i = 0; i < N; i++) {
var line = Console.ReadLine();
names[i] = line;
}
char[] march = "MARCH".ToCharArray();
int[] nums = new int[5];
for (int i = 0; i < N; i++) {
for (int j = 0; j < 5; j++) {
if (names[i][0] == march[j]) {
nums[j]++;
break;
}
}
}
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 += nums[i] * nums[j] * nums[k];
}
}
}
Console.WriteLine(ans);
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC089C {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
string[] names = new string[N];
for (int i = 0; i < N; i++) {
var line = Console.ReadLine();
names[i] = line;
}
char[] march = "MARCH".ToCharArray();
long[] nums = new long[5];
for (int i = 0; i < N; i++) {
for (int j = 0; j < 5; j++) {
if (names[i][0] == march[j]) {
nums[j]++;
break;
}
}
}
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 += nums[i] * nums[j] * nums[k];
}
}
}
Console.WriteLine(ans);
Console.ReadKey();
}
}
}
|
[["-", 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
| 271
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
class MainClass : Scanner {
static void Main() {
var (H, W, D) = ReadTuple<int, int, int>();
var A = new int[H, W];
var dic = new Dictionary<int, (int y, int x)>();
for (int i = 0; i < H; i++) {
var line = RInts();
for (int j = 0; j < W; j++) {
A[i, j] = line[j];
dic[line[j]] = (i, j);
}
}
var Q = RInt();
var LR = new int [Q][];
for (int i = 0; i < Q; i++) {
LR[i] = RInts();
}
var costs = Enumerable.Repeat(-1L, H * W + 1).ToArray();
int start = 0;
while (costs[++start] == -1) {
long cost = 0;
int now = start;
costs[now] = cost;
while (now + D <= H * W) {
var nowpos = dic[now];
var nextpos = dic[now + D];
cost += (Abs(nowpos.x - nextpos.x) + Abs(nowpos.y - nextpos.y));
now += D;
costs[now] = cost;
}
}
for (int i = 0; i < Q; i++) {
long ans = 0;
int L = LR[i][0];
int R = LR[i][1];
ans = Abs(costs[L] - costs[R]);
WriteLine(ans);
}
}
}
class Scanner {
public static string RString() => Console.ReadLine();
public static int RInt() => ReadTuple<int>();
public static long RLong() => ReadTuple<long>();
public static double RDouble() => ReadTuple<double>();
public static string[] RStrings() => Console.ReadLine().Split();
public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(),
int.Parse);
public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
public static double[] RDoubles() =>
Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
public static int[] RInts(Func<string, int> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static long[] RLongs(Func<string, long> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static double[] RDoubles(Func<string, double> func) =>
Console.ReadLine().Split().Select(func).ToArray();
// public static string[] RStrings(Func<string, string> func) =>
// Console.ReadLine().Split().Select(func).ToArray();
public static T1 ReadTuple<T1>() {
var r = RString();
var r1 = (T1)Convert.ChangeType(r, typeof(T1));
return r1;
}
public static (T1, T2) ReadTuple<T1, T2>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
return (r1, r2);
}
public static (T1, T2, T3) ReadTuple<T1, T2, T3>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
return (r1, r2, r3);
}
public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
return (r1, r2, r3, r4);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
class MainClass : Scanner {
static void Main() {
var (H, W, D) = ReadTuple<int, int, int>();
var A = new int[H, W];
var dic = new Dictionary<int, (int y, int x)>();
for (int i = 0; i < H; i++) {
var line = RInts();
for (int j = 0; j < W; j++) {
A[i, j] = line[j];
dic[line[j]] = (i, j);
}
}
var Q = RInt();
var LR = new int [Q][];
for (int i = 0; i < Q; i++) {
LR[i] = RInts();
}
var costs = Enumerable.Repeat(-1L, H * W + 1).ToArray();
int start = 0;
while (start < H * W && costs[++start] == -1) {
long cost = 0;
int now = start;
costs[now] = cost;
while (now + D <= H * W) {
var nowpos = dic[now];
var nextpos = dic[now + D];
cost += (Abs(nowpos.x - nextpos.x) + Abs(nowpos.y - nextpos.y));
now += D;
costs[now] = cost;
}
}
for (int i = 0; i < Q; i++) {
long ans = 0;
int L = LR[i][0];
int R = LR[i][1];
ans = Abs(costs[L] - costs[R]);
WriteLine(ans);
}
}
}
class Scanner {
public static string RString() => Console.ReadLine();
public static int RInt() => ReadTuple<int>();
public static long RLong() => ReadTuple<long>();
public static double RDouble() => ReadTuple<double>();
public static string[] RStrings() => Console.ReadLine().Split();
public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(),
int.Parse);
public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
public static double[] RDoubles() =>
Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
public static int[] RInts(Func<string, int> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static long[] RLongs(Func<string, long> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static double[] RDoubles(Func<string, double> func) =>
Console.ReadLine().Split().Select(func).ToArray();
// public static string[] RStrings(Func<string, string> func) =>
// Console.ReadLine().Split().Select(func).ToArray();
public static T1 ReadTuple<T1>() {
var r = RString();
var r1 = (T1)Convert.ChangeType(r, typeof(T1));
return r1;
}
public static (T1, T2) ReadTuple<T1, T2>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
return (r1, r2);
}
public static (T1, T2, T3) ReadTuple<T1, T2, T3>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
return (r1, r2, r3);
}
public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
return (r1, r2, r3, r4);
}
}
|
[["+", 8, 196, 0, 52, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 17, 18], ["+", 0, 52, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 52, 15, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 98]]
| 8
| 992
| 6
|
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;
}
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]]
| 8
| 97
| 2
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
//入力
// int[] input = Console.ReadLine().Split().Select(i =>
// int.Parse(i)).ToArray(); string input= Console.ReadLine();
int[] input = new int[3];
for (int a = 0; a < 3; a++) {
input[a] = int.Parse(Console.ReadLine());
}
// int input =int.Parse(input[0]+""+input[3+1]+""+input[3*2+2]);
Console.WriteLine((input[0] - input[1]) / input[2]);
/*
//処理速度計測
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
//解法
//処理速度表示
sw.Stop();
TimeSpan ts = sw.Elapsed;
Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
*/
Console.ReadLine();
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
//入力
// int[] input = Console.ReadLine().Split().Select(i =>
// int.Parse(i)).ToArray(); string input= Console.ReadLine();
int[] input = new int[3];
for (int a = 0; a < 3; a++) {
input[a] = int.Parse(Console.ReadLine());
}
// int input =int.Parse(input[0]+""+input[3+1]+""+input[3*2+2]);
Console.WriteLine((input[0] - input[1]) % input[2]);
/*
//処理速度計測
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
//解法
//処理速度表示
sw.Stop();
TimeSpan ts = sw.Elapsed;
Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
*/
Console.ReadLine();
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109]]
| 8
| 113
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class ConsoleApp1 {
public static void Main() {
var x = int.Parse(Console.ReadLine());
var y = int.Parse(Console.ReadLine());
var z = int.Parse(Console.ReadLine());
x = x - y;
Console.WriteLine(x - z * (x % z));
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class ConsoleApp1 {
public static void Main() {
var x = int.Parse(Console.ReadLine());
var y = int.Parse(Console.ReadLine());
var z = int.Parse(Console.ReadLine());
x = x - y;
Console.WriteLine(x - z * (x / z));
}
}
|
[["-", 0, 16, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 85]]
| 8
| 97
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
int a, b, c, d;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());
d = a - b;
while (d > c)
d = d - c;
//標準入力
// string[] str = Console.ReadLine().Split('
// ');//2つ以上のスペース区切り入力の取得 b = int.Parse(str[0]);
// //数値で受け取りたい場合は変換する c = int.Parse(str[1]);
Console.Write("{0}", d); //改行なし出力
// onsole.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b,
// c);//改行付き出力
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
int a, b, c, d;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());
d = a - b;
while (d >= c)
d = d - c;
//標準入力
// string[] str = Console.ReadLine().Split('
// ');//2つ以上のスペース区切り入力の取得 b = int.Parse(str[0]);
// //数値で受け取りたい場合は変換する c = int.Parse(str[1]);
Console.Write("{0}", d); //改行なし出力
// onsole.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b,
// c);//改行付き出力
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20]]
| 8
| 126
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.Collections;
namespace CompetitiveProgramming {
public class CPair<T, U> : IComparable
where T : IComparable<T> {
public readonly T Item1;
public readonly U Item2;
public int CompareTo(object obj) {
CPair<T, U> castedObj = (CPair<T, U>)obj;
return this.Item1.CompareTo(castedObj.Item1);
}
public CPair(T t, U u) {
Item1 = t;
Item2 = u;
}
}
class Pair : IComparable {
public long x;
public long a;
public long b;
public long c;
public Pair(long X, long Y, long Z, long D) {
x = X;
a = Y;
b = Z;
c = D;
}
public Pair(long a, long x) {
this.a = a;
this.x = x;
}
public Pair(long a, long b, long c) {
this.a = a;
this.b = b;
this.c = c;
}
public int CompareTo(object obj) {
Pair kore = (Pair)obj;
return x.CompareTo(kore.x);
}
public static bool operator <=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x <= p2.x;
} else {
return p1.a <= p2.a;
}
}
public static bool operator >=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x >= p2.x;
} else {
return p1.a >= p2.a;
}
}
}
class Zettiti : IComparable {
public long num;
public Zettiti(long num) { this.num = num; }
public int CompareTo(object obj) {
Zettiti kore = (Zettiti)obj;
long knum = Math.Abs(kore.num);
long mynum = Math.Abs(num);
return mynum.CompareTo(knum);
}
}
class Program {
static void Main(string[] args) {
// Utils.BinarySearch.Search
StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput());
int a = scan.Integer();
int b = scan.Integer();
int c = scan.Integer();
int x = scan.Integer();
int ans = 0;
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
for (int k = 0; k < c; k++) {
if (i * 500 + j * 100 + 50 * k == x)
ans++;
}
}
}
Console.WriteLine(ans);
}
static string dffs(int n, int m, Tuple<int, int>[] tuples, int cur, int sum,
string now) {
if (sum == n)
return now;
if (cur == m)
return "";
string zan = now;
for (int i = 0; i < (n - sum) / tuples[cur].Item1; i++) {
zan += tuples[cur].Item2;
}
for (int i = (n - sum) / tuples[cur].Item1; i >= 0; i--) {
string buf =
dffs(n, m, tuples, cur + 1, sum + i * tuples[cur].Item1, zan);
if (buf != "")
return buf;
zan = zan.Substring(0, zan.Length - 1);
;
}
return "";
}
static bool isOK(long mid, long[] a, long[] f, long k) {
long count = 0;
for (long i = 0; i < a.Length; i++) {
long togo = mid / f[i];
;
count += Math.Max(0, a[i] - togo);
}
return (count <= k);
}
static void Output<T>(List<T> list, string kugiri = "\n") {
for (int i = 0; i < list.Count; i++) {
Console.Write(list[i]);
if (i != list.Count - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[] list, string kugiri = "\n") {
for (int i = 0; i < list.Length; i++) {
Console.Write(list[i]);
if (i != list.Length - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[,] list, string kugiri1 = " ",
string kugiri2 = "\n") {
int len1 = list.GetLength(0);
int len2 = list.GetLength(1);
for (int i = 0; i < len1; i++) {
for (int j = 0; j < len2; j++) {
Console.Write(list[i, j]);
if (j != len2 - 1) {
Console.Write(kugiri1);
}
}
if (i != len1 - 1) {
Console.Write(kugiri2);
}
}
}
static int binary_search<T>(T key, T[] moto, Func<int, T, T[], bool> isok) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isok(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int binary_search(int key, int[] moto) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isOK(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int[] Togo;
static bool CheckBipartite(int now, int prev, List<int>[] g,
int c = 0) // 0,-1が想定
{
if (Togo == null)
Togo = Enumerable.Repeat(-1, g.Length).ToArray();
foreach (var next in g[now]) {
if (next == prev)
continue;
var nextc = Togo[next];
if (nextc >= 0 && nextc == c)
return false;
if (nextc >= 0)
continue;
Togo[next] = (c + 1) % 2;
var res = CheckBipartite(next, now, g, (c + 1) % 2);
if (res == false)
return false;
}
return true;
}
static bool isOK(int index, int key, int[] moto) { return moto[index] > key; }
public static int bitCount(int k) {
uint i = (uint)k;
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
i = (i + (i >> 4)) & 0x0f0f0f0f;
i = i + (i >> 8);
i = i + (i >> 16);
return (int)i & 0x3f;
}
static int check(long moto, long tai) {
if (tai % moto != 0) {
return 0;
}
while (tai > 1) {
if (tai % moto == 0) {
tai /= moto;
} else if (tai > moto) {
tai %= moto;
} else {
tai -= moto;
}
}
if (tai == 1) {
return 1;
} else {
return 0;
}
}
static bool NextPermutation(int[] array) {
var size = array.Length;
var ok = false;
// array[i]<array[i+1]を満たす最大のiを求める
int i = size - 2;
for (; 0 <= i; i--) {
if (array[i] < array[i + 1]) {
ok = true;
break;
}
}
//全ての要素が降順の場合、NextPermutationは存在しない
if (ok == false)
return false;
// array[i]<array[j]を満たす最大のjを求める
int j = size - 1;
for (;; j--) {
if (array[i] < array[j])
break;
}
// iとjの要素をswapする
var tmp = array[i];
array[i] = array[j];
array[j] = tmp;
// i以降の要素を反転させる
Array.Reverse(array, i + 1, size - (i + 1));
return true;
}
static List<int[]> GetAllPermutation(int N) {
var res = new List<int[]>();
var array = Enumerable.Range(0, N).ToArray();
do {
var copy = new int[N];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static List<int[]> GetAllPermutation(int[] array) {
var size = array.Length;
var res = new List<int[]>();
do {
var copy = new int[size];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static long Syakutori(
int[] a,
long
k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上
{
long sum = 0;
int right = 0;
long ans = 0;
for (int left = 0; left < a.Length; left++) {
while (right < a.Length && sum < k) {
sum += a[right];
right++;
}
if (k <= sum) {
ans += a.Length - right + 1;
}
if (left == right) {
right++;
} else {
sum -= a[left];
}
}
return ans;
}
static int[] zalgo(String s) {
int n = s.Length;
int[] ret = new int[n];
ret[0] = n;
int i = 1, j = 0;
while (i < n) {
while (i + j < n && s[j] == s[i + j])
++j;
ret[i] = j;
if (j == 0) {
++i;
continue;
}
int k = 1;
while (i + k < n && k + ret[k] < j) {
ret[i + k] = ret[k];
++k;
}
i += k;
j -= k;
}
return ret;
}
static int gcd(int a, int b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
static long gcd(long a, long b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
public static List<long> FactorialMemo = new List<long>() { 1 };
static long Fact(int x) {
for (int i = FactorialMemo.Count; i <= x; i++)
FactorialMemo.Add(FactorialMemo.Last() * i);
return FactorialMemo[x];
}
static int[] yousogotoplus(int[] a, int[] b) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[i];
}
return c;
}
static int[] yousogotoplus(int[] a, int[,] b, int l) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[l, i];
}
return c;
}
static int[] yousogotoplus(int[,] a, int l) {
int[] c = new int[a.GetLength(1)];
for (int i = 0; i < a.GetLength(1); i++) {
c[i] = a[l, i];
}
return c;
}
public static long LowerBound(long[] a, long key) {
long l = 0;
long r = a.Length;
long mid;
while (l < r) {
mid = ((r - l) / 2) + l;
if (a[mid] <= key)
l = mid + 1;
else
r = mid;
}
return l;
}
public static long LIS(long[] a) {
var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray();
for (int i = 0; i < a.Length; i++) {
dp[LowerBound(dp, a[i])] = a[i];
}
return LowerBound(dp, long.MaxValue - 1);
}
static long DivideWith(long m, long n, List<long> primes) {
while (m % n == 0) {
primes.Add(n);
m = m / n;
}
return m;
}
public static Dictionary<long, int> Soinsubunkai(long n) {
var map = new Dictionary<long, int>();
for (long p = 2; p * p <= n; p++) {
int count = 0;
while (n % p == 0) {
count++;
n /= p;
}
if (count != 0)
map.Add(p, count);
}
if (n > 1)
map.Add(n, 1);
return map;
}
static IEnumerable<int> Primes(int maxnum) {
// var sieve = new BitArray(maxnum + 1, true);
bool[] sieve = Enumerable.Repeat(true, maxnum + 1).ToArray();
int squareroot = (int)Math.Sqrt(maxnum);
for (int i = 2; i <= squareroot; i++) {
if (sieve[i] == false)
continue;
for (int n = i * 2; n <= maxnum; n += i)
sieve[n] = false;
}
for (int i = 2; i <= maxnum; i++)
if (sieve[i] == true)
yield return i;
}
/* static long[] SoinsuBunkai(long num)
{
if (num == 1)
return new long[] { 1 };
List<long> primes = new List<long>();
long n = DivideWith(num, 2, primes);
n = DivideWith(n, 3, primes);
n = DivideWith(n, 5, primes);
long i = 0;
while (n > 1)
{
int[] ps = { 7, 11, 13, 17, 19, 23, 29, 31 };
foreach (var p in ps)
{
// 30m+2, 30m+3, 30m+4, 30m+5, 30m+6、30m+8...
は割る必要はない。 n = DivideWith(n, i + p, primes); if (n == 1) break;
}
i += 30;
}
return primes.ToArray();
}*/
public static int h;
public static int w;
public static int BFS(int height, int width, char[,] map) {
int[] dx = new int[] { -1, 0, 0, 1 };
int[] dy = new int[] { 0, 1, -1, 0 };
bool[,] visited = new bool[h, w];
int[,] len = new int[h, w];
var queue = new Queue<Tuple<int, int>>();
queue.Enqueue(new Tuple<int, int>(height, width));
int max = 0;
visited[height, width] = true;
while (queue.Count > 0) {
var now = queue.Dequeue();
for (int i = 0; i < 4; i++) {
int ny = now.Item1 + dy[i];
int nx = now.Item2 + dx[i];
if (ny >= h || ny < 0 || nx >= w || nx < 0)
continue;
if (visited[ny, nx] || map[ny, nx] == '#')
continue;
visited[ny, nx] = true;
len[ny, nx] = len[now.Item1, now.Item2] + 1;
max = Math.Max(max, len[ny, nx]);
queue.Enqueue(new Tuple<int, int>(ny, nx));
}
}
return max;
}
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Initialize<T>(ref T[] array, T initialvalue) {
array = Array.ConvertAll(array, x => initialvalue);
}
static int[] Manacher(string S) {
int i = 0, j = 0;
int[] R = new int[S.Length];
while (i < S.Length) {
while (i - j >= 0 && i + j < S.Length && S[i - j] == S[i + j])
++j;
R[i] = j;
int k = 1;
while (i - k >= 0 && k + R[i - k] < j) {
R[i + k] = R[i - k];
++k;
}
i += k;
j -= k;
}
return R;
}
/* static Pair[] a;
static int SaikiZentansaku(List<int>now,int count,int last,int n,int m)
{
List<int> next = new List<int>();
for (int i = 0; i < now.Count; i++)
{
next.Add(now[i]);
}
next.Add(last);
var kore = next.ToArray();
int ans = 0;
if(count==n)
{
for (int i = 0; i < a.Length; i++)
{
int A = a[i].a;
int b = a[i].b;
int c = a[i].c;
int d = a[i].x;
if (kore[b] - kore[A] == c) { ans += d; }
}
return ans;
}
for (int i = last; i <= m; i++)
{
ans = Math.Max(ans, SaikiZentansaku(next, count + 1, i, n, m));
}
return ans;
}*/
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private long len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public char[] Char(long n) {
char[] kore = new char[n];
for (long i = 0; i < n; i++) {
kore[i] = Char();
}
return kore;
}
public char[,] Char(long n, long m) {
char[,] kore = new char[n, m];
for (long i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
kore[i, j] = Char();
}
}
return kore;
}
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[] Scan(long n) {
string[] str = new string[n];
for (long i = 0; i < n; i++) {
str[i] = Scan();
}
return str;
}
public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
public long[] Long(long n, bool minus1 = false) {
long[] kore = new long[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
if (minus1)
kore[i]--;
}
return kore;
}
public Mlong[] MLong(long n) {
Mlong[] kore = new Mlong[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
}
return kore;
}
public long[,] Long(long h, long w, bool minus1 = false) {
long[,] kore = new long[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int Integer() { return (int)Long(); }
public Mint[] MInteger(long n) {
Mint[] kore = new Mint[n];
for (int i = 0; i < n; i++) {
kore[i] = Integer();
}
return kore;
}
public int[] Integer(long n, bool minus1 = false) {
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = (int)Long();
if (minus1)
kore[i]--;
}
return kore;
}
public int[,] Integer(long h, long w, bool minus1 = false) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = (int)Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int[] StringToInt(int n) {
char[] s = Scan().ToCharArray();
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = s[i] - '0';
}
return kore;
}
public int[,] StringToInt(int h, int w) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
char[] s = Scan().ToCharArray();
for (int j = 0; j < w; j++) {
kore[i, j] = s[j] - '0';
}
}
return kore;
}
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
public class UnionFind {
public int[] data;
public UnionFind(int size) {
data = new int[size];
for (int i = 0; i < size; i++)
data[i] = -1;
}
public bool Unite(int x, int y) {
x = Root(x);
y = Root(y);
if (x != y) {
if (data[y] < data[x]) {
var tmp = y;
y = x;
x = tmp;
}
data[x] += data[y];
data[y] = x;
}
return x != y;
}
public bool IsSameGroup(int x, int y) { return Root(x) == Root(y); }
public int Root(int x) { return data[x] < 0 ? x : data[x] = Root(data[x]); }
public int Size(int x) { return -data[Root(x)]; }
}
public class Mlong : IComparable {
public static long mod = 1000000007;
public long num;
public Mlong(long num) {
if (num < 0) {
num += mod;
}
this.num = num % mod;
}
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mlong operator +(Mlong x, Mlong y) {
return new Mlong((x.num + y.num) % mod);
}
public static Mlong operator -(Mlong x, Mlong y) {
return new Mlong((x.num - y.num + mod) % mod);
}
public static Mlong operator *(Mlong x, Mlong y) {
return new Mlong((long)(((1L * x.num) * y.num) % mod));
}
public Mlong hutujyo(Mlong x) { return new Mlong(num / x.num); }
static long GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return x2 + mod;
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return x1 + mod;
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mlong modjyo(Mlong x) { return num * GetInverse(x.num) % mod; }
public static implicit operator Mlong(long x) { return new Mlong(x); }
public static Mlong operator %(Mlong x, Mlong y) {
return new Mlong(x.num % y.num);
}
public static explicit operator long(Mlong x) { return x.num; }
public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; }
public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; }
public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; }
public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; }
public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; }
public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; }
public Mlong Pow(Mlong n) {
Mlong pow = this;
Mlong res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n = n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); }
public static List<Mlong> FactorialMemo = new List<Mlong>() { 1 };
static Mlong Factorial(int x) {
for (int i = FactorialMemo.Count; i <= x; i++)
FactorialMemo.Add(FactorialMemo.Last() * i);
return FactorialMemo[x];
}
public static Mlong Comb(Mlong n, Mlong a) {
Mlong buf1 = 1;
Mlong buf2 = 1;
for (long i = 0; i < a.num; i++) {
buf1 *= n - i;
buf2 *= (i + 1);
}
return buf1.modjyo(buf2);
}
public static Mlong Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mlong x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mlong kore = (Mlong)obj;
return num.CompareTo(kore.num);
}
}
public class Mint : IComparable {
public static int mod = 1000000007;
public int num;
public Mint(int Num) { num = Num; }
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mint operator +(Mint x, Mint y) {
return new Mint((x.num + y.num) % mod);
}
public static Mint operator -(Mint x, Mint y) {
return new Mint((x.num - y.num + mod) % mod);
}
public static Mint operator *(Mint x, Mint y) {
return new Mint((int)(((1L * x.num) * y.num) % mod));
}
public Mint hutujyo(Mint x) { return new Mint(num / x.num); }
static int GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return (int)(x2 + mod);
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return (int)(x1 + mod);
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mint modjyo(Mint x) { return num * GetInverse(x.num) % mod; }
/* public Mint modjyo(Mint x)
{
return num * x.Pow(mod - 2);
}*/
public static implicit operator Mint(int x) { return new Mint(x); }
public static Mint[] Toarray(int[] x) {
Mint[] buf = new Mint[x.Length];
for (int i = 0; i < x.Length; i++) {
buf[i] = x[i];
}
return buf;
}
public static explicit operator int(Mint x) { return x.num; }
public static Mint operator %(Mint x, Mint y) {
return new Mint(x.num % y.num);
}
public static bool operator ==(Mint x, Mint y) { return x.num == y.num; }
public static bool operator !=(Mint x, Mint y) { return x.num != y.num; }
public static bool operator<(Mint x, Mint y) { return x.num < y.num; }
public static bool operator>(Mint x, Mint y) { return x.num > y.num; }
public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; }
public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; }
public Mint Pow(Mint n) {
Mint pow = this;
Mint res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mint Pow(Mint a, Mint n) { return a.Pow(n); }
public static List<Mint> FactorialMemo = new List<Mint>() { 1 };
static Mint Factorial(int x) {
for (int i = FactorialMemo.Count; i <= x; i++)
FactorialMemo.Add(FactorialMemo.Last() * i);
return FactorialMemo[x];
}
public static Mint Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mint x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mint kore = (Mint)obj;
return num.CompareTo(kore.num);
}
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class Tree {
public Node[] Nodes;
public List<int[]> hen;
public class Node {
public int? parent = null;
public List<int[]> children = new List<int[]>();
public int parentcolor = -1;
}
public Tree(int kosu) {
Nodes = new Node[kosu];
for (int i = 0; i < Nodes.Length; i++) {
Nodes[i] = new Node();
}
hen = new List<int[]>();
}
public void Connect(int oya, int ko, int id) {
hen.Add(new int[] { oya, ko, 0 });
Nodes[oya].children.Add(new int[] { ko, id });
Nodes[ko].parent = oya;
}
}
/// <summary>
/// Self-Balancing Binary Search Tree
/// (using Randamized BST)
/// </summary>
public class SB_BinarySearchTree<T>
where T : IComparable {
public class Node {
public T Value;
public Node LChild;
public Node RChild;
public int Count; // size of the sub tree
public Node(T v) {
Value = v;
Count = 1;
}
}
static Random _rnd = new Random();
public static int Count(Node t) { return t == null ? 0 : t.Count; }
static Node Update(Node t) {
t.Count = Count(t.LChild) + Count(t.RChild) + 1;
return t;
}
public static Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) {
l.RChild = Merge(l.RChild, r);
return Update(l);
} else {
r.LChild = Merge(l, r.LChild);
return Update(r);
}
}
/// <summary>
/// split as [0, k), [k, n)
/// </summary>
public static Tuple<Node, Node> Split(Node t, int k) {
if (t == null)
return new Tuple<Node, Node>(null, null);
if (k <= Count(t.LChild)) {
var s = Split(t.LChild, k);
t.LChild = s.Item2;
return new Tuple<Node, Node>(s.Item1, Update(t));
} else {
var s = Split(t.RChild, k - Count(t.LChild) - 1);
t.RChild = s.Item1;
return new Tuple<Node, Node>(Update(t), s.Item2);
}
}
public static Node Remove(Node t, T v) {
if (Find(t, v) == null)
return t;
return RemoveAt(t, LowerBound(t, v));
}
public static Node RemoveAt(Node t, int k) {
var s = Split(t, k);
var s2 = Split(s.Item2, 1);
return Merge(s.Item1, s2.Item2);
}
public static bool Contains(Node t, T v) { return Find(t, v) != null; }
public static Node Find(Node t, T v) {
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0)
t = t.LChild;
else if (cmp < 0)
t = t.RChild;
else
break;
}
return t;
}
public static Node FindByIndex(Node t, int idx) {
if (t == null)
return null;
var currentIdx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
if (currentIdx == idx)
return t;
if (currentIdx > idx) {
t = t.LChild;
currentIdx -= (Count(t == null ? null : t.RChild) + 1);
} else {
t = t.RChild;
currentIdx += (Count(t == null ? null : t.LChild) + 1);
}
}
return null;
}
public static int UpperBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var ret = Int32.MaxValue;
var idx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0) {
ret = Math.Min(ret, idx);
t = t.LChild;
idx -= (Count(t == null ? null : t.RChild) + 1);
} else if (cmp <= 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
}
}
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static int LowerBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var idx = Count(t) - Count(t.RChild) - 1;
var ret = Int32.MaxValue;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp >= 0) {
if (cmp == 0)
ret = Math.Min(ret, idx);
t = t.LChild;
if (t == null)
ret = Math.Min(ret, idx);
idx -= t == null ? 0 : (Count(t.RChild) + 1);
} else if (cmp < 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
if (t == null)
return idx;
}
}
// return ret;
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static Node Insert(Node t, T v) {
var ub = LowerBound(t, v);
return InsertByIdx(t, ub, v);
}
static Node InsertByIdx(Node t, int k, T v) {
var s = Split(t, k);
return Merge(Merge(s.Item1, new Node(v)), s.Item2);
}
public static IEnumerable<T> Enumerate(Node t) {
var ret = new List<T>();
Enumerate(t, ret);
return ret;
}
static void Enumerate(Node t, List<T> ret) {
if (t == null)
return;
Enumerate(t.LChild, ret);
ret.Add(t.Value);
Enumerate(t.RChild, ret);
}
}
/// <summary>
/// C-like set
/// </summary>
public class Set<T>
where T : IComparable {
protected SB_BinarySearchTree<T>.Node _root;
public T this[int idx] {
get { return ElementAt(idx); }
}
public int Count() { return SB_BinarySearchTree<T>.Count(_root); }
public bool Any() { return _root != null; }
public virtual void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else {
if (SB_BinarySearchTree<T>.Find(_root, v) != null)
return;
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public void Clear() { _root = null; }
public void Remove(T v) { _root = SB_BinarySearchTree<T>.Remove(_root, v); }
public bool Contains(T v) {
return SB_BinarySearchTree<T>.Contains(_root, v);
}
public T ElementAt(int k) {
var node = SB_BinarySearchTree<T>.FindByIndex(_root, k);
if (node == null)
throw new IndexOutOfRangeException();
return node.Value;
}
public int Count(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v) -
SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int LowerBound(T v) {
return SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int UpperBound(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v);
}
public T max() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.RChild != null) {
ima = ima.RChild;
}
return ima.Value;
}
public T min() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.LChild != null) {
ima = ima.LChild;
}
return ima.Value;
}
public Tuple<int, int> EqualRange(T v) {
if (!Contains(v))
return new Tuple<int, int>(-1, -1);
return new Tuple<int, int>(SB_BinarySearchTree<T>.LowerBound(_root, v),
SB_BinarySearchTree<T>.UpperBound(_root, v) - 1);
}
public List<T> ToList() {
return new List<T>(SB_BinarySearchTree<T>.Enumerate(_root));
}
}
/// <summary>
/// C-like multiset
/// </summary>
public class MultiSet<T> : Set<T>
where T : IComparable {
public override void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public class RollingHashSlow {
public const long B = (long)1e5 + 7;
public const long MOD = (long)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public long[] Power { get; set; }
public long[] Hash { get; set; }
public RollingHashSlow(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new long[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = (this.Power[i] * B) % MOD;
}
// ハッシュを前計算する
this.Hash = new long[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = (this.Hash[i] * B + S[i]) % MOD;
}
}
// S[l, r) のハッシュ値を求める
public long Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l] % MOD);
if (hash < 0)
hash += MOD;
return hash;
}
}
class RollingHashFast {
public const ulong B = (ulong)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public ulong[] Power { get; set; }
public ulong[] Hash { get; set; }
public RollingHashFast(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new ulong[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = this.Power[i] * B;
}
// ハッシュを前計算する
this.Hash = new ulong[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = this.Hash[i] * B + S[i];
}
}
// [l, r) のハッシュ値を求める
public ulong Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l]);
return hash;
}
}
class Segtree<T> {
int n;
T[] tree;
Func<T, T, T> f;
T exnum;
public Segtree(int m, Func<T, T, T> f, T ex) {
this.f = f;
this.exnum = ex;
n = 1;
while (n < m)
n <<= 1;
tree = new T[(n << 1) - 1];
for (int i = 0; i < tree.Length; i++)
tree[i] = ex;
}
public Segtree(int m, T ini, Func<T, T, T> f, T ex) : this(m, f, ex) {
for (int i = 0; i < m; ++i)
tree[i + n - 1] = ini;
all_update();
}
public void assign_without_update(int j, T x) { tree[j + n - 1] = x; }
public void update(int j, T x) {
int i = j + n - 1;
tree[i] = x;
while (i > 0) {
i = (i - 1) >> 1;
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
}
public void all_update() {
for (int i = n - 2; i >= 0; i--)
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
public T look(int i) { return tree[i + n - 1]; }
// [s, t)
public T run(int s, int t) { return query(s, t, 0, 0, n); }
T query(int s, int t, int k, int l, int r) {
if (r <= s || t <= l)
return exnum;
if (s <= l && r <= t)
return tree[k];
return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1),
query(s, t, (k + 1) << 1, (l + r) >> 1, r));
}
}
public class WarshallFloyd {
public int V { get; set; }
public long[,] DP { get; set; }
public long INF = long.MaxValue;
public bool[] Negative;
public WarshallFloyd(int v) {
this.V = v;
this.DP = new long[V, V];
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
this.DP[i, j] = INF;
}
this.DP[i, i] = 0;
}
}
public void SetCost(int a, int b, int c = 1) { this.DP[a, b] = c; }
public long[,] CalcMinCost() {
this.Negative = new bool[V];
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
DP[i, j] = Math.Min(DP[i, j], DP[i, k] + DP[k, j]);
}
}
}
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
if (DP[i, j] > DP[i, k] + DP[k, j]) {
this.Negative[i] = true;
this.Negative[j] = true;
this.Negative[k] = true;
}
}
}
}
return DP;
}
public long GetMinCost(int a, int b) { return DP[a, b]; }
public bool IsINF(int a, int b) { return DP[a, b] >= INF; }
public bool IsNegative(params int[] vs) {
if (vs.Length == 0)
vs = Enumerable.Range(0, V).ToArray();
foreach (var v in vs) {
if (Negative[v])
return true;
}
return false;
}
}
/// <summary>
/// Get min cost between two points
/// </summary>
public class Dijkstra {
private int maxIndex = -1;
private const int INF = Int32.MaxValue;
private int[,] _edgeArray;
/// <summary>
/// Dijkstra, get min cost between two points
/// should not contain negatie cost path
/// </summary>
/// <param name="size">max index of vertices</param>
public Dijkstra(int size) {
maxIndex = size + 1;
_edgeArray = new int[maxIndex, maxIndex];
for (int i = 0; i < _edgeArray.GetLength(0); i++) {
for (int j = 0; j < _edgeArray.GetLength(1); j++) {
_edgeArray[i, j] = INF;
if (i == j)
_edgeArray[i, j] = 0;
}
}
}
// Add a path(no direction) with its cost
public void AddPath(int s, int t, int cost) {
_edgeArray[s, t] = Math.Min(_edgeArray[s, t], cost);
_edgeArray[t, s] = _edgeArray[s, t];
}
// Get the min cost between s and t
// return Int32.MaxValue if no path
public int GetMinCost(int s, int t) {
int[] cost = new int[maxIndex];
for (int i = 0; i < cost.Length; i++)
cost[i] = INF;
cost[s] = 0;
var priorityQueue = new PriorityQueue<CPair<int, int>>();
priorityQueue.Enqueue(new CPair<int, int>(0, s));
while (priorityQueue.Count() > 0) {
var costDestinationPair = priorityQueue.Dequeue();
if (cost[costDestinationPair.Item2] < costDestinationPair.Item1)
continue;
for (int i = 0; i < maxIndex; i++) {
int newCostToi = _edgeArray[costDestinationPair.Item2, i] == INF
? INF
: costDestinationPair.Item1 +
_edgeArray[costDestinationPair.Item2, i];
if (newCostToi < cost[i]) {
cost[i] = newCostToi;
priorityQueue.Enqueue(new CPair<int, int>(newCostToi, i));
}
}
}
return cost[t];
}
}
class Deque<T> : IEnumerable<T> {
public T this[int i] {
get { return this.Buffer[(this.FirstIndex + i) % this.Capacity]; }
set {
if (i < 0)
throw new ArgumentOutOfRangeException();
this.Buffer[(this.FirstIndex + i) % this.Capacity] = value;
}
}
private T[] Buffer;
private int Capacity;
private int FirstIndex;
private int LastIndex {
get { return (this.FirstIndex + this.Length) % this.Capacity; }
}
public int Length;
public Deque(int capacity = 16) {
this.Capacity = capacity;
this.Buffer = new T[this.Capacity];
this.FirstIndex = 0;
}
public void PushBack(T data) {
if (this.Length == this.Capacity)
this.Resize();
this.Buffer[this.LastIndex] = data;
this.Length++;
}
public void PushFront(T data) {
if (this.Length == this.Capacity)
this.Resize();
var index = this.FirstIndex - 1;
if (index < 0)
index = this.Capacity - 1;
this.Buffer[index] = data;
this.Length++;
this.FirstIndex = index;
}
public T PopBack() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[this.Length - 1];
this.Length--;
return data;
}
public T PopFront() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[0];
this.FirstIndex++;
this.FirstIndex %= this.Capacity;
this.Length--;
return data;
}
private void Resize() {
var newArray = new T[this.Capacity * 2];
for (int i = 0; i < this.Length; i++) {
newArray[i] = this[i];
}
this.FirstIndex = 0;
this.Capacity *= 2;
this.Buffer = newArray;
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
IEnumerator IEnumerable.GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
public class PotentializedUnionFind {
int _count;
int[] par, sizes, rank;
long[] weight;
public PotentializedUnionFind(int N) {
_count = N;
par = new int[N];
sizes = new int[N];
rank = new int[N];
weight = new long[N];
for (int i = 0; i < N; ++i) {
par[i] = i;
sizes[i] = 1;
rank[i] = 0;
}
}
int Root(int X) {
if (par[X] == X) {
return X;
} else {
int r = Root(par[X]);
weight[X] += weight[par[X]];
return (par[X] = r);
}
}
public bool Merge(int X, int Y, long W) {
W += GetWeight(X);
W -= GetWeight(Y);
X = Root(X);
Y = Root(Y);
if (X == Y)
return false;
--_count;
if (rank[X] < rank[Y]) {
par[X] = Y;
sizes[Y] += sizes[X];
weight[X] = -W;
} else {
par[Y] = X;
sizes[X] += sizes[Y];
if (rank[X] == rank[Y])
++rank[X];
weight[Y] = W;
}
return true;
}
public bool IsSame(int X, int Y) => Root(X) == Root(Y);
public int Count => _count;
public bool IsParent(int X) => X == Root(X);
public int GetParent(int X) => Root(X);
public int Size(int X) => sizes[Root(X)];
public long GetWeight(int X) {
Root(X);
return weight[X];
}
public long GetDiff(int X, int Y) => GetWeight(Y) - GetWeight(X);
}
public static class BellmanFord {
public class Vertex {
public long Distance { get; set; }
public Vertex() { Distance = long.MaxValue; }
}
public class Edge {
public int From { get; private set; }
public int To { get; private set; }
public long Weight { get; private set; }
public Edge(int from, int to, long weight) {
From = from;
To = to;
Weight = weight;
}
}
private static void GetReachable(int origin, ref HashSet<int> reached,
ref Dictionary<int, int[]> paths) {
if (reached.Contains(origin))
return;
reached.Add(origin);
if (paths.ContainsKey(origin) == false)
return;
foreach (var p in paths[origin])
GetReachable(p, ref reached, ref paths);
}
/// <summary>
/// null: 負の無限大
/// long.MaxValue: たどり着けない
/// その他: 距離
/// </summary>
public static long? RunBellmanFord(int vertexCount, List<Edge> rawEdges,
int source, int dest) {
var forwards =
rawEdges.GroupBy(x => x.From)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.To).ToArray());
var reverses = rawEdges.GroupBy(x => x.To).ToDictionary(
x => x.Key, x => x.Select(xs => xs.From).ToArray());
var fromSource = new HashSet<int>();
var toDest = new HashSet<int>();
GetReachable(source, ref fromSource, ref forwards);
GetReachable(dest, ref toDest, ref reverses);
var edges = rawEdges.Where(e => fromSource.Contains(e.From))
.Where(e => fromSource.Contains(e.To))
.Where(e => toDest.Contains(e.From))
.Where(e => toDest.Contains(e.To))
.ToArray();
// initialize distances
var vertices = new List<Vertex>();
for (int i = 0; i < vertexCount; i++)
vertices.Add(new Vertex());
vertices[source].Distance = 0L;
// update distances
for (int i = 0; i < vertices.Count; i++) {
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance == long.MaxValue)
continue;
var newDistance = from.Distance + e.Weight;
if (to.Distance > newDistance) {
to.Distance = newDistance;
}
}
}
// check negative cycle
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance + e.Weight < to.Distance)
return null;
}
return vertices[dest].Distance;
}
}
public class SortedMultiSet<T> : IEnumerable<T> {
private SortedDictionary<T, int> _dict;
public SortedMultiSet() { _dict = new SortedDictionary<T, int>(); }
public SortedMultiSet(IEnumerable<T> items) : this() { Add(items); }
public bool Contains(T item) { return _dict.ContainsKey(item); }
public void Add(T item) {
if (_dict.ContainsKey(item))
_dict[item]++;
else
_dict[item] = 1;
}
public void Add(IEnumerable<T> items) {
foreach (var item in items)
Add(item);
}
public void Remove(T item) {
if (!_dict.ContainsKey(item))
throw new ArgumentException();
if (--_dict[item] == 0)
_dict.Remove(item);
}
// Return the last value in the multiset
public T Peek() {
if (!_dict.Any())
throw new NullReferenceException();
return _dict.Last().Key;
}
// Return the last value in the multiset and remove it.
public T Pop() {
T item = Peek();
Remove(item);
return item;
}
public IEnumerator<T> GetEnumerator() {
foreach (var kvp in _dict)
for (int i = 0; i < kvp.Value; i++)
yield return kvp.Key;
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
class Treap<T> : IEnumerable<T>
where T : IComparable {
public int Length {
get { return this.Root == null ? 0 : this.NodeCount(this.Root); }
}
public T this[int i] {
get {
if (this.Root.Count < i - 1)
throw new IndexOutOfRangeException();
return this.Root.Get(i);
}
}
public Node Root;
private IComparer<T> Cmp = Comparer<T>.Default;
public Treap(IComparer<T> cmp = null) {
if (cmp != null)
this.Cmp = cmp;
}
public Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if (l.Priority > r.Priority) {
l.R = this.Merge(l.R, r);
return this.Update(l);
} else {
r.L = this.Merge(l, r.L);
return this.Update(r);
}
}
// 左にk個、右に残り(n-k)個に分割する
public (Node, Node) Split(int k) { return this.Split(this.Root, k); }
public (Node, Node) Split(Node t, int k) {
if (t == null)
return (null, null);
if (k <= this.NodeCount(t.L)) {
var s = this.Split(t.L, k);
t.L = s.Item2;
return (s.Item1, this.Update(t));
} else {
var s = this.Split(t.R, k - this.NodeCount(t.L) - 1);
t.R = s.Item1;
return (this.Update(t), s.Item2);
}
}
public int NodeCount(Node node) { return node == null ? 0 : node.Count; }
public int LowerBouond(T value) { return this.LowerBouond(this.Root, value); }
public int LowerBouond(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) <= 0)
return this.LowerBouond(node.L, value);
else
return this.NodeCount(node.L) + 1 + this.LowerBouond(node.R, value);
}
public int UpperBound(T value) { return this.UpperBound(this.Root, value); }
public int UpperBound(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) >= 0)
return this.NodeCount(node.L) + 1 + this.UpperBound(node.R, value);
else
return this.UpperBound(node.L, value);
}
public int ValueCount(T value) {
return this.UpperBound(value) - this.LowerBouond(value);
}
public void Insert(T value) {
var sub = this.Split(this.Root, this.LowerBouond(value));
var newNode = new Node(value);
var merged = this.Merge(sub.Item1, newNode);
this.Root = this.Merge(merged, sub.Item2);
}
public void Erase(T value) {
if (this.ValueCount(value) == 0)
return;
var sub = this.Split(this.Root, this.LowerBouond(value));
this.Root = this.Merge(sub.Item1, this.Split(sub.Item2, 1).Item2);
}
public void InsertAt(Node node, int k) {
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public void InsertAt(T value, int k) {
var node = new Node(value);
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public Node EraseAt(int k) {
var sub = this.Split(this.Root, k);
var sub2 = this.Split(sub.Item2, 1);
var res = sub2.Item1;
this.Root = this.Merge(sub.Item1, sub2.Item2);
return res;
}
public Node Update(Node node) {
node.Count = this.NodeCount(node.L) + this.NodeCount(node.R) + 1;
return node;
}
public class Node {
private static Random Rand = new Random();
public T Value;
public Node L = null;
public Node R = null;
public int Count;
public double Priority;
public Node(T value, double priority) {
this.Value = value;
this.Priority = priority;
this.Count = 1;
}
public Node(T value) : this(value, Rand.NextDouble()) {}
public T Get(int i) { return this.GetNode(i).Value; }
public Node GetNode(int i) {
var lcount = 0;
if (this.L != null)
lcount = this.L.Count;
if (lcount == i)
return this;
else if (lcount < i)
return this.R.GetNode(i - lcount - 1);
else
return this.L.GetNode(i);
}
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++)
yield return this.Root.Get(i);
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
public static class ObjectExtension {
// ディープコピーの複製を作る拡張メソッド
public static T DeepClone<T>(this T src) {
using (var memoryStream = new System.IO.MemoryStream()) {
var binaryFormatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src); // シリアライズ
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream); // デシリアライズ
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.Collections;
namespace CompetitiveProgramming {
public class CPair<T, U> : IComparable
where T : IComparable<T> {
public readonly T Item1;
public readonly U Item2;
public int CompareTo(object obj) {
CPair<T, U> castedObj = (CPair<T, U>)obj;
return this.Item1.CompareTo(castedObj.Item1);
}
public CPair(T t, U u) {
Item1 = t;
Item2 = u;
}
}
class Pair : IComparable {
public long x;
public long a;
public long b;
public long c;
public Pair(long X, long Y, long Z, long D) {
x = X;
a = Y;
b = Z;
c = D;
}
public Pair(long a, long x) {
this.a = a;
this.x = x;
}
public Pair(long a, long b, long c) {
this.a = a;
this.b = b;
this.c = c;
}
public int CompareTo(object obj) {
Pair kore = (Pair)obj;
return x.CompareTo(kore.x);
}
public static bool operator <=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x <= p2.x;
} else {
return p1.a <= p2.a;
}
}
public static bool operator >=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x >= p2.x;
} else {
return p1.a >= p2.a;
}
}
}
class Zettiti : IComparable {
public long num;
public Zettiti(long num) { this.num = num; }
public int CompareTo(object obj) {
Zettiti kore = (Zettiti)obj;
long knum = Math.Abs(kore.num);
long mynum = Math.Abs(num);
return mynum.CompareTo(knum);
}
}
class Program {
static void Main(string[] args) {
// Utils.BinarySearch.Search
StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput());
int a = scan.Integer();
int b = scan.Integer();
int c = scan.Integer();
int x = scan.Integer();
int ans = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
if (i * 500 + j * 100 + 50 * k == x)
ans++;
}
}
}
Console.WriteLine(ans);
}
static string dffs(int n, int m, Tuple<int, int>[] tuples, int cur, int sum,
string now) {
if (sum == n)
return now;
if (cur == m)
return "";
string zan = now;
for (int i = 0; i < (n - sum) / tuples[cur].Item1; i++) {
zan += tuples[cur].Item2;
}
for (int i = (n - sum) / tuples[cur].Item1; i >= 0; i--) {
string buf =
dffs(n, m, tuples, cur + 1, sum + i * tuples[cur].Item1, zan);
if (buf != "")
return buf;
zan = zan.Substring(0, zan.Length - 1);
;
}
return "";
}
static bool isOK(long mid, long[] a, long[] f, long k) {
long count = 0;
for (long i = 0; i < a.Length; i++) {
long togo = mid / f[i];
;
count += Math.Max(0, a[i] - togo);
}
return (count <= k);
}
static void Output<T>(List<T> list, string kugiri = "\n") {
for (int i = 0; i < list.Count; i++) {
Console.Write(list[i]);
if (i != list.Count - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[] list, string kugiri = "\n") {
for (int i = 0; i < list.Length; i++) {
Console.Write(list[i]);
if (i != list.Length - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[,] list, string kugiri1 = " ",
string kugiri2 = "\n") {
int len1 = list.GetLength(0);
int len2 = list.GetLength(1);
for (int i = 0; i < len1; i++) {
for (int j = 0; j < len2; j++) {
Console.Write(list[i, j]);
if (j != len2 - 1) {
Console.Write(kugiri1);
}
}
if (i != len1 - 1) {
Console.Write(kugiri2);
}
}
}
static int binary_search<T>(T key, T[] moto, Func<int, T, T[], bool> isok) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isok(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int binary_search(int key, int[] moto) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isOK(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int[] Togo;
static bool CheckBipartite(int now, int prev, List<int>[] g,
int c = 0) // 0,-1が想定
{
if (Togo == null)
Togo = Enumerable.Repeat(-1, g.Length).ToArray();
foreach (var next in g[now]) {
if (next == prev)
continue;
var nextc = Togo[next];
if (nextc >= 0 && nextc == c)
return false;
if (nextc >= 0)
continue;
Togo[next] = (c + 1) % 2;
var res = CheckBipartite(next, now, g, (c + 1) % 2);
if (res == false)
return false;
}
return true;
}
static bool isOK(int index, int key, int[] moto) { return moto[index] > key; }
public static int bitCount(int k) {
uint i = (uint)k;
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
i = (i + (i >> 4)) & 0x0f0f0f0f;
i = i + (i >> 8);
i = i + (i >> 16);
return (int)i & 0x3f;
}
static int check(long moto, long tai) {
if (tai % moto != 0) {
return 0;
}
while (tai > 1) {
if (tai % moto == 0) {
tai /= moto;
} else if (tai > moto) {
tai %= moto;
} else {
tai -= moto;
}
}
if (tai == 1) {
return 1;
} else {
return 0;
}
}
static bool NextPermutation(int[] array) {
var size = array.Length;
var ok = false;
// array[i]<array[i+1]を満たす最大のiを求める
int i = size - 2;
for (; 0 <= i; i--) {
if (array[i] < array[i + 1]) {
ok = true;
break;
}
}
//全ての要素が降順の場合、NextPermutationは存在しない
if (ok == false)
return false;
// array[i]<array[j]を満たす最大のjを求める
int j = size - 1;
for (;; j--) {
if (array[i] < array[j])
break;
}
// iとjの要素をswapする
var tmp = array[i];
array[i] = array[j];
array[j] = tmp;
// i以降の要素を反転させる
Array.Reverse(array, i + 1, size - (i + 1));
return true;
}
static List<int[]> GetAllPermutation(int N) {
var res = new List<int[]>();
var array = Enumerable.Range(0, N).ToArray();
do {
var copy = new int[N];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static List<int[]> GetAllPermutation(int[] array) {
var size = array.Length;
var res = new List<int[]>();
do {
var copy = new int[size];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static long Syakutori(
int[] a,
long
k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上
{
long sum = 0;
int right = 0;
long ans = 0;
for (int left = 0; left < a.Length; left++) {
while (right < a.Length && sum < k) {
sum += a[right];
right++;
}
if (k <= sum) {
ans += a.Length - right + 1;
}
if (left == right) {
right++;
} else {
sum -= a[left];
}
}
return ans;
}
static int[] zalgo(String s) {
int n = s.Length;
int[] ret = new int[n];
ret[0] = n;
int i = 1, j = 0;
while (i < n) {
while (i + j < n && s[j] == s[i + j])
++j;
ret[i] = j;
if (j == 0) {
++i;
continue;
}
int k = 1;
while (i + k < n && k + ret[k] < j) {
ret[i + k] = ret[k];
++k;
}
i += k;
j -= k;
}
return ret;
}
static int gcd(int a, int b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
static long gcd(long a, long b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
public static List<long> FactorialMemo = new List<long>() { 1 };
static long Fact(int x) {
for (int i = FactorialMemo.Count; i <= x; i++)
FactorialMemo.Add(FactorialMemo.Last() * i);
return FactorialMemo[x];
}
static int[] yousogotoplus(int[] a, int[] b) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[i];
}
return c;
}
static int[] yousogotoplus(int[] a, int[,] b, int l) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[l, i];
}
return c;
}
static int[] yousogotoplus(int[,] a, int l) {
int[] c = new int[a.GetLength(1)];
for (int i = 0; i < a.GetLength(1); i++) {
c[i] = a[l, i];
}
return c;
}
public static long LowerBound(long[] a, long key) {
long l = 0;
long r = a.Length;
long mid;
while (l < r) {
mid = ((r - l) / 2) + l;
if (a[mid] <= key)
l = mid + 1;
else
r = mid;
}
return l;
}
public static long LIS(long[] a) {
var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray();
for (int i = 0; i < a.Length; i++) {
dp[LowerBound(dp, a[i])] = a[i];
}
return LowerBound(dp, long.MaxValue - 1);
}
static long DivideWith(long m, long n, List<long> primes) {
while (m % n == 0) {
primes.Add(n);
m = m / n;
}
return m;
}
public static Dictionary<long, int> Soinsubunkai(long n) {
var map = new Dictionary<long, int>();
for (long p = 2; p * p <= n; p++) {
int count = 0;
while (n % p == 0) {
count++;
n /= p;
}
if (count != 0)
map.Add(p, count);
}
if (n > 1)
map.Add(n, 1);
return map;
}
static IEnumerable<int> Primes(int maxnum) {
// var sieve = new BitArray(maxnum + 1, true);
bool[] sieve = Enumerable.Repeat(true, maxnum + 1).ToArray();
int squareroot = (int)Math.Sqrt(maxnum);
for (int i = 2; i <= squareroot; i++) {
if (sieve[i] == false)
continue;
for (int n = i * 2; n <= maxnum; n += i)
sieve[n] = false;
}
for (int i = 2; i <= maxnum; i++)
if (sieve[i] == true)
yield return i;
}
/* static long[] SoinsuBunkai(long num)
{
if (num == 1)
return new long[] { 1 };
List<long> primes = new List<long>();
long n = DivideWith(num, 2, primes);
n = DivideWith(n, 3, primes);
n = DivideWith(n, 5, primes);
long i = 0;
while (n > 1)
{
int[] ps = { 7, 11, 13, 17, 19, 23, 29, 31 };
foreach (var p in ps)
{
// 30m+2, 30m+3, 30m+4, 30m+5, 30m+6、30m+8...
は割る必要はない。 n = DivideWith(n, i + p, primes); if (n == 1) break;
}
i += 30;
}
return primes.ToArray();
}*/
public static int h;
public static int w;
public static int BFS(int height, int width, char[,] map) {
int[] dx = new int[] { -1, 0, 0, 1 };
int[] dy = new int[] { 0, 1, -1, 0 };
bool[,] visited = new bool[h, w];
int[,] len = new int[h, w];
var queue = new Queue<Tuple<int, int>>();
queue.Enqueue(new Tuple<int, int>(height, width));
int max = 0;
visited[height, width] = true;
while (queue.Count > 0) {
var now = queue.Dequeue();
for (int i = 0; i < 4; i++) {
int ny = now.Item1 + dy[i];
int nx = now.Item2 + dx[i];
if (ny >= h || ny < 0 || nx >= w || nx < 0)
continue;
if (visited[ny, nx] || map[ny, nx] == '#')
continue;
visited[ny, nx] = true;
len[ny, nx] = len[now.Item1, now.Item2] + 1;
max = Math.Max(max, len[ny, nx]);
queue.Enqueue(new Tuple<int, int>(ny, nx));
}
}
return max;
}
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Initialize<T>(ref T[] array, T initialvalue) {
array = Array.ConvertAll(array, x => initialvalue);
}
static int[] Manacher(string S) {
int i = 0, j = 0;
int[] R = new int[S.Length];
while (i < S.Length) {
while (i - j >= 0 && i + j < S.Length && S[i - j] == S[i + j])
++j;
R[i] = j;
int k = 1;
while (i - k >= 0 && k + R[i - k] < j) {
R[i + k] = R[i - k];
++k;
}
i += k;
j -= k;
}
return R;
}
/* static Pair[] a;
static int SaikiZentansaku(List<int>now,int count,int last,int n,int m)
{
List<int> next = new List<int>();
for (int i = 0; i < now.Count; i++)
{
next.Add(now[i]);
}
next.Add(last);
var kore = next.ToArray();
int ans = 0;
if(count==n)
{
for (int i = 0; i < a.Length; i++)
{
int A = a[i].a;
int b = a[i].b;
int c = a[i].c;
int d = a[i].x;
if (kore[b] - kore[A] == c) { ans += d; }
}
return ans;
}
for (int i = last; i <= m; i++)
{
ans = Math.Max(ans, SaikiZentansaku(next, count + 1, i, n, m));
}
return ans;
}*/
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private long len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public char[] Char(long n) {
char[] kore = new char[n];
for (long i = 0; i < n; i++) {
kore[i] = Char();
}
return kore;
}
public char[,] Char(long n, long m) {
char[,] kore = new char[n, m];
for (long i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
kore[i, j] = Char();
}
}
return kore;
}
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[] Scan(long n) {
string[] str = new string[n];
for (long i = 0; i < n; i++) {
str[i] = Scan();
}
return str;
}
public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
public long[] Long(long n, bool minus1 = false) {
long[] kore = new long[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
if (minus1)
kore[i]--;
}
return kore;
}
public Mlong[] MLong(long n) {
Mlong[] kore = new Mlong[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
}
return kore;
}
public long[,] Long(long h, long w, bool minus1 = false) {
long[,] kore = new long[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int Integer() { return (int)Long(); }
public Mint[] MInteger(long n) {
Mint[] kore = new Mint[n];
for (int i = 0; i < n; i++) {
kore[i] = Integer();
}
return kore;
}
public int[] Integer(long n, bool minus1 = false) {
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = (int)Long();
if (minus1)
kore[i]--;
}
return kore;
}
public int[,] Integer(long h, long w, bool minus1 = false) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = (int)Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int[] StringToInt(int n) {
char[] s = Scan().ToCharArray();
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = s[i] - '0';
}
return kore;
}
public int[,] StringToInt(int h, int w) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
char[] s = Scan().ToCharArray();
for (int j = 0; j < w; j++) {
kore[i, j] = s[j] - '0';
}
}
return kore;
}
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
public class UnionFind {
public int[] data;
public UnionFind(int size) {
data = new int[size];
for (int i = 0; i < size; i++)
data[i] = -1;
}
public bool Unite(int x, int y) {
x = Root(x);
y = Root(y);
if (x != y) {
if (data[y] < data[x]) {
var tmp = y;
y = x;
x = tmp;
}
data[x] += data[y];
data[y] = x;
}
return x != y;
}
public bool IsSameGroup(int x, int y) { return Root(x) == Root(y); }
public int Root(int x) { return data[x] < 0 ? x : data[x] = Root(data[x]); }
public int Size(int x) { return -data[Root(x)]; }
}
public class Mlong : IComparable {
public static long mod = 1000000007;
public long num;
public Mlong(long num) {
if (num < 0) {
num += mod;
}
this.num = num % mod;
}
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mlong operator +(Mlong x, Mlong y) {
return new Mlong((x.num + y.num) % mod);
}
public static Mlong operator -(Mlong x, Mlong y) {
return new Mlong((x.num - y.num + mod) % mod);
}
public static Mlong operator *(Mlong x, Mlong y) {
return new Mlong((long)(((1L * x.num) * y.num) % mod));
}
public Mlong hutujyo(Mlong x) { return new Mlong(num / x.num); }
static long GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return x2 + mod;
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return x1 + mod;
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mlong modjyo(Mlong x) { return num * GetInverse(x.num) % mod; }
public static implicit operator Mlong(long x) { return new Mlong(x); }
public static Mlong operator %(Mlong x, Mlong y) {
return new Mlong(x.num % y.num);
}
public static explicit operator long(Mlong x) { return x.num; }
public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; }
public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; }
public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; }
public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; }
public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; }
public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; }
public Mlong Pow(Mlong n) {
Mlong pow = this;
Mlong res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n = n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); }
public static List<Mlong> FactorialMemo = new List<Mlong>() { 1 };
static Mlong Factorial(int x) {
for (int i = FactorialMemo.Count; i <= x; i++)
FactorialMemo.Add(FactorialMemo.Last() * i);
return FactorialMemo[x];
}
public static Mlong Comb(Mlong n, Mlong a) {
Mlong buf1 = 1;
Mlong buf2 = 1;
for (long i = 0; i < a.num; i++) {
buf1 *= n - i;
buf2 *= (i + 1);
}
return buf1.modjyo(buf2);
}
public static Mlong Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mlong x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mlong kore = (Mlong)obj;
return num.CompareTo(kore.num);
}
}
public class Mint : IComparable {
public static int mod = 1000000007;
public int num;
public Mint(int Num) { num = Num; }
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mint operator +(Mint x, Mint y) {
return new Mint((x.num + y.num) % mod);
}
public static Mint operator -(Mint x, Mint y) {
return new Mint((x.num - y.num + mod) % mod);
}
public static Mint operator *(Mint x, Mint y) {
return new Mint((int)(((1L * x.num) * y.num) % mod));
}
public Mint hutujyo(Mint x) { return new Mint(num / x.num); }
static int GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return (int)(x2 + mod);
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return (int)(x1 + mod);
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mint modjyo(Mint x) { return num * GetInverse(x.num) % mod; }
/* public Mint modjyo(Mint x)
{
return num * x.Pow(mod - 2);
}*/
public static implicit operator Mint(int x) { return new Mint(x); }
public static Mint[] Toarray(int[] x) {
Mint[] buf = new Mint[x.Length];
for (int i = 0; i < x.Length; i++) {
buf[i] = x[i];
}
return buf;
}
public static explicit operator int(Mint x) { return x.num; }
public static Mint operator %(Mint x, Mint y) {
return new Mint(x.num % y.num);
}
public static bool operator ==(Mint x, Mint y) { return x.num == y.num; }
public static bool operator !=(Mint x, Mint y) { return x.num != y.num; }
public static bool operator<(Mint x, Mint y) { return x.num < y.num; }
public static bool operator>(Mint x, Mint y) { return x.num > y.num; }
public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; }
public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; }
public Mint Pow(Mint n) {
Mint pow = this;
Mint res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mint Pow(Mint a, Mint n) { return a.Pow(n); }
public static List<Mint> FactorialMemo = new List<Mint>() { 1 };
static Mint Factorial(int x) {
for (int i = FactorialMemo.Count; i <= x; i++)
FactorialMemo.Add(FactorialMemo.Last() * i);
return FactorialMemo[x];
}
public static Mint Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mint x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mint kore = (Mint)obj;
return num.CompareTo(kore.num);
}
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class Tree {
public Node[] Nodes;
public List<int[]> hen;
public class Node {
public int? parent = null;
public List<int[]> children = new List<int[]>();
public int parentcolor = -1;
}
public Tree(int kosu) {
Nodes = new Node[kosu];
for (int i = 0; i < Nodes.Length; i++) {
Nodes[i] = new Node();
}
hen = new List<int[]>();
}
public void Connect(int oya, int ko, int id) {
hen.Add(new int[] { oya, ko, 0 });
Nodes[oya].children.Add(new int[] { ko, id });
Nodes[ko].parent = oya;
}
}
/// <summary>
/// Self-Balancing Binary Search Tree
/// (using Randamized BST)
/// </summary>
public class SB_BinarySearchTree<T>
where T : IComparable {
public class Node {
public T Value;
public Node LChild;
public Node RChild;
public int Count; // size of the sub tree
public Node(T v) {
Value = v;
Count = 1;
}
}
static Random _rnd = new Random();
public static int Count(Node t) { return t == null ? 0 : t.Count; }
static Node Update(Node t) {
t.Count = Count(t.LChild) + Count(t.RChild) + 1;
return t;
}
public static Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) {
l.RChild = Merge(l.RChild, r);
return Update(l);
} else {
r.LChild = Merge(l, r.LChild);
return Update(r);
}
}
/// <summary>
/// split as [0, k), [k, n)
/// </summary>
public static Tuple<Node, Node> Split(Node t, int k) {
if (t == null)
return new Tuple<Node, Node>(null, null);
if (k <= Count(t.LChild)) {
var s = Split(t.LChild, k);
t.LChild = s.Item2;
return new Tuple<Node, Node>(s.Item1, Update(t));
} else {
var s = Split(t.RChild, k - Count(t.LChild) - 1);
t.RChild = s.Item1;
return new Tuple<Node, Node>(Update(t), s.Item2);
}
}
public static Node Remove(Node t, T v) {
if (Find(t, v) == null)
return t;
return RemoveAt(t, LowerBound(t, v));
}
public static Node RemoveAt(Node t, int k) {
var s = Split(t, k);
var s2 = Split(s.Item2, 1);
return Merge(s.Item1, s2.Item2);
}
public static bool Contains(Node t, T v) { return Find(t, v) != null; }
public static Node Find(Node t, T v) {
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0)
t = t.LChild;
else if (cmp < 0)
t = t.RChild;
else
break;
}
return t;
}
public static Node FindByIndex(Node t, int idx) {
if (t == null)
return null;
var currentIdx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
if (currentIdx == idx)
return t;
if (currentIdx > idx) {
t = t.LChild;
currentIdx -= (Count(t == null ? null : t.RChild) + 1);
} else {
t = t.RChild;
currentIdx += (Count(t == null ? null : t.LChild) + 1);
}
}
return null;
}
public static int UpperBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var ret = Int32.MaxValue;
var idx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0) {
ret = Math.Min(ret, idx);
t = t.LChild;
idx -= (Count(t == null ? null : t.RChild) + 1);
} else if (cmp <= 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
}
}
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static int LowerBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var idx = Count(t) - Count(t.RChild) - 1;
var ret = Int32.MaxValue;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp >= 0) {
if (cmp == 0)
ret = Math.Min(ret, idx);
t = t.LChild;
if (t == null)
ret = Math.Min(ret, idx);
idx -= t == null ? 0 : (Count(t.RChild) + 1);
} else if (cmp < 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
if (t == null)
return idx;
}
}
// return ret;
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static Node Insert(Node t, T v) {
var ub = LowerBound(t, v);
return InsertByIdx(t, ub, v);
}
static Node InsertByIdx(Node t, int k, T v) {
var s = Split(t, k);
return Merge(Merge(s.Item1, new Node(v)), s.Item2);
}
public static IEnumerable<T> Enumerate(Node t) {
var ret = new List<T>();
Enumerate(t, ret);
return ret;
}
static void Enumerate(Node t, List<T> ret) {
if (t == null)
return;
Enumerate(t.LChild, ret);
ret.Add(t.Value);
Enumerate(t.RChild, ret);
}
}
/// <summary>
/// C-like set
/// </summary>
public class Set<T>
where T : IComparable {
protected SB_BinarySearchTree<T>.Node _root;
public T this[int idx] {
get { return ElementAt(idx); }
}
public int Count() { return SB_BinarySearchTree<T>.Count(_root); }
public bool Any() { return _root != null; }
public virtual void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else {
if (SB_BinarySearchTree<T>.Find(_root, v) != null)
return;
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public void Clear() { _root = null; }
public void Remove(T v) { _root = SB_BinarySearchTree<T>.Remove(_root, v); }
public bool Contains(T v) {
return SB_BinarySearchTree<T>.Contains(_root, v);
}
public T ElementAt(int k) {
var node = SB_BinarySearchTree<T>.FindByIndex(_root, k);
if (node == null)
throw new IndexOutOfRangeException();
return node.Value;
}
public int Count(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v) -
SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int LowerBound(T v) {
return SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int UpperBound(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v);
}
public T max() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.RChild != null) {
ima = ima.RChild;
}
return ima.Value;
}
public T min() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.LChild != null) {
ima = ima.LChild;
}
return ima.Value;
}
public Tuple<int, int> EqualRange(T v) {
if (!Contains(v))
return new Tuple<int, int>(-1, -1);
return new Tuple<int, int>(SB_BinarySearchTree<T>.LowerBound(_root, v),
SB_BinarySearchTree<T>.UpperBound(_root, v) - 1);
}
public List<T> ToList() {
return new List<T>(SB_BinarySearchTree<T>.Enumerate(_root));
}
}
/// <summary>
/// C-like multiset
/// </summary>
public class MultiSet<T> : Set<T>
where T : IComparable {
public override void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public class RollingHashSlow {
public const long B = (long)1e5 + 7;
public const long MOD = (long)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public long[] Power { get; set; }
public long[] Hash { get; set; }
public RollingHashSlow(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new long[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = (this.Power[i] * B) % MOD;
}
// ハッシュを前計算する
this.Hash = new long[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = (this.Hash[i] * B + S[i]) % MOD;
}
}
// S[l, r) のハッシュ値を求める
public long Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l] % MOD);
if (hash < 0)
hash += MOD;
return hash;
}
}
class RollingHashFast {
public const ulong B = (ulong)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public ulong[] Power { get; set; }
public ulong[] Hash { get; set; }
public RollingHashFast(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new ulong[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = this.Power[i] * B;
}
// ハッシュを前計算する
this.Hash = new ulong[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = this.Hash[i] * B + S[i];
}
}
// [l, r) のハッシュ値を求める
public ulong Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l]);
return hash;
}
}
class Segtree<T> {
int n;
T[] tree;
Func<T, T, T> f;
T exnum;
public Segtree(int m, Func<T, T, T> f, T ex) {
this.f = f;
this.exnum = ex;
n = 1;
while (n < m)
n <<= 1;
tree = new T[(n << 1) - 1];
for (int i = 0; i < tree.Length; i++)
tree[i] = ex;
}
public Segtree(int m, T ini, Func<T, T, T> f, T ex) : this(m, f, ex) {
for (int i = 0; i < m; ++i)
tree[i + n - 1] = ini;
all_update();
}
public void assign_without_update(int j, T x) { tree[j + n - 1] = x; }
public void update(int j, T x) {
int i = j + n - 1;
tree[i] = x;
while (i > 0) {
i = (i - 1) >> 1;
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
}
public void all_update() {
for (int i = n - 2; i >= 0; i--)
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
public T look(int i) { return tree[i + n - 1]; }
// [s, t)
public T run(int s, int t) { return query(s, t, 0, 0, n); }
T query(int s, int t, int k, int l, int r) {
if (r <= s || t <= l)
return exnum;
if (s <= l && r <= t)
return tree[k];
return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1),
query(s, t, (k + 1) << 1, (l + r) >> 1, r));
}
}
public class WarshallFloyd {
public int V { get; set; }
public long[,] DP { get; set; }
public long INF = long.MaxValue;
public bool[] Negative;
public WarshallFloyd(int v) {
this.V = v;
this.DP = new long[V, V];
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
this.DP[i, j] = INF;
}
this.DP[i, i] = 0;
}
}
public void SetCost(int a, int b, int c = 1) { this.DP[a, b] = c; }
public long[,] CalcMinCost() {
this.Negative = new bool[V];
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
DP[i, j] = Math.Min(DP[i, j], DP[i, k] + DP[k, j]);
}
}
}
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
if (DP[i, j] > DP[i, k] + DP[k, j]) {
this.Negative[i] = true;
this.Negative[j] = true;
this.Negative[k] = true;
}
}
}
}
return DP;
}
public long GetMinCost(int a, int b) { return DP[a, b]; }
public bool IsINF(int a, int b) { return DP[a, b] >= INF; }
public bool IsNegative(params int[] vs) {
if (vs.Length == 0)
vs = Enumerable.Range(0, V).ToArray();
foreach (var v in vs) {
if (Negative[v])
return true;
}
return false;
}
}
/// <summary>
/// Get min cost between two points
/// </summary>
public class Dijkstra {
private int maxIndex = -1;
private const int INF = Int32.MaxValue;
private int[,] _edgeArray;
/// <summary>
/// Dijkstra, get min cost between two points
/// should not contain negatie cost path
/// </summary>
/// <param name="size">max index of vertices</param>
public Dijkstra(int size) {
maxIndex = size + 1;
_edgeArray = new int[maxIndex, maxIndex];
for (int i = 0; i < _edgeArray.GetLength(0); i++) {
for (int j = 0; j < _edgeArray.GetLength(1); j++) {
_edgeArray[i, j] = INF;
if (i == j)
_edgeArray[i, j] = 0;
}
}
}
// Add a path(no direction) with its cost
public void AddPath(int s, int t, int cost) {
_edgeArray[s, t] = Math.Min(_edgeArray[s, t], cost);
_edgeArray[t, s] = _edgeArray[s, t];
}
// Get the min cost between s and t
// return Int32.MaxValue if no path
public int GetMinCost(int s, int t) {
int[] cost = new int[maxIndex];
for (int i = 0; i < cost.Length; i++)
cost[i] = INF;
cost[s] = 0;
var priorityQueue = new PriorityQueue<CPair<int, int>>();
priorityQueue.Enqueue(new CPair<int, int>(0, s));
while (priorityQueue.Count() > 0) {
var costDestinationPair = priorityQueue.Dequeue();
if (cost[costDestinationPair.Item2] < costDestinationPair.Item1)
continue;
for (int i = 0; i < maxIndex; i++) {
int newCostToi = _edgeArray[costDestinationPair.Item2, i] == INF
? INF
: costDestinationPair.Item1 +
_edgeArray[costDestinationPair.Item2, i];
if (newCostToi < cost[i]) {
cost[i] = newCostToi;
priorityQueue.Enqueue(new CPair<int, int>(newCostToi, i));
}
}
}
return cost[t];
}
}
class Deque<T> : IEnumerable<T> {
public T this[int i] {
get { return this.Buffer[(this.FirstIndex + i) % this.Capacity]; }
set {
if (i < 0)
throw new ArgumentOutOfRangeException();
this.Buffer[(this.FirstIndex + i) % this.Capacity] = value;
}
}
private T[] Buffer;
private int Capacity;
private int FirstIndex;
private int LastIndex {
get { return (this.FirstIndex + this.Length) % this.Capacity; }
}
public int Length;
public Deque(int capacity = 16) {
this.Capacity = capacity;
this.Buffer = new T[this.Capacity];
this.FirstIndex = 0;
}
public void PushBack(T data) {
if (this.Length == this.Capacity)
this.Resize();
this.Buffer[this.LastIndex] = data;
this.Length++;
}
public void PushFront(T data) {
if (this.Length == this.Capacity)
this.Resize();
var index = this.FirstIndex - 1;
if (index < 0)
index = this.Capacity - 1;
this.Buffer[index] = data;
this.Length++;
this.FirstIndex = index;
}
public T PopBack() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[this.Length - 1];
this.Length--;
return data;
}
public T PopFront() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[0];
this.FirstIndex++;
this.FirstIndex %= this.Capacity;
this.Length--;
return data;
}
private void Resize() {
var newArray = new T[this.Capacity * 2];
for (int i = 0; i < this.Length; i++) {
newArray[i] = this[i];
}
this.FirstIndex = 0;
this.Capacity *= 2;
this.Buffer = newArray;
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
IEnumerator IEnumerable.GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
public class PotentializedUnionFind {
int _count;
int[] par, sizes, rank;
long[] weight;
public PotentializedUnionFind(int N) {
_count = N;
par = new int[N];
sizes = new int[N];
rank = new int[N];
weight = new long[N];
for (int i = 0; i < N; ++i) {
par[i] = i;
sizes[i] = 1;
rank[i] = 0;
}
}
int Root(int X) {
if (par[X] == X) {
return X;
} else {
int r = Root(par[X]);
weight[X] += weight[par[X]];
return (par[X] = r);
}
}
public bool Merge(int X, int Y, long W) {
W += GetWeight(X);
W -= GetWeight(Y);
X = Root(X);
Y = Root(Y);
if (X == Y)
return false;
--_count;
if (rank[X] < rank[Y]) {
par[X] = Y;
sizes[Y] += sizes[X];
weight[X] = -W;
} else {
par[Y] = X;
sizes[X] += sizes[Y];
if (rank[X] == rank[Y])
++rank[X];
weight[Y] = W;
}
return true;
}
public bool IsSame(int X, int Y) => Root(X) == Root(Y);
public int Count => _count;
public bool IsParent(int X) => X == Root(X);
public int GetParent(int X) => Root(X);
public int Size(int X) => sizes[Root(X)];
public long GetWeight(int X) {
Root(X);
return weight[X];
}
public long GetDiff(int X, int Y) => GetWeight(Y) - GetWeight(X);
}
public static class BellmanFord {
public class Vertex {
public long Distance { get; set; }
public Vertex() { Distance = long.MaxValue; }
}
public class Edge {
public int From { get; private set; }
public int To { get; private set; }
public long Weight { get; private set; }
public Edge(int from, int to, long weight) {
From = from;
To = to;
Weight = weight;
}
}
private static void GetReachable(int origin, ref HashSet<int> reached,
ref Dictionary<int, int[]> paths) {
if (reached.Contains(origin))
return;
reached.Add(origin);
if (paths.ContainsKey(origin) == false)
return;
foreach (var p in paths[origin])
GetReachable(p, ref reached, ref paths);
}
/// <summary>
/// null: 負の無限大
/// long.MaxValue: たどり着けない
/// その他: 距離
/// </summary>
public static long? RunBellmanFord(int vertexCount, List<Edge> rawEdges,
int source, int dest) {
var forwards =
rawEdges.GroupBy(x => x.From)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.To).ToArray());
var reverses = rawEdges.GroupBy(x => x.To).ToDictionary(
x => x.Key, x => x.Select(xs => xs.From).ToArray());
var fromSource = new HashSet<int>();
var toDest = new HashSet<int>();
GetReachable(source, ref fromSource, ref forwards);
GetReachable(dest, ref toDest, ref reverses);
var edges = rawEdges.Where(e => fromSource.Contains(e.From))
.Where(e => fromSource.Contains(e.To))
.Where(e => toDest.Contains(e.From))
.Where(e => toDest.Contains(e.To))
.ToArray();
// initialize distances
var vertices = new List<Vertex>();
for (int i = 0; i < vertexCount; i++)
vertices.Add(new Vertex());
vertices[source].Distance = 0L;
// update distances
for (int i = 0; i < vertices.Count; i++) {
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance == long.MaxValue)
continue;
var newDistance = from.Distance + e.Weight;
if (to.Distance > newDistance) {
to.Distance = newDistance;
}
}
}
// check negative cycle
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance + e.Weight < to.Distance)
return null;
}
return vertices[dest].Distance;
}
}
public class SortedMultiSet<T> : IEnumerable<T> {
private SortedDictionary<T, int> _dict;
public SortedMultiSet() { _dict = new SortedDictionary<T, int>(); }
public SortedMultiSet(IEnumerable<T> items) : this() { Add(items); }
public bool Contains(T item) { return _dict.ContainsKey(item); }
public void Add(T item) {
if (_dict.ContainsKey(item))
_dict[item]++;
else
_dict[item] = 1;
}
public void Add(IEnumerable<T> items) {
foreach (var item in items)
Add(item);
}
public void Remove(T item) {
if (!_dict.ContainsKey(item))
throw new ArgumentException();
if (--_dict[item] == 0)
_dict.Remove(item);
}
// Return the last value in the multiset
public T Peek() {
if (!_dict.Any())
throw new NullReferenceException();
return _dict.Last().Key;
}
// Return the last value in the multiset and remove it.
public T Pop() {
T item = Peek();
Remove(item);
return item;
}
public IEnumerator<T> GetEnumerator() {
foreach (var kvp in _dict)
for (int i = 0; i < kvp.Value; i++)
yield return kvp.Key;
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
class Treap<T> : IEnumerable<T>
where T : IComparable {
public int Length {
get { return this.Root == null ? 0 : this.NodeCount(this.Root); }
}
public T this[int i] {
get {
if (this.Root.Count < i - 1)
throw new IndexOutOfRangeException();
return this.Root.Get(i);
}
}
public Node Root;
private IComparer<T> Cmp = Comparer<T>.Default;
public Treap(IComparer<T> cmp = null) {
if (cmp != null)
this.Cmp = cmp;
}
public Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if (l.Priority > r.Priority) {
l.R = this.Merge(l.R, r);
return this.Update(l);
} else {
r.L = this.Merge(l, r.L);
return this.Update(r);
}
}
// 左にk個、右に残り(n-k)個に分割する
public (Node, Node) Split(int k) { return this.Split(this.Root, k); }
public (Node, Node) Split(Node t, int k) {
if (t == null)
return (null, null);
if (k <= this.NodeCount(t.L)) {
var s = this.Split(t.L, k);
t.L = s.Item2;
return (s.Item1, this.Update(t));
} else {
var s = this.Split(t.R, k - this.NodeCount(t.L) - 1);
t.R = s.Item1;
return (this.Update(t), s.Item2);
}
}
public int NodeCount(Node node) { return node == null ? 0 : node.Count; }
public int LowerBouond(T value) { return this.LowerBouond(this.Root, value); }
public int LowerBouond(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) <= 0)
return this.LowerBouond(node.L, value);
else
return this.NodeCount(node.L) + 1 + this.LowerBouond(node.R, value);
}
public int UpperBound(T value) { return this.UpperBound(this.Root, value); }
public int UpperBound(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) >= 0)
return this.NodeCount(node.L) + 1 + this.UpperBound(node.R, value);
else
return this.UpperBound(node.L, value);
}
public int ValueCount(T value) {
return this.UpperBound(value) - this.LowerBouond(value);
}
public void Insert(T value) {
var sub = this.Split(this.Root, this.LowerBouond(value));
var newNode = new Node(value);
var merged = this.Merge(sub.Item1, newNode);
this.Root = this.Merge(merged, sub.Item2);
}
public void Erase(T value) {
if (this.ValueCount(value) == 0)
return;
var sub = this.Split(this.Root, this.LowerBouond(value));
this.Root = this.Merge(sub.Item1, this.Split(sub.Item2, 1).Item2);
}
public void InsertAt(Node node, int k) {
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public void InsertAt(T value, int k) {
var node = new Node(value);
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public Node EraseAt(int k) {
var sub = this.Split(this.Root, k);
var sub2 = this.Split(sub.Item2, 1);
var res = sub2.Item1;
this.Root = this.Merge(sub.Item1, sub2.Item2);
return res;
}
public Node Update(Node node) {
node.Count = this.NodeCount(node.L) + this.NodeCount(node.R) + 1;
return node;
}
public class Node {
private static Random Rand = new Random();
public T Value;
public Node L = null;
public Node R = null;
public int Count;
public double Priority;
public Node(T value, double priority) {
this.Value = value;
this.Priority = priority;
this.Count = 1;
}
public Node(T value) : this(value, Rand.NextDouble()) {}
public T Get(int i) { return this.GetNode(i).Value; }
public Node GetNode(int i) {
var lcount = 0;
if (this.L != null)
lcount = this.L.Count;
if (lcount == i)
return this;
else if (lcount < i)
return this.R.GetNode(i - lcount - 1);
else
return this.L.GetNode(i);
}
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++)
yield return this.Root.Get(i);
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
public static class ObjectExtension {
// ディープコピーの複製を作る拡張メソッド
public static T DeepClone<T>(this T src) {
using (var memoryStream = new System.IO.MemoryStream()) {
var binaryFormatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src); // シリアライズ
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream); // デシリアライズ
}
}
}
}
|
[["-", 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]]
| 8
| 13,795
| 6
|
using System;
using System.IO;
class Solve {
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 answer = 0;
for (int i = 0; i <= A; i++) {
for (int j = 0; j <= B; j++) {
for (int k = 0; k <= C; k++) {
if (500 * A + 100 * B + 50 * C == X)
answer++;
}
}
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
class Solve {
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 answer = 0;
for (int i = 0; i <= A; i++) {
for (int j = 0; j <= B; j++) {
for (int k = 0; k <= C; k++) {
if (500 * i + 100 * j + 50 * k == X)
answer++;
}
}
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
[["-", 15, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 15, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 22]]
| 8
| 191
| 6
|
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;
int count = 0;
for (int ia = 0; ia <= A; ia++) {
for (int ib = 0; ib <= B; ib++) {
for (int ic = 0; ic <= C; ic++) {
if (500 * ia + 100 * ib + 10 * ic == X) {
count++;
}
}
}
}
WriteLine(count);
}
}
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;
int count = 0;
for (int ia = 0; ia <= A; ia++) {
for (int ib = 0; ib <= B; ib++) {
for (int ic = 0; ic <= C; ic++) {
if (500 * ia + 100 * ib + 50 * ic == X) {
count++;
}
}
}
}
WriteLine(count);
}
}
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, 57, 15, 16, 31, 16, 12, 16, 31, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 203]]
| 8
| 532
| 2
|
using System;
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 < A; i++) {
for (var j = 0; j < B; j++) {
for (var k = 0; k < C; k++) {
var total = i * 500 + j * 100 + k * 50;
if (total == X)
count++;
}
}
}
Console.WriteLine(count);
}
}
|
using System;
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 <= A; i++) {
for (var j = 0; j <= B; j++) {
for (var k = 0; k <= C; k++) {
var total = i * 500 + j * 100 + k * 50;
if (total == X)
count++;
}
}
}
Console.WriteLine(count);
}
}
|
[["-", 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]]
| 8
| 158
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class Abc_087_B {
public static void Main(string[] args) {
// 整数の入力
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 result = 0;
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
for (int k = 0; k < c; k++) {
int total = 500 * i + 100 * j + 50 * k; // 合計金額
if (total == x)
result++; // 合計金額が X に一致したら答えをインクリメント
}
}
}
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class Abc_087_B {
public static void Main(string[] args) {
// 整数の入力
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 result = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
int total = 500 * i + 100 * j + 50 * k; // 合計金額
if (total == x)
result++; // 合計金額が X に一致したら答えをインクリメント
}
}
}
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
[["-", 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]]
| 8
| 200
| 6
|
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 class Program {
public static void Main() {
var a = ScanInt();
var b = ScanInt();
var c = ScanInt();
var x = ScanInt();
var res = 0;
for (int i = 0; i <= a; i++)
for (int j = 0; j <= b; j++)
for (int k = 0; k <= c; k++)
if ((i * 500 - j * 100 - k * 50 == x))
res++;
WriteLine(res);
}
}
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 class Program {
public static void Main() {
var a = ScanInt();
var b = ScanInt();
var c = ScanInt();
var x = ScanInt();
var res = 0;
for (int i = 0; i <= a; i++)
for (int j = 0; j <= b; j++)
for (int k = 0; k <= c; k++)
if ((i * 500 + j * 100 + k * 50) == x)
res++;
WriteLine(res);
}
}
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;
}
}
}
|
[["-", 15, 23, 0, 16, 31, 16, 31, 16, 17, 33], ["+", 15, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["-", 8, 57, 15, 23, 0, 16, 31, 16, 17, 33], ["+", 8, 57, 15, 16, 31, 23, 0, 16, 17, 72], ["+", 8, 7, 8, 57, 15, 16, 31, 23, 0, 25], ["-", 8, 7, 8, 7, 8, 57, 15, 23, 0, 25]]
| 8
| 2,054
| 6
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
// 整数の入力
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long c = long.Parse(Console.ReadLine());
long x = long.Parse(Console.ReadLine());
int conbination = 0;
for (int i = 0; i < a; ++i) {
for (int j = 0; j < b; ++j) {
for (int k = 0; k < c; ++k) {
if (x == i * 500 + j * 100 + k * 50) {
++conbination;
}
}
}
}
Console.WriteLine(conbination.ToString());
Console.Out.Flush();
// Console.ReadLine();
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
// 整数の入力
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long c = long.Parse(Console.ReadLine());
long x = long.Parse(Console.ReadLine());
int conbination = 0;
for (int i = 0; i <= a; ++i) {
for (int j = 0; j <= b; ++j) {
for (int k = 0; k <= c; ++k) {
if (x == i * 500 + j * 100 + k * 50) {
++conbination;
}
}
}
}
Console.WriteLine(conbination.ToString());
Console.Out.Flush();
// Console.ReadLine();
}
}
}
|
[["-", 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]]
| 8
| 173
| 6
|
using System;
namespace atcoder {
class MainClass {
public static void Main(string[] args) {
// Console.WriteLine("Hello World!");
int howmany500 = Int32.Parse(Console.ReadLine());
int howmany100 = Int32.Parse(Console.ReadLine());
int howmany50 = Int32.Parse(Console.ReadLine());
int sum = Int32.Parse(Console.ReadLine());
int count = 0;
for (int i = 0; i < howmany500; i++) {
for (int j = 0; j < howmany100; j++) {
for (int k = 0; k < howmany50; k++) {
if (sum == (i * 500) + (j * 100) + (k * 50)) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace atcoder {
class MainClass {
public static void Main(string[] args) {
// Console.WriteLine("Hello World!");
int howmany500 = Int32.Parse(Console.ReadLine());
int howmany100 = Int32.Parse(Console.ReadLine());
int howmany50 = Int32.Parse(Console.ReadLine());
int sum = Int32.Parse(Console.ReadLine());
int count = 0;
for (int i = 0; i <= howmany500; i++) {
for (int j = 0; j <= howmany100; j++) {
for (int k = 0; k <= howmany50; k++) {
if (sum == (i * 500) + (j * 100) + (k * 50)) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 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]]
| 8
| 167
| 6
|
using System;
namespace ConsoleApp1 {
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 (int a = 1; a <= A; a++) {
for (int b = 1; b <= B; b++) {
for (int c = 1; c <= C; c++) {
if (500 * a + 100 * b + 50 * c == X) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace ConsoleApp1 {
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 (int a = 0; a <= A; a++) {
for (int b = 0; b <= B; b++) {
for (int c = 0; c <= C; c++) {
if (500 * a + 100 * b + 50 * c == X) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 159
| 6
|
using System;
using System.Collections.Generic;
namespace atcoder {
class Program {
static void Main(string[] args) {
int A = int.Parse(Console.ReadLine()); // 500
int B = int.Parse(Console.ReadLine()); // 100
int C = int.Parse(Console.ReadLine()); // 50
int X = int.Parse(Console.ReadLine()); // sum
int count = 0;
for (int i = 1; i <= A; i++) {
for (int j = 1; j <= B; j++) {
for (int k = 1; k <= C; k++) {
if (500 * i + 100 * j + 50 * k == X)
count++;
}
}
}
Console.WriteLine(count);
}
}
}
|
using System;
using System.Collections.Generic;
namespace atcoder {
class Program {
static void Main(string[] args) {
int A = int.Parse(Console.ReadLine()); // 500
int B = int.Parse(Console.ReadLine()); // 100
int C = int.Parse(Console.ReadLine()); // 50
int X = int.Parse(Console.ReadLine()); // sum
int count = 0;
for (int i = 0; i <= A; i++) {
for (int j = 0; j <= B; j++) {
for (int k = 0; k <= C; k++) {
if (500 * i + 100 * j + 50 * k == X)
count++;
}
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 168
| 6
|
using System;
namespace AtCoder_20190218 {
class Program {
static void Main(string[] args) {
string str_500 = Console.ReadLine();
string str_100 = Console.ReadLine();
string str_50 = Console.ReadLine();
string str_total = Console.ReadLine();
int Yen500 = int.Parse(str_500);
int Yen100 = int.Parse(str_100);
int Yen50 = int.Parse(str_50);
int total = int.Parse(str_total);
int count = 0;
for (int a = 0; a < Yen500; a++) {
for (int b = 0; b < Yen100; b++) {
for (int c = 0; c < Yen50; c++) {
if ((a * 500 + b * 100 + c * 50) == total) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace AtCoder_20190218 {
class Program {
static void Main(string[] args) {
string str_500 = Console.ReadLine();
string str_100 = Console.ReadLine();
string str_50 = Console.ReadLine();
string str_total = Console.ReadLine();
int Yen500 = int.Parse(str_500);
int Yen100 = int.Parse(str_100);
int Yen50 = int.Parse(str_50);
int total = int.Parse(str_total);
int count = 0;
for (int a = 0; a <= Yen500; a++) {
for (int b = 0; b <= Yen100; b++) {
for (int c = 0; c <= Yen50; c++) {
if ((a * 500 + b * 100 + c * 50) == total) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 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]]
| 8
| 181
| 6
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var fiveHund = int.Parse(Console.ReadLine());
var hund = int.Parse(Console.ReadLine());
var fifty = int.Parse(Console.ReadLine());
var result = int.Parse(Console.ReadLine());
var count = 0;
for (int i = 0; i < fiveHund; i++) {
var fh = 500 * i;
for (int j = 0; j < hund; j++) {
var h = 100 * j;
for (int k = 0; k < fifty; k++) {
var f = 50 * k;
if (fh + h + f == result) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var fiveHund = int.Parse(Console.ReadLine());
var hund = int.Parse(Console.ReadLine());
var fifty = int.Parse(Console.ReadLine());
var result = int.Parse(Console.ReadLine());
var count = 0;
for (int i = 0; i < fiveHund + 1; i++) {
var fh = 500 * i;
for (int j = 0; j < hund + 1; j++) {
var h = 100 * j;
for (int k = 0; k < fifty + 1; k++) {
var f = 50 * k;
if (fh + h + f == result) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 178
| 6
|
using System;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
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 count = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; i <= b; i++) {
for (int k = 0; i <= c; i++) {
if (x == 500 * i + 100 * j + 50 * k) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
using System;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
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 count = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
if (x == 500 * i + 100 * j + 50 * k) {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22]]
| 8
| 164
| 8
|
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
class P {
static void Main() {
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 res = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k < c; k++) {
if (i * 500 + j * 100 + k * 50 == x)
res++;
}
}
}
Console.WriteLine(res);
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
class P {
static void Main() {
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 res = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
if (i * 500 + j * 100 + k * 50 == x)
res++;
}
}
}
Console.WriteLine(res);
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 206
| 2
|
using System;
namespace Sample101 {
class Program {
static void Main(string[] args) {
int A500 = int.Parse(Console.ReadLine());
int B100 = int.Parse(Console.ReadLine());
int C50 = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int result = 0;
for (int a = 0; a <= A500; ++a) {
for (int b = 0; b <= B100; ++b) {
for (int c = 0; c <= C50; ++c) {
int total = 500 * a + 100 * b + 50 * c;
if (total == X) {
++result;
}
}
}
Console.WriteLine(result);
}
}
}
}
|
using System;
namespace Sample101 {
class Program {
static void Main(string[] args) {
int A500 = int.Parse(Console.ReadLine());
int B100 = int.Parse(Console.ReadLine());
int C50 = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int result = 0;
for (int a = 0; a <= A500; ++a) {
for (int b = 0; b <= B100; ++b) {
for (int c = 0; c <= C50; ++c) {
int total = 500 * a + 100 * b + 50 * c;
if (total == X) {
++result;
}
}
}
}
Console.WriteLine(result);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 164
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B_087 {
class Program {
static void Main(string[] args) {
int A = Convert.ToInt32(Console.ReadLine());
int B = Convert.ToInt32(Console.ReadLine());
int C = Convert.ToInt32(Console.ReadLine());
int X = Convert.ToInt32(Console.ReadLine());
int cnt = 0;
for (int E = 0; E <= A; ++E) {
for (int F = 0; F <= A; ++F) {
for (int G = 0; G <= A; ++G) {
int N = 500 * E + 100 * F + 50 * G;
if (N == X) {
cnt++;
} else {
}
}
}
}
Console.WriteLine(cnt);
Console.ReadLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B_087 {
class Program {
static void Main(string[] args) {
int A = Convert.ToInt32(Console.ReadLine());
int B = Convert.ToInt32(Console.ReadLine());
int C = Convert.ToInt32(Console.ReadLine());
int X = Convert.ToInt32(Console.ReadLine());
int cnt = 0;
for (int E = 0; E <= A; ++E) {
for (int F = 0; F <= B; ++F) {
for (int G = 0; G <= C; ++G) {
int N = 500 * E + 100 * F + 50 * G;
if (N == X) {
cnt++;
}
}
}
}
Console.WriteLine(cnt);
Console.ReadLine();
}
}
}
|
[["-", 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, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45]]
| 8
| 197
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive {
internal class Solution {
public int A, B, C, X;
public void Run() {
A = Input.ReadInt();
B = Input.ReadInt();
C = Input.ReadInt();
X = Input.ReadInt();
int ret = 0;
for (int a = 0; a <= A; a++)
for (int b = 0; b <= B; b++) {
int x = X - 500 * a - 100 * b;
if (x >= 0 && X % 50 == 0 && C >= X / 50)
ret++;
}
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();
}
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 A, B, C, X;
public void Run() {
A = Input.ReadInt();
B = Input.ReadInt();
C = Input.ReadInt();
X = Input.ReadInt();
int ret = 0;
for (int a = 0; a <= A; a++)
for (int b = 0; b <= B; b++) {
int x = X - 500 * a - 100 * b;
if (x >= 0 && x % 50 == 0 && C >= x / 50)
ret++;
}
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();
}
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();
}
}
}
|
[["-", 15, 16, 31, 16, 12, 16, 31, 16, 31, 22], ["+", 15, 16, 31, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 31, 22]]
| 8
| 296
| 4
|
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) {
int a = int.Parse(System.Console.ReadLine());
int b = int.Parse(System.Console.ReadLine());
int c = int.Parse(System.Console.ReadLine());
int x = int.Parse(System.Console.ReadLine());
int count = 0;
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
for (int k = 0; k < c; k++) {
if (500 * i + 100 * j + 50 * k == x)
count++;
}
}
}
System.Console.WriteLine(count);
}
}
}
|
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) {
int a = int.Parse(System.Console.ReadLine());
int b = int.Parse(System.Console.ReadLine());
int c = int.Parse(System.Console.ReadLine());
int x = int.Parse(System.Console.ReadLine());
int count = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
if (500 * i + 100 * j + 50 * k == x)
count++;
}
}
}
System.Console.WriteLine(count);
}
}
}
|
[["-", 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]]
| 8
| 191
| 6
|
using static System.Console;
class Program {
static void Main(string[] args) {
int a = int.Parse(ReadLine());
int b = int.Parse(ReadLine());
int c = int.Parse(ReadLine());
int x = int.Parse(ReadLine());
int count = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
if (a * i + b * j + c * k == x)
count++;
}
}
}
WriteLine(count);
}
}
|
using static System.Console;
class Program {
static void Main(string[] args) {
int a = int.Parse(ReadLine());
int b = int.Parse(ReadLine());
int c = int.Parse(ReadLine());
int x = int.Parse(ReadLine());
int count = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
if (500 * i + 100 * j + 50 * k == x)
count++;
}
}
}
WriteLine(count);
}
}
|
[["-", 15, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 31, 203], ["-", 15, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 31, 203], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 203]]
| 8
| 146
| 6
|
using System;
namespace abc087_b {
class Program {
static void Main(string[] args) {
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 ret = 0;
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
for (int k = 0; k < c; k++) {
if (i * 500 + j * 100 + k * 50 == x)
ret++;
}
}
}
Console.WriteLine(ret);
}
}
}
|
using System;
namespace abc087_b {
class Program {
static void Main(string[] args) {
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 ret = 0;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
for (int k = 0; k <= c; k++) {
if (i * 500 + j * 100 + k * 50 == x)
ret++;
}
}
}
Console.WriteLine(ret);
}
}
}
|
[["-", 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]]
| 8
| 157
| 6
|
using System;
using System.Linq;
public class Hello {
public static int[] dx = { 1, 0 };
public static int[] dy = { 0, 1 };
public static int max = 0;
public static void Main() {
int N = int.Parse(Console.ReadLine());
int[,] board = new int[2, N];
for (int i = 0; i < 2; i++) {
int[] line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
for (int j = 0; j < N; j++) {
board[i, j] = line[j];
}
}
dfs(board, 0, 0, ref N, board[0, 0]);
Console.WriteLine(max);
}
public static void dfs(int[,] board, int x, int y, ref int N, int sum) {
if (y == 1 && x == N - 1) {
max = Math.Max(sum, max);
// Console.WriteLine("max = " + max);
// sum = board[0, 0];
return;
}
for (int j = 0; j < 2; j++) {
int next_y = y + dy[j];
int next_x = x + dx[j];
if (next_y >= 2 || next_x >= N) {
continue;
} else {
// sumに次の移動先の値を加える
sum += board[next_y, next_x];
// Console.WriteLine("sum = " + sum);
dfs(board, next_x, next_y, ref N, sum);
sum -= board[y, x];
}
}
return;
}
}
|
using System;
using System.Linq;
public class Hello {
public static int[] dx = { 1, 0 };
public static int[] dy = { 0, 1 };
public static int max = 0;
public static void Main() {
int N = int.Parse(Console.ReadLine());
int[,] board = new int[2, N];
for (int i = 0; i < 2; i++) {
int[] line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
for (int j = 0; j < N; j++) {
board[i, j] = line[j];
}
}
dfs(board, 0, 0, ref N, board[0, 0]);
Console.WriteLine(max);
}
public static void dfs(int[,] board, int x, int y, ref int N, int sum) {
if (y == 1 && x == N - 1) {
max = Math.Max(sum, max);
// Console.WriteLine("max = " + max);
return;
}
for (int j = 0; j < 2; j++) {
int next_y = y + dy[j];
int next_x = x + dx[j];
if (next_y >= 2 || next_x >= N) {
continue;
} else {
// sumに次の移動先の値を加える
sum += board[next_y, next_x];
// Console.WriteLine("sum = " + sum);
dfs(board, next_x, next_y, ref N, sum);
sum -= board[next_y, next_x];
}
}
return;
}
}
|
[["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 330
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class ConsoleApp1 {
public static void Main(string[] args) {
Console.ReadLine();
var lists = Console.ReadLine()
.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
.ToList()
.OrderByDescending(x => int.Parse(x));
bool isAlice = true;
int alice;
int ken;
ken = alice = 0;
foreach (var item in lists) {
if (isAlice) {
alice += int.Parse(item);
} else
ken += int.Parse(item);
isAlice = !isAlice;
}
Console.WriteLine(alice);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class ConsoleApp1 {
public static void Main(string[] args) {
Console.ReadLine();
var lists = Console.ReadLine()
.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
.ToList()
.OrderByDescending(x => int.Parse(x));
bool isAlice = true;
int alice;
int ken;
ken = alice = 0;
foreach (var item in lists) {
if (isAlice) {
alice += int.Parse(item);
} else
ken += int.Parse(item);
isAlice = !isAlice;
}
Console.WriteLine(alice - ken);
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 148
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace C {
class Program {
static void Main(string[] args) {
var c = new List<List<int>>();
for (int i = 0; i < 3; i++) {
c.Add(Console.ReadLine().Split().Select(int.Parse).ToList());
}
foreach (var item in c)
item.AddRange(item);
var ansCheckList = new List<int>();
for (int i = 0; i < 3; i++) {
ansCheckList.Add(c[i][i] + c[i + 1][i + 1] + c[i + 2][i + 2]);
}
var ans = ansCheckList[0] == ansCheckList[1] &&
ansCheckList[1] == ansCheckList[2];
Console.WriteLine(ans ? "Yes" : "No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace C {
class Program {
static void Main(string[] args) {
var c = new List<List<int>>();
for (int i = 0; i < 3; i++) {
c.Add(Console.ReadLine().Split().Select(int.Parse).ToList());
}
foreach (var item in c)
item.AddRange(item);
var ansCheckList = new List<int>();
for (int i = 0; i < 3; i++) {
ansCheckList.Add(c[0][i] + c[1][i + 1] + c[2][i + 2]);
}
var ans = ansCheckList[0] == ansCheckList[1] &&
ansCheckList[1] == ansCheckList[2];
Console.WriteLine(ans ? "Yes" : "No");
}
}
}
|
[["-", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 203], ["-", 205, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 205, 204, 206, 207, 0, 28, 0, 16, 17, 72]]
| 8
| 206
| 6
|
using System;
namespace atCoder {
class Program {
static void Main() {
string[] c1 = Console.ReadLine().Split(' ');
string[] c2 = Console.ReadLine().Split(' ');
string[] c3 = Console.ReadLine().Split(' ');
int[,] c = new int[3, 3];
for (int i = 0; i < 3; i++) {
c[0, i] = int.Parse(c1[i]);
c[1, i] = int.Parse(c2[i]);
c[2, i] = int.Parse(c3[i]);
}
for (int a1 = 0; a1 <= 100; a1++) {
int b1 = c[0, 0] - a1;
int b2 = c[0, 1] - a1;
int b3 = c[0, 2] - a1;
int a2 = c[1, 0] - b1;
int a3 = c[2, 0] - b1;
if (c[1, 1] == a2 + b2 && c[1, 2] == a2 + b3 && c[2, 1] == a3 + b2 &&
c[2, 2] == a3 + b3) {
Console.WriteLine("YES");
return;
}
}
Console.WriteLine("No");
}
}
}
|
using System;
namespace atCoder {
class Program {
static void Main() {
string[] c1 = Console.ReadLine().Split(' ');
string[] c2 = Console.ReadLine().Split(' ');
string[] c3 = Console.ReadLine().Split(' ');
int[,] c = new int[3, 3];
for (int i = 0; i < 3; i++) {
c[0, i] = int.Parse(c1[i]);
c[1, i] = int.Parse(c2[i]);
c[2, i] = int.Parse(c3[i]);
}
for (int a1 = 0; a1 <= 100; a1++) {
int b1 = c[0, 0] - a1;
int b2 = c[0, 1] - a1;
int b3 = c[0, 2] - a1;
int a2 = c[1, 0] - b1;
int a3 = c[2, 0] - b1;
if (c[1, 1] == a2 + b2 && c[1, 2] == a2 + b3 && c[2, 1] == a3 + b2 &&
c[2, 2] == a3 + b3) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 297
| 2
|
using System;
namespace ConsoleApp5 {
class Program {
static void Main(string[] args) {
bool Ans = true;
string[] Inp1 = Console.ReadLine().Split(' ');
int A11 = int.Parse(Inp1[0]);
int A12 = int.Parse(Inp1[1]);
int A13 = int.Parse(Inp1[2]);
string[] Inp2 = Console.ReadLine().Split(' ');
int A21 = int.Parse(Inp2[0]);
int A22 = int.Parse(Inp2[1]);
int A23 = int.Parse(Inp2[2]);
string[] Inp3 = Console.ReadLine().Split(' ');
int A31 = int.Parse(Inp3[0]);
int A32 = int.Parse(Inp3[1]);
int A33 = int.Parse(Inp3[2]);
if (A11 - A12 == A21 - A22 && A21 - A22 == A31 - A32 &&
A12 - A13 == A22 - A23 && A22 - A23 == A32 - A33 &&
A11 - A21 == A12 - A22 && A12 - A22 == A13 - A23 &&
A21 - A31 == A22 - A31 && A22 - A32 == A23 - A33) {
Ans = true;
} else {
Ans = false;
}
if (Ans == true) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
// Console.WriteLine("Hello World!");
}
}
}
|
using System;
namespace ConsoleApp5 {
class Program {
static void Main(string[] args) {
bool Ans = true;
string[] Inp1 = Console.ReadLine().Split(' ');
int A11 = int.Parse(Inp1[0]);
int A12 = int.Parse(Inp1[1]);
int A13 = int.Parse(Inp1[2]);
string[] Inp2 = Console.ReadLine().Split(' ');
int A21 = int.Parse(Inp2[0]);
int A22 = int.Parse(Inp2[1]);
int A23 = int.Parse(Inp2[2]);
string[] Inp3 = Console.ReadLine().Split(' ');
int A31 = int.Parse(Inp3[0]);
int A32 = int.Parse(Inp3[1]);
int A33 = int.Parse(Inp3[2]);
if (A11 - A12 == A21 - A22 && A21 - A22 == A31 - A32 &&
A12 - A13 == A22 - A23 && A22 - A23 == A32 - A33) {
if (A11 - A21 == A12 - A22 && A12 - A22 == A13 - A23 &&
A21 - A31 == A22 - A31 && A22 - A32 == A23 - A33) {
Ans = true;
}
} else {
Ans = false;
}
if (Ans == true) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
// Console.WriteLine("Hello World!");
}
}
}
|
[["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 98], ["+", 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, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 307
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC088_C {
class Program {
static void Main(string[] args) {
int[] a = new int[3];
int[] b = new int[3];
int[][] c = new int [3][];
bool p = true;
bool ans = false;
for (int i = 0; i < 3; i++) {
c[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
}
for (int i = 0; i <= 100; i++) {
a[0] = i;
for (int j = 0; j <= 100; j++) {
a[1] = j;
for (int k = 0; k <= 100; k++) {
a[2] = k;
b = new int[3] { c[0][0] - a[0], c[0][1] - a[0], c[0][2] - a[0] };
for (int l = 0; l < 3; l++) {
for (int m = 0; m < 3; m++) {
if (c[l][m] != a[l] + b[m]) {
p = false;
}
}
}
ans |= p;
}
}
}
Console.WriteLine(ans ? "Yes" : "No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC088_C {
class Program {
static void Main(string[] args) {
int[] a = new int[3];
int[] b = new int[3];
int[][] c = new int [3][];
bool p = true;
bool ans = false;
for (int i = 0; i < 3; i++) {
c[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
}
for (int i = 0; i <= 100; i++) {
a[0] = i;
for (int j = 0; j <= 100; j++) {
a[1] = j;
for (int k = 0; k <= 100; k++) {
a[2] = k;
b = new int[3] { c[0][0] - a[0], c[0][1] - a[0], c[0][2] - a[0] };
p = true;
for (int l = 0; l < 3; l++) {
for (int m = 0; m < 3; m++) {
if (c[l][m] != a[l] + b[m]) {
p = false;
}
}
}
ans |= p;
}
}
}
Console.WriteLine(ans ? "Yes" : "No");
}
}
}
|
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 329
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class D {
struct P {
public int i, j;
public P(int _i, int _j) {
i = _i;
j = _j;
}
public bool IsInRange => 0 <= i && i < h && 0 <= j && j < w;
public P[] Nexts() => new[] { new P(i, j - 1), new P(i, j + 1),
new P(i - 1, j), new P(i + 1, j) };
}
static int h, w;
static string[] c;
static void Main() {
Func<int[]> read = () =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
var z = read();
h = z[0];
w = z[1];
c = new int [h].Select(_ => Console.ReadLine()).ToArray();
var sp = new P();
var gp = new P(h - 1, w - 1);
var r = Search(sp, gp);
Console.WriteLine(
r == 0 ? -1 : h * w - r - 1 - c.Sum(s => s.Count(x => x == '#')));
}
static int Search(P sp, P gp) {
var u = new int[h, w];
var q = new Queue<P>();
u[sp.i, sp.j] = 1;
q.Enqueue(sp);
while (q.Any()) {
var p = q.Dequeue();
foreach (var x in p.Nexts()) {
if (!x.IsInRange || u[x.i, x.j] > 0 || c[x.i][x.j] == '#')
continue;
u[x.i, x.j] = u[p.i, p.j] + 1;
q.Enqueue(x);
}
}
return u[gp.i, gp.j] - 1;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class D {
struct P {
public int i, j;
public P(int _i, int _j) {
i = _i;
j = _j;
}
public bool IsInRange => 0 <= i && i < h && 0 <= j && j < w;
public P[] Nexts() => new[] { new P(i, j - 1), new P(i, j + 1),
new P(i - 1, j), new P(i + 1, j) };
}
static int h, w;
static string[] c;
static void Main() {
Func<int[]> read = () =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
var z = read();
h = z[0];
w = z[1];
c = new int [h].Select(_ => Console.ReadLine()).ToArray();
var sp = new P();
var gp = new P(h - 1, w - 1);
var r = Search(sp, gp);
Console.WriteLine(
r == -1 ? -1 : h * w - r - 1 - c.Sum(s => s.Count(x => x == '#')));
}
static int Search(P sp, P gp) {
var u = new int[h, w];
var q = new Queue<P>();
u[sp.i, sp.j] = 1;
q.Enqueue(sp);
while (q.Any()) {
var p = q.Dequeue();
foreach (var x in p.Nexts()) {
if (!x.IsInRange || u[x.i, x.j] > 0 || c[x.i][x.j] == '#')
continue;
u[x.i, x.j] = u[p.i, p.j] + 1;
q.Enqueue(x);
}
}
return u[gp.i, gp.j] - 1;
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 28, 0, 41, 15, 16, 12, 241, 0, 33], ["+", 0, 28, 0, 41, 15, 16, 12, 241, 0, 203]]
| 8
| 458
| 3
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;
namespace AtCoderTemplate {
class Program {
static int H, W, i, j;
static char[,] maze;
static bool[,] reached;
static Queue<Tuple<int, int, int>> queue;
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
H = int.Parse(str[0]);
W = int.Parse(str[1]);
maze = new char[H, W];
reached = new bool[H, W];
int white = 0;
//迷路を読み込む
for (i = 0; i < H; i++) {
string str2 = Console.ReadLine();
for (j = 0; j < W; j++) {
maze[i, j] = str2[j];
//白マスの数
if (maze[i, j] == '.')
white++;
}
}
//幅優先探索で最短手数を求める
queue = new Queue<Tuple<int, int, int>>();
queue.Enqueue(Tuple.Create(0, 0, 0));
reached[0, 0] = true;
int mins = 0;
while (queue.Count > 0) {
Tuple<int, int, int> tuple = queue.Dequeue();
if (tuple.Item1 == H - 1 && tuple.Item2 == W - 1) {
mins = tuple.Item3;
break;
}
Search(tuple.Item1, tuple.Item2, tuple.Item3);
}
//最大得点=元の白マス-最短手数
if (reached[H - 1, W - 1] == false)
Console.WriteLine(-1);
Console.WriteLine(white - mins - 1);
return;
}
//幅優先探索
static void Search(int x, int y, int s) {
int[] vx = { 1, 0, -1, 0 };
int[] vy = { 0, 1, 0, -1 };
for (i = 0; i < 4; i++) {
int nx = x + vx[i];
int ny = y + vy[i];
if (nx < 0 || H <= nx || ny < 0 || W <= ny || maze[nx, ny] == '#')
continue;
if (reached[nx, ny])
continue;
reached[nx, ny] = true;
queue.Enqueue(Tuple.Create(nx, ny, s + 1));
}
}
}
class MyLibrary {
// 自作の関数
public static int MyFunction(int n) { return 0; }
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;
namespace AtCoderTemplate {
class Program {
static int H, W, i, j;
static char[,] maze;
static bool[,] reached;
static Queue<Tuple<int, int, int>> queue;
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
H = int.Parse(str[0]);
W = int.Parse(str[1]);
maze = new char[H, W];
reached = new bool[H, W];
int white = 0;
//迷路を読み込む
for (i = 0; i < H; i++) {
string str2 = Console.ReadLine();
for (j = 0; j < W; j++) {
maze[i, j] = str2[j];
//白マスの数
if (maze[i, j] == '.')
white++;
}
}
//幅優先探索で最短手数を求める
queue = new Queue<Tuple<int, int, int>>();
queue.Enqueue(Tuple.Create(0, 0, 0));
reached[0, 0] = true;
int mins = 0;
while (queue.Count > 0) {
Tuple<int, int, int> tuple = queue.Dequeue();
if (tuple.Item1 == H - 1 && tuple.Item2 == W - 1) {
mins = tuple.Item3;
break;
}
Search(tuple.Item1, tuple.Item2, tuple.Item3);
}
//最大得点=元の白マス-最短手数
if (reached[H - 1, W - 1] == false) {
Console.WriteLine(-1);
return;
}
Console.WriteLine(white - mins - 1);
return;
}
//幅優先探索
static void Search(int x, int y, int s) {
int[] vx = { 1, 0, -1, 0 };
int[] vy = { 0, 1, 0, -1 };
for (i = 0; i < 4; i++) {
int nx = x + vx[i];
int ny = y + vy[i];
if (nx < 0 || H <= nx || ny < 0 || W <= ny || maze[nx, ny] == '#')
continue;
if (reached[nx, ny])
continue;
reached[nx, ny] = true;
queue.Enqueue(Tuple.Create(nx, ny, s + 1));
}
}
}
class MyLibrary {
// 自作の関数
public static int MyFunction(int n) { return 0; }
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 560
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp11 {
class Class18 {
static void Main() {
var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
long x = I[0];
long y = I[1];
long ans = -1;
if (x % y != 0) {
for (int i = 1; i < 1000000000; i++) {
if (i * x % y != 0)
ans = i * x;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp11 {
class Class18 {
static void Main() {
var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
long x = I[0];
long y = I[1];
long ans = -1;
if (x % y != 0) {
for (int i = 1; i < 1000000000; i++) {
if (i * x % y != 0) {
ans = i * x;
break;
}
}
}
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 137
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var XY = ReadSplitInt();
var lcm = Lcm(XY[0], XY[1]);
if (XY[0] * 2 >= lcm)
Println(-1);
else
Println(XY[0] * 2);
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static void YESOrNO(bool e) => Println(e ? "YES" : "NO");
static void YesOrNo(bool e) => Println(e ? "Yes" : "No");
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
static int LowerBound<T>(T[] arr, int start, int end, T value,
IComparer<T> comparer) {
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;
}
static int LowerBound<T>(T[] arr, T value)
where T : IComparable => LowerBound(arr,
0,
arr.Length,
value,
Comparer<T>.Default); }
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var XY = ReadSplitLong();
var lcm = Lcm(XY[0], XY[1]);
if (XY[0] >= lcm)
Println(-1);
else
Println(XY[0]);
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static void YESOrNO(bool e) => Println(e ? "YES" : "NO");
static void YesOrNo(bool e) => Println(e ? "Yes" : "No");
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
static int LowerBound<T>(T[] arr, int start, int end, T value,
IComparer<T> comparer) {
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;
}
static int LowerBound<T>(T[] arr, T value)
where T : IComparable => LowerBound(arr,
0,
arr.Length,
value,
Comparer<T>.Default); }
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 858
| 6
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
public class A {
public static void Main() {
long x = GetLong();
long y = GetLong();
Console.WriteLine((x != y) ? x : -1);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
public class A {
public static void Main() {
long x = GetLong();
long y = GetLong();
Console.WriteLine((x % y != 0) ? x : -1);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
[["-", 0, 28, 0, 41, 15, 23, 0, 16, 17, 79], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 17, 109], ["+", 0, 28, 0, 41, 15, 23, 0, 16, 17, 79], ["+", 0, 28, 0, 41, 15, 23, 0, 16, 12, 203]]
| 8
| 218
| 4
|
using System;
using System.Linq;
class Program {
static void Main() {
var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x = arr[0];
int y = arr[1];
Console.WriteLine(y % x == 0 ? -1 : x);
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x = arr[0];
int y = arr[1];
Console.WriteLine(x % y == 0 ? -1 : x);
}
}
|
[["-", 0, 28, 0, 41, 15, 16, 31, 16, 31, 22], ["-", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 12, 22]]
| 8
| 75
| 4
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
ReadData re;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
re = new ReadData();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int X = re.i();
int Y = re.i();
if (X % Y == 0) {
sb.Append(X + "\n");
} else {
sb.Append("-1\n");
}
}
}
class ReadData {
string[] str;
int counter;
public ReadData() { counter = 0; }
public string s() {
if (counter == 0) {
str = Console.ReadLine().Split(' ');
counter = str.Length;
}
counter--;
return str[str.Length - counter - 1];
}
public int i() { return int.Parse(s()); }
public long l() { return long.Parse(s()); }
public double d() { return double.Parse(s()); }
public int[] ia(int N) {
int[] ans = new int[N];
for (int j = 0; j < N; j++) {
ans[j] = i();
}
return ans;
}
public int[] ia() {
str = Console.ReadLine().Split(' ');
counter = 0;
int[] ans = new int[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = int.Parse(str[j]);
}
return ans;
}
public long[] la(int N) {
long[] ans = new long[N];
for (int j = 0; j < N; j++) {
ans[j] = l();
}
return ans;
}
public long[] la() {
str = Console.ReadLine().Split(' ');
counter = 0;
long[] ans = new long[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = long.Parse(str[j]);
}
return ans;
}
public double[] da(int N) {
double[] ans = new double[N];
for (int j = 0; j < N; j++) {
ans[j] = d();
}
return ans;
}
public double[] da() {
str = Console.ReadLine().Split(' ');
counter = 0;
double[] ans = new double[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = double.Parse(str[j]);
}
return ans;
}
public List<int>[] g(int N, int[] f, int[] t) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < f.Length; j++) {
ans[f[j]].Add(t[j]);
ans[t[j]].Add(f[j]);
}
return ans;
}
public List<int>[] g(int N, int M) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
public List<int>[] g() {
int N = i();
int M = i();
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
}
public static class Define { public const long mod = 1000000007; }
public static class Debug {
public static void Print(double[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(double[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(double[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(long[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(long[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(long[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(int[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(int[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(int[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
ReadData re;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
re = new ReadData();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int X = re.i();
int Y = re.i();
if (X % Y != 0) {
sb.Append(X + "\n");
} else {
sb.Append("-1\n");
}
}
}
class ReadData {
string[] str;
int counter;
public ReadData() { counter = 0; }
public string s() {
if (counter == 0) {
str = Console.ReadLine().Split(' ');
counter = str.Length;
}
counter--;
return str[str.Length - counter - 1];
}
public int i() { return int.Parse(s()); }
public long l() { return long.Parse(s()); }
public double d() { return double.Parse(s()); }
public int[] ia(int N) {
int[] ans = new int[N];
for (int j = 0; j < N; j++) {
ans[j] = i();
}
return ans;
}
public int[] ia() {
str = Console.ReadLine().Split(' ');
counter = 0;
int[] ans = new int[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = int.Parse(str[j]);
}
return ans;
}
public long[] la(int N) {
long[] ans = new long[N];
for (int j = 0; j < N; j++) {
ans[j] = l();
}
return ans;
}
public long[] la() {
str = Console.ReadLine().Split(' ');
counter = 0;
long[] ans = new long[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = long.Parse(str[j]);
}
return ans;
}
public double[] da(int N) {
double[] ans = new double[N];
for (int j = 0; j < N; j++) {
ans[j] = d();
}
return ans;
}
public double[] da() {
str = Console.ReadLine().Split(' ');
counter = 0;
double[] ans = new double[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = double.Parse(str[j]);
}
return ans;
}
public List<int>[] g(int N, int[] f, int[] t) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < f.Length; j++) {
ans[f[j]].Add(t[j]);
ans[t[j]].Add(f[j]);
}
return ans;
}
public List<int>[] g(int N, int M) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
public List<int>[] g() {
int N = i();
int M = i();
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
}
public static class Define { public const long mod = 1000000007; }
public static class Debug {
public static void Print(double[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(double[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(double[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(long[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(long[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(long[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(int[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(int[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(int[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79]]
| 8
| 1,717
| 2
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static int N;
static long mod = 1000000007;
static char[] az =
Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var B = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
// var N = long.Parse(Console.ReadLine());
// var A = new int[N];
var C = new long[N];
long sum = 0L;
for (int i = 0; i < N; i++) {
C[i] = A[i] - B[i];
if (C[i] < 0) {
var tmp = Abs(C[i]);
sum = (tmp + 1) / 2;
C[i] = tmp % 2 == 0 ? 0 : 1;
}
}
if (sum >= C.Sum()) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
// R = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
// var S = Console.ReadLine();
}
// ユークリッドの互除法
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;
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static int N;
static long mod = 1000000007;
static char[] az =
Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var B = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
// var N = long.Parse(Console.ReadLine());
// var A = new int[N];
var C = new long[N];
long sum = 0L;
for (int i = 0; i < N; i++) {
C[i] = A[i] - B[i];
if (C[i] < 0) {
var tmp = Abs(C[i]);
sum += (tmp + 1) / 2;
C[i] = ((tmp % 2 == 0) ? 0 : 1);
}
}
if (sum >= C.Sum()) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
// R = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
// var S = Console.ReadLine();
}
// ユークリッドの互除法
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;
}
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 0, 11, 12, 23, 0, 41, 15, 23, 0, 24], ["+", 0, 11, 12, 23, 0, 41, 15, 23, 0, 25], ["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 25]]
| 8
| 367
| 6
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var n = int.Parse(input.ReadLine());
var aa = ToIntArray(input.ReadLine(), n);
var bb = ToIntArray(input.ReadLine(), n);
long overb = 0;
long overa = 0;
for (int i = 0; i < n; i++) {
if (aa[i] > bb[i]) {
overa += aa[i] - bb[i];
} else if (aa[i] < bb[i]) {
overb += (bb[i] - aa[i]) / 2;
}
}
if (overa >= overb)
return No;
return Yes;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var n = int.Parse(input.ReadLine());
var aa = ToIntArray(input.ReadLine(), n);
var bb = ToIntArray(input.ReadLine(), n);
long overb = 0;
long overa = 0;
for (int i = 0; i < n; i++) {
if (aa[i] > bb[i]) {
overa += aa[i] - bb[i];
} else if (aa[i] < bb[i]) {
overb += (bb[i] - aa[i]) / 2;
}
}
if (overa > overb)
return No;
return Yes;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47]]
| 8
| 344
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var sol = new Solve();
sol.Exec();
}
}
class Solve {
public void Exec() {
var N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
var b = Console.ReadLine().Split().Select(long.Parse).ToArray();
var sumA = a.Sum();
var sumB = b.Sum();
var diff = 0L;
for (var i = 0; i < N; i++) {
var t = b[i] - a[i];
if (t <= 0)
diff -= t;
else {
if (diff % 2 == 1) {
t++;
diff++;
}
diff -= (t / 2);
}
}
Console.WriteLine(diff <= 0 ? "Yes" : "No");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var sol = new Solve();
sol.Exec();
}
}
class Solve {
public void Exec() {
var N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
var b = Console.ReadLine().Split().Select(long.Parse).ToArray();
var sumA = a.Sum();
var sumB = b.Sum();
var diff = 0L;
for (var i = 0; i < N; i++) {
var t = b[i] - a[i];
if (t <= 0)
diff -= t;
else {
if (t % 2 == 1) {
t++;
diff++;
}
diff -= (t / 2);
}
}
Console.WriteLine(diff <= 0 ? "Yes" : "No");
}
}
|
[["-", 75, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 31, 22]]
| 8
| 223
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace AtCoder {
class Program {
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);
}
private static bool Solve(int N, int[] a, int[] b) {
long c1 = 0;
long c2 = 0;
for (int i = 0; i < N; ++i) {
if (a[i] < b[i]) {
c1 += (b[i] - a[i]) / 2;
c2 += (b[i] - a[i]) % 2;
} else {
c2 += (a[i] - b[i]);
}
}
return c1 >= c2;
}
static void Main(string[] args) {
int N = ReadInt();
int[] a = ReadInts();
int[] b = ReadInts();
Console.WriteLine(Solve(N, a, b) ? "Yes" : "No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace AtCoder {
class Program {
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);
}
private static bool Solve(int N, int[] a, int[] b) {
long c1 = 0;
long c2 = 0;
for (int i = 0; i < N; ++i) {
if (a[i] < b[i]) {
c1 += (b[i] - a[i] + 1) / 2;
c2 += (b[i] - a[i]) % 2;
} else {
c2 += (a[i] - b[i]);
}
}
return c1 >= c2;
}
static void Main(string[] args) {
int N = ReadInt();
int[] a = ReadInts();
int[] b = ReadInts();
Console.WriteLine(Solve(N, a, b) ? "Yes" : "No");
}
}
}
|
[["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 203]]
| 8
| 363
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
int N, M;
sc.Make(out N, out M);
var A = sc.ArrInt;
var uf = new UnionFind(N);
for (int i = 0; i < M; i++) {
int x, y;
sc.Make(out x, out y);
uf.Union(x, y);
}
if (uf.GroupCount == 1)
Fail(0);
if (uf.GroupCount * 2 > N)
Fail("Impossible");
var res = 0L;
var l = new List<int>();
var s = Create(N, () => new List<int>());
for (int i = 0; i < N; i++) {
s[uf[i]].Add(A[i]);
}
for (int i = 0; i < N; i++) {
if (s[i].Count == 0)
continue;
s[i].Sort();
res += s[i][0];
l.AddRange(s[i].Skip(1));
}
l.Sort();
WriteLine(res + l.Take(uf.GroupCount - 2).Aggregate(0L, (a, b) => a + b));
}
}
public class UnionFind {
public int GroupCount { get; private set; }
protected int[] data;
public virtual int this[int i] => Find(i);
public UnionFind(int size) {
data = Create(size, () => -1);
GroupCount = size;
}
protected int Find(int i) => data[i] < 0 ? i : (data[i] = Find(data[i]));
public int Size(int i) => -data[Find(i)];
public virtual bool Union(int u, int v) {
u = Find(u);
v = Find(v);
if (u == v)
return false;
if (data[u] > data[v])
swap(ref u, ref v);
GroupCount--;
data[u] += data[v];
data[v] = u;
return true;
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
int N, M;
sc.Make(out N, out M);
var A = sc.ArrInt;
var uf = new UnionFind(N);
for (int i = 0; i < M; i++) {
int x, y;
sc.Make(out x, out y);
uf.Union(x, y);
}
if (uf.GroupCount == 1)
Fail(0);
if ((uf.GroupCount - 1) * 2 > N)
Fail("Impossible");
var res = 0L;
var l = new List<int>();
var s = Create(N, () => new List<int>());
for (int i = 0; i < N; i++) {
s[uf[i]].Add(A[i]);
}
for (int i = 0; i < N; i++) {
if (s[i].Count == 0)
continue;
s[i].Sort();
res += s[i][0];
l.AddRange(s[i].Skip(1));
}
l.Sort();
WriteLine(res + l.Take(uf.GroupCount - 2).Aggregate(0L, (a, b) => a + b));
}
}
public class UnionFind {
public int GroupCount { get; private set; }
protected int[] data;
public virtual int this[int i] => Find(i);
public UnionFind(int size) {
data = Create(size, () => -1);
GroupCount = size;
}
protected int Find(int i) => data[i] < 0 ? i : (data[i] = Find(data[i]));
public int Size(int i) => -data[Find(i)];
public virtual bool Union(int u, int v) {
u = Find(u);
v = Find(v);
if (u == v)
return false;
if (data[u] > data[v])
swap(ref u, ref v);
GroupCount--;
data[u] += data[v];
data[v] = u;
return true;
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
[["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 2,012
| 4
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ここから
static long[] pare;
static long[] dist;
static void Solve() {
int N;
int M;
Multi(out N, out M);
var A = Enumerable.Repeat(0, N)
.Select(s => new List<Tuple<int, int>>())
.ToArray();
for (int i = 0; i < M; i++) {
int L;
int R;
int D;
Multi(out L, out R, out D);
A[L - 1].Add(new Tuple<int, int>(R - 1, D));
A[R - 1].Add(new Tuple<int, int>(L - 1, -1 * D));
}
var pare = Enumerable.Repeat(-1, N).ToArray();
var dist = Enumerable.Repeat(0, N).ToArray();
for (int i = 0; i < N; i++) {
if (pare[i] != -1)
continue;
var queue = new Queue<int>();
queue.Enqueue(i);
while (queue.Count > 0) {
var now = queue.Dequeue();
foreach (var next in A[now]) {
if (pare[next.Item1] == -1) {
pare[next.Item1] = i;
dist[next.Item1] = next.Item2 + dist[now];
queue.Enqueue(next.Item2);
} else {
if (dist[next.Item1] != next.Item2 + dist[now]) {
Console.WriteLine("No");
return;
}
}
}
}
}
Console.WriteLine("Yes");
}
}
//拡張メソッド
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
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]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
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]);
}
static 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 = GetStrArray();
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]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ここから
static long[] pare;
static long[] dist;
static void Solve() {
int N;
int M;
Multi(out N, out M);
var A = Enumerable.Repeat(0, N)
.Select(s => new List<Tuple<int, int>>())
.ToArray();
for (int i = 0; i < M; i++) {
int L;
int R;
int D;
Multi(out L, out R, out D);
A[L - 1].Add(new Tuple<int, int>(R - 1, D));
A[R - 1].Add(new Tuple<int, int>(L - 1, -1 * D));
}
var pare = Enumerable.Repeat(-1, N).ToArray();
var dist = Enumerable.Repeat(0, N).ToArray();
for (int i = 0; i < N; i++) {
if (pare[i] != -1)
continue;
var queue = new Queue<int>();
queue.Enqueue(i);
while (queue.Count > 0) {
var now = queue.Dequeue();
foreach (var next in A[now]) {
if (pare[next.Item1] == -1) {
pare[next.Item1] = i;
dist[next.Item1] = next.Item2 + dist[now];
queue.Enqueue(next.Item1);
} else {
if (dist[next.Item1] != next.Item2 + dist[now]) {
Console.WriteLine("No");
return;
}
}
}
}
}
Console.WriteLine("Yes");
}
}
//拡張メソッド
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
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]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
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]);
}
static 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 = GetStrArray();
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]);
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22]]
| 8
| 1,837
| 2
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
namespace Equeue {
class Equeue {
static Node[] Nodes;
static void Main(string[] args) {
var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var N = NM[0];
var M = NM[1];
Nodes = new Node[N + 1];
for (int i = 1; i <= N; i++) {
Nodes[i] = new Node();
}
var cand = new long[N + 1];
for (int i = 0; i < M; i++) {
var LRD =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var L = LRD[0];
var R = LRD[1];
var D = LRD[2];
cand[L] = 1;
cand[R] = 1;
Nodes[L].adj.Add(R, -D);
Nodes[R].adj.Add(L, D);
}
var ans = true;
for (int i = 1; i <= N; i++) {
if (cand[i] == 1 && Nodes[i].loc == -1) {
ans = WFS(i);
}
if (!ans) {
break;
}
}
Console.WriteLine(ans ? "Yes" : "No");
}
static bool WFS(long st) {
var q = new Queue<Node>();
var tmp = Nodes[st];
tmp.loc = 100;
q.Enqueue(tmp);
long max = tmp.loc;
long min = tmp.loc;
while (q.Count > 0) {
tmp = q.Dequeue();
foreach (KeyValuePair<long, long> item in tmp.adj) {
var child = Nodes[item.Key];
// Console.WriteLine(item.Key+" "+child.loc+" "+item.Value);
if (child.loc != -1 && (child.loc != (item.Value + tmp.loc))) {
return false;
} else if (child.loc == long.MinValue) {
child.loc = item.Value + tmp.loc;
max = Math.Max(max, child.loc);
min = Math.Min(min, child.loc);
q.Enqueue(Nodes[item.Key]);
// Console.WriteLine(item.Key+" "+child.loc+" "+item.Value);
}
}
}
if (max - min <= 1000000000) {
return true;
} else {
return false;
}
}
}
public class Node {
public long loc = long.MinValue;
public Dictionary<long, long> adj = new Dictionary<long, long>();
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
namespace Equeue {
class Equeue {
static Node[] Nodes;
static void Main(string[] args) {
var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var N = NM[0];
var M = NM[1];
Nodes = new Node[N + 1];
for (int i = 1; i <= N; i++) {
Nodes[i] = new Node();
}
var cand = new long[N + 1];
for (int i = 0; i < M; i++) {
var LRD =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var L = LRD[0];
var R = LRD[1];
var D = LRD[2];
cand[L] = 1;
cand[R] = 1;
Nodes[L].adj.Add(R, -D);
Nodes[R].adj.Add(L, D);
}
var ans = true;
for (int i = 1; i <= N; i++) {
if (cand[i] == 1 && Nodes[i].loc == long.MinValue) {
ans = WFS(i);
}
if (!ans) {
break;
}
}
// Console.WriteLine(Nodes[1].loc+" "+Nodes[2].loc+" "+Nodes[3].loc);
Console.WriteLine(ans ? "Yes" : "No");
}
static bool WFS(long st) {
var q = new Queue<Node>();
var tmp = Nodes[st];
tmp.loc = 100;
q.Enqueue(tmp);
long max = tmp.loc;
long min = tmp.loc;
while (q.Count > 0) {
tmp = q.Dequeue();
foreach (KeyValuePair<long, long> item in tmp.adj) {
var child = Nodes[item.Key];
// Console.WriteLine(item.Key+" "+child.loc+" "+item.Value);
if (child.loc != long.MinValue &&
(child.loc != (item.Value + tmp.loc))) {
return false;
} else if (child.loc == long.MinValue) {
child.loc = item.Value + tmp.loc;
max = Math.Max(max, child.loc);
min = Math.Min(min, child.loc);
q.Enqueue(Nodes[item.Key]);
// Console.WriteLine(item.Key+" "+child.loc+" "+item.Value);
}
}
}
if (max - min <= 1000000000) {
return true;
} else {
return false;
}
}
}
public class Node {
public long loc = long.MinValue;
public Dictionary<long, long> adj = new Dictionary<long, long>();
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
|
[["-", 0, 57, 15, 16, 12, 16, 12, 241, 0, 33], ["-", 0, 57, 15, 16, 12, 16, 12, 241, 0, 203], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 205, 199], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 141, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 241, 0, 33], ["-", 0, 57, 15, 16, 31, 16, 12, 241, 0, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 205, 199], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 141, 22]]
| 8
| 1,025
| 10
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
long n = long.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
long[] numsUnder =
Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
long answer = 0;
long sumMemo = 0;
for (long i = 0; i < n; i++) {
sumMemo = 0;
for (long j = 0; j <= i; j++)
sumMemo += nums[j];
for (long j = i; j < n; j++)
sumMemo += nums[j];
answer = Math.Max(answer, sumMemo);
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
long n = long.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
long[] numsUnder =
Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
long answer = 0;
long sumMemo = 0;
for (long i = 0; i < n; i++) {
sumMemo = 0;
for (long j = 0; j <= i; j++)
sumMemo += nums[j];
for (long j = i; j < n; j++)
sumMemo += numsUnder[j];
answer = Math.Max(answer, sumMemo);
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
[["-", 0, 7, 8, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 7, 8, 1, 0, 11, 12, 204, 205, 22]]
| 8
| 187
| 2
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using static System.Console;
using static System.Math;
//using CS_Contest.Graph;
using CS_Contest.Loop;
using CS_Contest.Utils;
using static Nakov.IO.Cin;
using static CS_Contest.IO.IO;
using static CS_Contest.Utils.MyMath;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
using ti3 = Tuple<int, int, int>;
using ti2 = Tuple<int, int>;
internal class Program {
private static void Main(string[] args) {
var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
SetOut(sw);
new Calc().Solve();
Out.Flush();
}
public class Calc
{
public void Solve() {
int N = NextInt(), M = NextInt();
var wuf=new WeightedUnionFind(N);
M.REP(i =>
{
int Li = NextInt(), Ri = NextInt(), Di = NextInt();
wuf.Unite(Li,Ri,Di);
});
(wuf.IsValid()?"Yes":"No").WL();
return;
}
public struct WeightedUnionFind
{
private readonly int N;
public int[] Parent { get; private set; }
public long[] Cost { get; private set; }
public int[] Rank { get; private set; }
public WeightedUnionFind(int n)
{
N = n;
Parent = Enumerable.Range(0, N).ToArray();
Cost = new long[N];
Rank = new int[N];
}
public int Root(int u, out long cost)
{
if (Parent[u] == u)
{
cost = Cost[u];
return u;
}
var v = Root(Parent[u], out cost);
cost += Cost[u];
Parent[u] = v;
Cost[u] = cost;
return v;
}
public void Unite(int lv, int rv, long cost)
{
long lc, rc;
lv = Root(lv, out lc);
rv = Root(rv, out rc);
cost = -rc + cost + lc;
if (Rank[lv] < Rank[rv])
{
Unite(rv, lv, -cost);
return;
}
Parent[rv] = lv;
Cost[rv] = cost;
Rank[lv] += Rank[rv] + 1;
}
public bool IsValid()
{
for (var i = 0; i < N; i++)
{
long _;
Root(i, out _);
}
for (var i = 0; i < N; i++)
{
if (Parent[i] == i && Cost[i] != 0L)
{
return false;
}
}
return true;
}
}
}
}
}
namespace Nakov.IO {
using System;
using System.Text;
using System.Globalization;
public static class Cin {
public static string NextToken() {
StringBuilder tokenChars = new StringBuilder();
bool tokenFinished = false;
bool skipWhiteSpaceMode = true;
while (!tokenFinished) {
int nextChar = Console.Read();
if (nextChar == -1) {
tokenFinished = true;
} else {
char ch = (char)nextChar;
if (char.IsWhiteSpace(ch)) {
if (!skipWhiteSpaceMode) {
tokenFinished = true;
if (ch == '\r' && (Environment.NewLine == "\r\n")) {
Console.Read();
}
}
} else {
skipWhiteSpaceMode = false;
tokenChars.Append(ch);
}
}
}
string token = tokenChars.ToString();
return token;
}
public static int NextInt() {
string token = Cin.NextToken();
return int.Parse(token);
}
public static long NextLong() {
string token = Cin.NextToken();
return long.Parse(token);
}
public static double NextDouble(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
double result = double.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
double result = double.Parse(token);
return result;
}
}
public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
decimal result = decimal.Parse(token);
return result;
}
}
}
}
namespace CS_Contest.Loop {
[DebuggerStepThrough]
public static class Loop {
public static void REP(this int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static void ForeachWith<T>(this IEnumerable<T> ie, Action<int, T> act) {
var i = 0;
foreach (var item in ie) {
act(i, item);
i++;
}
}
public static void Foreach<T>(this IEnumerable<T> ie, Action<T> act) {
foreach (var item in ie) {
act(item);
}
}
}
public class Generate
{
public static IEnumerable<int> Seq(int e) => Seq(0, e, 1);
public static IEnumerable<int> Seq(int s, int e) => Seq(s, e, 1);
public static IEnumerable<int> Seq(int s, int e, int a) {
while (s != e) {
yield return s;
s += a;
}
}
public static List<T> Repeat<T>(Func<int, T> result, int range) =>
Enumerable.Range(0, range).Select(result).ToList();
}
}
namespace CS_Contest.IO {
using Li = List<int>;
using Ll = List<long>;
public static class IO {
public static void WL(this object obj) => WriteLine(obj);
public static void WL(this string obj) => WriteLine(obj);
public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
public static Li NextIntList() => ReadLine().Split().Select(int.Parse).ToList();
public static Li NextIntList(int n) => Enumerable.Repeat(0, n).Select(x => ReadLine()).Select(int.Parse).ToList();
public static Ll NextLongList() => ReadLine().Split().Select(long.Parse).ToList();
public static T Tee<T>(this T t, Func<T, string> formatter = null) {
if (formatter == null) formatter = arg => arg.ToString();
formatter(t).WL();
return t;
}
public static void JoinWL<T>(this IEnumerable<T> @this, string sp = " ") => @this.StringJoin(sp).WL();
public static void W(this object @this) => Write(@this);
public static T[,] GetBox<T>(int h, int w, Func<int, int, T> getFunc) {
var rt = new T[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
rt[i, j] = getFunc(i, j);
}
}
return rt;
}
}
}
namespace CS_Contest.Utils {
using Li = List<int>;
using Ll = List<long>;
[DebuggerStepThrough]
public static class Utils {
public static bool Within(int x, int y, int lx, int ly) => !(x < 0 || x >= lx || y < 0 || y >= ly);
public static void Add<T1, T2>(this List<Tuple<T1, T2>> list, T1 t1, T2 t2) => list.Add(new Tuple<T1, T2>(t1, t2));
public static string StringJoin<T>(this IEnumerable<T> l, string separator = "") => string.Join(separator, l);
public static Queue<T> ToQueue<T>(this IEnumerable<T> iEnumerable) {
var rt = new Queue<T>();
foreach (var item in iEnumerable) {
rt.Enqueue(item);
}
return rt;
}
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static Map<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Map<TKey, int>();
foreach (var item in l) {
dic[item]++;
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l, T target) => l.Count(x => x.Equals(target));
public static IEnumerable<T> SkipAt<T>(this IEnumerable<T> @this, int at) {
var enumerable = @this as T[] ?? @this.ToArray();
for (var i = 0; i < enumerable.Count(); i++) {
if (i == at) continue;
yield return enumerable.ElementAt(i);
}
}
}
public class Map<TKey, TValue> : Dictionary<TKey, TValue> {
public Map() : base() { }
public Map(int capacity) : base(capacity) { }
public new TValue this[TKey index] {
get {
TValue v;
return this.TryGetValue(index, out v) ? v : base[index] = default(TValue);
}
set { base[index] = value; }
}
}
public static class MyMath {
public static T EMin<T>(params T[] a) where T : IComparable<T> => a.Min();
public static T EMax<T>(params T[] a) where T : IComparable<T> => a.Max();
}
}
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using static System.Console;
using static System.Math;
//using CS_Contest.Graph;
using CS_Contest.Loop;
using CS_Contest.Utils;
using static Nakov.IO.Cin;
using static CS_Contest.IO.IO;
using static CS_Contest.Utils.MyMath;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
using ti3 = Tuple<int, int, int>;
using ti2 = Tuple<int, int>;
internal class Program {
private static void Main(string[] args) {
var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
SetOut(sw);
new Calc().Solve();
Out.Flush();
}
public class Calc
{
public void Solve() {
int N = NextInt(), M = NextInt();
var wuf=new WeightedUnionFind(N);
M.REP(i =>
{
int Li = NextInt()-1, Ri = NextInt()-1, Di = NextInt();
wuf.Unite(Li,Ri,Di);
});
(wuf.IsValid()?"Yes":"No").WL();
return;
}
public struct WeightedUnionFind
{
private readonly int N;
public int[] Parent { get; private set; }
public long[] Cost { get; private set; }
public int[] Rank { get; private set; }
public WeightedUnionFind(int n)
{
N = n;
Parent = Enumerable.Range(0, N).ToArray();
Cost = new long[N];
Rank = new int[N];
}
public int Root(int u, out long cost)
{
if (Parent[u] == u)
{
cost = Cost[u];
return u;
}
var v = Root(Parent[u], out cost);
cost += Cost[u];
Parent[u] = v;
Cost[u] = cost;
return v;
}
public void Unite(int lv, int rv, long cost)
{
long lc, rc;
lv = Root(lv, out lc);
rv = Root(rv, out rc);
cost = -rc + cost + lc;
if (Rank[lv] < Rank[rv])
{
Unite(rv, lv, -cost);
return;
}
Parent[rv] = lv;
Cost[rv] = cost;
Rank[lv] += Rank[rv] + 1;
}
public bool IsValid()
{
for (var i = 0; i < N; i++)
{
long _;
Root(i, out _);
}
for (var i = 0; i < N; i++)
{
if (Parent[i] == i && Cost[i] != 0L)
{
return false;
}
}
return true;
}
}
}
}
}
namespace Nakov.IO {
using System;
using System.Text;
using System.Globalization;
public static class Cin {
public static string NextToken() {
StringBuilder tokenChars = new StringBuilder();
bool tokenFinished = false;
bool skipWhiteSpaceMode = true;
while (!tokenFinished) {
int nextChar = Console.Read();
if (nextChar == -1) {
tokenFinished = true;
} else {
char ch = (char)nextChar;
if (char.IsWhiteSpace(ch)) {
if (!skipWhiteSpaceMode) {
tokenFinished = true;
if (ch == '\r' && (Environment.NewLine == "\r\n")) {
Console.Read();
}
}
} else {
skipWhiteSpaceMode = false;
tokenChars.Append(ch);
}
}
}
string token = tokenChars.ToString();
return token;
}
public static int NextInt() {
string token = Cin.NextToken();
return int.Parse(token);
}
public static long NextLong() {
string token = Cin.NextToken();
return long.Parse(token);
}
public static double NextDouble(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
double result = double.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
double result = double.Parse(token);
return result;
}
}
public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
decimal result = decimal.Parse(token);
return result;
}
}
}
}
namespace CS_Contest.Loop {
[DebuggerStepThrough]
public static class Loop {
public static void REP(this int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static void ForeachWith<T>(this IEnumerable<T> ie, Action<int, T> act) {
var i = 0;
foreach (var item in ie) {
act(i, item);
i++;
}
}
public static void Foreach<T>(this IEnumerable<T> ie, Action<T> act) {
foreach (var item in ie) {
act(item);
}
}
}
public class Generate
{
public static IEnumerable<int> Seq(int e) => Seq(0, e, 1);
public static IEnumerable<int> Seq(int s, int e) => Seq(s, e, 1);
public static IEnumerable<int> Seq(int s, int e, int a) {
while (s != e) {
yield return s;
s += a;
}
}
public static List<T> Repeat<T>(Func<int, T> result, int range) =>
Enumerable.Range(0, range).Select(result).ToList();
}
}
namespace CS_Contest.IO {
using Li = List<int>;
using Ll = List<long>;
public static class IO {
public static void WL(this object obj) => WriteLine(obj);
public static void WL(this string obj) => WriteLine(obj);
public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
public static Li NextIntList() => ReadLine().Split().Select(int.Parse).ToList();
public static Li NextIntList(int n) => Enumerable.Repeat(0, n).Select(x => ReadLine()).Select(int.Parse).ToList();
public static Ll NextLongList() => ReadLine().Split().Select(long.Parse).ToList();
public static T Tee<T>(this T t, Func<T, string> formatter = null) {
if (formatter == null) formatter = arg => arg.ToString();
formatter(t).WL();
return t;
}
public static void JoinWL<T>(this IEnumerable<T> @this, string sp = " ") => @this.StringJoin(sp).WL();
public static void W(this object @this) => Write(@this);
public static T[,] GetBox<T>(int h, int w, Func<int, int, T> getFunc) {
var rt = new T[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
rt[i, j] = getFunc(i, j);
}
}
return rt;
}
}
}
namespace CS_Contest.Utils {
using Li = List<int>;
using Ll = List<long>;
[DebuggerStepThrough]
public static class Utils {
public static bool Within(int x, int y, int lx, int ly) => !(x < 0 || x >= lx || y < 0 || y >= ly);
public static void Add<T1, T2>(this List<Tuple<T1, T2>> list, T1 t1, T2 t2) => list.Add(new Tuple<T1, T2>(t1, t2));
public static string StringJoin<T>(this IEnumerable<T> l, string separator = "") => string.Join(separator, l);
public static Queue<T> ToQueue<T>(this IEnumerable<T> iEnumerable) {
var rt = new Queue<T>();
foreach (var item in iEnumerable) {
rt.Enqueue(item);
}
return rt;
}
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static Map<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Map<TKey, int>();
foreach (var item in l) {
dic[item]++;
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l, T target) => l.Count(x => x.Equals(target));
public static IEnumerable<T> SkipAt<T>(this IEnumerable<T> @this, int at) {
var enumerable = @this as T[] ?? @this.ToArray();
for (var i = 0; i < enumerable.Count(); i++) {
if (i == at) continue;
yield return enumerable.ElementAt(i);
}
}
}
public class Map<TKey, TValue> : Dictionary<TKey, TValue> {
public Map() : base() { }
public Map(int capacity) : base(capacity) { }
public new TValue this[TKey index] {
get {
TValue v;
return this.TryGetValue(index, out v) ? v : base[index] = default(TValue);
}
set { base[index] = value; }
}
}
public static class MyMath {
public static T EMin<T>(params T[] a) where T : IComparable<T> => a.Min();
public static T EMax<T>(params T[] a) where T : IComparable<T> => a.Max();
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 2,166
| 4
|
using System;
using System.Linq;
namespace Sample {
class Sample {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
long A = long.Parse(str[0]);
long B = long.Parse(str[1]);
if ((A * B / 2) == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
}
|
using System;
using System.Linq;
namespace Sample {
class Sample {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
long A = long.Parse(str[0]);
long B = long.Parse(str[1]);
if ((A * B % 2) == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
}
|
[["-", 0, 57, 15, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 109]]
| 8
| 106
| 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 s = GetIntArray();
var ans = s[0] * s[1] % 2 == 0 ? "Odd" : "Even";
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 s = GetIntArray();
var ans = s[0] * s[1] % 2 != 0 ? "Odd" : "Even";
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]);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 79]]
| 8
| 633
| 2
|
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 = a * 2 % 2;
string result = "";
if (c == 0) {
result = "Even";
} else {
result = "Odd";
}
WriteLine(result);
}
}
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 = a * b % 2;
string result = "";
if (c == 0) {
result = "Even";
} else {
result = "Odd";
}
WriteLine(result);
}
}
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, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22]]
| 8
| 482
| 2
|
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 * cin.ReadInt) / 2 == 0 ? "Even" : "Odd";
WriteLine(a);
}
}
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 * cin.ReadInt) % 2 == 0 ? "Even" : "Odd";
WriteLine(a);
}
}
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, 212, 0, 41, 15, 16, 31, 16, 17, 85], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 17, 109]]
| 8
| 454
| 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 inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long a = inputLongArray[0];
long b = inputLongArray[1];
string result = "Odd";
if ((a + b) % 2 == 0) {
result = "Even";
}
Console.WriteLine(result);
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 inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long a = inputLongArray[0];
long b = inputLongArray[1];
string result = "Odd";
if ((a * b) % 2 == 0) {
result = "Even";
}
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
[["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48]]
| 8
| 169
| 2
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A_project {
class Program {
static void Main(string[] args) {
string input = ReadLine();
string[] array = input.Split(' ');
int[] figure = new int[array.Length];
for (int i = 0; i < array.Length; i++) {
figure[i] = int.Parse(array[i]);
}
int result = figure[0] * figure[1] % 2;
if (result == 0) {
WriteLine("even");
} else {
WriteLine("odd");
}
ReadKey();
}
}
}
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A_project {
class Program {
static void Main(string[] args) {
string input = ReadLine();
string[] array = input.Split(' ');
int[] figure = new int[array.Length];
for (int i = 0; i < array.Length; i++) {
figure[i] = int.Parse(array[i]);
}
int result = figure[0] * figure[1] % 2;
if (result == 0) {
WriteLine("Even");
} else {
WriteLine("Odd");
}
ReadKey();
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 163
| 4
|
using System;
class Hello {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if ((a * b) % 2 == 0) {
Console.WriteLine("even");
} else {
Console.WriteLine("odd");
}
}
}
|
using System;
class Hello {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if ((a * b) % 2 == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 97
| 4
|
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) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
Console.WriteLine((a + b) % 2 == 0 ? "Even" : "Odd");
}
}
}
|
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) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
Console.WriteLine((a * b) % 2 == 0 ? "Even" : "Odd");
}
}
}
|
[["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48]]
| 8
| 113
| 2
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
if (a % 2 == 0 || b % 2 == 0) {
Console.WriteLine("Evan");
} else {
Console.WriteLine("Odd");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if (a % 2 == 0 || b % 2 == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 99
| 8
|
using System;
namespace test {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var b = int.Parse(input[0]);
var c = int.Parse(input[1]);
var a = b * c;
if (a % 2 == 0)
Console.WriteLine("Even");
Console.WriteLine("Odd");
// string s = Console.ReadLine();
}
}
}
|
using System;
namespace test {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var b = int.Parse(input[0]);
var c = int.Parse(input[1]);
var a = b * c;
if (a % 2 == 0) {
Console.WriteLine("Even");
return;
}
Console.WriteLine("Odd");
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 98
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC086A {
class Program {
static void Main(string[] args) {
string[] n = Console.ReadLine().Split(' ');
int a = int.Parse(n[0]);
int b = int.Parse(n[1]);
if (a % b == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC086A {
class Program {
static void Main(string[] args) {
string[] n = Console.ReadLine().Split(' ');
int a = int.Parse(n[0]);
int b = int.Parse(n[1]);
if ((a * b) % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
Console.ReadKey();
}
}
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 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
| 123
| 6
|
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) {
string[] a = Console.ReadLine().Split(' ');
if (int.Parse(a[0]) % 2 == 0 || int.Parse(a[1]) % 2 == 0) {
Console.WriteLine("even");
} else {
Console.WriteLine("odd");
};
}
}
}
|
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) {
string[] a = Console.ReadLine().Split(' ');
if (int.Parse(a[0]) % 2 == 0 || int.Parse(a[1]) % 2 == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
};
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 118
| 4
|
using System;
class program {
static void Main(string[] args) {
var read = Console.ReadLine();
var datas = read.Split(new char[] { ' ' });
int a = Convert.ToInt32(datas[0]);
int b = Convert.ToInt32(datas[1]);
int c = a * b;
if (c % 2 == 0) {
Console.WriteLine("even");
} else {
Console.WriteLine("odd");
}
}
}
|
using System;
class program {
static void Main(string[] args) {
var read = Console.ReadLine();
var datas = read.Split(new char[] { ' ' });
int a = Convert.ToInt32(datas[0]);
int b = Convert.ToInt32(datas[1]);
int c = a * b;
if (c % 2 == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 109
| 4
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main(string[] args) {
var ans = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
Console.WriteLine((ans[0] * ans[1]) % 2 == 0 ? "even" : "odd");
}
}
}
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main(string[] args) {
var ans = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
Console.WriteLine((ans[0] * ans[1]) % 2 == 0 ? "Even" : "Odd");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 85
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC086A_Product {
class Program {
static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int a = input[0];
int b = input[1];
if (a * b % 2 == 0) {
Console.WriteLine("Odd");
} else {
Console.WriteLine("Even");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC086A_Product {
class Program {
static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int a = input[0];
int b = input[1];
if (a * b % 2 == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 129
| 4
|
using System;
using System.Linq;
namespace myapp2 {
class Program {
static void Main(string[] args) {
var input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
int a = input[0];
int b = input[1];
string result = a / b == 0 ? "Even" : "Odd";
Console.WriteLine(result);
var end = Console.ReadLine();
}
}
}
|
using System;
using System.Linq;
namespace myapp2 {
class Program {
static void Main(string[] args) {
var input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
int a = input[0];
int b = input[1];
string result = (a * b) % 2 == 0 ? "Even" : "Odd";
Console.WriteLine(result);
var end = Console.ReadLine();
}
}
}
|
[["+", 0, 41, 15, 16, 31, 16, 31, 23, 0, 24], ["-", 0, 212, 0, 41, 15, 16, 31, 16, 17, 85], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 0, 41, 15, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 12, 203]]
| 8
| 108
| 6
|
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;
WriteLine(a * b % 2 == 0 ? "Even" : "0dd");
// 解答はココに書く
}
}
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;
WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
// 解答はココに書く
}
}
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;
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 458
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var ab = ReadSplitInt();
Println(ab[0] * ab[1] == 0 ? "Even" : "Odd");
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var ab = ReadSplitInt();
Println(ab[0] * ab[1] % 2 == 0 ? "Even" : "Odd");
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
[["+", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 12, 203]]
| 8
| 661
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
Console.WriteLine(a % 2 == 0 && b % 2 == 0 ? "Even" : "Odd");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
Console.WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
}
}
|
[["-", 0, 41, 15, 16, 31, 16, 31, 16, 17, 109], ["-", 0, 41, 15, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 28, 0, 41, 15, 16, 31, 16, 17, 60], ["-", 0, 28, 0, 41, 15, 16, 31, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 98], ["+", 0, 41, 15, 16, 31, 16, 31, 16, 17, 48]]
| 8
| 99
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
if ((str[0] * str[1]) % 2 == 0) {
Console.WriteLine("Odd");
} else {
Console.WriteLine("Even");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
if ((str[0] * str[1]) % 2 == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 100
| 4
|
using System;
class Program {
static int minNum = 1;
static int maxNum = 10000;
static void Main(string[] args) {
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if (!chectNum(a) && !chectNum(b)) {
Console.WriteLine("入力値が不正です。");
}
if (a % 2 == 0 && b % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
}
private static bool chectNum(int target) {
return minNum <= target && target <= maxNum;
}
}
|
using System;
class Program {
static int minNum = 1;
static int maxNum = 10000;
static void Main(string[] args) {
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if (!chectNum(a) && !chectNum(b)) {
Console.WriteLine("入力値が不正です。");
}
if (a % 2 == 0 || b % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
}
private static bool chectNum(int target) {
return minNum <= target && target <= maxNum;
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106]]
| 8
| 152
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class aaaa {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if ((a * b) % 2 == 0) {
Console.WriteLine("Odd");
} else {
Console.WriteLine("Even");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class aaaa {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if ((a * b) % 2 == 0) {
Console.WriteLine("Even");
} else {
Console.WriteLine("Odd");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 125
| 4
|
using System;
class Program {
static void Main(string[] args) {
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
//出力
Console.WriteLine(a * b % 2 == 0 ? "even" : "odd");
}
}
|
using System;
class Program {
static void Main(string[] args) {
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
//出力
Console.WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 85
| 4
|
using System;
class Program {
static void Main(String[] arg) {
//出力用の文字列
String ret;
// 整数の取得
String[] nums = Console.ReadLine().Split(' ');
int a = int.Parse(nums[0]);
int b = int.Parse(nums[1]);
// 積の演算
int product = a * b;
if (product % 2 == 0) {
ret = "even";
} else {
ret = "odd";
}
Console.WriteLine(ret);
}
}
|
using System;
class Program {
static void Main(String[] arg) {
//出力用の文字列
String ret;
// 整数の取得
String[] nums = Console.ReadLine().Split(' ');
int a = int.Parse(nums[0]);
int b = int.Parse(nums[1]);
// 積の演算
int product = a * b;
if (product % 2 == 0) {
ret = "Even";
} else {
ret = "Odd";
}
Console.WriteLine(ret);
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["-", 75, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 75, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 107
| 4
|
using System;
// using System.Linq;
class Program {
static void Main() {
string[] s_data = Console.ReadLine().Split(' ');
if ((int.Parse(s_data[0]) * int.Parse(s_data[1])) % 2 == 0)
Console.WriteLine("even");
else
Console.WriteLine("odd");
}
}
|
using System;
// using System.Linq;
class Program {
static void Main() {
string[] s_data = Console.ReadLine().Split(' ');
if ((int.Parse(s_data[0]) * int.Parse(s_data[1])) % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 80
| 4
|
public static class Program {
public static void Main(string[] args) {
string[] input = System.Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
string answer = ((a % 2 == 0) && (b % 2 == 0)) ? "Even" : "Odd";
System.Console.WriteLine(answer);
}
}
|
public static class Program {
public static void Main(string[] args) {
string[] input = System.Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
string answer = ((a % 2 == 0) || (b % 2 == 0)) ? "Even" : "Odd";
System.Console.WriteLine(answer);
}
}
|
[["-", 0, 212, 0, 41, 15, 23, 0, 16, 17, 98], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 17, 106]]
| 8
| 102
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Abc086A {
class Program {
static void Main(string[] args) {
var a_b = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
Console.WriteLine(a_b[0] * a_b[1] % 2 == 0 ? "Odd" : "Even");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Abc086A {
class Program {
static void Main(string[] args) {
var a_b = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
Console.WriteLine(a_b[0] * a_b[1] % 2 == 0 ? "Even" : "Odd");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 97
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderB {
static void Main() {
var sc = new Scanner();
int a = sc.NextInt();
int b = sc.NextInt();
int num = int.Parse(a.ToString() + b.ToString());
bool ok = false;
for (int i = 1; i * i <= num; i++) {
if (num / i == i) {
ok = true;
break;
}
}
string answer = ok ? "Yes" : "No";
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 a = sc.NextInt();
int b = sc.NextInt();
int num = int.Parse(a.ToString() + b.ToString());
bool ok = false;
for (int i = 1; i * i <= num; i++) {
if (i * i == num) {
ok = true;
break;
}
}
string answer = ok ? "Yes" : "No";
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, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 431
| 6
|
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) {
// 解答はココに書く
string date = cin.Read;
WriteLine("2018" + date.Substring(4, 9));
}
}
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) {
// 解答はココに書く
string date = cin.Read;
WriteLine("2018" + date.Substring(4, 6));
}
}
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, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 448
| 2
|
using System;
using System.Linq;
class Program {
static void Main() {
// int[] input = Console.ReadLine().Split().Select(i =>
// int.Parse(i)).ToArray(); int a=int.Parse(Console.ReadLine());
string a = Console.ReadLine();
Console.WriteLine("2018" + a.Substring(4, a.Length));
Console.ReadLine();
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
// int[] input = Console.ReadLine().Split().Select(i =>
// int.Parse(i)).ToArray(); int a=int.Parse(Console.ReadLine());
string a = Console.ReadLine();
Console.WriteLine("2018" + a.Substring(4, a.Length - 4));
Console.ReadLine();
}
}
|
[["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 56
| 2
|
using System;
class Program {
static void Main() {
string s = Console.ReadLine();
char[] c = s.ToCharArray();
c[3] = '0';
Console.WriteLine(c); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
using System;
class Program {
static void Main() {
string s = Console.ReadLine();
char[] c = s.ToCharArray();
c[3] = '8';
Console.WriteLine(c); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 12, 252, 0, 253], ["+", 8, 196, 0, 1, 0, 11, 12, 252, 0, 253]]
| 8
| 51
| 2
|
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 N = cin.ReadInt;
var size_list = new List<int>();
for (int k = 0; k < N; k++) {
size_list.Add(cin.ReadInt);
}
IEnumerable<int> result = size_list.Distinct();
int answer = size_list.Count();
WriteLine(answer);
}
}
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 N = cin.ReadInt;
var size_list = new List<int>();
for (int k = 0; k < N; k++) {
size_list.Add(cin.ReadInt);
}
IEnumerable<int> result = size_list.Distinct();
int answer = result.Count();
WriteLine(answer);
}
}
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, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22]]
| 8
| 493
| 2
|
using System;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
int[] nums = new int[n];
for (int i = 0; i < n; i++) {
nums[i] = int.Parse(Console.ReadLine());
}
Array.Sort(nums); //小さい順に並び替え
int cal = 0; //求める個数
for (int i = 0; i < n - 1; i++) {
if (nums[i] < nums[i + 1])
cal++;
}
//出力
Console.WriteLine(cal); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
using System;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
int[] nums = new int[n];
for (int i = 0; i < n; i++) {
nums[i] = int.Parse(Console.ReadLine());
}
Array.Sort(nums); //小さい順に並び替え
int cal = 1; //求める個数
for (int i = 0; i < n - 1; i++) {
if (nums[i] < nums[i + 1])
cal++;
}
//出力
Console.WriteLine(cal); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 130
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC085B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine()); // 2つ以上のスペース区切り入力の取得
int[] mochi = new int[N];
for (int i = 1; i < N; i++) {
mochi[i] = int.Parse(Console.ReadLine());
}
int[] dMochi = mochi.Distinct().ToArray();
// Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
// Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b,
// c);//改行付き出力
Console.WriteLine(dMochi.Count());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC085B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine()); // 2つ以上のスペース区切り入力の取得
int[] mochi = new int[N];
for (int i = 0; i < N; i++) {
mochi[i] = int.Parse(Console.ReadLine());
}
int[] dMochi = mochi.Distinct().ToArray();
// Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
// Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b,
// c);//改行付き出力
Console.WriteLine(dMochi.Count());
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 133
| 2
|
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) {
// Initialize
var intN = cin.ReadInt;
var intY = cin.ReadInt;
var ansI = -1;
var ansJ = -1;
var ansK = -1;
// Process
for (int i = 0; i <= intN; i++) {
for (int j = 0; i + j <= intN; j++) {
int k = intN - i + j;
if (10000 * i + 5000 * j + 1000 * k == intY) {
ansI = i;
ansJ = j;
ansK = k;
}
}
}
// Output
WriteLine($"{ansI} {ansJ} {ansK}");
}
}
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) {
// Initialize
var intN = cin.ReadInt;
var intY = cin.ReadInt;
var ansI = -1;
var ansJ = -1;
var ansK = -1;
// Process
for (int i = 0; i <= intN; i++) {
for (int j = 0; i + j <= intN; j++) {
int k = intN - i - j;
if (10000 * i + 5000 * j + 1000 * k == intY) {
ansI = i;
ansJ = j;
ansK = k;
}
}
}
// Output
WriteLine($"{ansI} {ansJ} {ansK}");
}
}
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, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33]]
| 8
| 549
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
var ny = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int n = ny[0];
int y = ny[1];
int yy = y / 1000;
for (int i = 0; i <= yy; i++) {
for (int j = 0; j <= yy; j++) {
int k = n - i - j;
if (k < 0) {
continue;
}
long sum = 1000L * i + 5000L * j;
if (sum == y) {
Console.WriteLine($"{k} {j} {i}");
return;
}
}
}
Console.WriteLine($"{-1} {-1} {-1}");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
var ny = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int n = ny[0];
int y = ny[1];
int yy = y / 1000;
for (int i = 0; i <= yy; i++) {
for (int j = 0; j <= yy; j++) {
int k = n - i - j;
if (k < 0) {
continue;
}
long sum = 1000L * i + 5000L * j + 10000L * k;
if (sum == y) {
Console.WriteLine($"{k} {j} {i}");
return;
}
}
}
Console.WriteLine($"{-1} {-1} {-1}");
}
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 31, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 12, 22]]
| 8
| 225
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace c {
class Program {
static void Main(string[] args) {
var vals = IOUtils.ReadInts();
var totalCount = vals[0];
var totalPrice = vals[1];
for (int x = 0; x < totalCount; x++) {
var xval = x * 10000;
if (totalPrice < xval)
break;
for (int y = 0; y < totalCount; y++) {
var yval = xval + y * 5000;
if (totalPrice < yval)
break;
if (x + y > totalCount)
break;
var z = totalCount - (x + y);
var val = yval + z * 1000;
if (val == totalPrice) {
Console.WriteLine($"{x} {y} {z}");
return;
}
if (val > totalPrice)
break;
}
}
Console.WriteLine("-1 -1 -1");
}
}
static class IOUtils {
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static ulong ReadUlong() { return ulong.Parse(Console.ReadLine()); }
public static int[] ReadInts() {
return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
}
public static long[] ReadLongs() {
return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
}
public static void WriteNums(params int[] nums) {
Console.WriteLine(string.Join(" ", nums));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace c {
class Program {
static void Main(string[] args) {
var vals = IOUtils.ReadInts();
var totalCount = vals[0];
var totalPrice = vals[1];
for (int x = 0; x <= totalCount; x++) {
var xval = x * 10000;
if (totalPrice < xval)
break;
for (int y = 0; y <= totalCount; y++) {
var yval = xval + y * 5000;
if (totalPrice < yval)
break;
if (x + y > totalCount)
break;
var z = totalCount - (x + y);
var val = yval + z * 1000;
if (val == totalPrice) {
Console.WriteLine($"{x} {y} {z}");
return;
}
if (val > totalPrice)
break;
}
}
Console.WriteLine("-1 -1 -1");
}
}
static class IOUtils {
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static ulong ReadUlong() { return ulong.Parse(Console.ReadLine()); }
public static int[] ReadInts() {
return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
}
public static long[] ReadLongs() {
return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
}
public static void WriteNums(params int[] nums) {
Console.WriteLine(string.Join(" ", nums));
}
}
}
|
[["-", 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]]
| 8
| 373
| 4
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
//// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int Y = int.Parse(input[1]);
//出力
Console.WriteLine(NewMethod(N, Y).ToString());
}
private static string NewMethod(int N, int Y) {
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= N; j++) {
var k = N - i - j;
if (k < 1) {
continue;
}
if (i * 10000 + j * 5000 + k * 1000 == Y && i + j + k == N) {
return i.ToString() + " " + j.ToString() + " " + k.ToString();
}
}
}
return "-1 -1 -1";
}
}
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
//// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int Y = int.Parse(input[1]);
//出力
Console.WriteLine(NewMethod(N, Y).ToString());
}
private static string NewMethod(int N, int Y) {
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= N; j++) {
var k = N - i - j;
if (k < 0) {
continue;
}
if (i * 10000 + j * 5000 + k * 1000 == Y && i + j + k == N) {
return i.ToString() + " " + j.ToString() + " " + k.ToString();
}
}
}
return "-1 -1 -1";
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 203
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.