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.Linq;
namespace ABC085_D___Katana_Thrower {
class Program {
static void Main(string[] args) {
var NH = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = NH[0];
var H = NH[1];
var attack = new int[N];
var throwing = new int[N];
for (int i = 0; i < N; i++) {
var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
attack[i] = ab[0];
throwing[i] = ab[1];
}
var attackMax = attack.Max();
throwing =
throwing.Where(s => s > attackMax).OrderByDescending(s => s).ToArray();
var attackCount = 0;
while (attackCount < throwing.Length && H > 0) {
H -= throwing[attackCount];
attackCount += 1;
}
attackCount += H / attackMax;
if ((H % attackMax) > 0)
attackCount += 1;
Console.WriteLine(attackCount);
}
}
}
|
using System;
using System.Linq;
namespace ABC085_D___Katana_Thrower {
class Program {
static void Main(string[] args) {
var NH = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = NH[0];
var H = NH[1];
var attack = new int[N];
var throwing = new int[N];
for (int i = 0; i < N; i++) {
var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
attack[i] = ab[0];
throwing[i] = ab[1];
}
var attackMax = attack.Max();
throwing =
throwing.Where(s => s > attackMax).OrderByDescending(s => s).ToArray();
var attackCount = 0;
while (attackCount < throwing.Length && H > 0) {
H -= throwing[attackCount];
attackCount += 1;
}
if (H > 0) {
attackCount += H / attackMax;
if ((H % attackMax) > 0)
attackCount += 1;
}
Console.WriteLine(attackCount);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 237
| 8
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
int H = cin.nextInt();
int[] a = new int[N];
int[] b = new int[N];
for (int i = 0; i < N; i++) {
a[i] = cin.nextInt();
b[i] = cin.nextInt();
}
Array.Sort(b);
Array.Reverse(b);
int MaxA = a.Max();
int ans = 0;
for (int i = 0; i < N; i++) {
if (MaxA < b[i] && H > 0) {
H -= b[i];
ans++;
}
}
ans += (H + MaxA - 1) / MaxA;
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
int H = cin.nextInt();
int[] a = new int[N];
int[] b = new int[N];
for (int i = 0; i < N; i++) {
a[i] = cin.nextInt();
b[i] = cin.nextInt();
}
Array.Sort(b);
Array.Reverse(b);
int MaxA = a.Max();
int ans = 0;
for (int i = 0; i < N; i++) {
if (MaxA < b[i] && H > 0) {
H -= b[i];
ans++;
}
}
ans += Math.Max(0, (H + MaxA - 1) / MaxA);
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 609
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = sc.nextInt();
var H = sc.nextLong();
var a = new int[N];
var b = new int[N];
for (int i = 0; i < N; i++) {
a[i] = sc.nextInt();
b[i] = sc.nextInt();
}
long ans = 0;
var amax = a.Max();
var thr = b.Where(i => i > amax).Select(i => (long)i).ToArray();
ans += thr.Length;
H -= thr.Sum();
if (H > 0) {
if (H % amax != 0) {
ans++;
}
ans += H / amax;
}
WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = sc.nextInt();
var H = sc.nextLong();
var a = new int[N];
var b = new int[N];
for (int i = 0; i < N; i++) {
a[i] = sc.nextInt();
b[i] = sc.nextInt();
}
long ans = 0;
var amax = a.Max();
var thr = b.Where(i => i > amax)
.Select(i => (long)i)
.OrderByDescending(l => l)
.ToArray();
for (int i = 0; i < thr.Length; i++) {
H -= thr[i];
ans++;
if (H <= 0)
break;
}
if (H > 0) {
if (H % amax != 0) {
ans++;
}
ans += H / amax;
}
WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
[["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 581
| 37
|
using System;
class Program {
static void Main() {
long[] s = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
long[][] arr = new long[s[0]][];
long a = 0, b = 0;
for (int i = 0; i < s[0]; i++) {
arr[i] = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
a = Math.Max(a, arr[i][0]);
}
Array.Sort(arr, ca);
for (int i = 0; i < s[0] && arr[i][1] > a; i++) {
s[1] -= arr[i][1];
b++;
}
if (s[1] < 0) {
Console.WriteLine("{0}", b);
} else {
Console.WriteLine("{0}", s[1] / a + (s[1] % a == 0 ? 0 : 1) + b);
}
}
static int ca(long[] a, long[] b) {
if (a[1] < b[1]) {
return 1;
} else if (a[1] > b[1]) {
return -1;
} else {
return 0;
}
}
}
|
using System;
class Program {
static void Main() {
long[] s = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
long[][] arr = new long[s[0]][];
long a = 0, b = 0;
for (int i = 0; i < s[0]; i++) {
arr[i] = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
a = Math.Max(a, arr[i][0]);
}
Array.Sort(arr, ca);
for (int i = 0; i < s[0] && arr[i][1] > a && s[1] > 0; i++) {
s[1] -= arr[i][1];
b++;
}
if (s[1] <= 0) {
Console.WriteLine("{0}", b);
} else {
Console.WriteLine("{0}", s[1] / a + (s[1] % a == 0 ? 0 : 1) + b);
}
}
static int ca(long[] a, long[] b) {
if (a[1] < b[1]) {
return 1;
} else if (a[1] > b[1]) {
return -1;
} else {
return 0;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 98], ["+", 0, 7, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 295
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARC85_D {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
long h = long.Parse(s[1]);
long amax = 0;
long bsum = 0;
var b = new long[n];
long count = n;
for (int i = 0; i < n; i++) {
var p = Console.ReadLine().Split(' ');
amax = Math.Max(amax, long.Parse(p[0]));
b[i] = long.Parse(p[1]);
bsum += b[i];
}
Array.Sort(b);
if (h < bsum) {
bsum = 0;
count = 0;
for (int i = 0; i < n; i++) {
if (b[n - i - 1] > amax) {
bsum += b[n - i - 1];
count++;
} else {
break;
}
if (bsum >= h) {
Console.WriteLine(i + 1);
return;
}
}
}
Console.WriteLine((h - bsum) % amax == 0 ? (h - bsum) / amax + count
: (h - bsum) / amax + count + 1);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARC85_D {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
long h = long.Parse(s[1]);
long amax = 0;
long bsum = 0;
var b = new long[n];
long count = n;
for (int i = 0; i < n; i++) {
var p = Console.ReadLine().Split(' ');
amax = Math.Max(amax, long.Parse(p[0]));
b[i] = long.Parse(p[1]);
bsum += b[i];
}
Array.Sort(b);
bsum = 0;
count = 0;
for (int i = 0; i < n; i++) {
if (b[n - i - 1] > amax) {
bsum += b[n - i - 1];
count++;
} else {
break;
}
if (bsum >= h) {
Console.WriteLine(i + 1);
return;
}
}
Console.WriteLine((h - bsum) % amax == 0 ? (h - bsum) / amax + count
: (h - bsum) / amax + count + 1);
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 314
| 8
|
using System.Linq;
using System.Collections.Generic;
using System;
public class Katana {
public long a { get; set; }
public long b { get; set; }
}
public class Hello {
public static void Main() {
var katanas = new List<Katana>();
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var h = long.Parse(line[1]);
for (int i = 0; i < n; i++) {
string[] line2 = Console.ReadLine().Trim().Split(' ');
var a = long.Parse(line2[0]);
var b = long.Parse(line2[1]);
katanas.Add(new Katana { a = a, b = b });
}
var amax = katanas.Max(x => x.a);
var count = 0;
foreach (var x in katanas.Where(y => y.b > amax)) {
h -= x.b;
count++;
}
Console.WriteLine(count + (h + amax - 1) / amax);
}
}
|
using System.Linq;
using System.Collections.Generic;
using System;
public class Katana {
public long a { get; set; }
public long b { get; set; }
}
public class Hello {
public static void Main() {
var katanas = new List<Katana>();
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var h = long.Parse(line[1]);
for (int i = 0; i < n; i++) {
string[] line2 = Console.ReadLine().Trim().Split(' ');
var a = long.Parse(line2[0]);
var b = long.Parse(line2[1]);
katanas.Add(new Katana { a = a, b = b });
}
var amax = katanas.Max(x => x.a);
var count = 1;
foreach (var x in katanas.Where(y => y.b > amax)
.OrderByDescending(y => y.b)) {
h -= x.b;
if (h <= 0) {
Console.WriteLine(count);
goto end;
}
count++;
}
Console.WriteLine(count - 1 + (h + amax - 1) / amax);
end:;
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 126, 0, 127], ["+", 8, 196, 0, 57, 64, 196, 0, 126, 0, 22], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 97, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 97, 0, 102]]
| 8
| 256
| 34
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
long[] inpt =
Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
int katanaCount = (int)inpt[0];
this.HP = inpt[1];
this.KatanaList = new List<Katana>();
for (int i = 0; i < katanaCount; i++) {
inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
Katana k = new Katana(i, inpt[0], inpt[1]);
if (Tuyoi == null) {
Tuyoi = k;
} else if (Tuyoi.Furu < k.Furu) {
Tuyoi = k;
} else if (Tuyoi.Furu == k.Furu && Tuyoi.Nageru > k.Nageru) {
Tuyoi = k;
}
KatanaList.Add(k);
}
KatanaList.RemoveAt(Tuyoi.ID);
List<Katana> ktn = KatanaList.OrderByDescending(a => a.Nageru).ToList();
int lastIndex = 0;
int cnt = 0;
for (int i = 0; i < ktn.Count; i++) {
if (ktn[i].Nageru <= Tuyoi.Furu) {
break;
}
cnt++;
HP -= ktn[i].Nageru;
if (HP <= Tuyoi.Nageru) {
cnt++;
Console.WriteLine(cnt);
return;
}
if (HP <= 0) {
Console.WriteLine(cnt);
return;
}
lastIndex = i;
}
int subCnt = 0;
long max = HP / Tuyoi.Furu;
if (HP % Tuyoi.Furu != 0) {
max++;
}
for (int i = lastIndex + 1; i < ktn.Count && i < max && HP > Tuyoi.Nageru &&
ktn[i].Nageru > Tuyoi.Furu;
i++) {
if (HP <= Tuyoi.Nageru) {
break;
}
subCnt++;
HP -= ktn[i].Nageru;
lastIndex = i;
}
if (HP > 0) {
int tmp = 1;
HP -= Tuyoi.Nageru;
if (HP > 0) {
tmp += (int)(HP / Tuyoi.Furu);
if (HP % Tuyoi.Furu > 0) {
tmp++;
}
}
subCnt += tmp;
}
int ans = cnt + subCnt;
ans = Math.Min(ans, cnt + (int)max);
Console.WriteLine(ans);
}
private long HP;
private List<Katana> KatanaList;
private Katana Tuyoi;
private class Katana {
public long Furu;
public long Nageru;
public bool CanUse = true;
public int ID;
public Katana(int id, long furu, long nageru) {
this.ID = id;
this.Furu = furu;
this.Nageru = nageru;
}
}
public class Reader {
private static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
5 500
35 44
28 83
46 62
31 79
40 43
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
long[] inpt =
Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
int katanaCount = (int)inpt[0];
this.HP = inpt[1];
this.KatanaList = new List<Katana>();
for (int i = 0; i < katanaCount; i++) {
inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
Katana k = new Katana(i, inpt[0], inpt[1]);
if (Tuyoi == null) {
Tuyoi = k;
} else if (Tuyoi.Furu < k.Furu) {
Tuyoi = k;
} else if (Tuyoi.Furu == k.Furu && Tuyoi.Nageru > k.Nageru) {
Tuyoi = k;
}
KatanaList.Add(k);
}
KatanaList.RemoveAt(Tuyoi.ID);
List<Katana> ktn = KatanaList.OrderByDescending(a => a.Nageru).ToList();
int lastIndex = 0;
int cnt = 0;
for (int i = 0; i < ktn.Count; i++) {
if (ktn[i].Nageru < Tuyoi.Furu) {
break;
}
cnt++;
HP -= ktn[i].Nageru;
if (HP <= Tuyoi.Nageru) {
if (HP > 0) {
cnt++;
}
Console.WriteLine(cnt);
return;
}
if (HP <= 0) {
Console.WriteLine(cnt);
return;
}
lastIndex = i;
}
int subCnt = 0;
long max = HP / Tuyoi.Furu;
if (HP % Tuyoi.Furu != 0) {
max++;
}
for (int i = lastIndex + 1; i < ktn.Count && i < max && HP > Tuyoi.Nageru &&
ktn[i].Nageru > Tuyoi.Furu;
i++) {
subCnt++;
HP -= ktn[i].Nageru;
lastIndex = i;
}
if (HP > 0) {
int tmp = 1;
HP -= Tuyoi.Nageru;
if (HP > 0) {
tmp += (int)(HP / Tuyoi.Furu);
if (HP % Tuyoi.Furu > 0) {
tmp++;
}
}
subCnt += tmp;
}
int ans = cnt + subCnt;
ans = Math.Min(ans, cnt + (int)max);
Console.WriteLine(ans);
}
private long HP;
private List<Katana> KatanaList;
private Katana Tuyoi;
private class Katana {
public long Furu;
public long Nageru;
public bool CanUse = true;
public int ID;
public Katana(int id, long furu, long nageru) {
this.ID = id;
this.Furu = furu;
this.Nageru = nageru;
}
}
public class Reader {
private static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
5 500
35 44
28 83
46 62
31 79
40 43
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 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, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 12, 214, 141, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 729
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var M = sc.ReadInt();
var ans = 24 + 24 % (M == 0 ? 24 : M);
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var M = sc.ReadInt();
var ans = 24 + (24 - M);
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 12, 16, 31, 203], ["-", 0, 200, 0, 212, 0, 16, 12, 16, 17, 109], ["-", 12, 16, 12, 23, 0, 41, 15, 16, 31, 22], ["-", 12, 16, 12, 23, 0, 41, 15, 16, 17, 60], ["-", 12, 16, 12, 23, 0, 41, 15, 16, 12, 203], ["-", 0, 16, 12, 16, 12, 23, 0, 41, 0, 101], ["-", 0, 16, 12, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 17, 33]]
| 8
| 1,034
| 8
|
using System;
class Program {
static void Main(string[] args) {
String[] tmp = Console.ReadLine().Split(' ');
try {
int A = int.Parse(tmp[0]);
int B = int.Parse(tmp[1]);
String[] S = Console.ReadLine().Split('-');
String S_a = S[0];
String S_b = S[1];
int check = int.Parse(S_a);
check = int.Parse(S_b);
Console.WriteLine("Yes");
} catch (Exception e) {
Console.WriteLine("No");
}
// System.Threading.Thread.Sleep(5000);
}
}
|
using System;
class Program {
static void Main(string[] args) {
String[] tmp = Console.ReadLine().Split(' ');
try {
int A = int.Parse(tmp[0]);
int B = int.Parse(tmp[1]);
String[] S = Console.ReadLine().Split('-');
String S_a = S[0];
String S_b = S[1];
int check = int.Parse(S_a);
check = int.Parse(S_b);
if (S_a.Length == A)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
} catch (Exception e) {
Console.WriteLine("No");
}
// System.Threading.Thread.Sleep(5000);
}
}
|
[["+", 8, 196, 0, 246, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 246, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 246, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 246, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 246, 8, 196, 0, 57, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 246, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 246, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 144
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp11 {
class Program {
static void Main(string[] args) {
int[] AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
string S = Console.ReadLine();
string ans = "Yes";
if (AB[0] + AB[1] + 1 == S.Length) {
if (S[AB[0]] == '-') {
for (int i = 0; i < S.Length; i++) {
switch (S[i]) {
case '0':
break;
case '1':
break;
case '2':
break;
case '3':
break;
case '4':
break;
case '5':
break;
case '6':
break;
case '7':
break;
case '8':
break;
case '9':
break;
default:
ans = "No";
break;
}
}
} else {
ans = "No";
}
} else {
ans = "No";
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp11 {
class Program {
static void Main(string[] args) {
int[] AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
string S = Console.ReadLine();
string ans = "Yes";
if (AB[0] + AB[1] + 1 == S.Length) {
if (S[AB[0]] == '-') {
for (int i = 0; i < S.Length; i++) {
if (AB[0] == i) {
continue;
}
switch (S[i]) {
case '0':
break;
case '1':
break;
case '2':
break;
case '3':
break;
case '4':
break;
case '5':
break;
case '6':
break;
case '7':
break;
case '8':
break;
case '9':
break;
default:
ans = "No";
break;
}
}
} else {
ans = "No";
}
} else {
ans = "No";
}
Console.WriteLine(ans);
}
}
}
|
[["+", 64, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 64, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 64, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 244
| 13
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var C = new long[N - 1];
var S = new long[N - 1];
var F = new long[N - 1];
for (long i = 0; i < N - 1; i++) {
C[i] = sc.ReadLong();
S[i] = sc.ReadLong();
F[i] = sc.ReadLong();
}
for (int i = 0; i < N; i++) {
var ans = 0L;
var now = i;
while (now != N - 1) {
if (S[now] > ans) {
ans = S[now] + C[now];
} else {
var tmp = ans - S[now];
tmp %= F[now];
ans += tmp + C[now];
}
now++;
}
Console.WriteLine(ans);
}
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var C = new long[N - 1];
var S = new long[N - 1];
var F = new long[N - 1];
for (long i = 0; i < N - 1; i++) {
C[i] = sc.ReadLong();
S[i] = sc.ReadLong();
F[i] = sc.ReadLong();
}
for (int i = 0; i < N; i++) {
var ans = 0L;
var now = i;
while (now != N - 1) {
if (S[now] > ans) {
ans = S[now] + C[now];
} else {
var tmp = ans % F[now];
ans += (F[now] - tmp) % F[now] + C[now];
}
now++;
}
Console.WriteLine(ans);
}
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 24], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 12, 204, 205, 22], ["+", 12, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 31, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 1,246
| 19
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
var n = int.Parse(Console.ReadLine());
int[] c = new int[n - 1];
int[] s = new int[n - 1];
int[] f = new int[n - 1];
for (int i = 0; i < n - 1; i++) {
int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
c[i] = tmp[0];
s[i] = tmp[1];
f[i] = tmp[2];
}
int[] ans = new int[n];
for (int i = 0; i < n; i++) {
if (i != n - 1) {
for (int k = i; k < n - 1; k++) {
// s秒経過したかを確認
if (ans[i] < s[k]) {
if (ans[i] == 0) {
ans[i] += c[k] + s[k];
} else {
ans[i] += c[k] + s[k] - ans[i];
}
} else {
ans[i] += c[k] + (ans[i] - s[k]) % f[k];
}
}
}
}
// 出力
for (int i = 0; i < n; i++) {
Console.WriteLine(ans[i]);
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
var n = int.Parse(Console.ReadLine());
int[] c = new int[n - 1];
int[] s = new int[n - 1];
int[] f = new int[n - 1];
for (int i = 0; i < n - 1; i++) {
int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
c[i] = tmp[0];
s[i] = tmp[1];
f[i] = tmp[2];
}
int[] ans = new int[n];
for (int i = 0; i < n; i++) {
if (i != n - 1) {
for (int k = i; k < n - 1; k++) {
// s秒経過したかを確認
if (ans[i] < s[k]) {
if (ans[i] == 0) {
ans[i] += c[k] + s[k];
} else {
ans[i] += c[k] + s[k] - ans[i];
}
} else {
ans[i] += c[k] + ((f[k] - (ans[i] % f[k])) + (s[k] % f[k])) % f[k];
;
}
}
}
}
// 出力
for (int i = 0; i < n; i++) {
Console.WriteLine(ans[i]);
}
}
}
|
[["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 16, 12, 23, 0, 16, 12, 204, 205, 22], ["+", 12, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 345
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999999;
public class Station {
public int Start { get; set; }
public int Cycle { get; set; }
public int Cost { get; set; }
}
public static void Main(string[] args) {
var n = Console.ReadLine().ToInt();
var stations = new Station[n - 1];
for (int i = 0; i < n - 1; i++) {
var p = Input().ToInt();
var st = new Station() { Cost = p[0], Start = p[1], Cycle = p[2] };
stations[i] = st;
}
for (int j = 0; j < n; j++) {
long time = 0;
for (int i = j; i < n - 1; i++) {
if (time < stations[i].Start) {
time = stations[i].Start;
} else if (time % stations[i].Cycle != 0) {
time += time % stations[i].Cycle;
}
time += stations[i].Cost;
}
Console.WriteLine(time);
}
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999999;
public class Station {
public int Start { get; set; }
public int Cycle { get; set; }
public int Cost { get; set; }
}
public static void Main(string[] args) {
var n = Console.ReadLine().ToInt();
var stations = new Station[n - 1];
for (int i = 0; i < n - 1; i++) {
var p = Input().ToInt();
var st = new Station() { Cost = p[0], Start = p[1], Cycle = p[2] };
stations[i] = st;
}
for (int j = 0; j < n; j++) {
long time = 0;
for (int i = j; i < n - 1; i++) {
if (time < stations[i].Start) {
time = stations[i].Start;
} else if (time % stations[i].Cycle != 0) {
time += (stations[i].Cycle - time % stations[i].Cycle);
}
time += stations[i].Cost;
}
Console.WriteLine(time);
}
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
[["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 214, 205, 204, 205, 22], ["+", 0, 16, 31, 214, 205, 204, 206, 207, 0, 70], ["+", 31, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 31, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 23, 0, 16, 31, 214, 0, 131], ["+", 0, 11, 12, 23, 0, 16, 31, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 25]]
| 8
| 471
| 9
|
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) {
int n = int.Parse(Console.ReadLine());
var csf = new CSF[n];
for (int i = 0; i < n - 1; i++) {
var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
csf[i] = new CSF { C = temp[0], S = temp[1], F = temp[2] };
}
var sb = new StringBuilder();
for (int i = 0; i < n; i++) {
int time = 0;
for (int j = i; j < n - 1; j++) {
if (time <= csf[j].S) {
time = csf[j].S + csf[j].C;
} else {
time = (time + csf[j].F - 1) / csf[j].F + csf[j].C;
}
}
sb.AppendLine(time.ToString());
}
Console.WriteLine(sb.ToString());
}
public struct CSF {
public int C { get; set; }
public int S { get; set; }
public int F { get; set; }
}
}
}
|
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) {
int n = int.Parse(Console.ReadLine());
var csf = new CSF[n];
for (int i = 0; i < n - 1; i++) {
var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
csf[i] = new CSF { C = temp[0], S = temp[1], F = temp[2] };
}
var sb = new StringBuilder();
for (int i = 0; i < n; i++) {
int time = 0;
for (int j = i; j < n - 1; j++) {
if (time <= csf[j].S) {
time = csf[j].S + csf[j].C;
} else {
time = (time + csf[j].F - 1) / csf[j].F * csf[j].F + csf[j].C;
}
}
sb.AppendLine(time.ToString());
}
Console.WriteLine(sb.ToString());
}
public struct CSF {
public int C { get; set; }
public int S { get; set; }
public int F { get; set; }
}
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 12, 16, 31, 16, 12, 214, 205, 204, 205, 22], ["+", 31, 16, 12, 214, 205, 204, 206, 207, 0, 70], ["+", 12, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 16, 12, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 16, 31, 16, 12, 214, 0, 131], ["+", 0, 11, 12, 16, 31, 16, 12, 214, 141, 22]]
| 8
| 322
| 7
|
using System;
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Split(' ');
var min = 0;
int[] AA = new int[210];
int[] count = new int[210];
for (int i = 0; i < N; ++i) {
AA[i] = int.Parse(A[i]);
while (AA[i] % 2 == 0 && AA[i] != 0) {
AA[i] /= 2;
++count[i];
}
min = count[0];
if (min >= count[i]) {
min = count[i];
}
}
Console.WriteLine(min);
}
}
|
using System;
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Split(' ');
var min = 1000;
int[] AA = new int[210];
int[] count = new int[210];
for (int i = 0; i < N; ++i) {
AA[i] = int.Parse(A[i]);
while (AA[i] % 2 == 0 && AA[i] != 0) {
AA[i] /= 2;
++count[i];
}
if (min > count[i]) {
min = count[i];
}
// Console.WriteLine("count" + count[i] + ", ");
// Console.WriteLine("min" + min);
}
Console.WriteLine(min);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 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, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47]]
| 8
| 171
| 11
|
using System;
class Program {
static void Main() {
int divideNum = int.Parse(Console.ReadLine()); //割られる数
int[] numbers = new int[divideNum];
int divideCount = 0; //割った回数
int divideSource = 2; //割る数
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
for (int i = 0; i < input.Length; i++) {
numbers[i] = int.Parse(input[i]);
}
while (true) {
for (int i = 0; i < input.Length; i++) {
if (!(numbers[i] % divideSource == 0)) {
break;
}
}
divideSource *= 2;
divideCount++;
}
Console.WriteLine(divideCount);
}
}
|
using System;
class Program {
static void Main() {
int breakb = 0;
int divideNum = int.Parse(Console.ReadLine()); //割られる数
int[] numbers = new int[divideNum];
int divideCount = 0; //割った回数
int divideSource = 2; //割る数
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
for (int i = 0; i < input.Length; i++) {
numbers[i] = int.Parse(input[i]);
}
while (true) {
for (int i = 0; i < input.Length; i++) {
if (!(numbers[i] % divideSource == 0)) {
breakb = 1;
}
}
if (breakb == 1)
break;
else {
divideSource *= 2;
divideCount++;
}
}
Console.WriteLine(divideCount);
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 35], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 95], ["+", 0, 52, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 160
| 20
|
using System;
namespace ConsoleApp6 {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string[] s = Console.ReadLine().Split();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = int.Parse(s[i]);
}
int cnt = 0;
int m = 0;
while ((a[m] % 2) == 0) {
a[m] /= 2;
m++;
if (m == n) {
cnt++;
m = 0;
foreach (int x in a)
Console.Write(x + " ");
Console.WriteLine();
}
}
Console.WriteLine(cnt);
}
}
}
|
using System;
namespace ConsoleApp6 {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string[] s = Console.ReadLine().Split();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = int.Parse(s[i]);
}
int cnt = 0;
int m = 0;
while ((a[m] % 2) == 0) {
a[m] /= 2;
m++;
if (m == n) {
cnt++;
m = 0;
}
}
Console.WriteLine(cnt);
}
}
}
|
[["-", 8, 196, 0, 57, 64, 196, 0, 210, 0, 266], ["-", 8, 196, 0, 57, 64, 196, 0, 210, 0, 24], ["-", 8, 196, 0, 57, 64, 196, 0, 210, 39, 199], ["-", 8, 196, 0, 57, 64, 196, 0, 210, 31, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 210, 0, 267], ["-", 8, 196, 0, 57, 64, 196, 0, 210, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 210, 0, 25], ["-", 0, 210, 8, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 210, 8, 1, 0, 213, 63, 214, 0, 131], ["-", 0, 210, 8, 1, 0, 213, 63, 214, 141, 22], ["-", 0, 210, 8, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 16, 12, 5, 0, 62], ["-", 3, 4, 0, 28, 0, 16, 12, 5, 0, 222], ["-", 0, 210, 8, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 210, 8, 1, 0, 35], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 174
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace TestApp {
class Program {
static void Main(string[] args) {
Console.ReadLine();
var str = Console.ReadLine()
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x.ToString()))
.ToList();
var count = 0;
while (true) {
var isCan = false;
foreach (var item in str) {
if (item % 2 == 1)
break;
isCan = true;
}
if (isCan) {
str = str.Select(x => x / 2).ToList();
count++;
} else
break;
}
Console.WriteLine(count);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace TestApp {
class Program {
static void Main(string[] args) {
Console.ReadLine();
var str = Console.ReadLine()
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x.ToString()))
.ToList();
var count = 0;
while (true) {
var isCan = true;
foreach (var item in str) {
if (item % 2 == 1) {
isCan = false;
break;
}
}
if (isCan) {
str = str.Select(x => x / 2).ToList();
count++;
} else
break;
}
Console.WriteLine(count);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["-", 0, 210, 8, 196, 0, 57, 64, 93, 0, 94], ["-", 0, 210, 8, 196, 0, 57, 64, 93, 0, 35], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 160
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var K = sc.ReadInt();
var A = sc.ReadIntArray(N);
var group = A.GroupBy(x => x).ToArray();
if (K - group.Length >= 0) {
Console.WriteLine(K - group.Length);
} else {
var count = group.Length - K;
var ans = 0;
foreach (var g in group.OrderBy(x => x.Count())) {
if (count == 0)
break;
count--;
ans += g.Count();
}
Console.WriteLine(ans);
}
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var K = sc.ReadInt();
var A = sc.ReadIntArray(N);
var group = A.GroupBy(x => x).ToArray();
if (group.Length <= K) {
Console.WriteLine(0);
} else {
var count = group.Length - K;
var ans = 0;
foreach (var g in group.OrderBy(x => x.Count())) {
if (count == 0)
break;
count--;
ans += g.Count();
}
Console.WriteLine(ans);
}
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 28, 0, 16, 12, 214, 205, 22, 0, 327], ["-", 3, 4, 0, 28, 0, 16, 12, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 16, 12, 214, 141, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 1,131
| 12
|
using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
int n = int.Parse(input[0]);
int k = int.Parse(input[1]);
int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
int[] howmany = new int[200000]; //各数字はいくつか
int answer = 0;
for (int i = 1; i < nums.Length; i++) {
howmany[nums[i]]++; //数える
}
Array.Sort(howmany);
for (int i = k; i < nums.Length; i++) {
answer += howmany[i];
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
int n = int.Parse(input[0]);
int k = int.Parse(input[1]);
int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
int[] howmany = new int[200001]; //各数字はいくつか
int answer = 0;
for (int i = 0; i < nums.Length; i++) {
howmany[nums[i]]++; //数える
}
Array.Sort(howmany);
for (int i = 200000 - k; i >= 0; i--) {
answer += howmany[i];
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
}
|
[["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68]]
| 8
| 171
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC080A {
class Program {
static void Main(string[] args) {
int n, a, b, p1, p2, x;
var word = Console.ReadLine().Split(' ');
n = int.Parse(word[0]);
a = int.Parse(word[1]);
b = int.Parse(word[2]);
p1 = n * a;
p2 = b;
if (n * a > b)
x = p2;
else if (p1 < p2)
x = p1;
else
x = 0;
Console.WriteLine(x);
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC080A {
class Program {
static void Main(string[] args) {
int n, a, b, p1, p2, x;
var word = Console.ReadLine().Split(' ');
n = int.Parse(word[0]);
a = int.Parse(word[1]);
b = int.Parse(word[2]);
p1 = n * a;
p2 = b;
if (p1 < p2)
x = p1;
else
x = p2;
Console.WriteLine(x);
Console.ReadKey();
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["-", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["-", 0, 57, 75, 57, 75, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 12, 22]]
| 8
| 162
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC080A {
class Program {
static void Main(string[] args) {
int n, a, b, p1, p2, x;
var word = Console.ReadLine().Split(' ');
n = int.Parse(word[0]);
a = int.Parse(word[1]);
b = int.Parse(word[2]);
p1 = x = a * n;
p2 = x = b;
Console.WriteLine(x);
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC080A {
class Program {
static void Main(string[] args) {
int n, a, b, p1, p2, x;
var word = Console.ReadLine().Split(' ');
n = int.Parse(word[0]);
a = int.Parse(word[1]);
b = int.Parse(word[2]);
if (a * n < b)
x = a * n;
else
x = b;
Console.WriteLine(x);
Console.ReadKey();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 138
| 13
|
#pragma warning disable
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
static class MainClass {
public static void Main() {
var nab = Console.ReadLine().SplittedStringToInt32List();
Console.WriteLine(nab[0] * nab[1] >= nab[2] ? nab[2] : nab[0] * nab[2]);
}
#region ライブラリ
#region 二分探索
public static int LowerBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int LowerBound<T>(this IEnumerable<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
public static int UpperBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(this IEnumerable<T> arr, T value) {
return UpperBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
#endregion
#region bit全探索
/// <summary>
/// Bit全探索用のライブラリ
/// </summary>
/// <param name="len">作る配列の長さ(lenが0以下だと(ry)</param>
/// <returns>できた配列</returns>
public static List<List<bool>> CreateBits(int len) {
return CreateBitsPri(new List<List<bool>>(), len, 0);
}
private static List<List<bool>> CreateBitsPri(List<List<bool>> bits, int len,
int count) {
if (count == 0) {
var lss = new List<bool>();
lss.Add(true);
bits.Add(lss);
var lx = new List<bool>();
lx.Add(false);
bits.Add(lx);
count++;
return CreateBitsPri(bits, len, count);
}
if (len - count == 0)
return bits;
count++;
var ls = new List<List<bool>>();
foreach (var item in bits) {
var x = item.ToList();
x.Add(true);
item.Add(false);
ls.Add(item);
ls.Add(x);
}
return CreateBitsPri(ls, len, count);
}
#endregion
#region 文字列処理
public static int ToInt32(this string str) { return int.Parse(str); }
public static List<string> SplittedStringToList(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.ToList();
}
public static List<int> SplittedStringToInt32List(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x))
.ToList();
}
#endregion
#region エラトステネスの篩
/**
* MIT License
Copyright (c) 2018 gushwell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**/
public class BoundedBoolArray {
private BitArray _array;
private int _lower;
public BoundedBoolArray(int lower, int upper) {
_array = new BitArray(upper - lower + 1);
_lower = lower;
}
public bool this[int index] {
get { return _array[index - _lower]; }
set { _array[index - _lower] = value; }
}
}
public static IEnumerable<int> GeneratePrimes() {
var primes = new List<int>() { 2, 3 };
foreach (var p in primes)
yield return p;
int ix = 0;
while (true) {
int prime1st = primes[ix];
int prime2nd = primes[++ix];
var lower = prime1st * prime1st;
var upper = prime2nd * prime2nd - 1;
var sieve = new BoundedBoolArray(lower, upper);
foreach (var prime in primes.Take(ix)) {
var start = (int)Math.Ceiling((double)lower / prime) * prime;
for (int index = start; index <= upper; index += prime)
sieve[index] = true;
}
for (int i = lower; i <= upper; i++) {
if (sieve[i] == false) {
primes.Add(i);
yield return i;
}
}
}
}
#endregion
#region DeepClone
public static T DeepClone<T>(this T src) {
using (var memoryStream = new MemoryStream()) {
var binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src);
memoryStream.Seek(0, SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream);
}
}
#endregion
#region 順列を作るやつ
public static List<List<int>> GeneratePermutations(int n) {
if (n > 14)
throw new ArgumentOutOfRangeException();
var ls = new List<List<int>>();
ls.Add(new List<int>() { 1 });
for (int i = 0; i < n - 1; i++) {
var newls = new List<List<int>>();
ls.ForEach(x => {
var len = x.Count;
for (int j = 0; j <= len; j++) {
var item = x.DeepClone();
item.Insert(j, i + 2);
newls.Add(item);
}
});
ls = newls;
}
return ls;
}
#endregion
#endregion
}
|
#pragma warning disable
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
static class MainClass {
public static void Main() {
var nab = Console.ReadLine().SplittedStringToInt32List();
Console.WriteLine(nab[0] * nab[1] >= nab[2] ? nab[2] : nab[0] * nab[1]);
Console.ReadLine();
}
#region ライブラリ
#region 二分探索
public static int LowerBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int LowerBound<T>(this IEnumerable<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
public static int UpperBound<T>(this IEnumerable<T> ar, int start, int end,
T value, IComparer<T> comparer) {
var arr = ar.ToArray();
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(this IEnumerable<T> arr, T value) {
return UpperBound(arr, 0, arr.Count(), value, Comparer<T>.Default);
}
#endregion
#region bit全探索
/// <summary>
/// Bit全探索用のライブラリ
/// </summary>
/// <param name="len">作る配列の長さ(lenが0以下だと(ry)</param>
/// <returns>できた配列</returns>
public static List<List<bool>> CreateBits(int len) {
return CreateBitsPri(new List<List<bool>>(), len, 0);
}
private static List<List<bool>> CreateBitsPri(List<List<bool>> bits, int len,
int count) {
if (count == 0) {
var lss = new List<bool>();
lss.Add(true);
bits.Add(lss);
var lx = new List<bool>();
lx.Add(false);
bits.Add(lx);
count++;
return CreateBitsPri(bits, len, count);
}
if (len - count == 0)
return bits;
count++;
var ls = new List<List<bool>>();
foreach (var item in bits) {
var x = item.ToList();
x.Add(true);
item.Add(false);
ls.Add(item);
ls.Add(x);
}
return CreateBitsPri(ls, len, count);
}
#endregion
#region 文字列処理
public static int ToInt32(this string str) { return int.Parse(str); }
public static List<string> SplittedStringToList(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.ToList();
}
public static List<int> SplittedStringToInt32List(this string str) {
return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x))
.ToList();
}
#endregion
#region エラトステネスの篩
/**
* MIT License
Copyright (c) 2018 gushwell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**/
public class BoundedBoolArray {
private BitArray _array;
private int _lower;
public BoundedBoolArray(int lower, int upper) {
_array = new BitArray(upper - lower + 1);
_lower = lower;
}
public bool this[int index] {
get { return _array[index - _lower]; }
set { _array[index - _lower] = value; }
}
}
public static IEnumerable<int> GeneratePrimes() {
var primes = new List<int>() { 2, 3 };
foreach (var p in primes)
yield return p;
int ix = 0;
while (true) {
int prime1st = primes[ix];
int prime2nd = primes[++ix];
var lower = prime1st * prime1st;
var upper = prime2nd * prime2nd - 1;
var sieve = new BoundedBoolArray(lower, upper);
foreach (var prime in primes.Take(ix)) {
var start = (int)Math.Ceiling((double)lower / prime) * prime;
for (int index = start; index <= upper; index += prime)
sieve[index] = true;
}
for (int i = lower; i <= upper; i++) {
if (sieve[i] == false) {
primes.Add(i);
yield return i;
}
}
}
}
#endregion
#region DeepClone
public static T DeepClone<T>(this T src) {
using (var memoryStream = new MemoryStream()) {
var binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src);
memoryStream.Seek(0, SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream);
}
}
#endregion
#region 順列を作るやつ
public static List<List<int>> GeneratePermutations(int n) {
if (n > 14)
throw new ArgumentOutOfRangeException();
var ls = new List<List<int>>();
ls.Add(new List<int>() { 1 });
for (int i = 0; i < n - 1; i++) {
var newls = new List<List<int>>();
ls.ForEach(x => {
var len = x.Count;
for (int j = 0; j <= len; j++) {
var item = x.DeepClone();
item.Insert(j, i + 2);
newls.Add(item);
}
});
ls = newls;
}
return ls;
}
#endregion
#endregion
}
|
[["-", 75, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 75, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
| 8
| 1,263
| 8
|
using System;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int a = int.Parse(input[1]);
int b = int.Parse(input[2]);
if (a * n <= b)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int a = int.Parse(input[1]);
int b = int.Parse(input[2]);
if (a * n <= b)
Console.WriteLine("{0}", a * n);
else
Console.WriteLine("{0}", b);
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 21], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 102
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
Console.WriteLine(n % sum == 0 ? "Yes" : "No");
}
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 AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int x = n;
int sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
Console.WriteLine(n % sum == 0 ? "Yes" : "No");
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22]]
| 8
| 385
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
string S = cin.next();
int N = 0;
double ans = 0;
string A = "No";
for (int i = 0; i < S.Length; i++) {
ans += double.Parse(S[i].ToString()) * Math.Pow(10, (double)i);
N += int.Parse(S[i].ToString());
}
if (ans % N == 0)
A = "Yes";
Console.WriteLine(A);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
string S = cin.next();
int N = 0;
double ans = 0;
string A = "No";
for (int i = 0; i < S.Length; i++) {
ans += double.Parse(S[i].ToString()) *
Math.Pow(10, (double)(S.Length - i - 1));
N += int.Parse(S[i].ToString());
}
if (ans % N == 0)
A = "Yes";
Console.WriteLine(A);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
[["+", 3, 4, 0, 28, 0, 74, 51, 23, 0, 24], ["+", 51, 23, 0, 16, 31, 16, 31, 214, 205, 22], ["+", 51, 23, 0, 16, 31, 16, 31, 214, 0, 131], ["+", 51, 23, 0, 16, 31, 16, 31, 214, 141, 22], ["+", 0, 74, 51, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 28, 0, 74, 51, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 74, 51, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 74, 51, 23, 0, 25]]
| 8
| 580
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var dump = Console.ReadLine();
var A = Console.ReadLine()
.Split(' ')
.Select(x => Convert.ToInt32(x))
.OrderBy(x => x)
.ToArray();
var dec = new Dictionary<int, int>();
var sum = 0;
foreach (var a in A) {
dec.Add(a, 0);
}
foreach (var a in A) {
dec[a]++;
}
foreach (var elem in dec) {
var key = elem.Key;
var value = elem.Value;
if (key == value) {
} else if (key > value) {
sum += value;
} else {
sum += (value - key);
}
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var dump = Console.ReadLine();
var tmp = Console.ReadLine()
.Split(' ')
.Select(x => Convert.ToInt32(x))
.OrderBy(x => x);
var A = tmp.ToArray();
var B = tmp.Distinct().ToArray();
var dec = new Dictionary<int, int>();
var sum = 0;
foreach (var a in B) {
dec.Add(a, 0);
}
foreach (var a in A) {
dec[a]++;
}
foreach (var elem in dec) {
var key = elem.Key;
var value = elem.Value;
if (key == value) {
} else if (key > value) {
sum += value;
} else {
sum += (value - key);
}
}
Console.WriteLine(sum);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22]]
| 8
| 200
| 22
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
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 void Solve() {
var S = GetStr().ToArray();
int X;
int Y;
Multi(out X, out Y);
X -= S.TakeWhile(t => t == 'F').Count();
S = S.SkipWhile(t => t == 'F').ToArray();
bool isx = true;
var xlen = new List<int>();
var ylen = new List<int>();
int cnt = 0;
for (int i = 0; i < S.Length; i++) {
if (i == 0 || S[i - 1] == S[i]) {
cnt++;
} else {
if (S[i] == 'T') {
if (isx)
xlen.Add(cnt);
else
ylen.Add(cnt);
cnt = 1;
} else {
if (cnt % 2 != 0) {
isx = !isx;
}
cnt = 1;
}
}
}
if (S.Any() && S.Last() == 'F') {
if (isx)
xlen.Add(cnt);
else
ylen.Add(cnt);
cnt = 1;
} else {
if (cnt % 2 != 0) {
isx = !isx;
cnt = 1;
}
}
var xset = new HashSet<int>();
xset.Add(0);
for (int i = 0; i < xlen.Count; i++) {
var tmp = new HashSet<int>();
foreach (var x in xset.SelectMany(
s => new int[] { s + xlen[i], s - xlen[i] })) {
tmp.Add(x);
}
}
var yset = new HashSet<int>();
yset.Add(0);
for (int i = 0; i < ylen.Count; i++) {
var tmp = new HashSet<int>();
foreach (var y in yset.SelectMany(
s => new int[] { s + ylen[i], s - ylen[i] })) {
tmp.Add(y);
}
}
var ans = (xset.Contains(X) && yset.Contains(Y)).YesNo();
Console.WriteLine(ans);
}
}
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;
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 void Solve() {
var S = GetStr().ToArray();
int X;
int Y;
Multi(out X, out Y);
X -= S.TakeWhile(t => t == 'F').Count();
S = S.SkipWhile(t => t == 'F').ToArray();
bool isx = true;
var xlen = new List<int>();
var ylen = new List<int>();
int cnt = 0;
for (int i = 0; i < S.Length; i++) {
if (i == 0 || S[i - 1] == S[i]) {
cnt++;
} else {
if (S[i] == 'T') {
if (isx)
xlen.Add(cnt);
else
ylen.Add(cnt);
cnt = 1;
} else {
if (cnt % 2 != 0) {
isx = !isx;
}
cnt = 1;
}
}
}
if (S.Any() && S.Last() == 'F') {
if (isx)
xlen.Add(cnt);
else
ylen.Add(cnt);
cnt = 1;
} else {
if (cnt % 2 != 0) {
isx = !isx;
cnt = 1;
}
}
var xset = new HashSet<int>();
xset.Add(0);
for (int i = 0; i < xlen.Count; i++) {
var tmp = new HashSet<int>();
foreach (var x in xset.SelectMany(
s => new int[] { s + xlen[i], s - xlen[i] })) {
tmp.Add(x);
}
xset = tmp;
}
var yset = new HashSet<int>();
yset.Add(0);
for (int i = 0; i < ylen.Count; i++) {
var tmp = new HashSet<int>();
foreach (var y in yset.SelectMany(
s => new int[] { s + ylen[i], s - ylen[i] })) {
tmp.Add(y);
}
yset = tmp;
}
var ans = (xset.Contains(X) && yset.Contains(Y)).YesNo();
Console.WriteLine(ans);
}
}
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, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 1,936
| 8
|
using System;
using System.Collections.Generic;
public class Test {
public static int goodSequence(int[] arr) {
int count = 0;
Dictionary<int, int> goodSeq = new Dictionary<int, int>();
for (int i = 0; i < arr.Length; i++) {
if (goodSeq.ContainsKey(arr[i]))
goodSeq[arr[i]]++;
else
goodSeq.Add(arr[i], 1);
}
foreach (var ele in goodSeq) {
if (ele.Value > ele.Key)
count += ele.Value - ele.Key;
}
return count;
}
public static void Main() {
// your code goes here
int n = Convert.ToInt32(Console.ReadLine());
string[] inp = Console.ReadLine().Split(' ');
int[] arr = new int[n];
for (int q = 0; q < n; q++) {
arr[q] = Convert.ToInt32(inp[q]);
}
Console.WriteLine(goodSequence(arr));
}
}
|
using System;
using System.Collections.Generic;
public class Test {
public static int goodSequence(int[] arr) {
int count = 0;
Dictionary<int, int> goodSeq = new Dictionary<int, int>();
for (int i = 0; i < arr.Length; i++) {
if (goodSeq.ContainsKey(arr[i]))
goodSeq[arr[i]]++;
else
goodSeq.Add(arr[i], 1);
}
foreach (var ele in goodSeq) {
if (ele.Value > ele.Key)
count += ele.Value - ele.Key;
else if (ele.Value != ele.Key)
count += ele.Value;
}
return count;
}
public static void Main() {
// your code goes here
int n = Convert.ToInt32(Console.ReadLine());
string[] inp = Console.ReadLine().Split(' ');
int[] arr = new int[n];
for (int q = 0; q < n; q++) {
arr[q] = Convert.ToInt32(inp[q]);
}
Console.WriteLine(goodSequence(arr));
}
}
|
[["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 95], ["+", 0, 210, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 210, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 214, 205, 22], ["+", 0, 57, 75, 57, 15, 16, 31, 214, 0, 131], ["+", 0, 57, 75, 57, 15, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 79], ["+", 0, 57, 75, 57, 15, 16, 12, 214, 205, 22], ["+", 0, 57, 75, 57, 15, 16, 12, 214, 0, 131], ["+", 0, 57, 75, 57, 15, 16, 12, 214, 141, 22], ["+", 0, 210, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 64, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 75, 57, 64, 1, 0, 11, 12, 214, 205, 22], ["+", 75, 57, 64, 1, 0, 11, 12, 214, 0, 131], ["+", 75, 57, 64, 1, 0, 11, 12, 214, 141, 22], ["+", 8, 196, 0, 57, 75, 57, 64, 1, 0, 35]]
| 8
| 227
| 17
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace ARC087C {
public class Program {
void Solve(StreamScanner ss, StreamWriter sw) {
//---------------------------------
var N = ss.Next(int.Parse);
var A = ss.Next(int.Parse, N);
var dic = new Dictionary<int, int>();
foreach (var a in A) {
if (dic.ContainsKey(a)) {
dic[a]++;
} else {
dic.Add(a, 1);
}
}
sw.WriteLine(dic.Sum(x => x.Value % x.Key));
//---------------------------------
}
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;
}
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 ARC087C {
public class Program {
void Solve(StreamScanner ss, StreamWriter sw) {
//---------------------------------
var N = ss.Next(int.Parse);
var A = ss.Next(int.Parse, N);
var dic = new Dictionary<int, int>();
foreach (var a in A) {
if (dic.ContainsKey(a)) {
dic[a]++;
} else {
dic.Add(a, 1);
}
}
sw.WriteLine(dic.Sum(x => x.Value >= x.Key ? x.Value - x.Key : x.Value));
//---------------------------------
}
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;
}
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;
}
}
}
|
[["-", 3, 4, 0, 28, 0, 218, 8, 16, 17, 109], ["+", 0, 28, 0, 218, 8, 41, 15, 16, 17, 20], ["+", 0, 218, 8, 41, 15, 16, 12, 214, 205, 22], ["+", 0, 218, 8, 41, 15, 16, 12, 214, 0, 131], ["+", 0, 218, 8, 41, 15, 16, 12, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 41, 0, 101], ["+", 0, 218, 8, 41, 64, 16, 31, 214, 205, 22], ["+", 0, 218, 8, 41, 64, 16, 31, 214, 0, 131], ["+", 0, 218, 8, 41, 64, 16, 31, 214, 141, 22], ["+", 0, 28, 0, 218, 8, 41, 64, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 218, 8, 41, 0, 102], ["+", 0, 28, 0, 218, 8, 41, 75, 214, 205, 22], ["+", 0, 28, 0, 218, 8, 41, 75, 214, 0, 131], ["+", 0, 28, 0, 218, 8, 41, 75, 214, 141, 22]]
| 8
| 462
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static _20200218.Cin;
using static _20200218.Util;
using Pair = _20200218.VTuple<long, long>;
using Graph =
System.Collections.Generic.List<System.Collections.Generic.List<long>>;
using System.Text;
namespace _20200218 {
public class Program {
public static void Main(string[] args) {
// A(); 15m
// B(); 21m
// C(); 32m
// D(); 43m
// E(); 67m
// F(); 92m
// G(); 110m
// ABC057_C();11m
// ABC142_D(); // 60m
ARC087_D();
}
public static void ARC087_D() {
string S = rs;
long x = rl;
long y = rl;
long N = S.Length;
const long MC = 8001;
bool[][] dp = new bool [2][];
dp[0] = new bool[MC];
dp[1] = new bool[MC];
dp[0][0] = true;
dp[1][0] = true;
int i = 0;
while (i < S.Length && S[i] == 'F')
i++;
x -= i;
if (Abs(x) > MC) {
Console.WriteLine("No");
return;
}
S += "T";
int turn = 0;
int cnt = 0;
bool[] tmp;
for (; i < N; i++) {
if (S[i] == 'F') {
cnt++;
} else {
if (cnt > 0) {
tmp = new bool[MC];
for (int j = 0; j < i; j++) {
if (!dp[turn][j])
continue;
tmp[j + cnt] = tmp[Abs(j - cnt)] = true;
}
Swap(ref dp[turn], ref tmp);
}
cnt = 0;
turn ^= 1;
}
}
string ans = "No";
if (dp[0][Abs(x)] && dp[1][Abs(y)]) {
ans = "Yes";
}
Console.WriteLine(ans);
}
public static void ABC142_D() {
long A = rl;
long B = rl;
List<long> primes = new List<long>();
primes.Add(1);
if (A % 2 == 0) {
primes.Add(2);
while (A % 2 == 0)
A /= 2;
}
for (long i = 3; i * i <= A; i += 2) {
if (A % i == 0) {
primes.Add(i);
while (A % i == 0)
A /= i;
}
}
if (A != 1)
primes.Add(A);
long ans = 0;
foreach (var p in primes) {
if (B % p == 0)
ans++;
}
Console.WriteLine(ans);
}
public static void ABC057_C() {
long N = rl;
long root = (long)Sqrt(N);
long A = 1;
for (int i = 2; i <= root; i++) {
if (N % i == 0) {
A = i;
}
}
long B = N / A;
long ans = 0;
while (B != 0) {
B /= 10;
ans++;
}
Console.WriteLine(ans);
}
public static void G() {
long N = rl;
long M = rl;
Graph G = new Graph();
for (int i = 0; i < N; i++) {
G.Add(new List<long>());
}
for (int i = 0; i < M; i++) {
int x = (int)rl - 1;
int y = (int)rl - 1;
G[x].Add(y);
}
int[] memo = new int[N + 1];
FillArray(memo, -1);
Func<int, int> rec = null;
rec = (v) => {
if (memo[v] != -1)
return memo[v];
if (!G[v].Any()) {
return memo[v] = 0;
}
long res = 0;
foreach (int nv in G[v]) {
ChMax(ref res, rec(nv) + 1);
};
return memo[v] = (int)res;
};
long ans = -1;
for (int i = 0; i < N; i++) {
ChMax(ref ans, rec(i));
}
Console.WriteLine(ans);
}
public static void F() {
string s = rs;
string t = rs;
long[,] dp = new long[s.Length + 1, t.Length + 1];
for (int i = 1; i <= s.Length; i++) {
for (int j = 1; j <= t.Length; j++) {
if (s[i - 1] == t[j - 1]) {
dp[i, j] = dp[i - 1, j - 1] + 1;
} else {
dp[i, j] = Max(dp[i - 1, j], dp[i, j - 1]);
}
}
}
// 復元
int x = s.Length;
int y = t.Length;
StringBuilder sb = new StringBuilder();
while (dp[x, y] != 0) {
while (dp[x - 1, y] == dp[x, y])
x--;
while (dp[x, y - 1] == dp[x, y])
y--;
x--;
y--;
sb.Append(s[x]);
}
string ans = string.Concat(sb.ToString().Reverse());
Console.WriteLine(ans);
}
public static void E() {
long N = rl;
long W = rl;
long[] w, v;
ReadCols(out w, out v, N);
long MAX_V = 1000 * N;
long[,] dp = new long[N + 1, MAX_V + 1];
FillArray(dp, INF);
dp[0, 0] = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j <= MAX_V; j++) {
if (j - v[i] < 0)
dp[i + 1, j] = dp[i, j];
else {
dp[i + 1, j] = Min(dp[i, j], dp[i, j - v[i]] + w[i]);
}
}
}
long ans = 0;
for (long i = 0; i <= MAX_V; i++) {
if (dp[N, i] <= W) {
ans = i;
}
}
Console.WriteLine(ans);
}
public static void D() {
long N = rl;
long W = rl;
long[] w, v;
ReadCols(out w, out v, N);
long[,] dp = new long[N + 1, W + 1];
for (int i = 0; i < N; i++) {
for (int j = 0; j <= W; j++) {
if (j - w[i] < 0) {
dp[i + 1, j] = dp[i, j];
} else {
dp[i + 1, j] = Max(dp[i, j], dp[i, j - w[i]] + v[i]);
}
}
}
Console.WriteLine(dp[N, W]);
}
public static void C() {
long N = rl;
long[] a, b, c;
ReadCols(out a, out b, out c, N);
long[,] dp = new long[N + 1, 3];
for (int i = 0; i < N; i++) {
dp[i + 1, 0] = Max(dp[i, 1], dp[i, 2]) + a[i];
dp[i + 1, 1] = Max(dp[i, 0], dp[i, 2]) + b[i];
dp[i + 1, 2] = Max(dp[i, 0], dp[i, 1]) + c[i];
}
long ans = Max(dp[N, 0], Max(dp[N, 1], dp[N, 2]));
Console.WriteLine(ans);
}
public static void B() {
long N = rl;
long K = rl;
long[] A = rla;
long[] dp = new long[N];
FillArray(dp, INF);
dp[0] = 0;
for (int i = 0; i < N - 1; i++) {
for (int j = 1; j <= K && i + j < N; j++) {
dp[i + j] = Min(dp[i + j], dp[i] + Abs(A[i + j] - A[i]));
}
}
Console.WriteLine(dp[N - 1]);
}
public static void A() {
long N = rl;
long[] A = rla;
long[] dp = new long[N];
FillArray(dp, INF);
dp[0] = 0;
for (int i = 0; i < N - 1; i++) {
dp[i + 1] = Min(dp[i + 1], dp[i] + Abs(A[i + 1] - A[i]));
if (i + 2 < N)
dp[i + 2] = dp[i] + Abs(A[i + 2] - A[i]);
}
Console.WriteLine(dp[N - 1]);
}
}
public class HashMap<K, V> : Dictionary<K, V> {
V i;
static Func<V> j =
System.Linq.Expressions.Expression
.Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V)))
.Compile();
public HashMap() {}
public HashMap(V a) { i = a; }
new public V this[K a] { get { V b;
if (TryGetValue(a, out b))
return b;
else
return base[a] = i != null ? i : j();
}
set { base[a] = value; }
}
}
public static class Util {
public static readonly long INF = (long)1e17;
public readonly static long MOD = (long)1e9 + 7;
public static void DontAutoFlush() {
var a = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(a);
}
public static void Flush() { Console.Out.Flush(); }
public static T[] Sort<T>(T[] a) {
Array.Sort<T>(a);
return a;
}
public static T[] SortDecend<T>(T[] a) {
Array.Sort<T>(a);
Array.Reverse(a);
return a;
}
public static void Swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public static long ModAdd(long a, long b) {
long c = a + b;
if (c >= MOD)
return c % MOD;
return c;
}
public static long ModMul(long a, long b) {
long c = a * b;
if (c >= MOD)
return c % MOD;
return c;
}
public static void ChModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static void ChModMul(ref long a, long b) {
a *= b;
if (a >= MOD)
a %= MOD;
}
public static void FillArray<T>(T[] a, T b) {
int c = a.Length;
for (int d = 0; d < c; d++)
a[d] = b;
}
public static void FillArray<T>(T[,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
for (int e = 0; e < c; e++)
for (int f = 0; f < d; f++) {
a[e, f] = b;
}
}
public static void FillArray<T>(T[,,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
int e = a.GetLength(2);
for (int f = 0; f < c; f++)
for (int g = 0; g < d; g++) {
for (int h = 0; h < e; h++) {
a[f, g, h] = b;
}
}
}
public static long[] Accumulate(long[] a) {
long[] b = new long[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
public static double[] Accumulate(double[] a) {
double[] b = new double[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
}
public static class Cin {
public static long rl {
get { return ReadLong(); }
}
public static long[] rla {
get { return ReadLongArray(); }
}
public static double rd {
get { return ReadDouble(); }
}
public static double[] rda {
get { return ReadDoubleArray(); }
}
public static string rs {
get { return ReadString(); }
}
public static int ReadInt() { return int.Parse(k()); }
public static long ReadLong() { return long.Parse(k()); }
public static double ReadDouble() { return double.Parse(k()); }
public static string ReadString() { return k(); }
public static int[] ReadIntArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static void ReadCols(out long[] a, out long[] b, long c) {
a = new long[c];
b = new long[c];
for (int d = 0; d < c; d++) {
a[d] = ReadLong();
b[d] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, out long[] c,
long d) {
a = new long[d];
b = new long[d];
c = new long[d];
for (int e = 0; e < d; e++) {
a[e] = ReadLong();
b[e] = ReadLong();
c[e] = ReadLong();
}
}
public static int[][] ReadIntTable(int a) {
i = null;
int[][] b = new int [a][];
for (int c = 0; c < a; c++)
b[c] = ReadIntArray();
return b;
}
public static long[][] ReadLongTable(long a) {
i = null;
long[][] b = new long [a][];
for (long c = 0; c < a; c++)
b[c] = ReadLongArray();
return b;
}
static string[] i { get; set; }
static int j { get; set; }
static string k() {
if (i == null || i.Length <= j) {
i = Console.ReadLine().Split(' ');
j = 0;
}
return i[j++];
}
}
public struct VTuple<T1, T2> : IComparable<VTuple<T1, T2>>,
IEquatable<VTuple<T1, T2>> {
public T1 First;
public T2 Second;
public VTuple(T1 a, T2 b) {
First = a;
Second = b;
}
public int CompareTo(VTuple<T1, T2> a) {
int b = Comparer<T1>.Default.Compare(First, a.First);
if (b != 0)
return b;
return Comparer<T2>.Default.Compare(Second, a.Second);
}
public override bool Equals(object a) {
return a is VTuple<T1, T2> && Equals((VTuple<T1, T2>)a);
}
public bool Equals(VTuple<T1, T2> a) {
return EqualityComparer<T1>.Default.Equals(First, a.First) &&
EqualityComparer<T2>.Default.Equals(Second, a.Second);
}
public override int GetHashCode() {
int a = First != null ? First.GetHashCode() : 0;
int b = Second != null ? Second.GetHashCode() : 0;
uint c = ((uint)a << 5) | ((uint)a >> 27);
return ((int)c + a) ^ b;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static _20200218.Cin;
using static _20200218.Util;
using Pair = _20200218.VTuple<long, long>;
using Graph =
System.Collections.Generic.List<System.Collections.Generic.List<long>>;
using System.Text;
namespace _20200218 {
public class Program {
public static void Main(string[] args) {
// A(); 15m
// B(); 21m
// C(); 32m
// D(); 43m
// E(); 67m
// F(); 92m
// G(); 110m
// ABC057_C();11m
// ABC142_D(); // 60m
ARC087_D();
}
public static void ARC087_D() {
string S = rs;
long x = rl;
long y = rl;
const long MC = 8001;
bool[][] dp = new bool [2][];
dp[0] = new bool[MC];
dp[1] = new bool[MC];
dp[0][0] = true;
dp[1][0] = true;
int i = 0;
while (i < S.Length && S[i] == 'F')
i++;
x -= i;
// 次の比較を解釈するのはちょっと難しい。
// 文字通り最初にTが出た時点で、Abs(x)+iがMCを超えてたら到達不可能という意味だが、これはどういうことか。
// 例えばi = 3000 で x = -6000(入力時は-3000)だった場合、Abs(x) +
// iは9000となり、
// これはまず右に30000進み、左に6000進み、合計で9000回進む必要があるということ。
// それは入力値の制限がMAX8000なのでどうあがいても無理。Abs(x) +
// iは移動に最低限必要な回数を表しているのだ。
// この行がないと境界値例外が出る。
if (Abs(x) + i >= MC) {
Console.WriteLine("No");
return;
}
S += "T";
int turn = 0;
int cnt = 0;
bool[] tmp;
for (; i < S.Length; i++) {
if (S[i] == 'F') {
cnt++;
} else {
if (cnt > 0) {
tmp = new bool[MC];
for (int j = 0; j < i; j++) {
if (!dp[turn][j])
continue;
tmp[j + cnt] = tmp[Abs(j - cnt)] = true;
}
dp[turn] = tmp;
}
cnt = 0;
turn ^= 1;
}
}
string ans = "No";
if (dp[0][Abs(x)] && dp[1][Abs(y)]) {
ans = "Yes";
}
Console.WriteLine(ans);
}
public static void ABC142_D() {
long A = rl;
long B = rl;
List<long> primes = new List<long>();
primes.Add(1);
if (A % 2 == 0) {
primes.Add(2);
while (A % 2 == 0)
A /= 2;
}
for (long i = 3; i * i <= A; i += 2) {
if (A % i == 0) {
primes.Add(i);
while (A % i == 0)
A /= i;
}
}
if (A != 1)
primes.Add(A);
long ans = 0;
foreach (var p in primes) {
if (B % p == 0)
ans++;
}
Console.WriteLine(ans);
}
public static void ABC057_C() {
long N = rl;
long root = (long)Sqrt(N);
long A = 1;
for (int i = 2; i <= root; i++) {
if (N % i == 0) {
A = i;
}
}
long B = N / A;
long ans = 0;
while (B != 0) {
B /= 10;
ans++;
}
Console.WriteLine(ans);
}
public static void G() {
long N = rl;
long M = rl;
Graph G = new Graph();
for (int i = 0; i < N; i++) {
G.Add(new List<long>());
}
for (int i = 0; i < M; i++) {
int x = (int)rl - 1;
int y = (int)rl - 1;
G[x].Add(y);
}
int[] memo = new int[N + 1];
FillArray(memo, -1);
Func<int, int> rec = null;
rec = (v) => {
if (memo[v] != -1)
return memo[v];
if (!G[v].Any()) {
return memo[v] = 0;
}
long res = 0;
foreach (int nv in G[v]) {
ChMax(ref res, rec(nv) + 1);
};
return memo[v] = (int)res;
};
long ans = -1;
for (int i = 0; i < N; i++) {
ChMax(ref ans, rec(i));
}
Console.WriteLine(ans);
}
public static void F() {
string s = rs;
string t = rs;
long[,] dp = new long[s.Length + 1, t.Length + 1];
for (int i = 1; i <= s.Length; i++) {
for (int j = 1; j <= t.Length; j++) {
if (s[i - 1] == t[j - 1]) {
dp[i, j] = dp[i - 1, j - 1] + 1;
} else {
dp[i, j] = Max(dp[i - 1, j], dp[i, j - 1]);
}
}
}
// 復元
int x = s.Length;
int y = t.Length;
StringBuilder sb = new StringBuilder();
while (dp[x, y] != 0) {
while (dp[x - 1, y] == dp[x, y])
x--;
while (dp[x, y - 1] == dp[x, y])
y--;
x--;
y--;
sb.Append(s[x]);
}
string ans = string.Concat(sb.ToString().Reverse());
Console.WriteLine(ans);
}
public static void E() {
long N = rl;
long W = rl;
long[] w, v;
ReadCols(out w, out v, N);
long MAX_V = 1000 * N;
long[,] dp = new long[N + 1, MAX_V + 1];
FillArray(dp, INF);
dp[0, 0] = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j <= MAX_V; j++) {
if (j - v[i] < 0)
dp[i + 1, j] = dp[i, j];
else {
dp[i + 1, j] = Min(dp[i, j], dp[i, j - v[i]] + w[i]);
}
}
}
long ans = 0;
for (long i = 0; i <= MAX_V; i++) {
if (dp[N, i] <= W) {
ans = i;
}
}
Console.WriteLine(ans);
}
public static void D() {
long N = rl;
long W = rl;
long[] w, v;
ReadCols(out w, out v, N);
long[,] dp = new long[N + 1, W + 1];
for (int i = 0; i < N; i++) {
for (int j = 0; j <= W; j++) {
if (j - w[i] < 0) {
dp[i + 1, j] = dp[i, j];
} else {
dp[i + 1, j] = Max(dp[i, j], dp[i, j - w[i]] + v[i]);
}
}
}
Console.WriteLine(dp[N, W]);
}
public static void C() {
long N = rl;
long[] a, b, c;
ReadCols(out a, out b, out c, N);
long[,] dp = new long[N + 1, 3];
for (int i = 0; i < N; i++) {
dp[i + 1, 0] = Max(dp[i, 1], dp[i, 2]) + a[i];
dp[i + 1, 1] = Max(dp[i, 0], dp[i, 2]) + b[i];
dp[i + 1, 2] = Max(dp[i, 0], dp[i, 1]) + c[i];
}
long ans = Max(dp[N, 0], Max(dp[N, 1], dp[N, 2]));
Console.WriteLine(ans);
}
public static void B() {
long N = rl;
long K = rl;
long[] A = rla;
long[] dp = new long[N];
FillArray(dp, INF);
dp[0] = 0;
for (int i = 0; i < N - 1; i++) {
for (int j = 1; j <= K && i + j < N; j++) {
dp[i + j] = Min(dp[i + j], dp[i] + Abs(A[i + j] - A[i]));
}
}
Console.WriteLine(dp[N - 1]);
}
public static void A() {
long N = rl;
long[] A = rla;
long[] dp = new long[N];
FillArray(dp, INF);
dp[0] = 0;
for (int i = 0; i < N - 1; i++) {
dp[i + 1] = Min(dp[i + 1], dp[i] + Abs(A[i + 1] - A[i]));
if (i + 2 < N)
dp[i + 2] = dp[i] + Abs(A[i + 2] - A[i]);
}
Console.WriteLine(dp[N - 1]);
}
}
public class HashMap<K, V> : Dictionary<K, V> {
V i;
static Func<V> j =
System.Linq.Expressions.Expression
.Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V)))
.Compile();
public HashMap() {}
public HashMap(V a) { i = a; }
new public V this[K a] { get { V b;
if (TryGetValue(a, out b))
return b;
else
return base[a] = i != null ? i : j();
}
set { base[a] = value; }
}
}
public static class Util {
public static readonly long INF = (long)1e17;
public readonly static long MOD = (long)1e9 + 7;
public static void DontAutoFlush() {
var a = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(a);
}
public static void Flush() { Console.Out.Flush(); }
public static T[] Sort<T>(T[] a) {
Array.Sort<T>(a);
return a;
}
public static T[] SortDecend<T>(T[] a) {
Array.Sort<T>(a);
Array.Reverse(a);
return a;
}
public static void Swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public static long ModAdd(long a, long b) {
long c = a + b;
if (c >= MOD)
return c % MOD;
return c;
}
public static long ModMul(long a, long b) {
long c = a * b;
if (c >= MOD)
return c % MOD;
return c;
}
public static void ChModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static void ChModMul(ref long a, long b) {
a *= b;
if (a >= MOD)
a %= MOD;
}
public static void FillArray<T>(T[] a, T b) {
int c = a.Length;
for (int d = 0; d < c; d++)
a[d] = b;
}
public static void FillArray<T>(T[,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
for (int e = 0; e < c; e++)
for (int f = 0; f < d; f++) {
a[e, f] = b;
}
}
public static void FillArray<T>(T[,,] a, T b) {
int c = a.GetLength(0);
int d = a.GetLength(1);
int e = a.GetLength(2);
for (int f = 0; f < c; f++)
for (int g = 0; g < d; g++) {
for (int h = 0; h < e; h++) {
a[f, g, h] = b;
}
}
}
public static long[] Accumulate(long[] a) {
long[] b = new long[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
public static double[] Accumulate(double[] a) {
double[] b = new double[a.Length + 1];
for (int c = 0; c < a.Length; c++)
b[c + 1] = b[c] + a[c];
return b;
}
}
public static class Cin {
public static long rl {
get { return ReadLong(); }
}
public static long[] rla {
get { return ReadLongArray(); }
}
public static double rd {
get { return ReadDouble(); }
}
public static double[] rda {
get { return ReadDoubleArray(); }
}
public static string rs {
get { return ReadString(); }
}
public static int ReadInt() { return int.Parse(k()); }
public static long ReadLong() { return long.Parse(k()); }
public static double ReadDouble() { return double.Parse(k()); }
public static string ReadString() { return k(); }
public static int[] ReadIntArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
i = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static void ReadCols(out long[] a, out long[] b, long c) {
a = new long[c];
b = new long[c];
for (int d = 0; d < c; d++) {
a[d] = ReadLong();
b[d] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, out long[] c,
long d) {
a = new long[d];
b = new long[d];
c = new long[d];
for (int e = 0; e < d; e++) {
a[e] = ReadLong();
b[e] = ReadLong();
c[e] = ReadLong();
}
}
public static int[][] ReadIntTable(int a) {
i = null;
int[][] b = new int [a][];
for (int c = 0; c < a; c++)
b[c] = ReadIntArray();
return b;
}
public static long[][] ReadLongTable(long a) {
i = null;
long[][] b = new long [a][];
for (long c = 0; c < a; c++)
b[c] = ReadLongArray();
return b;
}
static string[] i { get; set; }
static int j { get; set; }
static string k() {
if (i == null || i.Length <= j) {
i = Console.ReadLine().Split(' ');
j = 0;
}
return i[j++];
}
}
public struct VTuple<T1, T2> : IComparable<VTuple<T1, T2>>,
IEquatable<VTuple<T1, T2>> {
public T1 First;
public T2 Second;
public VTuple(T1 a, T2 b) {
First = a;
Second = b;
}
public int CompareTo(VTuple<T1, T2> a) {
int b = Comparer<T1>.Default.Compare(First, a.First);
if (b != 0)
return b;
return Comparer<T2>.Default.Compare(Second, a.Second);
}
public override bool Equals(object a) {
return a is VTuple<T1, T2> && Equals((VTuple<T1, T2>)a);
}
public bool Equals(VTuple<T1, T2> a) {
return EqualityComparer<T1>.Default.Equals(First, a.First) &&
EqualityComparer<T2>.Default.Equals(Second, a.Second);
}
public override int GetHashCode() {
int a = First != null ? First.GetHashCode() : 0;
int b = Second != null ? Second.GetHashCode() : 0;
uint c = ((uint)a << 5) | ((uint)a >> 27);
return ((int)c + a) ^ b;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 275], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25]]
| 8
| 3,842
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var str = ReadLine();
var xy = Input.ar;
var li = new[] { new List<int>(), new List<int>() };
var s = str.Trim().Split('T');
for (var i = 0; i < s.Length; i++)
if (i % 2 == 0)
li[0].Add(s[i].Length);
else
li[1].Add(s[i].Length);
for (var i = 0; i < 2; i++) {
var dp = Enumerable.Repeat(0, li[i].Count)
.Select(v => new HashSet<int>())
.ToArray();
if (i == 0)
dp[0].Add(li[i][0]);
else {
dp[0].Add(li[i][0]);
dp[0].Add(-li[i][0]);
}
for (var j = 1; j < li[i].Count; j++)
for (var h = -str.Length; h <= str.Length; h++)
if (dp[j - 1].Contains(h)) {
if (-str.Length <= h - li[i][j])
dp[j].Add(h - li[i][j]);
if (str.Length >= h + li[i][j])
dp[j].Add(h + li[i][j]);
}
if (!dp[li[i].Count - 1].Contains(xy[i])) {
WriteLine("No");
return;
}
}
WriteLine("Yes");
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static string[] gred(int h) =>
Enumerable.Repeat(0, h).Select(v => read).ToArray();
public static int[][] twodim(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] twodimL(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const long Inf = (long)1e18;
public const double eps = 1e-11;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var str = ReadLine();
var xy = Input.ar;
var li = new[] { new List<int>(), new List<int>() };
var s = str.Trim().Split('T');
for (var i = 0; i < s.Length; i++)
if (i % 2 == 0)
li[0].Add(s[i].Length);
else
li[1].Add(s[i].Length);
for (var i = 0; i < 2; i++) {
var dp = Enumerable.Repeat(0, li[i].Count)
.Select(v => new HashSet<int>())
.ToArray();
if (i == 0)
dp[0].Add(li[i][0]);
else {
if (li[1].Count == 0) {
WriteLine(xy[1] == 0 ? "Yes" : "No");
return;
}
dp[0].Add(li[i][0]);
dp[0].Add(-li[i][0]);
}
for (var j = 1; j < li[i].Count; j++)
for (var h = -str.Length; h <= str.Length; h++)
if (dp[j - 1].Contains(h)) {
if (-str.Length <= h - li[i][j])
dp[j].Add(h - li[i][j]);
if (str.Length >= h + li[i][j])
dp[j].Add(h + li[i][j]);
}
if (!dp[li[i].Count - 1].Contains(xy[i])) {
WriteLine("No");
return;
}
}
WriteLine("Yes");
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static string[] gred(int h) =>
Enumerable.Repeat(0, h).Select(v => read).ToArray();
public static int[][] twodim(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] twodimL(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const long Inf = (long)1e18;
public const double eps = 1e-11;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
|
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 214, 205, 204, 205, 22], ["+", 15, 16, 31, 214, 205, 204, 206, 207, 0, 70], ["+", 31, 214, 205, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 214, 205, 204, 206, 207, 0, 73], ["+", 75, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 75, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 41, 15, 16, 31, 204, 205, 22], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 75, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 75, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 670
| 33
|
using System;
using System.Collections.Generic;
using System.Linq;
using Debug = System.Diagnostics.Debug;
using System.Numerics;
using static System.Math;
using Number = System.Int64;
namespace Program {
public class Solver {
public void Solve() {
var s = rs;
var a = new List<int>() { 0 };
var u = ri;
var v = ri;
foreach (var x in s) {
if (x == 'F')
a[a.Count - 1]++;
else
a.Add(0);
}
var A = Enumerate(2, x => new List<int>());
for (int k = 0; k < a.Count; k++)
A[k % 2].Add(a[k]);
if (solve(true, u, A[0]) && solve(false, v, A[1]))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
bool solve(bool xx, int u, List<int> a) {
var s = new HashSet<int>();
if (xx) {
s.Add(a[0]);
a.RemoveAt(0);
} else
s.Add(0);
foreach (var x in a) {
var next = new HashSet<int>();
foreach (var y in a) {
next.Add(x + y);
next.Add(y - x);
}
s = next;
}
return s.Contains(u);
}
const long INF = 1L << 60;
int[] dx = { 1, 0, -1, 0 };
int[] dy = { 0, 1, 0, -1 };
//*
int ri {
get { return sc.Integer(); }
}
long rl {
get { return sc.Long(); }
}
double rd {
get { return sc.Double(); }
}
string rs {
get { return sc.Scan(); }
}
//*/
public IO.StreamScanner sc =
new IO.StreamScanner(Console.OpenStandardInput());
static T[] Enumerate<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f(i);
return a;
}
static public void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
}
}
#region main
static class Ex {
static public string AsString(this IEnumerable<char> ie) {
return new string(ie.ToArray());
}
static public string AsJoinedString<T>(this IEnumerable<T> ie,
string st = " ") {
return string.Join(st, ie.Select(x => x.ToString()).ToArray());
// return string.Join(st, ie);
}
static public void Main() {
Console.SetOut(new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false });
var solver = new Program.Solver();
solver.Solve();
Console.Out.Flush();
}
}
#endregion
#region Ex
namespace Program.IO {
using System.Globalization;
using System.IO;
using System.Text;
public class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
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) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n' && b != 0; b = (char)read())
if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
public double Double() {
return isEof ? double.NaN
: double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
}
#endregion
#region HashMap < K, V>
public class HashMap<K, V> : Dictionary<K, V>
// where V : new()
{
public HashMap() : base() {}
public HashMap(int cap) : base(cap) {}
new public V this[K i] { get { V v;
return TryGetValue(i, out v) ? v : base[i] = default(V);
// base[i] = new V();
}
set { base[i] = value; }
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using Debug = System.Diagnostics.Debug;
using System.Numerics;
using static System.Math;
using Number = System.Int64;
namespace Program {
public class Solver {
public void Solve() {
var s = rs;
var a = new List<int>() { 0 };
var u = ri;
var v = ri;
foreach (var x in s) {
if (x == 'F')
a[a.Count - 1]++;
else
a.Add(0);
}
var A = Enumerate(2, x => new List<int>());
for (int k = 0; k < a.Count; k++)
A[k % 2].Add(a[k]);
if (solve(true, u, A[0]) && solve(false, v, A[1]))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
bool solve(bool xx, int u, List<int> a) {
var s = new HashSet<int>();
if (xx) {
s.Add(a[0]);
a.RemoveAt(0);
} else
s.Add(0);
foreach (var x in a) {
var next = new HashSet<int>();
foreach (var y in s) {
next.Add(y + x);
next.Add(y - x);
}
s = next;
Debug.WriteLine(s.AsJoinedString());
}
return s.Contains(u);
}
const long INF = 1L << 60;
int[] dx = { 1, 0, -1, 0 };
int[] dy = { 0, 1, 0, -1 };
//*
int ri {
get { return sc.Integer(); }
}
long rl {
get { return sc.Long(); }
}
double rd {
get { return sc.Double(); }
}
string rs {
get { return sc.Scan(); }
}
//*/
public IO.StreamScanner sc =
new IO.StreamScanner(Console.OpenStandardInput());
static T[] Enumerate<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f(i);
return a;
}
static public void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
}
}
#region main
static class Ex {
static public string AsString(this IEnumerable<char> ie) {
return new string(ie.ToArray());
}
static public string AsJoinedString<T>(this IEnumerable<T> ie,
string st = " ") {
return string.Join(st, ie.Select(x => x.ToString()).ToArray());
// return string.Join(st, ie);
}
static public void Main() {
Console.SetOut(new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false });
var solver = new Program.Solver();
solver.Solve();
Console.Out.Flush();
}
}
#endregion
#region Ex
namespace Program.IO {
using System.Globalization;
using System.IO;
using System.Text;
public class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
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) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n' && b != 0; b = (char)read())
if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
public double Double() {
return isEof ? double.NaN
: double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
}
#endregion
#region HashMap < K, V>
public class HashMap<K, V> : Dictionary<K, V>
// where V : new()
{
public HashMap() : base() {}
public HashMap(int cap) : base(cap) {}
new public V this[K i] { get { V v;
return TryGetValue(i, out v) ? v : base[i] = default(V);
// base[i] = new V();
}
set { base[i] = value; }
}
}
#endregion
|
[["-", 8, 196, 0, 210, 8, 196, 0, 210, 12, 22], ["+", 8, 196, 0, 210, 8, 196, 0, 210, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25]]
| 8
| 1,195
| 17
|
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();
int num = int.Parse(a);
int flag = 0;
if (num % 100 == 1) {
flag++;
}
if (num / 10 % 10 == 1) {
flag++;
}
if (num / 100 == 1) {
flag++;
}
Console.WriteLine(flag);
}
}
}
|
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();
int num = int.Parse(a);
int flag = 0;
if (num % 10 == 1) {
flag++;
} //1桁目
if ((num / 10) % 10 == 1) {
flag++;
} //2桁目
if ((num / 100) == 1) {
flag++;
} //3桁目
Console.WriteLine(flag);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25]]
| 8
| 118
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Atcoder {
public class Class1 {
static void Main(string[] args) {
int count = 0;
var i = (Console.ReadLine()).Split(' ');
foreach (var item in i) {
if (item == "1") {
count++;
}
}
Console.WriteLine(count);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Atcoder {
public class Class1 {
static void Main(string[] args) {
int count = 0;
var a = Console.ReadLine();
foreach (var item in a) {
if (item == '1') {
count++;
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 212, 0, 213, 63, 214, 205, 23, 0, 24], ["-", 63, 214, 205, 23, 0, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 5, 0, 62], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104]]
| 8
| 94
| 17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
char[] input = Console.ReadLine().ToCharArray();
int answer = 0;
foreach (char num in input) {
if (Convert.ToInt32(num.ToString()) == 1) {
answer += 1;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
char[] input = Console.ReadLine().ToCharArray();
int answer = 0;
foreach (char num in input) {
if (Convert.ToInt32(num.ToString()) == 1) {
answer += 1;
}
}
Console.WriteLine(answer);
}
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 89
| 7
|
using System;
namespace AtCoder {
class A_PlacingMarbles_081 {
public static void Main() {
var input = Console.ReadLine();
var count = 0;
if (input[0] == 1) {
++count;
}
if (input[1] == 1) {
++count;
}
if (input[2] == 1) {
++count;
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace AtCoder {
class A_PlacingMarbles_081 {
public static void Main() {
var input = Console.ReadLine().ToCharArray();
var count = 0;
if (input[0] == '1') {
++count;
}
if (input[1] == '1') {
++count;
}
if (input[2] == '1') {
++count;
}
Console.WriteLine(count);
}
}
}
|
[["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104]]
| 8
| 82
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public class Program {
public static void Main() {
Console.WriteLine(Console.ReadLine()
.Split(' ')
.Select(i => int.Parse(i))
.ToArray()
.Sum());
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public class Program {
public static void Main() {
Console.WriteLine(Console.ReadLine()
.ToCharArray()
.Select(i => int.Parse(i.ToString()))
.ToArray()
.Sum());
}
}
|
[["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["-", 205, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 73
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder03 {
class Program {
static void Main(string[] args) {
var a = Console.ReadLine().Split(' ').Select(int.Parse);
var count = 0;
while (a.All(IsEven)) {
count++;
a = a.Select(x => x / 2).ToArray();
}
}
private static bool IsEven(int a) { return a % 2 == 0; }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder03 {
class Program {
static void Main(string[] args) {
Console.ReadLine();
var a = Console.ReadLine().Split(' ').Select(int.Parse);
var count = 0;
while (a.All(IsEven)) {
count++;
a = a.Select(x => x / 2).ToArray();
}
Console.Write(count);
}
private static bool IsEven(int a) { return a % 2 == 0; }
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 122
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC081 {
class ProblemB {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int res = 0;
while (true) {
bool hasOddNum = false;
for (int i = 0; i < N; i++)
if (A[i] % 2 != 0)
hasOddNum = true;
if (hasOddNum)
break;
for (int i = 0; i < N; i++)
A[i] /= 2;
res++;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC081 {
class ProblemB {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int res = 0;
while (true) {
bool hasOddNum = false;
for (int i = 0; i < N; i++)
if (A[i] % 2 != 0)
hasOddNum = true;
if (hasOddNum)
break;
for (int i = 0; i < N; i++)
A[i] /= 2;
res++;
}
Console.WriteLine(res);
}
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 169
| 7
|
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);
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
int count = 0;
bool flg = false;
while (true) {
if (flg) {
break;
}
for (int i = 0; i < n; i++) {
if (inputLongArray[i] % 2 != 0) {
flg = true;
break;
}
inputLongArray[i] = inputLongArray[i] / 2;
}
count++;
}
Console.WriteLine(count);
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);
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
int count = -1;
bool flg = false;
while (true) {
if (flg) {
break;
}
count++;
for (int i = 0; i < n; i++) {
if (inputLongArray[i] % 2 != 0) {
flg = true;
break;
}
inputLongArray[i] = inputLongArray[i] / 2;
}
}
Console.WriteLine(count);
Console.Out.Flush();
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 8
| 215
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
// https://atcoder.jp/contests/abc081/tasks/abc081_b
class Abc_081_B {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
int result = 0;
bool res = true;
while (res) {
for (int i = 0; i < inputLongArray.Length; i++) {
if (inputLongArray[i] % 2 != 0) {
res = false;
break;
}
}
for (int i = 0; i < inputLongArray.Length; i++) {
inputLongArray[i] = inputLongArray[i] / 2;
}
result++;
}
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 {
// https://atcoder.jp/contests/abc081/tasks/abc081_b
class Abc_081_B {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
int result = 0;
bool res = true;
while (res) {
for (int i = 0; i < inputLongArray.Length; i++) {
if (inputLongArray[i] % 2 != 0) {
Console.WriteLine(result);
Console.Out.Flush();
return;
}
}
for (int i = 0; i < inputLongArray.Length; i++) {
inputLongArray[i] = inputLongArray[i] / 2;
}
result++;
}
}
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 141, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 141, 22]]
| 8
| 228
| 34
|
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
int total = int.Parse(ReadLine());
string input = ReadLine();
string[] array = input.Split(' ');
int[] n = new int[array.Length];
for (int i = 0; i < total; i++) {
n[i] = int.Parse(array[i]);
}
int count = 0;
int result = 1000000000;
for (int i = 0; i < total; i++) {
for (int m = 0; m < total; m++) {
if (n[i] % 2 == 0) {
n[i] = n[i] / 2;
count++;
}
}
if (count < result) {
result = count;
count = 0;
}
}
WriteLine("{0}", result);
ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
long total = long.Parse(ReadLine());
string input = ReadLine();
string[] array = input.Split(' ');
long[] n = new long[array.Length];
for (long i = 0; i < total; i++) {
n[i] = long.Parse(array[i]);
}
long count = 0;
long result = 1000000000;
for (long i = 0; i < total; i++) {
for (long m = 0; m < result; m++) {
if (n[i] % 2 == 0) {
n[i] = n[i] / 2;
count++;
} else {
break;
}
}
if (count < result) {
result = count;
}
count = 0;
}
WriteLine("{0}", result);
ReadKey();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 93, 0, 94], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 228
| 29
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class Question3 {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 文字列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
var list = inputLongArray;
var result = list.Min(x => {
var c = 0;
while (x % 2 == 0 && x > 0) {
x >>= 1;
c++;
}
return c;
});
Console.WriteLine(result);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class Question3 {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
var list = inputLongArray;
var result = list.Min(x => {
var c = 0;
while (x % 2 == 0 && x > 0) {
x >>= 1;
c++;
}
return c;
});
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
[["+", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 180
| 8
|
public class B {
public static void Main() {
string[] s = System.Console.ReadLine().Split();
int[] num = new int[s.Length];
for (int i = 0; i < num.Length; i++) {
num[i] = int.Parse(s[i]);
}
int count = 0;
bool isOdd = false;
while (true) {
for (int i = 0; i < num.Length; i++) {
if (num[i] % 2 == 1) {
isOdd = true;
break;
}
}
if (isOdd)
break;
for (int i = 0; i < num.Length; i++) {
num[i] = num[i] >> 1;
}
count++;
}
System.Console.WriteLine(count);
}
}
|
public class B {
public static void Main() {
System.Console.ReadLine();
string[] s = System.Console.ReadLine().Split();
int[] num = new int[s.Length];
for (int i = 0; i < num.Length; i++) {
num[i] = int.Parse(s[i]);
}
int count = 0;
bool isOdd = false;
while (true) {
for (int i = 0; i < num.Length; i++) {
if (num[i] % 2 == 1) {
isOdd = true;
break;
}
}
if (isOdd)
break;
for (int i = 0; i < num.Length; i++) {
num[i] = num[i] >> 1;
}
count++;
}
System.Console.WriteLine(count);
}
}
|
[["+", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 177
| 8
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
int N = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int count = 0;
var inputInt = new int[N];
for (int i = 0; i < N; i++) {
inputInt[i] = int.Parse(input[i]);
}
bool flg = true;
while (flg) {
for (int i = 0; i < N; i++) {
if (inputInt[i] % 2 == 1) {
flg = false;
return;
} else {
inputInt[i] = inputInt[i] / 2;
}
}
count++;
}
//// 文字列の入力
// string s = Console.ReadLine();
//出力
Console.WriteLine(count.ToString());
}
}
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
int N = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int count = 0;
var inputInt = new int[N];
for (int i = 0; i < N; i++) {
inputInt[i] = int.Parse(input[i]);
}
bool flg = true;
while (flg) {
for (int i = 0; i < N; i++) {
if (inputInt[i] % 2 == 1) {
flg = false;
break;
} else {
inputInt[i] = inputInt[i] / 2;
}
}
if (flg) {
count++;
}
}
//// 文字列の入力
// string s = Console.ReadLine();
//出力
Console.WriteLine(count.ToString());
}
}
|
[["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 15, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 175
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
public class Program {
public static void Main(string[] args) {
Program p = new Program();
var n = int.Parse(System.Console.ReadLine());
int[] aList =
System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var counter = 0;
var allEven = true;
var result = p.Divide2(n, aList, allEven, counter);
System.Console.WriteLine(result.ToString());
}
/// <summary>
/// 引数が偶数か奇数か判定
/// 偶数 → true
/// </summary>
/// <param name="_number"></param>
/// <returns></returns>
public bool OddOrEven(int _number) {
if (_number % 2 == 0)
return true;
else
return false;
}
/// <summary>
/// aListを2で割る
/// </summary>
/// <param name="_n"></param>
/// <param name="_aList"></param>
/// <param name="_allEven"></param>
/// <param name="_counter"></param>
/// <returns></returns>
public int Divide2(int _n, int[] _aList, bool _allEven, int _counter) {
for (int i = 0; i < _n; i++) {
if (!OddOrEven(_aList[i])) {
_allEven = false;
break;
}
}
if (_allEven) {
for (int i = 0; i < _n; i++) {
_aList[i] = _aList[i] / 2;
}
_counter = _counter + 1;
Divide2(_n, _aList, _allEven, _counter);
}
return _counter;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
public class Program {
public int counter { get; set; }
public static void Main(string[] args) {
Program p = new Program();
var n = int.Parse(System.Console.ReadLine());
int[] aList =
System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var allEven = true;
p.counter = 0;
var result = p.Divide2(n, aList, allEven, p.counter);
System.Console.WriteLine(result.ToString());
}
/// <summary>
/// 引数が偶数か奇数か判定
/// 偶数 → true
/// </summary>
/// <param name="_number"></param>
/// <returns></returns>
public bool OddOrEven(int _number) {
if (_number % 2 == 0)
return true;
else
return false;
}
/// <summary>
/// aListを2で割る
/// </summary>
/// <param name="_n"></param>
/// <param name="_aList"></param>
/// <param name="_allEven"></param>
/// <param name="_counter"></param>
/// <returns></returns>
public int Divide2(int _n, int[] _aList, bool _allEven, int _counter) {
for (int i = 0; i < _n; i++) {
if (!OddOrEven(_aList[i])) {
_allEven = false;
break;
}
}
if (_allEven) {
for (int i = 0; i < _n; i++) {
_aList[i] = _aList[i] / 2;
}
counter = counter + 1;
Divide2(_n, _aList, _allEven, counter);
}
return counter;
}
}
}
|
[["+", 8, 201, 0, 235, 8, 201, 0, 277, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 277, 141, 22], ["+", 0, 235, 8, 201, 0, 277, 278, 279, 0, 45], ["+", 8, 201, 0, 277, 278, 279, 0, 280, 141, 281], ["+", 8, 201, 0, 277, 278, 279, 0, 280, 0, 35], ["+", 8, 201, 0, 277, 278, 279, 0, 280, 141, 282], ["+", 0, 235, 8, 201, 0, 277, 278, 279, 0, 46], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 259], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 11, 31, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 11, 31, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 11, 31, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 37, 0, 22]]
| 8
| 289
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC081B_ShiftOnly {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int count = 0;
for (int i = 0; i < n; i++) {
if (input.Count(x => x % 2 == 0) == input.Length) {
input = input.Select(x => x / 2).ToArray();
count++;
} else {
break;
}
}
Console.WriteLine(count);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC081B_ShiftOnly {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int count = 0;
while (input.Count(x => x % 2 == 0) == input.Length) {
input = input.Select(x => x / 2).ToArray();
count++;
}
Console.WriteLine(count);
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["-", 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, 196, 0, 57, 75, 196, 0, 93, 0, 94], ["-", 8, 196, 0, 57, 75, 196, 0, 93, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 168
| 23
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 min = 30; // 今回はceil(log2(最大値))なら何でもいいです
var N = cin.ReadInt;
var ans = cin.ReadIntArray(N).Min(x => {
var c = 0;
while (x % 2 == 0 && x != 0) {
x /= 2;
}
return c;
});
WriteLine(ans);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 ans = cin.ReadIntArray(N).Min(x => {
var c = 0;
while (x % 2 == 0 && x != 0) {
x /= 2;
++c;
}
return c;
});
WriteLine(ans);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 241, 0, 29], ["+", 0, 52, 8, 196, 0, 1, 0, 241, 0, 22]]
| 8
| 491
| 8
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
// 整数の入力
var a = Console.ReadLine().Split().Select(x => int.Parse(x));
int ans = 0;
while (a.All(x => x % 2 == 0)) {
a = a.Select(x => x / 2);
ans++;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
// 整数の入力
var n = Console.ReadLine();
var a = Console.ReadLine().Split().Select(x => int.Parse(x));
int ans = 0;
while (a.All(x => x % 2 == 0)) {
a = a.Select(x => x / 2);
ans++;
}
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217]]
| 8
| 94
| 9
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
class Myon {
public Myon() {}
public static int Main() {
cin = new Scanner();
new Myon().calc();
return 0;
}
static Scanner cin;
// メンバ変数---
struct edge {
public long C;
public long S;
public long F;
public edge(long c, long s, long f) {
C = c;
S = s;
F = f;
}
}
long N;
edge[] edges;
// -------------
void calc() {
N = cin.nextLong();
edges = new edge[N - 1];
for (long i = 0; i < N - 1; i++) {
edges[i] = new edge(cin.nextLong(), cin.nextLong(), cin.nextLong());
}
// 駅ごとのループ
for (long i = 0; i < N; i++) {
long time = 0;
for (long j = i; j < N - 1; j++) {
// 待ち時間の計算
time = Math.Max(edges[j].S, time);
if (time % edges[j].F > 0) {
time += time % edges[j].F;
}
// 移動時間の加算
time += edges[j].C;
}
Write(time);
}
}
void Write<T>(T v) { Console.WriteLine(v); }
int Pow(int x, int y) {
return (int)Math.Pow(double.Parse(x.ToString()),
double.Parse(y.ToString()));
}
double Pow(double x, double y) { return Math.Pow(x, y); }
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
class Myon {
public Myon() {}
public static int Main() {
cin = new Scanner();
new Myon().calc();
return 0;
}
static Scanner cin;
// メンバ変数---
struct edge {
public long C;
public long S;
public long F;
public edge(long c, long s, long f) {
C = c;
S = s;
F = f;
}
}
long N;
edge[] edges;
// -------------
void calc() {
N = cin.nextLong();
edges = new edge[N - 1];
for (long i = 0; i < N - 1; i++) {
edges[i] = new edge(cin.nextLong(), cin.nextLong(), cin.nextLong());
}
// 駅ごとのループ
for (long i = 0; i < N; i++) {
long time = 0;
for (long j = i; j < N - 1; j++) {
// 待ち時間の計算
time = Math.Max(edges[j].S, time);
if (time % edges[j].F > 0) {
time += edges[j].F - (time % edges[j].F);
}
// 移動時間の加算
time += edges[j].C;
}
Write(time);
}
}
void Write<T>(T v) { Console.WriteLine(v); }
int Pow(int x, int y) {
return (int)Math.Pow(double.Parse(x.ToString()),
double.Parse(y.ToString()));
}
double Pow(double x, double y) { return Math.Pow(x, y); }
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
}
|
[["+", 0, 11, 12, 16, 31, 214, 205, 204, 205, 22], ["+", 12, 16, 31, 214, 205, 204, 206, 207, 0, 70], ["+", 31, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 31, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 1, 0, 11, 12, 16, 31, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 16, 31, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
| 8
| 726
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static AtCoderTemplate.MyExtensions;
using static AtCoderTemplate.MyInputOutputs;
using static AtCoderTemplate.MyNumericFunctions;
namespace AtCoderTemplate {
public class Program {
public static void Main(string[] args) {
var N = ReadInt();
var CSF = ReadIntColumns(N - 1);
var C = CSF[0].Prepend(0).ToList();
var S = CSF[1].Prepend(0).ToList();
var F = CSF[2].Prepend(0).ToList();
var ans = Enumerable.Range(1, N).Select(
k => Enumerable.Range(k, N - k).Aggregate(0, (T, i) => {
if (T < S[i]) {
return S[i] + C[i];
} else {
return T + T % F[i] + C[i];
}
}));
PrintColomn(ans);
}
}
static class MyInputOutputs {
/* Input & Output*/
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
public static List<long> ReadLongs() {
return Console.ReadLine().Split(' ').Select(c => long.Parse(c)).ToList();
}
public static List<List<int>> ReadIntColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static List<List<long>> ReadLongColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadLongs()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static void Print<T>(T item) { Console.WriteLine(item); }
public static void PrintIf<T1, T2>(bool condition, T1 trueResult,
T2 falseResult) {
if (condition) {
Console.WriteLine(trueResult);
} else {
Console.WriteLine(falseResult);
}
}
public static void PrintRow<T>(IEnumerable<T> list) {
/* 横ベクトルで表示
A B C D ...
*/
if (!list.IsEmpty()) {
Console.Write(list.First());
foreach (var item in list.Skip(1)) {
Console.Write($" {item}");
}
}
Console.Write("\n");
}
public static void PrintColomn<T>(IEnumerable<T> list) {
/* 縦ベクトルで表示
A
B
C
D
...
*/
foreach (var item in list) {
Console.WriteLine(item);
}
}
public static void Print2DArray<T>(IEnumerable<IEnumerable<T>> sources) {
foreach (var row in sources) {
PrintRow(row);
}
}
}
static class MyNumericFunctions {
public static bool isEven(int a) { return a % 2 == 0; }
public static bool isEven(long a) { return a % 2 == 0; }
public static bool isOdd(int a) { return !isEven(a); }
public static bool isOdd(long a) { return !isEven(a); }
public static long nPk(int n, int k) {
if (k > n) {
return 0;
} else {
return Enumerable.Range(n - k + 1, k)
.Aggregate((long)1, ((i, m) => i * m));
}
}
public static long Fact(int n) { return nPk(n, n); }
public static long nCk(int n, int k) {
if (k > n) {
return 0;
} else {
return nPk(n, k) / Fact(k);
}
}
// 最大公約数
public static long GCD(long m, long n) {
if (m < n) {
return GCD(n, m);
} else if (n == 0) {
return m;
} else {
return GCD(n, m % n);
}
}
// 最小公倍数
public static long LCM(long m, long n) {
if (m < n) {
return LCM(n, m);
} else {
return (m * n) / GCD(m, n);
}
}
}
static class MyExtensions {
// AppendとPrependが、.NET Standard 1.6からの追加で、Mono 4.6.2
// はそれに対応して仕様はあるが、実装がない
public static IEnumerable<T> Append<T>(this IEnumerable<T> source,
T element) {
return source.Concat(Enumerable.Repeat(element, 1));
}
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> source,
T element) {
return Enumerable.Repeat(element, 1).Concat(source);
}
// TakeLastとSkipLastが、.Net Standard 2.1からの追加で、Mono 4.6.2
// はそれに対応していない
public static IEnumerable<T> TakeLast<T>(this IEnumerable<T> source,
int count) {
return source.Skip(source.Count() - count);
}
public static IEnumerable<T> SkipLast<T>(this IEnumerable<T> source,
int count) {
return source.Take(source.Count() - count);
}
public static bool IsEmpty<T>(this IEnumerable<T> source) {
return !source.Any();
}
/// <summary>
/// インデックスiの位置の要素からk個取り除く
/// O(N)
/// </summary>
public static IEnumerable<T> TakeAwayRange<T>(this IEnumerable<T> source,
int i, int count) {
return source.Take(i).Concat(source.Skip(i + count));
}
/// <summary>
/// インデックスiの位置の要素を取り除く
/// O(N)
/// </summary>
public static IEnumerable<T> TakeAwayAt<T>(this IEnumerable<T> source,
int i) {
return source.TakeAwayRange(i, 1);
}
/// <summary>
/// インデックスiの位置にシーケンスを挿入する
/// O(N + K)
/// </summary>
public static IEnumerable<T> InsertEnumAt<T>(this IEnumerable<T> source,
int i, IEnumerable<T> inserted) {
return source.Take(i).Concat(inserted).Concat(source.Skip(i));
}
/// <summary>
/// 順列を得る
/// O(N!)
/// </summary>
public static IEnumerable<IEnumerable<T>> Perm<T>(this IEnumerable<T> source,
int n) {
if (n == 0 || source.IsEmpty() || source.Count() < n) {
return Enumerable.Empty<IEnumerable<T>>();
} else if (n == 1) {
return source.Select(i => new List<T> { i });
} else {
var nexts = source.Select(
(x, i) => new { next = source.Take(i).Concat(source.Skip(i + 1)),
selected = source.Take(i + 1).Last() });
return nexts.SelectMany(
next => Perm(next.next, n - 1)
.Select(item => item.Prepend(next.selected)));
}
}
/// <summary>
/// シーケンスの隣り合う要素を2引数の関数に適用したシーケンスを得る
/// </summary>
/// <para>O(N)</para>
/// <param name="source">元のシーケンス</param>
/// <param name="func">2引数関数</param>
/// <example>[1,2,3,4].MapAdjacent(f) => [f(1,2), f(2,3), f(3,4)]</example>
public static IEnumerable<TR> MapAdjacent<T1, TR>(this IEnumerable<T1> source,
Func<T1, T1, TR> func) {
var list = source.ToList();
return Enumerable.Range(1, list.Count - 1)
.Select(i => func(list[i], list[i - 1]));
}
/// <summary>
/// 累積項を要素にもつシーケンスを得る(初項は、first)
/// <para>O(N)</para>
/// </summary>
/// <param name="source">元のシーケンス</param>
/// <param name="func">2引数関数f</param>
/// <param name="first">func(first, source[0])のための初項</param>
/// <example> [1,2,3].Scanl1(f,0) => [0, f(0,1), f(f(0,1),2),
/// f(f(f(0,1),2),3)]</example>
public static IEnumerable<TR> Scanl<T, TR>(this IEnumerable<T> source,
TR first, Func<TR, T, TR> func) {
var list = source.ToList();
var result = new List<TR> { first };
foreach (var i in Enumerable.Range(0, source.Count())) {
result.Add(func(result[i], list[i]));
}
return result;
}
/// <summary>
/// 累積項を要素にもつシーケンスを得る(初項は、source.First())
/// <para>O(N)</para>
/// </summary>
/// <param name="source">元のシーケンス</param>
/// <param name="func">2引数関数f</param>
/// <example> [1,2,3].Scanl1(f) => [1, f(1,2), f(f(1,2),3)]</example>
public static IEnumerable<T> Scanl1<T>(this IEnumerable<T> source,
Func<T, T, T> func) {
var list = source.ToList();
var result = new List<T> { list[0] };
foreach (var i in Enumerable.Range(1, source.Count() - 1)) {
result.Add(func(result[i - 1], list[i]));
}
return result;
}
/// <summary>
/// 昇順にソートしたインデックスを得る
/// </summary>
/// <para>O(N * log N)</para>
public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) {
return source.Select((item, i) => new { Item = item, Index = i })
.OrderBy(x => x.Item)
.Select(x => x.Index);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static AtCoderTemplate.MyExtensions;
using static AtCoderTemplate.MyInputOutputs;
using static AtCoderTemplate.MyNumericFunctions;
namespace AtCoderTemplate {
public class Program {
public static void Main(string[] args) {
var N = ReadInt();
var CSF = ReadIntColumns(N - 1);
var C = CSF[0].Prepend(0).ToList();
var S = CSF[1].Prepend(0).ToList();
var F = CSF[2].Prepend(0).ToList();
var ans = Enumerable.Range(1, N).Select(
k => Enumerable.Range(k, N - k).Aggregate(0, (T, i) => {
if (T < S[i]) {
return S[i] + C[i];
} else if (T % F[i] == 0) {
return T + C[i];
} else {
return T + (F[i] - T % F[i]) + C[i];
}
}));
PrintColomn(ans);
}
}
static class MyInputOutputs {
/* Input & Output*/
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
public static List<long> ReadLongs() {
return Console.ReadLine().Split(' ').Select(c => long.Parse(c)).ToList();
}
public static List<List<int>> ReadIntColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static List<List<long>> ReadLongColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadLongs()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static void Print<T>(T item) { Console.WriteLine(item); }
public static void PrintIf<T1, T2>(bool condition, T1 trueResult,
T2 falseResult) {
if (condition) {
Console.WriteLine(trueResult);
} else {
Console.WriteLine(falseResult);
}
}
public static void PrintRow<T>(IEnumerable<T> list) {
/* 横ベクトルで表示
A B C D ...
*/
if (!list.IsEmpty()) {
Console.Write(list.First());
foreach (var item in list.Skip(1)) {
Console.Write($" {item}");
}
}
Console.Write("\n");
}
public static void PrintColomn<T>(IEnumerable<T> list) {
/* 縦ベクトルで表示
A
B
C
D
...
*/
foreach (var item in list) {
Console.WriteLine(item);
}
}
public static void Print2DArray<T>(IEnumerable<IEnumerable<T>> sources) {
foreach (var row in sources) {
PrintRow(row);
}
}
}
static class MyNumericFunctions {
public static bool isEven(int a) { return a % 2 == 0; }
public static bool isEven(long a) { return a % 2 == 0; }
public static bool isOdd(int a) { return !isEven(a); }
public static bool isOdd(long a) { return !isEven(a); }
public static long nPk(int n, int k) {
if (k > n) {
return 0;
} else {
return Enumerable.Range(n - k + 1, k)
.Aggregate((long)1, ((i, m) => i * m));
}
}
public static long Fact(int n) { return nPk(n, n); }
public static long nCk(int n, int k) {
if (k > n) {
return 0;
} else {
return nPk(n, k) / Fact(k);
}
}
// 最大公約数
public static long GCD(long m, long n) {
if (m < n) {
return GCD(n, m);
} else if (n == 0) {
return m;
} else {
return GCD(n, m % n);
}
}
// 最小公倍数
public static long LCM(long m, long n) {
if (m < n) {
return LCM(n, m);
} else {
return (m * n) / GCD(m, n);
}
}
}
static class MyExtensions {
// AppendとPrependが、.NET Standard 1.6からの追加で、Mono 4.6.2
// はそれに対応して仕様はあるが、実装がない
public static IEnumerable<T> Append<T>(this IEnumerable<T> source,
T element) {
return source.Concat(Enumerable.Repeat(element, 1));
}
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> source,
T element) {
return Enumerable.Repeat(element, 1).Concat(source);
}
// TakeLastとSkipLastが、.Net Standard 2.1からの追加で、Mono 4.6.2
// はそれに対応していない
public static IEnumerable<T> TakeLast<T>(this IEnumerable<T> source,
int count) {
return source.Skip(source.Count() - count);
}
public static IEnumerable<T> SkipLast<T>(this IEnumerable<T> source,
int count) {
return source.Take(source.Count() - count);
}
public static bool IsEmpty<T>(this IEnumerable<T> source) {
return !source.Any();
}
/// <summary>
/// インデックスiの位置の要素からk個取り除く
/// O(N)
/// </summary>
public static IEnumerable<T> TakeAwayRange<T>(this IEnumerable<T> source,
int i, int count) {
return source.Take(i).Concat(source.Skip(i + count));
}
/// <summary>
/// インデックスiの位置の要素を取り除く
/// O(N)
/// </summary>
public static IEnumerable<T> TakeAwayAt<T>(this IEnumerable<T> source,
int i) {
return source.TakeAwayRange(i, 1);
}
/// <summary>
/// インデックスiの位置にシーケンスを挿入する
/// O(N + K)
/// </summary>
public static IEnumerable<T> InsertEnumAt<T>(this IEnumerable<T> source,
int i, IEnumerable<T> inserted) {
return source.Take(i).Concat(inserted).Concat(source.Skip(i));
}
/// <summary>
/// 順列を得る
/// O(N!)
/// </summary>
public static IEnumerable<IEnumerable<T>> Perm<T>(this IEnumerable<T> source,
int n) {
if (n == 0 || source.IsEmpty() || source.Count() < n) {
return Enumerable.Empty<IEnumerable<T>>();
} else if (n == 1) {
return source.Select(i => new List<T> { i });
} else {
var nexts = source.Select(
(x, i) => new { next = source.Take(i).Concat(source.Skip(i + 1)),
selected = source.Take(i + 1).Last() });
return nexts.SelectMany(
next => Perm(next.next, n - 1)
.Select(item => item.Prepend(next.selected)));
}
}
/// <summary>
/// シーケンスの隣り合う要素を2引数の関数に適用したシーケンスを得る
/// </summary>
/// <para>O(N)</para>
/// <param name="source">元のシーケンス</param>
/// <param name="func">2引数関数</param>
/// <example>[1,2,3,4].MapAdjacent(f) => [f(1,2), f(2,3), f(3,4)]</example>
public static IEnumerable<TR> MapAdjacent<T1, TR>(this IEnumerable<T1> source,
Func<T1, T1, TR> func) {
var list = source.ToList();
return Enumerable.Range(1, list.Count - 1)
.Select(i => func(list[i], list[i - 1]));
}
/// <summary>
/// 累積項を要素にもつシーケンスを得る(初項は、first)
/// <para>O(N)</para>
/// </summary>
/// <param name="source">元のシーケンス</param>
/// <param name="func">2引数関数f</param>
/// <param name="first">func(first, source[0])のための初項</param>
/// <example> [1,2,3].Scanl1(f,0) => [0, f(0,1), f(f(0,1),2),
/// f(f(f(0,1),2),3)]</example>
public static IEnumerable<TR> Scanl<T, TR>(this IEnumerable<T> source,
TR first, Func<TR, T, TR> func) {
var list = source.ToList();
var result = new List<TR> { first };
foreach (var i in Enumerable.Range(0, source.Count())) {
result.Add(func(result[i], list[i]));
}
return result;
}
/// <summary>
/// 累積項を要素にもつシーケンスを得る(初項は、source.First())
/// <para>O(N)</para>
/// </summary>
/// <param name="source">元のシーケンス</param>
/// <param name="func">2引数関数f</param>
/// <example> [1,2,3].Scanl1(f) => [1, f(1,2), f(f(1,2),3)]</example>
public static IEnumerable<T> Scanl1<T>(this IEnumerable<T> source,
Func<T, T, T> func) {
var list = source.ToList();
var result = new List<T> { list[0] };
foreach (var i in Enumerable.Range(1, source.Count() - 1)) {
result.Add(func(result[i - 1], list[i]));
}
return result;
}
/// <summary>
/// 昇順にソートしたインデックスを得る
/// </summary>
/// <para>O(N * log N)</para>
public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) {
return source.Select((item, i) => new { Item = item, Index = i })
.OrderBy(x => x.Item)
.Select(x => x.Index);
}
}
}
|
[["+", 0, 218, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 218, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 109], ["+", 75, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 12, 203], ["+", 0, 218, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 64, 196, 0, 37, 0, 16, 12, 204, 205, 22], ["+", 0, 37, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 37, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 57, 64, 196, 0, 37, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 0, 218, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 57, 75, 196, 0, 37, 0, 38], ["+", 75, 196, 0, 37, 0, 16, 31, 16, 31, 22], ["+", 75, 196, 0, 37, 0, 16, 31, 16, 17, 72], ["+", 0, 37, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 23, 0, 16, 31, 204, 205, 22], ["+", 12, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 37, 0, 16, 31, 16, 12, 23, 0, 25]]
| 8
| 1,893
| 29
|
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine()) - 1;
var c = new int[n];
var s = new int[n];
var f = new int[n];
for (int i = 0; i < n; i++) {
string[] cin = Console.ReadLine().Split();
c[i] = int.Parse(cin[0]);
s[i] = int.Parse(cin[1]);
f[i] = int.Parse(cin[2]);
}
for (int i = 0; i < n; i++) {
int ans = 0;
for (int j = i; j < n; j++) {
if (ans <= s[j])
ans = s[j];
else
ans += (ans - s[j]) % f[j];
ans += c[j];
}
Console.WriteLine(ans);
}
Console.WriteLine(0);
}
}
|
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine()) - 1;
var c = new int[n];
var s = new int[n];
var f = new int[n];
for (int i = 0; i < n; i++) {
string[] cin = Console.ReadLine().Split();
c[i] = int.Parse(cin[0]);
s[i] = int.Parse(cin[1]);
f[i] = int.Parse(cin[2]);
}
for (int i = 0; i < n; i++) {
int ans = 0;
for (int j = i; j < n; j++) {
if (ans <= s[j])
ans = s[j];
else {
int tmp = (ans - s[j]) % f[j];
if (tmp != 0)
ans += (f[j] - tmp);
}
ans += c[j];
}
Console.WriteLine(ans);
}
Console.WriteLine(0);
}
}
|
[["-", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["-", 0, 57, 75, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 75, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["+", 0, 212, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 212, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 75, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 1, 0, 11, 12, 23, 0, 24], ["+", 64, 1, 0, 11, 12, 23, 0, 16, 17, 33], ["+", 64, 1, 0, 11, 12, 23, 0, 16, 12, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 23, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 241
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var num = ToInt32(ReadLine());
var csf = new int [num - 1][];
for (var i = 0; i < num - 1; i++)
csf[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
for (var i = 0; i < num; i++) {
var time = 0;
for (var j = i; j < num - 1; j++) {
if (time >= csf[j][1])
time += time % csf[j][2] + csf[j][0];
else
time = csf[j][1] + csf[j][0];
}
WriteLine(time);
}
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var num = ToInt32(ReadLine());
var csf = new int [num - 1][];
for (var i = 0; i < num - 1; i++)
csf[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
for (var i = 0; i < num; i++) {
var time = 0;
for (var j = i; j < num - 1; j++) {
if (time < csf[j][1])
time = csf[j][1];
else if (time % csf[j][2] != 0)
time += csf[j][2] - time % csf[j][2];
time += csf[j][0];
}
WriteLine(time);
}
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 1, 0, 11, 12, 204, 205, 204, 205, 22], ["+", 0, 11, 12, 204, 205, 204, 206, 207, 0, 70], ["+", 12, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 204, 205, 204, 206, 207, 0, 73], ["+", 64, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 64, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 64, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 75, 57, 64, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 1, 0, 11, 12, 16, 12, 16, 17, 109], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 75, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 57, 75, 57, 64, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107]]
| 8
| 223
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
static void Main(string[] args) {
SolveA();
// SolveB();
// SolveC();
// SolveD();
}
private const long MOD = 1000000007;
static void SolveA() {
int n = ReadAndParseInt();
long[] c = new long[n - 1];
long[] s = new long[n - 1];
long[] f = new long[n - 1];
for (int i = 0; i < n - 1; ++i) {
var tmp = ReadAndParseIntArr();
c[i] = tmp[0];
s[i] = tmp[1];
f[i] = tmp[2];
}
for (int i = 0; i < n - 1; ++i) {
long sec = CalcSec(i, c, s, f);
Console.WriteLine(sec);
}
Console.WriteLine(0);
}
private static long CalcSec(int startStation, long[] c, long[] s, long[] f) {
long time = 0;
for (int i = startStation; i < c.Length; ++i) {
if (s[i] <= time && (time % f[i] == 0)) {
time += c[i];
} else if (time < s[i]) {
time = s[i] + c[i];
} else {
// 待ち
time += (time - s[i]) % f[i];
time += c[i];
}
}
return time;
}
#region よく使う便利関数
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
static void Main(string[] args) {
SolveA();
// SolveB();
// SolveC();
// SolveD();
}
private const long MOD = 1000000007;
static void SolveA() {
int n = ReadAndParseInt();
long[] c = new long[n - 1];
long[] s = new long[n - 1];
long[] f = new long[n - 1];
for (int i = 0; i < n - 1; ++i) {
var tmp = ReadAndParseIntArr();
c[i] = tmp[0];
s[i] = tmp[1];
f[i] = tmp[2];
}
for (int i = 0; i < n - 1; ++i) {
long sec = CalcSec(i, c, s, f);
Console.WriteLine(sec);
}
Console.WriteLine(0);
}
private static long CalcSec(int startStation, long[] c, long[] s, long[] f) {
long time = 0;
for (int i = startStation; i < c.Length; ++i) {
if (s[i] <= time && (time % f[i] == 0)) {
// 加算無し
} else if (time < s[i]) {
time = s[i];
} else {
// 待ち
time += f[i] - time % f[i];
}
time += c[i];
}
return time;
}
#region よく使う便利関数
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
#endregion
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["-", 12, 16, 31, 23, 0, 16, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 46], ["-", 8, 196, 0, 57, 75, 57, 75, 196, 0, 46]]
| 8
| 578
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
static void Main(string[] args) {
SolveA();
// SolveB();
// SolveC();
// SolveD();
}
private const long MOD = 1000000007;
static void SolveA() {
int n = ReadAndParseInt();
long[] c = new long[n - 1];
long[] s = new long[n - 1];
long[] f = new long[n - 1];
for (int i = 0; i < n - 1; ++i) {
var tmp = ReadAndParseIntArr();
c[i] = tmp[0];
s[i] = tmp[1];
f[i] = tmp[2];
}
for (int i = 0; i < n - 1; ++i) {
long sec = CalcSec(i, c, s, f);
Console.WriteLine(sec);
}
Console.WriteLine(0);
}
private static long CalcSec(int startStation, long[] c, long[] s, long[] f) {
long time = 0;
for (int i = startStation; i < c.Length; ++i) {
if (s[i] <= time && (time % f[i] == 0)) {
time += c[i];
} else if (time < s[i]) {
time = s[i] + c[i];
} else {
// 待ち
time += (time - s[i]) % f[i];
time += c[i];
}
}
return time;
}
#region よく使う便利関数
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
static void Main(string[] args) {
SolveA();
// SolveB();
// SolveC();
// SolveD();
}
private const long MOD = 1000000007;
static void SolveA() {
int n = ReadAndParseInt();
long[] c = new long[n - 1];
long[] s = new long[n - 1];
long[] f = new long[n - 1];
for (int i = 0; i < n - 1; ++i) {
var tmp = ReadAndParseIntArr();
c[i] = tmp[0];
s[i] = tmp[1];
f[i] = tmp[2];
}
for (int i = 0; i < n - 1; ++i) {
long sec = CalcSec(i, c, s, f);
Console.WriteLine(sec);
}
Console.WriteLine(0);
}
private static long CalcSec(int startStation, long[] c, long[] s, long[] f) {
long time = 0;
for (int i = startStation; i < c.Length; ++i) {
if (s[i] <= time && (time % f[i] == 0)) {
time += c[i];
} else if (time < s[i]) {
time = s[i] + c[i];
} else {
// 待ち
// time += (time - s[i]) % f[i];
time = f[i] * (long)Math.Ceiling((1.0 + time) / f[i]);
time += c[i];
}
}
return time;
}
#region よく使う便利関数
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
#endregion
}
}
|
[["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["-", 12, 16, 31, 23, 0, 16, 12, 204, 205, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 12, 16, 12, 74, 51, 213, 63, 214, 205, 22], ["+", 12, 16, 12, 74, 51, 213, 63, 214, 0, 131], ["+", 12, 16, 12, 74, 51, 213, 63, 214, 141, 22], ["+", 12, 16, 12, 74, 51, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 31, 250], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 51, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 12, 16, 12, 74, 51, 213, 3, 4, 0, 25]]
| 8
| 578
| 22
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc84_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[,] dis = new int[n, 3];
for (int i = 0; i < n - 1; i++) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
dis[i, 0] = input[0];
dis[i, 1] = input[1];
dis[i, 2] = input[2];
}
for (int i = 0; i < n - 1; i++) {
int time = 0;
time += dis[i, 0] + dis[i, 1];
for (int j = i + 1; j < n - 1; j++) {
if (time < dis[j, 1]) {
time = dis[j, 1];
} else if (dis[j - 1, 0] % dis[j, 2] != 0) {
time += dis[j, 2] - (dis[j - 1, 0] % dis[j, 2]);
}
time += dis[j, 0];
}
WriteLine(time);
}
// n番目の駅
WriteLine(0);
// Write();
// WriteLine();
// WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);
// WriteLine($"答えは{input[0]+input[1]}");
}
/// 値のスワップ
static void Swap<T>(ref T lhs, ref T rhs) {
T temp;
temp = lhs;
lhs = rhs;
rhs = temp;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc84_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[,] dis = new int[n, 3];
for (int i = 0; i < n - 1; i++) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
dis[i, 0] = input[0];
dis[i, 1] = input[1];
dis[i, 2] = input[2];
}
for (int i = 0; i < n - 1; i++) {
int time = 0;
time += dis[i, 0] + dis[i, 1];
for (int j = i + 1; j < n - 1; j++) {
if (time < dis[j, 1])
time = dis[j, 1];
else if (time % dis[j, 2] == 0)
;
else
time += dis[j, 2] - (time % dis[j, 2]);
time += dis[j, 0];
}
WriteLine(time);
}
// n番目の駅
WriteLine(0);
// Write();
// WriteLine();
// WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);
// WriteLine($"答えは{input[0]+input[1]}");
}
/// 値のスワップ
static void Swap<T>(ref T lhs, ref T rhs) {
T temp;
temp = lhs;
lhs = rhs;
rhs = temp;
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 75, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 21], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 60], ["-", 8, 196, 0, 57, 75, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 57, 64, 260, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 95], ["-", 12, 16, 12, 23, 0, 16, 31, 204, 205, 22], ["-", 12, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 23, 0, 16, 31, 204, 206, 207, 0, 21], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46]]
| 8
| 365
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6 {
class Program {
static int n;
static Dictionary<Tuple<int, long>, long> N =
new Dictionary<Tuple<int, long>, long>();
static List<long[]> list;
static void Main(string[] args) {
n = int.Parse(Console.ReadLine());
list = new List<long[]>();
list.Add(new long[1] { 0 });
int i = 0;
while (i < n - 1) {
var temp =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
list.Add(temp);
i++;
}
for (i = 1; i <= n; i++) {
Console.WriteLine(Calc(i, 0));
}
}
static long Calc(int i_, long spent) {
Tuple<int, long> t = Tuple.Create(i_, spent);
if (N.ContainsKey(t)) {
return N[t];
}
if (i_ == n) {
N.Add(Tuple.Create(n, spent), spent);
return spent;
}
if (spent < list[i_][1]) {
var time = Calc(i_ + 1, list[i_][0] + list[i_][1]);
N.Add(Tuple.Create(i_, spent), time);
return time;
}
var mod = spent % list[i_][2] == (long)0 ? 0 : spent - spent % list[i_][2];
var time2 = Calc(i_ + 1, spent + mod + list[i_][0]);
N.Add(Tuple.Create(i_, spent), time2);
return time2;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6 {
class Program {
static int n;
static Dictionary<Tuple<int, long>, long> N =
new Dictionary<Tuple<int, long>, long>();
static List<long[]> list;
static void Main(string[] args) {
n = int.Parse(Console.ReadLine());
list = new List<long[]>();
list.Add(new long[1] { 0 });
int i = 0;
while (i < n - 1) {
var temp =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
list.Add(temp);
i++;
}
for (i = 1; i <= n; i++) {
Console.WriteLine(Calc(i, 0));
}
}
static long Calc(int i_, long spent) {
Tuple<int, long> t = Tuple.Create(i_, spent);
if (N.ContainsKey(t)) {
return N[t];
}
if (i_ == n) {
N.Add(Tuple.Create(n, spent), spent);
return spent;
}
if (spent < list[i_][1]) {
var time = Calc(i_ + 1, list[i_][0] + list[i_][1]);
N.Add(Tuple.Create(i_, spent), time);
return time;
}
var mod =
spent % list[i_][2] == (long)0 ? 0 : list[i_][2] - spent % list[i_][2];
var time2 = Calc(i_ + 1, spent + mod + list[i_][0]);
N.Add(Tuple.Create(i_, spent), time2);
return time2;
}
}
}
|
[["-", 0, 200, 0, 212, 0, 41, 75, 16, 31, 22], ["+", 0, 41, 75, 16, 31, 204, 205, 204, 205, 22], ["+", 75, 16, 31, 204, 205, 204, 206, 207, 0, 70], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 75, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["+", 0, 41, 75, 16, 31, 204, 206, 207, 0, 70], ["+", 75, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 41, 75, 16, 31, 204, 206, 207, 0, 73]]
| 8
| 416
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999;
public static void Main(string[] args) {
var q = Console.ReadLine().ToInt();
int k = 100010;
var primes = new bool[k];
for (int i = 2; i < k; i++) {
if (primes[i])
continue;
for (int j = 2; j * i < k; j++) {
primes[j * i] = true;
}
}
var a = new int[k];
for (int i = 0; i < k; i++) {
if (!primes[i] && !primes[(i + 1) / 2])
a[i] = 1;
}
var s = new int[k];
for (int i = 1; i < k; i++) {
s[i] = s[i - 1] + a[i - 1];
}
for (int i = 0; i < q; i++) {
var p = Input().ToInt();
Console.WriteLine(s[p[1] + 1] - s[p[0]]);
}
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999;
public static void Main(string[] args) {
var q = Console.ReadLine().ToInt();
int k = 100010;
var primes = new bool[k];
primes[1] = true;
for (int i = 2; i < k; i++) {
if (primes[i])
continue;
for (int j = i * 2; j < k; j += i) {
primes[j] = true;
}
}
var a = new int[k];
for (int i = 0; i < k; i++) {
if (i % 2 == 0)
continue;
if (!primes[i] && !primes[(i + 1) / 2])
a[i] = 1;
}
var s = new int[k + 1];
for (int i = 0; i < k; i++) {
s[i + 1] = s[i] + a[i];
}
for (int i = 0; i < q; i++) {
var p = Input().ToInt();
Console.WriteLine(s[(p[1] + 1)] - s[p[0]]);
}
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
[["+", 8, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 7, 26, 11, 0, 202, 0, 107], ["+", 0, 7, 8, 196, 0, 7, 26, 11, 12, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 48], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 23, 0, 24], ["+", 31, 204, 206, 207, 0, 28, 0, 23, 0, 25]]
| 8
| 470
| 38
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using static CS_Contest.Utils;
using static Nakov.IO.Cin;
// using static CS_Contest.Library;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
using ti3 = Tuple<int, 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 Q = NextInt();
Func<int, IEnumerable<int>> GetPrime = (Max) => {
int[] sieve = Enumerable.Range(0, Max + 1).ToArray();
sieve[1] = 0;
int sq = (int)Sqrt(Max);
for (int i = 2; i <= sq; i++) {
if (sieve[i] <= 0)
continue;
for (int n = i * 2; n <= Max; n += i)
sieve[n] = 0;
}
return sieve.Where(_ => _ > 0);
};
Func<int, bool> isPrime = (num) => {
if (num == 2)
return true;
if (num < 2 || num % 2 == 0)
return false;
int i = 3;
int sq = (int)Sqrt(num);
while (i <= sq) {
if (num % i == 0)
return false;
i += 2;
}
return true;
};
var primes = GetPrime(100000);
primes = primes.Where(_ => isPrime((_ + 1) / 2));
int sum = 0;
var box = new int[100001];
int start = 2;
foreach (var item in primes) {
sum++;
for (int i = start; i <= item; i++) {
box[i] = sum;
}
start = item + 1;
}
for (int i = start; i < 100001; i++) {
box[i] = sum;
}
REP(Q, _ => {
var li = NextInt();
var ri = NextInt();
(box[ri] - box[li]).WL();
});
return;
}
}
}
public static class Utils {
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 ReadInts() => ReadLine().Split().Select(int.Parse).ToList();
public static string
StringJoin<T>(this IEnumerable<T> l,
string separator = "") => string.Join(separator, l);
public static void REP(int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static int ManhattanDistance(int x1, int y1, int x2,
int y2) => Abs(x2 - x1) + Abs(y2 - y1);
public struct IndexT<T> {
public T Value { get; set; }
public int Index { get; set; }
public IndexT(T v, int i) {
Value = v;
Index = i;
}
public override string ToString() { return Value + " " + Index; }
}
public static IEnumerable<IndexT<T>> ToIndexEnumerable<T>(
this IEnumerable<T> list) => list.Select((x, i) => new IndexT<T>(x, i));
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 IndexT<T>
IndexOf<T>(this IEnumerable<T> ie,
Func<IndexT<T>, IndexT<T>, IndexT<T>> func) =>
ie.ToIndexEnumerable().Aggregate(func);
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static Dictionary<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Dictionary<TKey, int>();
foreach (var item in l) {
if (dic.ContainsKey(item))
dic[item]++;
else
dic.Add(item, 1);
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l,
T target) => l.Count(x => x.Equals(target));
}
}
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;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using static CS_Contest.Utils;
using static Nakov.IO.Cin;
// using static CS_Contest.Library;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
using ti3 = Tuple<int, 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 Q = NextInt();
Func<int, IEnumerable<int>> GetPrime = (Max) => {
int[] sieve = Enumerable.Range(0, Max + 1).ToArray();
sieve[1] = 0;
int sq = (int)Sqrt(Max);
for (int i = 2; i <= sq; i++) {
if (sieve[i] <= 0)
continue;
for (int n = i * 2; n <= Max; n += i)
sieve[n] = 0;
}
return sieve.Where(_ => _ > 0);
};
Func<int, bool> isPrime = (num) => {
if (num == 2)
return true;
if (num < 2 || num % 2 == 0)
return false;
int i = 3;
int sq = (int)Sqrt(num);
while (i <= sq) {
if (num % i == 0)
return false;
i += 2;
}
return true;
};
var primes = GetPrime(100000);
primes = primes.Where(_ => isPrime((_ + 1) / 2));
var isTarget = new bool[100001];
int sum = 0;
var box = new int[100001];
int start = 0;
foreach (var item in primes) {
for (int i = start; i < item; i++) {
box[i] = sum;
}
sum++;
start = item;
}
for (int i = start; i < 100001; i++) {
box[i] = sum;
}
REP(Q, _ => {
var li = NextInt();
var ri = NextInt();
(box[ri] - box[li - 1]).WL();
});
return;
}
}
}
public static class Utils {
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 ReadInts() => ReadLine().Split().Select(int.Parse).ToList();
public static string
StringJoin<T>(this IEnumerable<T> l,
string separator = "") => string.Join(separator, l);
public static void REP(int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static int ManhattanDistance(int x1, int y1, int x2,
int y2) => Abs(x2 - x1) + Abs(y2 - y1);
public struct IndexT<T> {
public T Value { get; set; }
public int Index { get; set; }
public IndexT(T v, int i) {
Value = v;
Index = i;
}
public override string ToString() { return Value + " " + Index; }
}
public static IEnumerable<IndexT<T>> ToIndexEnumerable<T>(
this IEnumerable<T> list) => list.Select((x, i) => new IndexT<T>(x, i));
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 IndexT<T>
IndexOf<T>(this IEnumerable<T> ie,
Func<IndexT<T>, IndexT<T>, IndexT<T>> func) =>
ie.ToIndexEnumerable().Aggregate(func);
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static Dictionary<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Dictionary<TKey, int>();
foreach (var item in l) {
if (dic.ContainsKey(item))
dic[item]++;
else
dic.Add(item, 1);
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l,
T target) => l.Count(x => x.Equals(target));
}
}
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;
}
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 210, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 210, 8, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["-", 0, 210, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 210, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 210, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 210, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 1,436
| 23
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
private const int MODULO = 1000000007;
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);
}
class Solver {
private int[] sums = new int[100001];
public Solver() {
var p1 = new HashSet<int>() { 2 };
var p2 = new HashSet<int>();
for (int i = 3; i <= 100000; ++i) {
if (p1.All(j => i % j != 0)) {
if (i * i <= 100000) {
p1.Add(i);
} else {
p2.Add(i);
}
}
}
Predicate<int> prime = n =>
(n * n <= 10000) ? p1.Contains(n) : p2.Contains(n);
for (int i = 3; i < 100000; ++i) {
sums[i] = (i % 2 != 0 && prime(i) && prime((i + 1) / 2))
? 1 + sums[i - 1]
: sums[i - 1];
sums[i + 1] = sums[i];
}
}
public int Solve(int l, int r) { return sums[r] - sums[l - 1]; }
}
static void Main(string[] args) {
int Q = ReadInt();
var solver = new Solver();
for (int i = 0; i < Q; ++i) {
int[] v = ReadInts();
Console.WriteLine(solver.Solve(v[0], v[1]));
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
private const int MODULO = 1000000007;
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);
}
class Solver {
const int N = 100000;
private int[] sums = new int[N + 1];
public Solver() {
var p1 = new HashSet<int>() { 2 };
var p2 = new HashSet<int>();
for (int i = 3; i <= N; ++i) {
if (p1.All(j => i % j != 0)) {
if (i * i <= N) {
p1.Add(i);
} else {
p2.Add(i);
}
}
}
Predicate<int> prime = n =>
(n * n <= N) ? p1.Contains(n) : p2.Contains(n);
for (int i = 3; i < N; ++i) {
sums[i] = (i % 2 != 0 && prime(i) && prime((i + 1) / 2))
? 1 + sums[i - 1]
: sums[i - 1];
sums[i + 1] = sums[i];
}
}
public int Solve(int l, int r) { return sums[r] - sums[l - 1]; }
}
static void Main(string[] args) {
int Q = ReadInt();
var solver = new Solver();
for (int i = 0; i < Q; ++i) {
int[] v = ReadInts();
Console.WriteLine(solver.Solve(v[0], v[1]));
}
}
}
}
|
[["+", 0, 235, 8, 201, 0, 124, 0, 251, 0, 154], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 8, 201, 0, 124, 0, 198, 0, 200, 141, 22], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 235, 8, 201, 0, 124, 0, 35], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["-", 0, 263, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 263, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 218, 8, 41, 15, 23, 0, 16, 12, 203], ["+", 0, 218, 8, 41, 15, 23, 0, 16, 12, 22]]
| 8
| 494
| 18
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Prime {
int n;
// Sieve of Eratosthenes
BitArray sieve;
public Prime(int _n) {
n = _n;
sieve = new BitArray(n + 1);
var end = (int)(Math.Sqrt(n) + 0.1);
for (int i = 2; i <= end; i++) {
if (!sieve.Get(i)) {
for (int j = i * 2; j <= n; j += i) {
sieve.Set(j, true);
}
}
}
}
public bool IsPrime(int i) { return !sieve.Get(i); }
}
class Solution {
static void Main() {
var q = int.Parse(Console.ReadLine());
var l = new int[q];
var r = new int[q];
for (int i = 0; i < q; i++) {
var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
l[i] = vals[0];
r[i] = vals[1];
}
var min = l.Min();
var max = r.Max();
var prime = new Prime(max);
var accSum = new int[max + 1];
for (int i = 1; i <= max; i++) {
var isLike2017 = prime.IsPrime(i) && prime.IsPrime((i + 1) / 2);
accSum[i] = accSum[i - 1];
if (isLike2017) {
accSum[i]++;
}
}
for (int i = 0; i < q; i++) {
var x = accSum[r[i]] - accSum[l[i] - 1];
Console.WriteLine(x);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Prime {
int n;
// Sieve of Eratosthenes
BitArray sieve;
public Prime(int _n) {
n = _n;
sieve = new BitArray(n + 1);
var end = (int)(Math.Sqrt(n) + 0.1);
for (int i = 2; i <= end; i++) {
if (!sieve.Get(i)) {
for (int j = i * 2; j <= n; j += i) {
sieve.Set(j, true);
}
}
}
sieve.Set(1, true);
}
public bool IsPrime(int i) { return !sieve.Get(i); }
}
class Solution {
static void Main() {
var q = int.Parse(Console.ReadLine());
var l = new int[q];
var r = new int[q];
for (int i = 0; i < q; i++) {
var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
l[i] = vals[0];
r[i] = vals[1];
}
var min = l.Min();
var max = r.Max();
var prime = new Prime(max);
var accSum = new int[max + 1];
for (int i = 1; i <= max; i++) {
var isLike2017 = prime.IsPrime(i) && prime.IsPrime((i + 1) / 2);
accSum[i] = accSum[i - 1];
if (isLike2017) {
accSum[i]++;
}
}
for (int i = 0; i < q; i++) {
var x = accSum[r[i]] - accSum[l[i] - 1];
Console.WriteLine(x);
}
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 213, 3, 4, 0, 28, 0, 211, 0, 146], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 263, 8, 196, 0, 1, 0, 35]]
| 8
| 396
| 9
|
using System;
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int b = int.Parse(input[0]);
int c = int.Parse(input[1]);
int d = int.Parse(input[2]);
int e = int.Parse(input[3]);
if (b + c == d + e) {
Console.WriteLine("Balanced");
} else if ((b + c > d + e)) {
Console.WriteLine("Left");
} else {
Console.WriteLine("Right");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int b = int.Parse(input[0]);
int c = int.Parse(input[1]);
int d = int.Parse(input[2]);
int e = int.Parse(input[3]);
if (b + c == d + e) {
Console.WriteLine("Balanced");
} else if ((b + c > d + e)) {
Console.WriteLine("Left");
} else {
Console.WriteLine("Right");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35]]
| 8
| 160
| 14
|
using System;
public class Program {
public static void Main() {
string n = Console.ReadLine();
int N = int.Parse(n);
string a = Console.ReadLine();
int A = int.Parse(a);
string b = Console.ReadLine();
int B = int.Parse(b);
Console.WriteLine(SomeSum(A, B, N));
}
public static int SomeSum(int A, int B, int N) {
int AllSum = 0;
int sum = 0;
for (int i = 1; i <= N; i++) {
int hitotsu = 0;
int futatsu = 0;
int mittsu = 0;
int yottsu = 0;
int itsutsu = 0;
hitotsu = i % 10;
if (i >= 10) {
futatsu = (i / 10) % 10;
if (i >= 100) {
mittsu = (i / 100) % 10;
if (i >= 1000) {
yottsu = (i / 1000) % 10;
if (i >= 10000) {
itsutsu = (i / 10000) % 10;
}
}
}
}
sum = hitotsu + futatsu + mittsu + yottsu + itsutsu;
if (A <= sum && sum <= B) {
AllSum += i;
}
}
return AllSum;
}
}
|
using System;
public class Program {
public static void Main() {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int A = int.Parse(input[1]);
int B = int.Parse(input[2]);
Console.WriteLine(SomeSum(A, B, N));
}
public static int SomeSum(int A, int B, int N) {
int AllSum = 0;
int sum = 0;
for (int i = 1; i <= N; i++) {
int hitotsu = 0;
int futatsu = 0;
int mittsu = 0;
int yottsu = 0;
int itsutsu = 0;
hitotsu = i % 10;
if (i >= 10) {
futatsu = (i / 10) % 10;
if (i >= 100) {
mittsu = (i / 100) % 10;
if (i >= 1000) {
yottsu = (i / 1000) % 10;
if (i >= 10000) {
itsutsu = (i / 10000) % 10;
}
}
}
}
sum = hitotsu + futatsu + mittsu + yottsu + itsutsu;
if (A <= sum && sum <= B) {
AllSum += i;
}
}
return AllSum;
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
| 8
| 263
| 44
|
using System;
using System.Linq;
public class Hello {
public static void Main() {
//使わないのはコメントアウトしないとエラー
var num = NumInput();
// var text = StringInput();
int res = 0;
for (int i = 0; i <= num[0]; i++) {
var sum = (i / 10) + (i % 10);
if (sum >= num[1] && sum <= num[2])
res += i;
}
Result(res);
}
static int[] NumInput() {
var input_line = Console.ReadLine().Split(' ');
return input_line.Select(int.Parse).ToArray();
}
static string[] StringInput() { return Console.ReadLine().Split(' '); }
static void Result(string text) { Console.WriteLine(text); }
static void Result(int num) { Console.WriteLine(num); }
static void Result(float num) { Console.WriteLine(num); }
}
|
using System;
using System.Linq;
public class Hello {
public static void Main() {
//使わないのはコメントアウトしないとエラー
var num = NumInput();
// var text = StringInput();
int res = 0;
for (int i = 0; i <= num[0]; i++) {
var sum = 0;
var n = i;
while (n > 0) {
sum += n % 10;
n /= 10;
}
if (sum >= num[1] && sum <= num[2])
res += i;
// Result(i +" " +sum);
}
Result(res);
}
static int[] NumInput() {
var input_line = Console.ReadLine().Split(' ');
return input_line.Select(int.Parse).ToArray();
}
static string[] StringInput() { return Console.ReadLine().Split(' '); }
static void Result(string text) { Console.WriteLine(text); }
static void Result(int num) { Console.WriteLine(num); }
static void Result(float num) { Console.WriteLine(num); }
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 17, 85], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 8, 196, 0, 7, 8, 196, 0, 52, 0, 89], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 52, 0, 25], ["+", 0, 7, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 7, 8, 196, 0, 52, 8, 196, 0, 46]]
| 8
| 204
| 27
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace PastQuestions {
class Program {
static void Main(string[] args) {
new Program().Solve(new Input(Console.In));
}
public void Solve(Input input) {
var n = input.ReadInt;
var a = input.ReadInt;
var b = input.ReadInt;
var count = 0;
for (var i = 0; i <= n; ++i) {
var iArr = i.ToString().ToArray();
var total = 0;
for (var j = 0; j < iArr.Length - 1; j++) {
total += int.Parse(iArr[j].ToString());
}
if (a <= total && total <= b)
count++;
}
}
}
public class Input {
private TextReader Stream { get; }
private char Separator { get; }
private Queue<string> InputStream { get; }
public Input(TextReader stream, char separator = ' ') {
Stream = stream;
Separator = separator;
InputStream = new Queue<string>();
}
public string Read {
get {
if (InputStream.Count != 0)
return InputStream.Dequeue();
string[] tmp = Stream.ReadLine().Split(Separator);
for (int i = 0; i < tmp.Length; ++i)
InputStream.Enqueue(tmp[i]);
return InputStream.Dequeue();
}
}
public string ReadLine => Stream.ReadLine();
public int ReadInt => int.Parse(Read);
public long ReadLong => long.Parse(Read);
public double ReadDouble => double.Parse(Read);
public long[] ReadLongArray =>
Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace PastQuestions {
class Program {
static void Main(string[] args) {
new Program().Solve(new Input(Console.In));
}
public void Solve(Input input) {
var n = input.ReadInt;
var a = input.ReadInt;
var b = input.ReadInt;
var answer = 0;
for (var i = 1; i <= n; ++i) {
var iArr = i.ToString().ToArray();
var total = 0;
for (var j = 0; j < iArr.Length; j++) {
total += int.Parse(iArr[j].ToString());
}
if (a <= total && total <= b)
answer += i;
}
Console.WriteLine(answer);
}
}
public class Input {
private TextReader Stream { get; }
private char Separator { get; }
private Queue<string> InputStream { get; }
public Input(TextReader stream, char separator = ' ') {
Stream = stream;
Separator = separator;
InputStream = new Queue<string>();
}
public string Read {
get {
if (InputStream.Count != 0)
return InputStream.Dequeue();
string[] tmp = Stream.ReadLine().Split(Separator);
for (int i = 0; i < tmp.Length; ++i)
InputStream.Enqueue(tmp[i]);
return InputStream.Dequeue();
}
}
public string ReadLine => Stream.ReadLine();
public int ReadInt => int.Parse(Read);
public long ReadLong => long.Parse(Read);
public double ReadDouble => double.Parse(Read);
public long[] ReadLongArray =>
Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 383
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC083B {
class Program {
static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int n = input[0];
int a = input[1];
int b = input[2];
int ans = 0;
for (int t = 1; t <= n; t++) {
int[] tArray = IntToArray(t);
int sum = 0;
for (int s = 0; s < tArray.Length; s++) {
sum += tArray[s];
}
if (a <= sum && sum <= b) {
Console.WriteLine(sum);
ans += t;
}
}
Console.WriteLine(ans);
}
static int[] IntToArray(int s) {
return s.ToString()
.ToCharArray()
.Select(x => x.ToString())
.Select(x => int.Parse(x))
.ToArray();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC083B {
class Program {
static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int n = input[0];
int a = input[1];
int b = input[2];
int ans = 0;
for (int t = 1; t <= n; t++) {
int[] tArray = IntToArray(t);
int sum = 0;
for (int s = 0; s < tArray.Length; s++) {
sum += tArray[s];
}
if (a <= sum && sum <= b) {
ans += t;
}
}
Console.WriteLine(ans);
}
static int[] IntToArray(int s) {
return s.ToString()
.ToCharArray()
.Select(x => x.ToString())
.Select(x => int.Parse(x))
.ToArray();
}
}
}
|
[["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 244
| 7
|
using System;
using System.Linq;
namespace Program {
class test {
static void Main() {
int ans1 = 0;
int ans2 = 0;
string[] s = Console.ReadLine().Split();
int[] intArray = s.Select(int.Parse).ToArray();
for (int i = 1; i <= intArray[0]; i++) {
if (i >= 10) {
var aaa = i % 10;
var bbb = i / 10;
ans1 = aaa + bbb;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i >= 100) {
var aaa = i % 10;
var bbb = i / 10;
var ccc = bbb % 10;
var ddd = bbb / 10;
ans1 = aaa + ccc + ddd;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i >= 1000) {
var aaa = i % 10; // 4
var bbb = i / 10;
var ccc = bbb % 10; // 3
var ddd = bbb / 10;
var eee = ddd % 10; // 2
var fff = ddd / 10; // 1
ans1 = aaa + ccc + eee + fff;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i == 10000) {
ans1 = 1;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i < 10) {
ans1 = i;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
}
Console.WriteLine(ans2);
}
}
}
|
using System;
using System.Linq;
namespace Program {
class test {
static void Main() {
int ans1 = 0;
int ans2 = 0;
string[] s = Console.ReadLine().Split();
int[] intArray = s.Select(int.Parse).ToArray();
for (int i = 1; i <= intArray[0]; i++) {
ans1 = 0;
if (i >= 10 && i < 100) {
var aaa = i % 10;
var bbb = i / 10;
ans1 = aaa + bbb;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i >= 100 && i < 1000) {
var aaa = i % 10;
var bbb = i / 10;
var ccc = bbb % 10;
var ddd = bbb / 10;
ans1 = aaa + ccc + ddd;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i >= 1000 && i < 10000) {
var aaa = i % 10; // 4
var bbb = i / 10;
var ccc = bbb % 10; // 3
var ddd = bbb / 10;
var eee = ddd % 10; // 2
var fff = ddd / 10; // 1
ans1 = aaa + ccc + eee + fff;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i == 10000) {
ans1 = 1;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
if (i < 10) {
ans1 = i;
if (intArray[1] <= ans1 && ans1 <= intArray[2]) {
ans2 += i;
}
}
}
Console.WriteLine(ans2);
}
}
}
|
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 362
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC083B {
class Program {
static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int N = input[0];
int A = input[1];
int B = input[2];
int answer = 0;
for (int i = 1; i < N + 1; i++) {
int sum = 0;
int j = 0;
while (Math.Pow(10, j) <= i) {
if (j == 0) {
sum += i % 10;
} else {
sum += ((i % (int)Math.Pow(10, j + 1)) - (i % (int)Math.Pow(10, j))) /
(int)Math.Pow(10, j);
}
j++;
}
Console.WriteLine(sum);
if (A <= sum && sum <= B) {
answer += i;
}
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC083B {
class Program {
static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int N = input[0];
int A = input[1];
int B = input[2];
int answer = 0;
for (int i = 1; i < N + 1; i++) {
int sum = 0;
int j = 0;
while (Math.Pow(10, j) <= i) {
if (j == 0) {
sum += i % 10;
} else {
sum += ((i % (int)Math.Pow(10, j + 1)) - (i % (int)Math.Pow(10, j))) /
(int)Math.Pow(10, j);
}
j++;
}
if (A <= sum && sum <= B) {
answer += i;
}
}
Console.WriteLine(answer);
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 252
| 7
|
using System;
using System.Linq;
namespace agc083_c {
class Program {
static void Main(string[] args) {
long[] inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long x = inputLongArray[0];
long y = inputLongArray[1];
long cnt = 0;
while (x < y) {
cnt++;
x *= 2;
}
Console.WriteLine(cnt);
}
}
}
|
using System;
using System.Linq;
namespace agc083_c {
class Program {
static void Main(string[] args) {
long[] inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long x = inputLongArray[0];
long y = inputLongArray[1];
long cnt = 0;
while (x <= y) {
x *= 2;
cnt++;
}
Console.WriteLine(cnt);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 104
| 8
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Contest.C {
class Program {
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Scanner cin = new Scanner();
long x = cin.nextLong();
long y = cin.nextLong();
Console.WriteLine(Math.Log((x + 0.0) / y, 2.0));
Console.Out.Flush();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Contest.C {
class Program {
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Scanner cin = new Scanner();
long x = cin.nextLong();
long y = cin.nextLong();
long a = x;
int ans = 0;
while (a <= y) {
a *= 2;
ans++;
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 250], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 250], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 485
| 40
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class MyProgram {
public static void Main() {
long[] n =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long X = n[0];
long Y = n[1];
int cnt = 0;
int A = 1;
while (Y >= 0) {
Y -= X;
X *= 2;
cnt++;
}
Console.WriteLine(cnt);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class MyProgram {
public static void Main() {
long[] n =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long X = n[0];
long Y = n[1];
int cnt = 0;
while (X <= Y) {
X *= 2;
cnt++;
}
Console.WriteLine(cnt);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 8
| 119
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Contest {
class Scanner {
private string[] line = new string[0];
private int index = 0;
public string Next() {
if (line.Length <= index) {
line = Console.ReadLine().Split(' ');
index = 0;
}
var res = line[index];
index++;
return res;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public string[] Array() {
line = Console.ReadLine().Split(' ');
index = line.Length;
return line;
}
public int[] IntArray() { return Array().Select(int.Parse).ToArray(); }
public long[] LongArray() { return Array().Select(long.Parse).ToArray(); }
}
class Program {
private long X, Y;
private void Scan() {
var sc = new Scanner();
X = sc.NextLong();
Y = sc.NextLong();
}
public void Solve() {
Scan();
for (int i = 1; i <= 100; i++) {
if (X * (1 << i) > Y) {
Console.WriteLine(i);
return;
}
}
}
static void Main(string[] args) { new Program().Solve(); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Contest {
class Scanner {
private string[] line = new string[0];
private int index = 0;
public string Next() {
if (line.Length <= index) {
line = Console.ReadLine().Split(' ');
index = 0;
}
var res = line[index];
index++;
return res;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public string[] Array() {
line = Console.ReadLine().Split(' ');
index = line.Length;
return line;
}
public int[] IntArray() { return Array().Select(int.Parse).ToArray(); }
public long[] LongArray() { return Array().Select(long.Parse).ToArray(); }
}
class Program {
private long X, Y;
private void Scan() {
var sc = new Scanner();
X = sc.NextLong();
Y = sc.NextLong();
}
public void Solve() {
Scan();
for (int i = 1; i <= 100; i++) {
X *= 2;
if (X > Y) {
Console.WriteLine(i);
return;
}
}
}
static void Main(string[] args) { new Program().Solve(); }
}
}
|
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 16, 31, 16, 12, 23, 0, 24], ["-", 15, 16, 31, 16, 12, 23, 0, 16, 31, 203], ["-", 15, 16, 31, 16, 12, 23, 0, 16, 17, 151], ["-", 15, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 23, 0, 25]]
| 8
| 336
| 10
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var x = long.Parse(line[0]);
var y = long.Parse(line[1]);
var a = y / x;
var count = 1;
while (true) {
if (a <= y)
count++;
else {
Console.WriteLine(count + 1);
break;
}
a *= 2;
}
}
}
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var x = long.Parse(line[0]);
var y = long.Parse(line[1]);
var count = 0;
while (true) {
if (x <= y)
count++;
else {
Console.WriteLine(count);
break;
}
x *= 2;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22]]
| 8
| 109
| 15
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.D_Challenge {
class ABC_083 {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
string s = Read();
var sequenceList = new List<int>();
bool isZero = s[0] == '0';
int nowCnt = 1;
for (int i = 1; i < s.Length; i++) {
if ((isZero && s[i] == '0') || (!isZero && s[i] == '1')) {
nowCnt++;
} else {
sequenceList.Add(nowCnt);
isZero = s[i] == '0';
nowCnt = 1;
}
}
sequenceList.Add(nowCnt);
for (int i = 0; i < sequenceList.Count; i++) {
Console.WriteLine(sequenceList[i]);
}
int first = 0;
int last = sequenceList.Count - 1;
int head = sequenceList[first];
int tail = sequenceList[last];
int min = int.MaxValue;
while (head + tail < s.Length) {
if (head < tail) {
min = Math.Min(min, s.Length - head);
first++;
head += sequenceList[first];
} else {
min = Math.Min(min, s.Length - tail);
last--;
tail += sequenceList[last];
}
// Console.WriteLine(head + " " + tail);
}
Console.WriteLine(Math.Max(head, tail));
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.D_Challenge {
class ABC_083 {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
string s = Read();
var sequenceList = new List<int>();
bool isZero = s[0] == '0';
int nowCnt = 1;
for (int i = 1; i < s.Length; i++) {
if ((isZero && s[i] == '0') || (!isZero && s[i] == '1')) {
nowCnt++;
} else {
sequenceList.Add(nowCnt);
isZero = s[i] == '0';
nowCnt = 1;
}
}
sequenceList.Add(nowCnt);
for (int i = 0; i < sequenceList.Count; i++) {
// Console.WriteLine(sequenceList[i]);
}
int first = 0;
int last = sequenceList.Count - 1;
int head = sequenceList[first];
int tail = sequenceList[last];
int min = int.MaxValue;
while (head + tail < s.Length) {
if (head < tail) {
min = Math.Min(min, s.Length - head);
first++;
head += sequenceList[first];
} else {
min = Math.Min(min, s.Length - tail);
last--;
tail += sequenceList[last];
}
// Console.WriteLine(head + " " + tail);
}
Console.WriteLine(Math.Max(head, tail));
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 483
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Contest {
class Scanner {
private string[] line = new string[0];
private int index = 0;
public string Next() {
if (line.Length <= index) {
line = Console.ReadLine().Split(' ');
index = 0;
}
var res = line[index];
index++;
return res;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public string[] Array() {
line = Console.ReadLine().Split(' ');
index = line.Length;
return line;
}
public int[] IntArray() { return Array().Select(int.Parse).ToArray(); }
public long[] LongArray() { return Array().Select(long.Parse).ToArray(); }
}
class HashMap<K, V> : Dictionary<K, V> {
new public V this[K i] { get { V v;
return TryGetValue(i, out v) ? v : base[i] = default(V);
}
set { base[i] = value; }
}
}
class Program {
private string S;
private void Scan() {
var sc = new Scanner();
S = sc.Next();
}
public void Solve() {
Scan();
int ans = S.Length;
for (int i = 1; i < S.Length; i++) {
if (S[i] != S[i - 1])
ans = Math.Min(ans, Math.Max(S.Length - i, i));
}
}
static void Main(string[] args) { new Program().Solve(); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Contest {
class Scanner {
private string[] line = new string[0];
private int index = 0;
public string Next() {
if (line.Length <= index) {
line = Console.ReadLine().Split(' ');
index = 0;
}
var res = line[index];
index++;
return res;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public string[] Array() {
line = Console.ReadLine().Split(' ');
index = line.Length;
return line;
}
public int[] IntArray() { return Array().Select(int.Parse).ToArray(); }
public long[] LongArray() { return Array().Select(long.Parse).ToArray(); }
}
class HashMap<K, V> : Dictionary<K, V> {
new public V this[K i] { get { V v;
return TryGetValue(i, out v) ? v : base[i] = default(V);
}
set { base[i] = value; }
}
}
class Program {
private string S;
private void Scan() {
var sc = new Scanner();
S = sc.Next();
}
public void Solve() {
Scan();
int ans = S.Length;
for (int i = 1; i < S.Length; i++) {
if (S[i] != S[i - 1])
ans = Math.Min(ans, Math.Max(S.Length - i, i));
}
Console.WriteLine(ans);
}
static void Main(string[] args) { new Program().Solve(); }
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 411
| 7
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
string inpt = Reader.ReadLine();
List<string> list = new List<string>();
int idx = 0;
int ans = 0;
for (int i = 1; i < inpt.Length; i++) {
if (inpt[i] != inpt[i - 1]) {
list.Add(inpt.Substring(idx, i - idx));
idx = i;
if (inpt.Length % 2 == 0 && i == inpt.Length / 2) {
Console.WriteLine(inpt.Length / 2);
return;
}
}
}
list.Add(inpt.Substring(idx));
idx = 0;
for (int i = 0; i < list.Count; i++) {
if (idx <= inpt.Length / 2 && idx + list[i].Length > inpt.Length / 2) {
ans = Math.Min(idx + list[i].Length - 1, inpt.Length - idx);
break;
}
idx += list[i].Length;
}
Console.WriteLine(ans);
}
public class Reader {
private static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
1111101
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
string inpt = Reader.ReadLine();
List<string> list = new List<string>();
int idx = 0;
int ans = 0;
for (int i = 1; i < inpt.Length; i++) {
if (inpt[i] != inpt[i - 1]) {
list.Add(inpt.Substring(idx, i - idx));
idx = i;
}
}
list.Add(inpt.Substring(idx));
idx = 0;
for (int i = 0; i < list.Count; i++) {
if (idx <= inpt.Length / 2 && idx + list[i].Length > inpt.Length / 2) {
ans = Math.Min(idx + list[i].Length, inpt.Length - idx);
break;
}
idx += list[i].Length;
}
Console.WriteLine(ans);
}
public class Reader {
private static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
1122
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
[["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["-", 15, 16, 31, 16, 31, 16, 31, 214, 205, 22], ["-", 15, 16, 31, 16, 31, 16, 31, 214, 0, 131], ["-", 15, 16, 31, 16, 31, 16, 31, 214, 141, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 15, 16, 12, 16, 12, 16, 31, 214, 205, 22], ["-", 15, 16, 12, 16, 12, 16, 31, 214, 0, 131], ["-", 15, 16, 12, 16, 12, 16, 31, 214, 141, 22], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 64, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258]]
| 8
| 372
| 37
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
public static void Main(string[] args) {
var a = ReadLineIntSpilit();
Console.WriteLine((a[0] + a[1]) / 2);
ReadLine();
}
public static string ReadLine() { return Console.ReadLine(); }
public static int ReadLineInt() { return int.Parse(Console.ReadLine()); }
public static string[] ReadLineStringSplit(char a = ' ') {
return ReadLine().Split(a).ToArray();
}
public static int[] ReadLineIntSpilit(char a = ' ') {
return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
public static void Main(string[] args) {
var a = ReadLineIntSpilit();
var result = Math.Ceiling(((float)a[0] + a[1]) / 2);
Console.WriteLine(result);
ReadLine();
}
public static string ReadLine() { return Console.ReadLine(); }
public static int ReadLineInt() { return int.Parse(Console.ReadLine()); }
public static string[] ReadLineStringSplit(char a = ' ') {
return ReadLine().Split(a).ToArray();
}
public static int[] ReadLineIntSpilit(char a = ' ') {
return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 74, 39, 199], ["+", 0, 16, 31, 23, 0, 16, 31, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 184
| 17
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
//入力
// int n = 100;
/*
long n = long.Parse(Console.ReadLine());
long[] input = new long[5];
for(int a = 0; a < 5; a++)
{
input[a]=long.Parse(Console.ReadLine());
}
*/
int[] input =
Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
// string input= Console.ReadLine();
Console.WriteLine((input.Sum()) / 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 n = 100;
/*
long n = long.Parse(Console.ReadLine());
long[] input = new long[5];
for(int a = 0; a < 5; a++)
{
input[a]=long.Parse(Console.ReadLine());
}
*/
int[] input =
Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
// string input= Console.ReadLine();
Console.WriteLine(Math.Ceiling((double)input.Sum() / 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();
}
}
|
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 94
| 8
|
using System;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var t = Console.ReadLine();
var output = a(s, t) ? "Yes" : "No";
Console.WriteLine(output);
}
static bool a(string s, string t) {
var s_sorted = s.OrderBy(c => c).ToArray();
var t_sorted = t.OrderByDescending(c => c).ToArray();
for (var i = 0; i < s_sorted.Length; i++) {
if (i == t_sorted.Length)
return false;
if (s_sorted[i] > t_sorted[i])
return false;
if (s_sorted[i] < t_sorted[i])
return true;
}
return true;
}
}
}
|
using System;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var t = Console.ReadLine();
var output = a(s, t) ? "Yes" : "No";
Console.WriteLine(output);
}
static bool a(string s, string t) {
var s_sorted = s.OrderBy(c => c).ToArray();
var t_sorted = t.OrderByDescending(c => c).ToArray();
for (var i = 0; i < s_sorted.Length; i++) {
if (i == t_sorted.Length)
return false;
if (s_sorted[i] > t_sorted[i])
return false;
if (s_sorted[i] < t_sorted[i])
return true;
}
return s_sorted.Length < t_sorted.Length;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 37, 0, 211, 0, 146], ["+", 8, 196, 0, 37, 0, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 37, 0, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 37, 0, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 17, 18], ["+", 8, 196, 0, 37, 0, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 37, 0, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 37, 0, 16, 12, 214, 141, 22]]
| 8
| 176
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
public static bool f = false, t = true;
static void Main(string[] args) {
string a = Console.ReadLine();
string b = Console.ReadLine();
string a1 = "", b1 = "";
List<char> d1 = new List<char> {};
List<char> d2 = new List<char> {};
for (int i = 0; i < a.Length; i++) {
d1.Add(a[i]);
}
for (int i = 0; i < b.Length; i++) {
d1.Add(b[i]);
}
d1.Sort();
d2.Sort();
bool con = true;
for (int i = 0; i < Math.Min(d1.Count(), d2.Count()); i++) {
if (d1[i] > d2[i]) {
con = false;
}
if (d1[i] < d2[i]) {
Console.WriteLine("Yes");
return;
}
}
if (con && d1.Count() < d2.Count) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
public static long gcd(long a, long b) {
while (true) {
if (a == 0) {
return b;
}
if (b == 0) {
return a;
}
if (a > b) {
a -= b;
} else {
b -= a;
}
}
}
public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
public static bool IsPrime(int num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
}
public static class Read {
public static void outl(string n = "") {
Console.WriteLine(n);
return;
}
public static long Long() { return long.Parse(Console.ReadLine()); }
public static long[] longs() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static int Int() { return int.Parse(Console.ReadLine()); }
public static int[] ints() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
public static string Str() { return Console.ReadLine(); }
public static string[] Strs() { return Console.ReadLine().Split(); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
public static bool f = false, t = true;
static void Main(string[] args) {
string a = Console.ReadLine();
string b = Console.ReadLine();
string a1 = "", b1 = "";
List<char> d1 = new List<char> {};
List<char> d2 = new List<char> {};
for (int i = 0; i < a.Length; i++) {
d1.Add(a[i]);
}
for (int i = 0; i < b.Length; i++) {
d2.Add(b[i]);
}
d1.Sort();
d2.Sort();
d2.Reverse();
bool con = true;
for (int i = 0; i < Math.Min(d1.Count(), d2.Count()); i++) {
if (d1[i] > d2[i]) {
con = false;
}
if (d1[i] < d2[i]) {
Console.WriteLine("Yes");
return;
}
}
if (con && d1.Count() < d2.Count) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
Console.ReadLine();
}
public static long gcd(long a, long b) {
while (true) {
if (a == 0) {
return b;
}
if (b == 0) {
return a;
}
if (a > b) {
a -= b;
} else {
b -= a;
}
}
}
public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
public static bool IsPrime(int num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
}
public static class Read {
public static void outl(string n = "") {
Console.WriteLine(n);
return;
}
public static long Long() { return long.Parse(Console.ReadLine()); }
public static long[] longs() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static int Int() { return int.Parse(Console.ReadLine()); }
public static int[] ints() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
public static string Str() { return Console.ReadLine(); }
public static string[] Strs() { return Console.ReadLine().Split(); }
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22]]
| 8
| 622
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var A = sc.ReadIntArray(N);
var g = A.GroupBy(a => a);
int ans = 0;
foreach (var item in g) {
if (item.Key > item.Count()) {
ans += item.Count();
} else {
ans += item.Key - item.Count();
}
}
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var A = sc.ReadIntArray(N);
var g = A.GroupBy(a => a);
int ans = 0;
foreach (var item in g) {
if (item.Key > item.Count()) {
ans += item.Count();
} else {
ans += item.Count() - item.Key;
}
}
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 0, 1, 0, 11, 12, 16, 31, 214, 141, 22], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 16, 12, 214, 141, 22]]
| 8
| 1,090
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
namespace AtCodeeeer {
class AtCOOOOOOOOOOOder {
static void Main(string[] args) {
int n = int.Parse(ReadLine());
long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
Array.Sort(s);
long ans = 0;
long target = s[0];
long cnt = 1;
for (int i = 1; i < n; i++) {
if (target == s[i]) {
cnt++;
} else {
if (cnt < target) {
ans += cnt;
} else if (cnt > target) {
ans += cnt - target;
}
//初期化
target = s[i];
cnt = 1;
}
if (i == n - 1) {
if (cnt < target) {
ans += cnt;
} else if (cnt > target) {
ans += cnt - target;
}
}
}
WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
namespace AtCodeeeer {
class AtCOOOOOOOOOOOder {
static void Main(string[] args) {
int n = int.Parse(ReadLine());
long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
Array.Sort(s);
long ans = 0;
long target = s[0];
long cnt = 1;
if (n == 1) {
WriteLine(s[0] == 1 ? "0" : "1");
return;
}
for (int i = 1; i < n; i++) {
if (target == s[i]) {
cnt++;
} else {
if (cnt < target) {
ans += cnt;
} else if (cnt > target) {
ans += cnt - target;
}
//初期化
target = s[i];
cnt = 1;
}
if (i == n - 1) {
if (cnt < target) {
ans += cnt;
} else if (cnt > target) {
ans += cnt - target;
}
}
}
WriteLine(ans);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 41, 15, 16, 31, 204, 205, 22], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 224
| 28
|
using System;
using System.Linq;
using System.Collections.Generic;
class Cmondai {
static void Main() {
var N = Int64.Parse(Console.ReadLine());
var a = Console.ReadLine()
.Split(' ')
.Select(x => Int64.Parse(x))
.OrderBy(x => x)
.ToArray();
var array = new long[N + 1];
var ans = 0L;
for (int i = 0; i < N - 1; ++i) {
if (N < a[i]) {
ans++;
continue;
}
array[a[i]]++;
if (a[i] < array[a[i]])
ans++;
if (array[a[i]] < a[i] && a[i + 1] != a[i])
ans += array[a[i]];
}
if (N < a[N - 1])
ans++;
else {
array[a[N - 1]]++;
if (a[N - 1] != array[a[N - 1]])
ans += array[a[N - 1]];
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Cmondai {
static void Main() {
var N = Int64.Parse(Console.ReadLine());
var a = Console.ReadLine()
.Split(' ')
.Select(x => Int64.Parse(x))
.OrderBy(x => x)
.ToArray();
var array = new long[N + 1];
var ans = 0L;
for (int i = 0; i < N - 1; ++i) {
if (N < a[i]) {
ans++;
continue;
}
array[a[i]]++;
if (a[i] < array[a[i]])
ans++;
else if (array[a[i]] < a[i] && a[i + 1] != a[i])
ans += array[a[i]];
}
if (N < a[N - 1])
ans++;
else {
array[a[N - 1]]++;
if (a[N - 1] < array[a[N - 1]])
ans++;
else if (array[a[N - 1]] < a[N - 1])
ans += array[a[N - 1]];
}
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 75, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 75, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 75, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 57, 75, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 57, 75, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 57, 15, 16, 12, 204, 205, 22], ["+", 75, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 259
| 26
|
using System;
using System.Linq;
namespace AtCoder {
class program {
static void Main(string[] args) {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = n[0];
int M = n[1];
Console.WriteLine(M * (100 * (N - M) + 1900 * M));
Console.ReadLine();
}
}
}
|
using System;
using System.Linq;
namespace AtCoder {
class program {
static void Main(string[] args) {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = n[0];
int M = n[1];
Console.WriteLine((int)Math.Pow(2, M) * (100 * (N - M) + 1900 * M));
Console.ReadLine();
}
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 74, 51, 213, 3, 4, 0, 24], ["+", 31, 74, 51, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 31, 74, 51, 213, 3, 4, 0, 21], ["+", 0, 16, 31, 74, 51, 213, 3, 4, 0, 25]]
| 8
| 96
| 10
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int n = Cin.Ni();
int m = Cin.Ni();
int ans = m * 950 + ((n - m) * 100);
Console.WriteLine(ans);
}
}
public struct Parts {
public int Size;
public int Count;
public Parts(int size, int count) {
Size = size;
Count = count;
}
}
public class Cin {
private static string[] s = new string[0];
private static int i = 0;
private static char[] cs = new char[] { ' ' };
public static string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return Next();
}
public static int Ni() { return int.Parse(Next()); }
public static long NextLong() { return long.Parse(Next()); }
public static double NextDouble() { return double.Parse(Next()); }
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int n = Cin.Ni();
int m = Cin.Ni();
int ans = (m * 1900 + ((n - m) * 100)) * (int)Math.Pow(2, m);
Console.WriteLine(ans);
}
}
public struct Parts {
public int Size;
public int Count;
public Parts(int size, int count) {
Size = size;
Count = count;
}
}
public class Cin {
private static string[] s = new string[0];
private static int i = 0;
private static char[] cs = new char[] { ' ' };
public static string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return Next();
}
public static int Ni() { return int.Parse(Next()); }
public static long NextLong() { return long.Parse(Next()); }
public static double NextDouble() { return double.Parse(Next()); }
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 203], ["+", 0, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25], ["+", 0, 16, 12, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 16, 12, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 16, 12, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 74, 51, 213, 3, 4, 0, 24], ["+", 12, 74, 51, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 12, 74, 51, 213, 3, 4, 0, 21], ["+", 12, 74, 51, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 262
| 16
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
int N, Z, W;
int[] a;
void Solve() {
// input
N = io.Int;
Z = io.Int;
W = io.Int;
a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = io.Int;
// cal
var ans1 = Math.Abs(a.Last() - W);
var ans2 = Math.Abs(a[N - 1] - a.Last());
var ans = new int[] { ans1, ans2 }.Max();
Console.WriteLine(ans);
}
SimpleIO io = new SimpleIO();
public static void Main(string[] args) { new Simple().Stream(); }
void Stream() {
Solve();
io.writeFlush();
}
}
class SimpleIO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public SimpleIO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string Next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public string String => Next();
public char Char => char.Parse(String);
public int Int => int.Parse(String);
public long Long => long.Parse(String);
public double Double => double.Parse(String);
public void writeFlush() { Console.Out.Flush(); }
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
int N, Z, W;
int[] a;
void Solve() {
// input
N = io.Int;
Z = io.Int;
W = io.Int;
a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = io.Int;
// cal
var ans1 = Math.Abs(a.Last() - W);
if (N == 1) {
Console.WriteLine(ans1);
return;
}
var ans2 = Math.Abs(a[N - 2] - a.Last());
var ans = new int[] { ans1, ans2 }.Max();
Console.WriteLine(ans);
}
SimpleIO io = new SimpleIO();
public static void Main(string[] args) { new Simple().Stream(); }
void Stream() {
Solve();
io.writeFlush();
}
}
class SimpleIO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public SimpleIO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string Next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public string String => Next();
public char Char => char.Parse(String);
public int Int => int.Parse(String);
public long Long => long.Parse(String);
public double Double => double.Parse(String);
public void writeFlush() { Console.Out.Flush(); }
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 428
| 19
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using static System.Console;
using static System.Math;
using static CS_Contest.Utils;
using System.Numerics;
using System.Linq.Expressions;
using Nakov.IO;
using static Nakov.IO.Cin;
// using static CS_Contest.Library;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
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(), Z = NextInt(), W = NextInt();
var list = ReadInt();
int abs = 0;
Max(Abs(W - list.Last()), Abs(list[N - 1] - list[N - 2])).WL();
return;
}
}
}
public static class Utils {
public static long ModValue = (long)1e9 + 7;
public static long INF = long.MaxValue;
public static long Mod(long x) => x % ModValue;
public static long ModPow(long x, long n) {
long tmp = 1;
while (n != 0) {
if (n % 2 == 1) {
tmp = Mod(tmp * x);
}
x = Mod(x * x);
n /= 2;
}
return tmp;
}
public static long DivMod(long x,
long y) => Mod(x * ModPow(y, (long)(1e9 + 5)));
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 ReadInt() => ReadLine().Split().Select(int.Parse).ToList();
public static string
StringJoin<T>(this IEnumerable<T> l,
string separator = "") => string.Join(separator, l);
public static long GCD(long m, long n) {
long tmp;
if (m < n) {
tmp = n;
n = m;
m = tmp;
}
while (m % n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
return n;
}
public static long LCM(long m, long n) => m * (n / GCD(m, n));
public static void REP(int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static int ManhattanDistance(int x1, int y1, int x2,
int y2) => Abs(x2 - x1) + Abs(y2 - y1);
public struct IndexT<T> {
public T Value { get; set; }
public int Index { get; set; }
public IndexT(T v, int i) {
Value = v;
Index = i;
}
public override string ToString() { return Value + " " + Index; }
}
public static IEnumerable<IndexT<T>> ToIndexEnumerable<T>(
this IEnumerable<T> list) => list.Select((x, i) => new IndexT<T>(x, i));
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 IndexT<T>
IndexOf<T>(this IEnumerable<T> ie,
Func<IndexT<T>, IndexT<T>, IndexT<T>> func) =>
ie.ToIndexEnumerable().Aggregate(func);
public static T[] Range<T>(int range, Func<int, T> func) {
var rt = new T[range];
for (var i = 0; i < range; i++)
rt[i] = func(i);
return rt;
}
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static Dictionary<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Dictionary<TKey, int>();
foreach (var item in l) {
if (dic.ContainsKey(item))
dic[item]++;
else
dic.Add(item, 1);
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l,
T target) => l.Count(x => x.Equals(target));
public static int UpperBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : (idx + 1);
return Min(idx, list.Count());
}
public static int LowerBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : idx;
return Max(0, idx - 1);
}
}
}
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;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using static System.Console;
using static System.Math;
using static CS_Contest.Utils;
using System.Numerics;
using System.Linq.Expressions;
using Nakov.IO;
using static Nakov.IO.Cin;
// using static CS_Contest.Library;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
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(), Z = NextInt(), W = NextInt();
var list = ReadInt();
int abs = 0;
if (N == 1) {
Abs(W - list.Last()).WL();
return;
}
Max(Abs(W - list.Last()), Abs(list[N - 1] - list[N - 2])).WL();
return;
}
}
}
public static class Utils {
public static long ModValue = (long)1e9 + 7;
public static long INF = long.MaxValue;
public static long Mod(long x) => x % ModValue;
public static long ModPow(long x, long n) {
long tmp = 1;
while (n != 0) {
if (n % 2 == 1) {
tmp = Mod(tmp * x);
}
x = Mod(x * x);
n /= 2;
}
return tmp;
}
public static long DivMod(long x,
long y) => Mod(x * ModPow(y, (long)(1e9 + 5)));
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 ReadInt() => ReadLine().Split().Select(int.Parse).ToList();
public static string
StringJoin<T>(this IEnumerable<T> l,
string separator = "") => string.Join(separator, l);
public static long GCD(long m, long n) {
long tmp;
if (m < n) {
tmp = n;
n = m;
m = tmp;
}
while (m % n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
return n;
}
public static long LCM(long m, long n) => m * (n / GCD(m, n));
public static void REP(int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static int ManhattanDistance(int x1, int y1, int x2,
int y2) => Abs(x2 - x1) + Abs(y2 - y1);
public struct IndexT<T> {
public T Value { get; set; }
public int Index { get; set; }
public IndexT(T v, int i) {
Value = v;
Index = i;
}
public override string ToString() { return Value + " " + Index; }
}
public static IEnumerable<IndexT<T>> ToIndexEnumerable<T>(
this IEnumerable<T> list) => list.Select((x, i) => new IndexT<T>(x, i));
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 IndexT<T>
IndexOf<T>(this IEnumerable<T> ie,
Func<IndexT<T>, IndexT<T>, IndexT<T>> func) =>
ie.ToIndexEnumerable().Aggregate(func);
public static T[] Range<T>(int range, Func<int, T> func) {
var rt = new T[range];
for (var i = 0; i < range; i++)
rt[i] = func(i);
return rt;
}
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static Dictionary<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Dictionary<TKey, int>();
foreach (var item in l) {
if (dic.ContainsKey(item))
dic[item]++;
else
dic.Add(item, 1);
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l,
T target) => l.Count(x => x.Equals(target));
public static int UpperBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : (idx + 1);
return Min(idx, list.Count());
}
public static int LowerBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : idx;
return Max(0, idx - 1);
}
}
}
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;
}
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 1, 0, 213, 63, 214, 205, 213, 63, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,532
| 25
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
using System.Text; //テキストの高速出力に必要
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long n = long.Parse(input[0]);
long m = long.Parse(input[1]);
long oneTime = 1900 * m + 100 * (n - m);
long probability = 1;
for (int i = 0; i < m; i++) {
probability *= 2;
}
long answer = (oneTime * probability) /
(1 - 2 * probability + probability * probability);
Console.WriteLine(answer);
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
using System.Text; //テキストの高速出力に必要
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long n = long.Parse(input[0]);
long m = long.Parse(input[1]);
long oneTime = 1900 * m + 100 * (n - m);
long probability = 1;
for (int i = 0; i < m; i++) {
probability *= 2;
}
long answer = oneTime * probability;
Console.WriteLine(answer);
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 17, 48], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 31, 203], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 17, 33], ["-", 12, 23, 0, 16, 31, 16, 12, 16, 31, 203], ["-", 12, 23, 0, 16, 31, 16, 12, 16, 17, 48], ["-", 12, 23, 0, 16, 31, 16, 12, 16, 12, 22], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 17, 72], ["-", 0, 16, 12, 23, 0, 16, 12, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25]]
| 8
| 146
| 14
|
using System;
namespace ARC085_D___ABS {
class Program {
static void Main(string[] args) {
var NZW = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
Console.WriteLine(Math.Max(Math.Abs(Ai[Ai.Length - 1] - Ai[Ai.Length - 2]),
Math.Abs(NZW[2] - Ai[Ai.Length - 1])));
}
}
}
|
using System;
namespace ARC085_D___ABS {
class Program {
static void Main(string[] args) {
var NZW = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
Console.WriteLine(
NZW[0] != 1 ? Math.Max(Math.Abs(Ai[Ai.Length - 1] - Ai[Ai.Length - 2]),
Math.Abs(NZW[2] - Ai[Ai.Length - 1]))
: Math.Abs(NZW[2] - Ai[0]));
}
}
}
|
[["+", 0, 28, 0, 41, 15, 16, 31, 204, 205, 22], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 79], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 28, 0, 41, 75, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 41, 75, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 41, 75, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 41, 75, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 204, 205, 22], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 75, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 12, 204, 205, 22], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 124
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp66 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
Console.WriteLine((int)Math.Sqrt(N));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp66 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
Console.WriteLine((int)Math.Sqrt(N) * (int)Math.Sqrt(N));
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 25], ["+", 0, 16, 12, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 16, 12, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 16, 12, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 74, 51, 213, 3, 4, 0, 24], ["+", 12, 74, 51, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25]]
| 8
| 75
| 10
|
using System;
namespace debug {
class Program {
static void Main(string[] args) {
ProgramC a = new ProgramC();
a.main();
}
}
// ABC077
class ProgramA {
public void main() {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
class ProgramB {
public void main() {
long n = long.Parse(Console.ReadLine());
for (long i = 1; i < 100000; i++) {
if (i * i > n) {
Console.WriteLine((i - 1) * (i - 1));
return;
}
}
}
}
// ABC162
class ProgramC {
public void main() {
int n = int.Parse(Console.ReadLine());
long[] a = new long[n];
long[] b = new long[n];
long[] c = new long[n];
string[] s1 = Console.ReadLine().Split(' ');
string[] s2 = Console.ReadLine().Split(' ');
string[] s3 = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++) {
a[i] = long.Parse(s1[i]);
b[i] = long.Parse(s2[i]);
c[i] = long.Parse(s3[i]);
}
if (n == 1) {
if (a[0] < b[0] && b[0] < c[0])
Console.WriteLine(1);
else
Console.WriteLine(0);
return;
}
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
long ans = 0;
for (int i = 0; i < n; i++) {
long ans1 = 0;
if (a[0] > b[i])
continue;
long min = 0;
long max = n - 1;
if (a[n - 1] < b[i]) {
ans1 = n;
} else {
while (min + 1 != max) {
long temp = (max + min) / 2;
if (a[temp] < b[i])
min = temp;
else
max = temp;
}
ans1 = min + 1;
}
long ans2 = 0;
if (c[n - 1] < b[i])
continue;
if (c[0] > b[i]) {
ans2 = n;
} else {
min = 0;
max = n - 1;
while (min + 1 != max) {
long temp = (max + min) / 2;
if (c[temp] <= b[i])
min = temp;
else
max = temp;
}
ans2 = n - min - 1;
}
ans += ans1 * ans2;
}
Console.WriteLine(ans);
}
}
class ProgramD {
static long[] dp;
static long[] p;
public void main() {
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long x = long.Parse(s[1]);
//あらかじめ層の数とパティの数は数えておく
dp = new long[n + 1];
p = new long[n + 1];
dp[0] = 1;
p[0] = 1;
for (int i = 0; i < n; i++) {
dp[i + 1] = 3 + 2 * dp[i];
p[i + 1] = 1 + 2 * p[i];
}
Console.WriteLine(dfs(n, x));
}
/*再帰関数で把握(レベルnのバーガーの下からx番目までにあるパティの数)*/
static long dfs(long n, long x) {
if (n == 0) {
if (x >= 1)
return 1;
else
return 0;
} else if (x <= 1 + dp[n - 1])
return dfs(n - 1, x - 1);
else
return p[n - 1] + 1 + dfs(n - 1, x - 2 - dp[n - 1]);
}
}
}
|
using System;
namespace debug {
class Program {
static void Main(string[] args) {
ProgramC a = new ProgramC();
a.main();
}
}
// ABC077
class ProgramA {
public void main() {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
class ProgramB {
public void main() {
long n = long.Parse(Console.ReadLine());
for (long i = 1; i < 100000; i++) {
if (i * i > n) {
Console.WriteLine((i - 1) * (i - 1));
return;
}
}
}
}
// ABC162
class ProgramC {
public void main() {
int n = int.Parse(Console.ReadLine());
long[] a = new long[n];
long[] b = new long[n];
long[] c = new long[n];
string[] s1 = Console.ReadLine().Split(' ');
string[] s2 = Console.ReadLine().Split(' ');
string[] s3 = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++) {
a[i] = long.Parse(s1[i]);
b[i] = long.Parse(s2[i]);
c[i] = long.Parse(s3[i]);
}
if (n == 1) {
if (a[0] < b[0] && b[0] < c[0])
Console.WriteLine(1);
else
Console.WriteLine(0);
return;
}
//ソートする
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
long ans = 0;
for (int i = 0; i < n; i++) {
// aの二分探索(bより小さいものを探す)
long ans1 = 0;
if (a[0] > b[i])
continue;
long min = -1;
long max = n;
if (a[n - 1] < b[i]) {
ans1 = n;
} else {
while (min + 1 != max) {
long temp = (max + min) / 2;
if (a[temp] < b[i])
min = temp;
else
max = temp;
}
ans1 = min + 1;
}
// cの二分探索(bより大きいものを探す)
long ans2 = 0;
if (c[n - 1] < b[i])
continue;
if (c[0] > b[i]) {
ans2 = n;
} else {
min = -1;
max = n;
while (min + 1 != max) {
long temp = (max + min) / 2;
if (c[temp] > b[i])
max = temp;
else
min = temp;
}
ans2 = n - max;
}
//答えを足す
ans += ans1 * ans2;
}
Console.WriteLine(ans);
}
}
class ProgramD {
static long[] dp;
static long[] p;
public void main() {
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long x = long.Parse(s[1]);
//あらかじめ層の数とパティの数は数えておく
dp = new long[n + 1];
p = new long[n + 1];
dp[0] = 1;
p[0] = 1;
for (int i = 0; i < n; i++) {
dp[i + 1] = 3 + 2 * dp[i];
p[i + 1] = 1 + 2 * p[i];
}
Console.WriteLine(dfs(n, x));
}
/*再帰関数で把握(レベルnのバーガーの下からx番目までにあるパティの数)*/
static long dfs(long n, long x) {
if (n == 0) {
if (x >= 1)
return 1;
else
return 0;
} else if (x <= 1 + dp[n - 1])
return dfs(n - 1, x - 1);
else
return p[n - 1] + 1 + dfs(n - 1, x - 2 - dp[n - 1]);
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 75, 196, 0, 1, 0, 11, 12, 241, 0, 33], ["+", 75, 196, 0, 1, 0, 11, 12, 241, 0, 203], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 918
| 20
|
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Collections.Generic;
class Program {
private static int[] a;
private static int[] b;
private static int[] c;
static void Main() {
int n = int.Parse(Console.ReadLine());
a = Console.ReadLine().Split().Select(s => -int.Parse(s)).ToArray();
b = Console.ReadLine().Split().Select(int.Parse).ToArray();
c = Console.ReadLine().Split().Select(int.Parse).ToArray();
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
long ans = 0;
foreach (var bi in b) {
ans +=
(n - (long)Search(a, -bi, 0, n - 1)) * (n - Search(c, bi, 0, n - 1));
}
Console.WriteLine(ans);
}
private static int Search(int[] array, int n, int s, int e) {
if (s == e)
return s;
int m = s + (e - s) / 2;
if (array[m] <= n)
return Search(a, n, m + 1, e);
else
return Search(a, n, s, m);
}
}
|
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Collections.Generic;
class Program {
private static int[] a;
private static int[] b;
private static int[] c;
static void Main() {
int n = int.Parse(Console.ReadLine());
a = Console.ReadLine().Split().Select(s => -int.Parse(s)).ToArray();
b = Console.ReadLine().Split().Select(int.Parse).ToArray();
c = Console.ReadLine().Split().Select(int.Parse).ToArray();
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
long ans = 0;
foreach (var bi in b) {
if (bi >= c[n - 1] || bi <= -a[n - 1])
continue;
ans +=
(n - (long)Search(a, -bi, 0, n - 1)) * (n - Search(c, bi, 0, n - 1));
}
Console.WriteLine(ans);
}
private static int Search(int[] array, int n, int s, int e) {
if (s == e)
return s;
int m = s + (e - s) / 2;
if (array[m] <= n)
return Search(array, n, m + 1, e);
else
return Search(array, n, s, m);
}
}
|
[["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 0, 57, 15, 16, 12, 16, 12, 241, 0, 33], ["+", 15, 16, 12, 16, 12, 241, 0, 204, 205, 22], ["+", 12, 16, 12, 241, 0, 204, 206, 207, 0, 70], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 12, 16, 12, 241, 0, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 210, 8, 196, 0, 57, 64, 116, 0, 35], ["-", 64, 37, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 37, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 75, 37, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 75, 37, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 307
| 27
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC_C {
class C077 {
//ヒストグラムから累積和を作成
// dicCountは昇順ソートされている必要.
static Dictionary<T, long> SumTable<T>(Dictionary<T, long> dicCount) {
Dictionary<T, long> dic = new Dictionary<T, long>();
long counter = 0;
foreach (var v in dicCount) {
counter += v.Value;
dic.Add(v.Key, counter);
}
return dic;
}
//ソート済みListの中でvalue以下の最大の要素を取得O(log n)
// Listの最小値よりも小さい場合はdefを返す
static T MaxEqualOrLessThan<T>(List<T> list, T value, T def)
where T : IComparable {
if (value.CompareTo(list[0]) < 0)
return def;
int s = 0;
int t = list.Count();
while (s + 1 < t) {
int k = s + (t - s) / 2;
int c = value.CompareTo(list[k]);
if (c == 0) {
return value;
} else if (c > 0) {
s = k;
} else {
t = k;
}
}
return list[s];
}
static void Main(string[] args) {
string path = @"C:\temp\01.txt";
System.IO.StreamReader sr = new System.IO.StreamReader(path);
Console.SetIn(sr);
int N = int.Parse(Console.ReadLine());
List<int> A =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
List<int> B =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
List<int> C =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
A.Sort();
B.Sort();
C.Sort();
var adic =
A.ToLookup(x => x).ToDictionary(x => x.Key, x => (long)x.Count());
var asum = SumTable(adic);
var akeys = asum.Keys.ToList();
var bdic = B.ToLookup(x => x).ToDictionary(x => x.Key, x => x.Count());
Dictionary<int, long> bcount = new Dictionary<int, long>();
foreach (var pair in bdic) {
int k = pair.Key;
int key = MaxEqualOrLessThan(akeys, k - 1, -1);
if (key < 0)
bcount.Add(k, 0);
else {
long cB = (long)pair.Value * asum[key];
bcount.Add(k, cB);
}
}
var bsum = SumTable(bcount);
var bkeys = bsum.Keys.ToList();
var cdic = C.ToLookup(x => x).ToDictionary(x => x.Key, x => x.Count());
Dictionary<int, long> ccount = new Dictionary<int, long>();
foreach (var pair in cdic) {
int k = pair.Key;
int key = MaxEqualOrLessThan(bkeys, k - 1, -1);
if (key < 0)
ccount.Add(k, 0);
else {
long cC = (long)pair.Value * bsum[key];
ccount.Add(k, cC);
}
}
long count = ccount.Sum(x => x.Value);
Console.WriteLine(count);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC_C {
class C077 {
//ヒストグラムから累積和を作成
// dicCountは昇順ソートされている必要.
static Dictionary<T, long> SumTable<T>(Dictionary<T, long> dicCount) {
Dictionary<T, long> dic = new Dictionary<T, long>();
long counter = 0;
foreach (var v in dicCount) {
counter += v.Value;
dic.Add(v.Key, counter);
}
return dic;
}
//ソート済みListの中でvalue以下の最大の要素を取得O(log n)
// Listの最小値よりも小さい場合はdefを返す
static T MaxEqualOrLessThan<T>(List<T> list, T value, T def)
where T : IComparable {
if (value.CompareTo(list[0]) < 0)
return def;
int s = 0;
int t = list.Count();
while (s + 1 < t) {
int k = s + (t - s) / 2;
int c = value.CompareTo(list[k]);
if (c == 0) {
return value;
} else if (c > 0) {
s = k;
} else {
t = k;
}
}
return list[s];
}
static void Main(string[] args) {
// string path = @"C:\temp\01.txt";
// System.IO.StreamReader sr = new System.IO.StreamReader(path);
// Console.SetIn(sr);
int N = int.Parse(Console.ReadLine());
List<int> A =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
List<int> B =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
List<int> C =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
A.Sort();
B.Sort();
C.Sort();
var adic =
A.ToLookup(x => x).ToDictionary(x => x.Key, x => (long)x.Count());
var asum = SumTable(adic);
var akeys = asum.Keys.ToList();
var bdic = B.ToLookup(x => x).ToDictionary(x => x.Key, x => x.Count());
Dictionary<int, long> bcount = new Dictionary<int, long>();
foreach (var pair in bdic) {
int k = pair.Key;
int key = MaxEqualOrLessThan(akeys, k - 1, -1);
if (key < 0)
bcount.Add(k, 0);
else {
long cB = (long)pair.Value * asum[key];
bcount.Add(k, cB);
}
}
var bsum = SumTable(bcount);
var bkeys = bsum.Keys.ToList();
var cdic = C.ToLookup(x => x).ToDictionary(x => x.Key, x => x.Count());
Dictionary<int, long> ccount = new Dictionary<int, long>();
foreach (var pair in cdic) {
int k = pair.Key;
int key = MaxEqualOrLessThan(bkeys, k - 1, -1);
if (key < 0)
ccount.Add(k, 0);
else {
long cC = (long)pair.Value * bsum[key];
ccount.Add(k, cC);
}
}
long count = ccount.Sum(x => x.Value);
Console.WriteLine(count);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 258], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 197, 0, 198, 39, 232, 234, 232, 234, 22], ["-", 0, 197, 0, 198, 39, 232, 234, 232, 0, 131], ["-", 0, 197, 0, 198, 39, 232, 234, 232, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 232, 0, 131], ["-", 8, 196, 0, 197, 0, 198, 39, 232, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["-", 0, 212, 0, 230, 39, 232, 234, 232, 234, 22], ["-", 0, 212, 0, 230, 39, 232, 234, 232, 0, 131], ["-", 0, 212, 0, 230, 39, 232, 234, 232, 141, 22], ["-", 0, 200, 0, 212, 0, 230, 39, 232, 0, 131], ["-", 0, 200, 0, 212, 0, 230, 39, 232, 141, 22], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 212, 0, 230, 3, 4, 0, 28, 0, 22], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 750
| 29
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Common;
public static class Common {
public static int BinSearchIndex(int v, int[] list) {
if (v > list.Last()) {
return list.Length;
}
int minRange = 0;
int maxRange = list.Count() - 1;
while (minRange != maxRange) {
var center = (minRange + maxRange) / 2;
if (list[center] <= v) {
minRange = center + 1;
} else {
maxRange = center;
}
}
return minRange;
}
}
class Solution {
static void Main() {
var n = int.Parse(Console.ReadLine());
var a = Console.ReadLine()
.Split(' ')
.Select(int.Parse)
.OrderBy(i => i)
.ToArray();
var b = Console.ReadLine()
.Split(' ')
.Select(int.Parse)
.OrderBy(i => i)
.ToArray();
var c = Console.ReadLine()
.Split(' ')
.Select(int.Parse)
.OrderBy(i => i)
.ToArray();
long count = 0;
var bPattern = new long[b.Length + 1];
bPattern[b.Length] = 0;
for (int bi = 0; bi < b.Length; bi++) {
var y = b[bi];
var cIndex = BinSearchIndex(y, c);
bPattern[bi] = c.Length - cIndex;
}
var bSum = new long[b.Length + 1];
bSum[b.Length] = 0;
long sum = 0;
for (int bi = b.Length - 1; bi >= 0; bi--) {
sum += bPattern[bi];
bSum[bi] = sum;
}
foreach (var x in a) {
var bIndex = BinSearchIndex(x, b);
count += bSum[bIndex];
}
Console.WriteLine(count);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Common;
public static class Common {
public static int BinSearchIndex(int v, int[] list) {
v = v + 1;
if (v > list.Last()) {
return list.Length;
}
int minRange = 0;
int maxRange = list.Count() - 1;
while (minRange != maxRange) {
var center = (minRange + maxRange) / 2;
if (list[center] < v) {
minRange = center + 1;
} else {
maxRange = center;
}
}
return minRange;
}
}
class Solution {
static void Main() {
var n = int.Parse(Console.ReadLine());
var a = Console.ReadLine()
.Split(' ')
.Select(int.Parse)
.OrderBy(i => i)
.ToArray();
var b = Console.ReadLine()
.Split(' ')
.Select(int.Parse)
.OrderBy(i => i)
.ToArray();
var c = Console.ReadLine()
.Split(' ')
.Select(int.Parse)
.OrderBy(i => i)
.ToArray();
long count = 0;
var bPattern = new long[b.Length + 1];
bPattern[b.Length] = 0;
for (int bi = 0; bi < b.Length; bi++) {
var y = b[bi];
var cIndex = BinSearchIndex(y, c);
bPattern[bi] = c.Length - cIndex;
}
var bSum = new long[b.Length + 1];
bSum[b.Length] = 0;
long sum = 0;
for (int bi = b.Length - 1; bi >= 0; bi--) {
sum += bPattern[bi];
bSum[bi] = sum;
}
foreach (var x in a) {
var bIndex = BinSearchIndex(x, b);
count += bSum[bIndex];
}
Console.WriteLine(count);
}
}
|
[["+", 0, 195, 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, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 18]]
| 8
| 414
| 8
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
const int ShopCount = 10;
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var openTimes = new int [N][];
var prices = new int [N][];
for (var i = 0; i < N; i++)
openTimes[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (var i = 0; i < N; i++)
prices[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
var res = 0L;
for (var bit = 1; bit < 1 << ShopCount; bit++) {
var cc = 0;
for (var i = 0; i < N; i++) {
var c = 0;
for (var j = 0; j < ShopCount; j++) {
if ((bit & (1 << j)) != 0 && openTimes[i][j] == 1)
c++;
}
cc += prices[i][c];
res = Math.Max(cc, res);
}
}
Console.WriteLine(res);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
const int ShopCount = 10;
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var openTimes = new int [N][];
var prices = new int [N][];
for (var i = 0; i < N; i++)
openTimes[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (var i = 0; i < N; i++)
prices[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
var res = -(int.MaxValue);
for (var bit = 1; bit < (1 << ShopCount); bit++) {
var cc = 0;
for (var i = 0; i < N; i++) {
var c = 0;
for (var j = 0; j < ShopCount; j++) {
if ((bit & (1 << j)) != 0 && openTimes[i][j] == 1)
c++;
}
cc += prices[i][c];
}
res = Math.Max(cc, res);
}
Console.WriteLine(res);
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 200, 0, 212, 0, 241, 0, 23, 0, 24], ["+", 0, 212, 0, 241, 0, 23, 0, 214, 205, 199], ["+", 0, 212, 0, 241, 0, 23, 0, 214, 0, 131], ["+", 0, 212, 0, 241, 0, 23, 0, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 241, 0, 23, 0, 25], ["+", 8, 196, 0, 7, 15, 16, 12, 23, 0, 24], ["+", 8, 196, 0, 7, 15, 16, 12, 23, 0, 25], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 276
| 11
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc80_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[][] f = new int [n][];
int[][] p = new int [n][];
for (int i = 0; i < n; i++) {
int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
f[i] = tmp;
}
for (int i = 0; i < n; i++) {
int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
p[i] = tmp;
}
int max = int.MinValue;
for (int i = 1; i < (1 << 10); i++) {
int cc = 0;
for (int j = 0; j < n; j++) {
int c = 0;
for (int k = 0; k < 10; k++) {
if (((i >> j & 1) == 1) && f[j][k] == 1) {
c++;
}
}
cc += p[j][c];
}
max = Max(max, cc);
}
WriteLine(max);
}
}
}
|
using System;
using System.Linq;
using static System.Console;
using static System.Math;
namespace abc80_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[][] f = new int [n][];
int[][] p = new int [n][];
for (int i = 0; i < n; i++) {
int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
f[i] = tmp;
}
for (int i = 0; i < n; i++) {
int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
p[i] = tmp;
}
int max = int.MinValue;
for (int i = 1; i < (1 << 10); i++) { // bit全探索
int cc = 0;
for (int j = 0; j < n; j++) {
int c = 0;
for (int k = 0; k < 10; k++) {
if (((i >> k & 1) == 1) && f[j][k] == 1)
c++;
}
cc += p[j][c];
}
max = Max(max, cc);
}
WriteLine(max);
}
}
}
|
[["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 331
| 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) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
new Program().Solve(new MyInputStream(Console.In, ' '));
Console.Out.Flush();
}
public void Solve(MyInputStream cin) {
var N = cin.ReadInt();
var L0 = 2L;
var L1 = 1L;
var L = 0L;
for (int i = 1; i < N; ++i) {
L = L0 + L1;
L0 = L1;
L1 = L;
}
WriteLine(L);
}
}
public class MyInputStream {
private readonly System.IO.TextReader _stream;
private char separator = ' ';
private Queue<string> inputStream;
public MyInputStream(System.IO.TextReader s, char separator = ' ') {
this.separator = separator;
this._stream = s;
inputStream = new Queue<string>();
}
public string Read() {
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() { return _stream.ReadLine(); }
public int ReadInt() { return int.Parse(Read()); }
public long ReadLong() { return long.Parse(Read()); }
public double ReadDouble() { 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) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
new Program().Solve(new MyInputStream(Console.In, ' '));
Console.Out.Flush();
}
public void Solve(MyInputStream cin) {
var N = cin.ReadInt();
if (N == 0) {
WriteLine(2);
return;
}
if (N == 1) {
WriteLine(1);
return;
}
var L0 = 2L;
var L1 = 1L;
var L = 0L;
for (int i = 1; i < N; ++i) {
L = L0 + L1;
L0 = L1;
L1 = L;
}
WriteLine(L);
}
}
public class MyInputStream {
private readonly System.IO.TextReader _stream;
private char separator = ' ';
private Queue<string> inputStream;
public MyInputStream(System.IO.TextReader s, char separator = ' ') {
this.separator = separator;
this._stream = s;
inputStream = new Queue<string>();
}
public string Read() {
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() { return _stream.ReadLine(); }
public int ReadInt() { return int.Parse(Read()); }
public long ReadLong() { return long.Parse(Read()); }
public double ReadDouble() { 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;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 527
| 30
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace competitive_programming {
class Program {
static void Main(string[] args) {
var main = new Program();
main.solve();
}
void solve() {
nums =
Console.ReadLine().Select(val => int.Parse(val.ToString())).ToArray();
// foreach (var n in nums) Console.WriteLine(n);
while (true) {
char[] rec = new char[4];
if (dfs(0, 0, rec)) {
Console.WriteLine(nums[0] + rec[0].ToString() + nums[1] +
rec[1].ToString() + nums[2] + rec[2].ToString() +
nums[3] + "=7");
return;
}
}
}
int[] nums;
bool dfs(int sum, int num, char[] rec) {
if (num == 4)
return sum == 7;
else {
if (dfs(sum + nums[num], num + 1, rec)) {
rec[num] = '+';
return true;
}
if (dfs(sum - nums[num], num + 1, rec)) {
rec[num] = '-';
return true;
}
return false;
}
}
}
struct Vector2 {
public Vector2(long x, long y) {
this.x = x;
this.y = y;
}
public long x;
public long y;
}
struct Vector3 {
public int x;
public int y;
public int z;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace competitive_programming {
class Program {
static void Main(string[] args) {
var main = new Program();
main.solve();
}
void solve() {
nums =
Console.ReadLine().Select(val => int.Parse(val.ToString())).ToArray();
// foreach (var n in nums) Console.WriteLine(n);
while (true) {
char[] rec = new char[4];
if (dfs(nums[0], 1, rec)) {
Console.WriteLine(nums[0] + rec[0].ToString() + nums[1] +
rec[1].ToString() + nums[2] + rec[2].ToString() +
nums[3] + "=7");
return;
}
}
}
int[] nums;
bool dfs(int sum, int num, char[] rec) {
if (num == 4)
return sum == 7;
else {
if (dfs(sum + nums[num], num + 1, rec)) {
rec[num - 1] = '+';
return true;
}
if (dfs(sum - nums[num], num + 1, rec)) {
rec[num - 1] = '-';
return true;
}
return false;
}
}
}
struct Vector2 {
public Vector2(long x, long y) {
this.x = x;
this.y = y;
}
public long x;
public long y;
}
struct Vector3 {
public int x;
public int y;
public int z;
}
}
|
[["+", 15, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 57, 15, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 15, 213, 3, 4, 0, 28, 0, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 329
| 9
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCorders {
public class Program {
static void Main(string[] args) {
var abcd = Console.ReadLine();
for (int i = 0; i < 1 << 3; i++) {
int val = abcd[0] - '0';
for (int j = 0; j < 3; j++) {
if ((i & (1 << j)) != 0) {
val += abcd[j + 1] - '0';
} else {
val -= abcd[j + 1] - '0';
}
}
if (val == 7) {
var sb = new StringBuilder();
sb.Append(abcd[0]);
sb.Append((i & (1 << 0)) != 0 ? '+' : '-');
sb.Append(abcd[1]);
sb.Append((i & (1 << 1)) != 0 ? '+' : '-');
sb.Append(abcd[2]);
sb.Append((i & (1 << 2)) != 0 ? '+' : '-');
sb.Append(abcd[3]);
Console.WriteLine(sb.ToString());
return;
}
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCorders {
public class Program {
static void Main(string[] args) {
var abcd = Console.ReadLine();
for (int i = 0; i < 1 << 3; i++) {
int val = abcd[0] - '0';
for (int j = 0; j < 3; j++) {
if ((i & (1 << j)) != 0) {
val += abcd[j + 1] - '0';
} else {
val -= abcd[j + 1] - '0';
}
}
if (val == 7) {
var sb = new StringBuilder();
sb.Append(abcd[0]);
sb.Append((i & (1 << 0)) != 0 ? '+' : '-');
sb.Append(abcd[1]);
sb.Append((i & (1 << 1)) != 0 ? '+' : '-');
sb.Append(abcd[2]);
sb.Append((i & (1 << 2)) != 0 ? '+' : '-');
sb.Append(abcd[3]);
sb.Append("=7");
Console.WriteLine(sb.ToString());
return;
}
}
}
}
}
|
[["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 318
| 9
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.