buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;
public class Hello {
private const int INF = 1000000000;
public static void Main() {
string S = Console.ReadLine();
int Mbit = (int)Math.Pow(2, S.Length - 1) - 1;
long ans = 0;
for (int bit = 0; bit <= Mbit; bit++) {
string stok = Convert.ToString(bit, 2).PadLeft(S.Length - 1, '0');
string A = S[0].ToString();
int count = 1;
foreach (var s in stok) {
if (s == '1') {
ans += long.Parse(A);
A = S[count].ToString();
} else
A += S[count];
count++;
}
ans += long.Parse(A);
}
Console.WriteLine(ans);
}
}
public class Atcoder {
static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static int LCM(int a, int b) {
int c = a * b;
if (a < b)
Swap(ref a, ref b);
int d = a % b;
while (d != 0) {
a = b;
b = d;
d = a % b;
}
return c / b;
}
public static string StrReverce(string s) {
return new string(s.Reverse().ToArray());
}
public static int IntRead() { return int.Parse(Console.ReadLine()); }
public static bool IsPrime(int n) {
if (n < 2)
return false;
if (n == 2)
return true;
if (n % 2 == 0)
return false;
// double sqrtNum = Math.Sqrt(n);
for (int i = 3; i < n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
public static string[] SpRead(char c) { return Console.ReadLine().Split(c); }
public static long[] LSRead() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;
public class Hello {
private const int INF = 1000000000;
public static void Main() {
string S = Console.ReadLine();
if (S.Length == 1) {
Console.WriteLine(S);
return;
}
int Mbit = (int)Math.Pow(2, S.Length - 1) - 1;
long ans = 0;
for (int bit = 0; bit <= Mbit; bit++) {
string stok = Convert.ToString(bit, 2).PadLeft(S.Length - 1, '0');
string A = S[0].ToString();
int count = 1;
foreach (var s in stok) {
if (s == '1') {
ans += long.Parse(A);
A = S[count].ToString();
} else
A += S[count];
count++;
}
ans += long.Parse(A);
}
Console.WriteLine(ans);
}
}
public class Atcoder {
static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static int LCM(int a, int b) {
int c = a * b;
if (a < b)
Swap(ref a, ref b);
int d = a % b;
while (d != 0) {
a = b;
b = d;
d = a % b;
}
return c / b;
}
public static string StrReverce(string s) {
return new string(s.Reverse().ToArray());
}
public static int IntRead() { return int.Parse(Console.ReadLine()); }
public static bool IsPrime(int n) {
if (n < 2)
return false;
if (n == 2)
return true;
if (n % 2 == 0)
return false;
// double sqrtNum = Math.Sqrt(n);
for (int i = 3; i < n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
public static string[] SpRead(char c) { return Console.ReadLine().Split(c); }
public static long[] LSRead() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
}
|
[["+", 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, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 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]]
| 8
| 489
| 19
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
string s = Console.ReadLine();
long answer = 0;
long answerPlus = 0;
long multiplyMemo = 1;
for (long i = 0; i < (1 << s.Length - 1); i++) // bit全探索
{
answerPlus = s[(int)(s.Length - 1)] - '0'; //一の位
for (long checkDigit = 0; checkDigit < s.Length - 1;
checkDigit++) //右からcheckDigit桁目を見る
{
multiplyMemo = 1;
if ((i & (1 << (int)checkDigit)) != 0) //右からcheckDigit番目が1ならば
{
multiplyMemo *= 10;
} else //右からcheckDigit番目が0ならば
{
multiplyMemo = 1;
}
answerPlus +=
(s[(int)(s.Length - 2 - checkDigit)] - '0') * multiplyMemo;
// Console.WriteLine(answerPlus);
}
answer += answerPlus;
}
Console.WriteLine(answer);
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
string s = Console.ReadLine();
long answer = 0;
long answerPlus = 0;
long multiplyMemo = 1;
for (long i = 0; i < (1 << s.Length - 1); i++) // bit全探索
{
answerPlus = s[(int)(s.Length - 1)] - '0'; //一の位
multiplyMemo = 1;
for (long checkDigit = 0; checkDigit < s.Length - 1;
checkDigit++) //右からcheckDigit桁目を見る
{
if ((i & (1 << (int)checkDigit)) != 0) //右からcheckDigit番目が1ならば
{
multiplyMemo *= 10;
} else //右からcheckDigit番目が0ならば
{
multiplyMemo = 1;
}
answerPlus +=
(s[(int)(s.Length - 2 - checkDigit)] - '0') * multiplyMemo;
}
answer += answerPlus;
// Console.WriteLine(answerPlus);
}
Console.WriteLine(answer);
}
}
|
[["+", 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, 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]]
| 8
| 192
| 8
|
using System;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine()); // int.Parseは文字列を整数に変換。
int digit = whatDigit(n);
int answer = 0;
int multypleNum = 1; //+がないとき左の数は10倍
for (int i = 0; i < (Math.Pow(2, digit - 1)); i++) //2進数で全通り試す
{
int ii = i;
int nn = n;
for (int j = 0; j < digit; j++) {
answer += (nn % 10) * multypleNum;
nn /= 10;
if (ii % 2 == 1)
multypleNum *= 10;
else
multypleNum = 1;
ii /= 2;
}
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
static int whatDigit(int n) // nは何桁か
{
for (int i = 1; i < 20; i++) {
n /= 10;
if (n == 0) {
return i;
break;
}
}
return 0;
}
}
|
using System;
class Program {
static void Main() {
long n = long.Parse(Console.ReadLine()); // long.Parseは文字列を整数に変換。
long digit = whatDigit(n);
long answer = 0;
long multypleNum = 1; //+がないとき左の数は10倍
for (long i = 0; i < (Math.Pow(2, digit - 1)); i++) //2進数で全通り試す
{
long ii = i;
long nn = n;
for (long j = 0; j < digit; j++) {
answer += (nn % 10) * multypleNum;
nn /= 10;
if (ii % 2 == 1)
multypleNum *= 10;
else
multypleNum = 1;
ii /= 2;
}
}
Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。
}
static long whatDigit(long n) // nは何桁か
{
for (long i = 1; i < 20; i++) {
n /= 10;
if (n == 0) {
return i;
break;
}
}
return 0;
}
}
|
[["-", 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], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199]]
| 8
| 191
| 24
|
using System;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;
using static NotFounds.MyMath;
using static NotFounds.MyUtility;
namespace NotFounds {
public class Program {
public static void Main(string[] args) { new Program().Solve(); }
private void Solve() {
var cin = new MyInputStream();
var S = cin.ReadLine();
var l = S.Length;
ulong ans = 0;
var t = 1 << l - 1;
for (uint i = 0; i < t; ++i) {
var sum = 0;
var parm1 = (S[0] - '0');
for (var j = 1; j < l; ++j) {
if (((i >> (j - 1)) & 1) == 1) {
sum += parm1;
parm1 = S[j] - '0';
} else {
parm1 *= 10;
parm1 += S[j] - '0';
}
}
sum += parm1;
ans += (ulong)sum;
}
WriteLine(ans);
}
private long func(long b, long n) {
if (n < b)
return n;
else
return func(b, (int)(n / b)) + n % b;
}
}
public class MyInputStream {
private char separator = ' ';
private Queue<string> inputStream;
public MyInputStream(char separator = ' ') {
this.separator = separator;
inputStream = new Queue<string>();
}
public string Read() {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = Console.ReadLine().Split(separator);
for (int i = 0; i < tmp.Length; i++) {
inputStream.Enqueue(tmp[i]);
}
return inputStream.Dequeue();
}
public string ReadLine() => Console.ReadLine();
public int ReadInt() => int.Parse(Read());
public long ReadLong() => long.Parse(Read());
public double ReadDouble() => double.Parse(Read());
}
public class MyMath {
// nx = x + dxy[i], ny = y + dxy[i + 1] (i = 0..3)
public static int[] dxy = new int[] { 0, 1, 0, -1, 0 };
/// <summary>最大値</summary>
public static int INF = int.MaxValue >> 1;
/// <summary>許容する誤差ε</summary>
public static double EPS = 1e-11;
/// <summary>よく使う素数</summary>
public static long MOD = 1000000007;
/// <summary>2つのスカラー値が等しいかどうか</summary>
public static bool EQ(double d1, double d2) => (Math.Abs(d1 - d2) < EPS);
/// <summary>x^n % m</summary>
public static long PowMod(long x, long n, long m) {
long ans = 1;
long mul = x;
for (; n > 0; n >>= 1, mul = (mul * mul) % m) {
if ((n & 1) == 1)
ans = (ans * mul) % m;
}
return ans % m;
}
/// <summary>n! % m</summary>
public static long FactMod(int n, long m) {
long ans = 1;
for (int i = 2; i <= n; i++) {
ans *= i;
ans %= m;
}
return ans;
}
/// <summary>n!</summary>
public static long Fact(int n) {
long ans = 1;
for (int i = 2; i <= n; i++)
ans *= i;
return ans;
}
/// <summary>nCr % mod</summary>
public static long ConbMod(int n, int r, long m) {
long mul = FactMod(n, m);
long div = (FactMod(r, m) * FactMod(n - r, m)) % m;
long inv = PowMod(div, m - 2, m);
return (mul * inv) % m;
}
/// <summary>nCr</summary>
public static long Conb(int n, int r) {
long mul = Parm(n, r);
long div = Fact(r);
return mul / div;
}
/// <summary>nPr</summary>
public static long Parm(int n, int r) {
long ans = 1;
for (int i = n; i >= r; i--)
ans *= i;
return ans;
}
/// <summary>最大公約数</summary>
public static long Gcd(long m, long n) {
if (n == 0)
return m;
if (m < n)
MyUtility.Swap(ref m, ref n);
long tmp;
while ((tmp = m % n) != 0) {
m = n;
n = tmp;
}
return n;
}
/// <summary>最小公倍数</summary>
public static long Lcm(long m, long n) { return m * n / Gcd(m, n); }
/// <summary>ピタゴラス</summary>
public static double Dist(double x, double y) {
return Math.Sqrt(x * x + y * y);
}
/// <summary>素数判定</summary>
public static bool isPrime(int n) {
if (n < 2)
return false;
if ((n & 1) == 0)
return n == 2 ? true : false;
for (int i = 3; i * i <= n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
/// <summary>素数取得(random)</summary>
public static IEnumerable<int> GetPrimes(int n) {
return Enumerable.Range(2, n - 1).AsParallel().Where(x => isPrime(x));
}
/// <summary>ビットの数を数える</summary>
public static int BitCount(uint n) {
n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f);
n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff);
return (int)((n & 0x0000ffff) + ((n >> 16) & 0x0000ffff));
}
public static string FizzBuzz(long n) {
var ret = "";
if (n % 3 == 0)
ret += "Fizz";
if (n % 5 == 0)
ret += "Buzz";
return ret == "" ? n.ToString() : ret;
}
}
public class MyUtility {
/// <summary>二分法:単調増加(n次関数を微分して渡しても可)</summary>
public static double binarySearch(Func<double, double> calc, double min,
double max, double target) {
var mid = 0.0;
for (int i = 0; i < 50; i++) {
mid = min + (max - min) / 2.0;
if (calc(mid) < target)
min = mid;
else
max = mid;
}
return mid;
}
public static double binarySearch(Func<double, double> calc, double min,
double max) {
return binarySearch(calc, min, max, 0.0);
}
/// <summary>三分法:凸を探索<summary>
public static double ternarySearch(Func<double, double> calc, double min,
double max) {
var left = 0.0;
var right = 0.0;
for (int i = 0; i < 200; i++) {
left = (min * 2 + max) / 3.0;
right = (min + max * 2) / 3.0;
if (calc(left) < calc(right))
max = right;
else
min = left;
}
return (left + right) * 0.5;
}
/// <summary>ニュートン法</summary>
/// calc : 元の方程式( = 0), calcdash : calcの微分形
public static double newtonSearch(Func<double, double> calc,
Func<double, double> calcdash) {
var ans0 = 0.0;
var ans1 = calc(ans0) / calcdash(ans0);
for (int i = 0; i < 100; i++) {
if (MyMath.EQ(ans0 - ans1, 0.0))
break;
ans1 = ans0;
ans0 -= calc(ans0) / calcdash(ans0);
}
return ans0;
}
public static int Coin(int[] coins, int price) {
var N = coins.Length;
var dp = new int[price + 1];
dp[0] = 0;
for (var i = 1; i <= price; i++)
dp[i] = int.MaxValue;
for (var i = 1; i <= price; i++)
for (var j = 0; j < N; j++)
if (i >= coins[j])
dp[i] = Math.Min(dp[i], dp[i - coins[j]] + 1);
else
dp[i] = Math.Min(dp[i], dp[i - 1] + 1);
return dp[price];
}
/// <summary>2値を入れ替える</summary>
public static void Swap<T>(ref T m, ref T n) {
T tmp = m;
m = n;
n = tmp;
}
/// <summary>値を出力する</summary>
public static void Dump(params object[] data) { data.Dump(); }
}
#region extentions
public static class MyExtentions {
public static int CountStringOfString(this string source, string target) {
int cnt = 0;
int targetLen = target.Length;
if (targetLen == 0)
return 0;
for (int i = 0; i <= source.Length - targetLen; i++) {
int tmp = source.IndexOf(target, i);
if (tmp != -1) {
cnt++;
i = Math.Max(tmp + targetLen - 1, 0);
} else
break;
}
return cnt;
}
public static int Max(this int source, int num) {
return Math.Max(source, num);
}
public static int Min(this int source, int num) {
return Math.Min(source, num);
}
}
public static class MyEnumerableExtentions {
public static string ConcatWith<T>(this IEnumerable<T> source,
string separator, string format,
IFormatProvider provider = null)
where T : IFormattable {
return source.Select(x => x.ToString(format, provider))
.Aggregate((a, b) => a + separator + b);
}
public static string ConcatWith<T>(this IEnumerable<T> source,
string separator) {
return string.Join(separator, source);
}
public static void ForEach<T>(this IEnumerable<T> source,
Action<T, int> func) {
foreach (var item in source.Select((x, i) => new { val = x, idx = i }))
func(item.val, item.idx);
}
public static void ForEach<T>(this IEnumerable<T> source, Action<T> func) {
foreach (var item in source)
func(item);
}
public static void Dump<T>(this IEnumerable<T> source) {
Console.WriteLine("{ " + source.ConcatWith(", ") + " }");
}
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source) {
return source.OrderBy(x => Guid.NewGuid());
}
public static bool IsEmpty<T>(this IEnumerable<T> source) {
return !source.Any();
}
public static string MaxLengthString(this IEnumerable<string> source) {
return source.Aggregate("", (max, s) => s.Length > max.Length ? s : max);
}
public static string MinLengthString(this IEnumerable<string> source) {
return source.Aggregate(
"", (min, s) => (s.Length < min.Length || min == "") ? s : min);
}
public static IEnumerable<IEnumerable<T>>
Permutations<T>(this IEnumerable<T> source) {
if (source.Count() != 0) {
int index = 0;
foreach (var item in source) {
var allOtherItems = source.RemoveAt(index++);
foreach (var permutation in allOtherItems.Permutations()) {
yield return new[] { item }.Concat(permutation);
}
}
} else {
yield return new T[0];
}
}
public static IEnumerable<T> RemoveAt<T>(this IEnumerable<T> source,
int indexToRemove) {
int index = 0;
foreach (T item in source)
if (index++ != indexToRemove)
yield return item;
}
}
#endregion
public class Graph {
private struct Edge {
public int To;
public long Cost;
public Edge(int t, long c) {
this.To = t;
this.Cost = c;
}
}
private struct Node : IComparable<Node> {
public int Pos;
public long Cost;
public Node(int p, long c) {
this.Pos = p;
this.Cost = c;
}
public int CompareTo(Node obj) { return (int)(this.Cost - obj.Cost); }
}
private List<List<Edge>> g;
private int N { get; set; }
public Graph(int size) {
N = size;
g = new List<List<Edge>>(size);
for (int i = 0; i < size; i++)
g.Add(new List<Edge>());
}
public List<long> Dijkstra(int start = 0) {
long Inf = (long)MyMath.INF << 16;
var q = new PriorityQueue<Node>();
q.Enqueue(new Node(start, 0));
var ret = new List<long>(N);
for (int i = 0; i < N; i++)
ret.Add(Inf);
while (q.Any()) {
var tmp = q.Dequeue();
if (ret[tmp.Pos] == Inf)
ret[tmp.Pos] = tmp.Cost;
else
continue;
foreach (var e in g[tmp.Pos])
q.Enqueue(new Node(e.To, e.Cost + tmp.Cost));
}
return ret;
}
// 戻り値がnullのとき、負の閉路を含む
public List<long> BellmanFord(int start = 0) {
long Inf = (long)MyMath.INF << 16;
var ret = new List<long>(N);
for (int i = 0; i < N; i++)
ret.Add(Inf);
ret[start] = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
for (int k = 0; k < g[j].Count(); k++) {
var e = g[j][k];
if (ret[j] != Inf && ret[e.To] > ret[j] + e.Cost) {
ret[e.To] = ret[j] + e.Cost;
if (i == N - 1)
return null;
}
}
}
}
return ret;
}
public void AddDirectedEdge(int from, int to, long cost) {
g[from].Add(new Edge(to, cost));
}
public void AddUnDirectedEdge(int from, int to, int cost) {
AddDirectedEdge(from, to, cost);
AddDirectedEdge(to, from, cost);
}
}
#region Pair
public class Pair<T> {
public T First { get; set; }
public T Second { get; set; }
public Pair(T f, T s) {
First = f;
Second = s;
}
public override string ToString() {
return "(" + First + ", " + Second + ")";
}
public override int GetHashCode() {
return First.GetHashCode() ^ Second.GetHashCode();
}
public override bool Equals(object obj) {
if (ReferenceEquals(this, obj))
return true;
else if (obj == null)
return false;
var tmp = obj as Pair<T, T>;
return (object)tmp != null && First.Equals(tmp.First) &&
Second.Equals(tmp.Second);
}
}
public class Pair<T1, T2> {
public T1 First;
public T2 Second;
public Pair() {
First = default(T1);
Second = default(T2);
}
public Pair(T1 f, T2 s) {
First = f;
Second = s;
}
public override string ToString() {
return "(" + First + ", " + Second + ")";
}
public override int GetHashCode() {
return First.GetHashCode() ^ Second.GetHashCode();
}
public override bool Equals(object obj) {
if (ReferenceEquals(this, obj))
return true;
else if (obj == null)
return false;
var tmp = obj as Pair<T1, T2>;
return (object)tmp != null && First.Equals(tmp.First) &&
Second.Equals(tmp.Second);
}
}
#endregion
#region PriorityQueue
public class PriorityQueue<T> : IEnumerable<T>, ICollection, IEnumerable {
private Comparison<T> comp;
private List<T> list;
private int count;
public int Count {
get { return count; }
}
public bool IsEmpty {
get { return count == 0; }
}
public PriorityQueue(IComparer<T> comp)
: this((x, y) => comp.Compare(x, y)) {}
public PriorityQueue(IComparer<T> comp, int capacity)
: this((x, y) => comp.Compare(x, y), capacity) {}
public PriorityQueue(IComparer<T> comp, IEnumerable<T> source)
: this((x, y) => comp.Compare(x, y), source) {}
public PriorityQueue(IComparer<T> comp, int capacity, IEnumerable<T> source)
: this((x, y) => comp.Compare(x, y), source) {
list.Capacity = capacity;
}
public PriorityQueue() : this((x, y) => ((IComparable<T>)x).CompareTo(y)) {}
public PriorityQueue(int capacity)
: this((x, y) => ((IComparable<T>)x).CompareTo(y), capacity) {}
public PriorityQueue(IEnumerable<T> source)
: this((x, y) => ((IComparable<T>)x).CompareTo(y), source) {}
public PriorityQueue(int capacity, IEnumerable<T> source)
: this((x, y) => ((IComparable<T>)x).CompareTo(y), source) {
list.Capacity = capacity;
}
public PriorityQueue(Comparison<T> comparison) {
comp = comparison;
list = new List<T>();
count = 0;
}
public PriorityQueue(Comparison<T> comparison, IEnumerable<T> source)
: this(comparison) {
foreach (var x in source)
Enqueue(x);
}
public PriorityQueue(Comparison<T> comparison, int capacity)
: this(comparison) {
list.Capacity = capacity;
}
public void Enqueue(T x) // O(log n)
{
var pos = count++;
list.Add(x);
while (pos > 0) {
var p = (pos - 1) / 2;
if (comp(list[p], x) <= 0)
break;
list[pos] = list[p];
pos = p;
}
list[pos] = x;
}
public T Dequeue() // O(log n)
{
if (count == 0)
throw new InvalidOperationException();
var value = list[0];
var x = list[--count];
list.RemoveAt(count);
if (count == 0)
return value;
var pos = 0;
while (pos * 2 + 1 < count) {
var a = 2 * pos + 1;
var b = 2 * pos + 2;
if (b < count && comp(list[b], list[a]) < 0)
a = b;
if (comp(list[a], x) >= 0)
break;
list[pos] = list[a];
pos = a;
}
list[pos] = x;
return value;
}
public T Peek() { return list[0]; } // O(1)
public void Clear() {
list = new List<T>();
count = 0;
} // O(1)
public void TrimExcess() { list.TrimExcess(); } // O(1)
public bool Contains(T item) { return list.Contains(item); } // O(n)
void CopyTo(Array array, int index) {
if (array == null)
throw new ArgumentNullException();
if (index < 0)
throw new ArgumentOutOfRangeException();
var tmp = new PriorityQueue<T>(comp, list.Count);
for (var i = 0; i < count; i++)
tmp.Enqueue(list[i]);
while (!tmp.IsEmpty)
array.SetValue(tmp.Dequeue(), index++);
}
bool ICollection.IsSynchronized {
get { return false; }
}
object ICollection.SyncRoot {
get { return this; }
}
public IEnumerator<T> GetEnumerator() {
var tmp = new PriorityQueue<T>(comp, list.Count);
for (var i = 0; i < count; i++)
tmp.Enqueue(list[i]);
while (!tmp.IsEmpty)
yield return tmp.Dequeue();
}
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
void ICollection.CopyTo(Array array, int index) { CopyTo(array, index); }
int ICollection.Count {
get { return count; }
}
public bool Any() { return count > 0; }
}
#endregion
}
|
using System;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;
using static NotFounds.MyMath;
using static NotFounds.MyUtility;
namespace NotFounds {
public class Program {
public static void Main(string[] args) { new Program().Solve(); }
private void Solve() {
var cin = new MyInputStream();
var S = cin.ReadLine();
var l = S.Length;
ulong ans = 0;
var t = 1 << l - 1;
for (uint i = 0; i < t; ++i) {
long sum = 0;
long parm = (long)(S[0] - '0');
for (var j = 1; j < l; ++j) {
if (((i >> (j - 1)) & 1) == 1) {
sum += parm;
parm = S[j] - '0';
} else {
parm *= 10;
parm += S[j] - '0';
}
}
sum += parm;
ans += (ulong)sum;
}
WriteLine(ans);
}
private long func(long b, long n) {
if (n < b)
return n;
else
return func(b, (int)(n / b)) + n % b;
}
}
public class MyInputStream {
private char separator = ' ';
private Queue<string> inputStream;
public MyInputStream(char separator = ' ') {
this.separator = separator;
inputStream = new Queue<string>();
}
public string Read() {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = Console.ReadLine().Split(separator);
for (int i = 0; i < tmp.Length; i++) {
inputStream.Enqueue(tmp[i]);
}
return inputStream.Dequeue();
}
public string ReadLine() => Console.ReadLine();
public int ReadInt() => int.Parse(Read());
public long ReadLong() => long.Parse(Read());
public double ReadDouble() => double.Parse(Read());
}
public class MyMath {
// nx = x + dxy[i], ny = y + dxy[i + 1] (i = 0..3)
public static int[] dxy = new int[] { 0, 1, 0, -1, 0 };
/// <summary>最大値</summary>
public static int INF = int.MaxValue >> 1;
/// <summary>許容する誤差ε</summary>
public static double EPS = 1e-11;
/// <summary>よく使う素数</summary>
public static long MOD = 1000000007;
/// <summary>2つのスカラー値が等しいかどうか</summary>
public static bool EQ(double d1, double d2) => (Math.Abs(d1 - d2) < EPS);
/// <summary>x^n % m</summary>
public static long PowMod(long x, long n, long m) {
long ans = 1;
long mul = x;
for (; n > 0; n >>= 1, mul = (mul * mul) % m) {
if ((n & 1) == 1)
ans = (ans * mul) % m;
}
return ans % m;
}
/// <summary>n! % m</summary>
public static long FactMod(int n, long m) {
long ans = 1;
for (int i = 2; i <= n; i++) {
ans *= i;
ans %= m;
}
return ans;
}
/// <summary>n!</summary>
public static long Fact(int n) {
long ans = 1;
for (int i = 2; i <= n; i++)
ans *= i;
return ans;
}
/// <summary>nCr % mod</summary>
public static long ConbMod(int n, int r, long m) {
long mul = FactMod(n, m);
long div = (FactMod(r, m) * FactMod(n - r, m)) % m;
long inv = PowMod(div, m - 2, m);
return (mul * inv) % m;
}
/// <summary>nCr</summary>
public static long Conb(int n, int r) {
long mul = Parm(n, r);
long div = Fact(r);
return mul / div;
}
/// <summary>nPr</summary>
public static long Parm(int n, int r) {
long ans = 1;
for (int i = n; i >= r; i--)
ans *= i;
return ans;
}
/// <summary>最大公約数</summary>
public static long Gcd(long m, long n) {
if (n == 0)
return m;
if (m < n)
MyUtility.Swap(ref m, ref n);
long tmp;
while ((tmp = m % n) != 0) {
m = n;
n = tmp;
}
return n;
}
/// <summary>最小公倍数</summary>
public static long Lcm(long m, long n) { return m * n / Gcd(m, n); }
/// <summary>ピタゴラス</summary>
public static double Dist(double x, double y) {
return Math.Sqrt(x * x + y * y);
}
/// <summary>素数判定</summary>
public static bool isPrime(int n) {
if (n < 2)
return false;
if ((n & 1) == 0)
return n == 2 ? true : false;
for (int i = 3; i * i <= n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
/// <summary>素数取得(random)</summary>
public static IEnumerable<int> GetPrimes(int n) {
return Enumerable.Range(2, n - 1).AsParallel().Where(x => isPrime(x));
}
/// <summary>ビットの数を数える</summary>
public static int BitCount(uint n) {
n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f);
n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff);
return (int)((n & 0x0000ffff) + ((n >> 16) & 0x0000ffff));
}
public static string FizzBuzz(long n) {
var ret = "";
if (n % 3 == 0)
ret += "Fizz";
if (n % 5 == 0)
ret += "Buzz";
return ret == "" ? n.ToString() : ret;
}
}
public class MyUtility {
/// <summary>二分法:単調増加(n次関数を微分して渡しても可)</summary>
public static double binarySearch(Func<double, double> calc, double min,
double max, double target) {
var mid = 0.0;
for (int i = 0; i < 50; i++) {
mid = min + (max - min) / 2.0;
if (calc(mid) < target)
min = mid;
else
max = mid;
}
return mid;
}
public static double binarySearch(Func<double, double> calc, double min,
double max) {
return binarySearch(calc, min, max, 0.0);
}
/// <summary>三分法:凸を探索<summary>
public static double ternarySearch(Func<double, double> calc, double min,
double max) {
var left = 0.0;
var right = 0.0;
for (int i = 0; i < 200; i++) {
left = (min * 2 + max) / 3.0;
right = (min + max * 2) / 3.0;
if (calc(left) < calc(right))
max = right;
else
min = left;
}
return (left + right) * 0.5;
}
/// <summary>ニュートン法</summary>
/// calc : 元の方程式( = 0), calcdash : calcの微分形
public static double newtonSearch(Func<double, double> calc,
Func<double, double> calcdash) {
var ans0 = 0.0;
var ans1 = calc(ans0) / calcdash(ans0);
for (int i = 0; i < 100; i++) {
if (MyMath.EQ(ans0 - ans1, 0.0))
break;
ans1 = ans0;
ans0 -= calc(ans0) / calcdash(ans0);
}
return ans0;
}
public static int Coin(int[] coins, int price) {
var N = coins.Length;
var dp = new int[price + 1];
dp[0] = 0;
for (var i = 1; i <= price; i++)
dp[i] = int.MaxValue;
for (var i = 1; i <= price; i++)
for (var j = 0; j < N; j++)
if (i >= coins[j])
dp[i] = Math.Min(dp[i], dp[i - coins[j]] + 1);
else
dp[i] = Math.Min(dp[i], dp[i - 1] + 1);
return dp[price];
}
/// <summary>2値を入れ替える</summary>
public static void Swap<T>(ref T m, ref T n) {
T tmp = m;
m = n;
n = tmp;
}
/// <summary>値を出力する</summary>
public static void Dump(params object[] data) { data.Dump(); }
}
#region extentions
public static class MyExtentions {
public static int CountStringOfString(this string source, string target) {
int cnt = 0;
int targetLen = target.Length;
if (targetLen == 0)
return 0;
for (int i = 0; i <= source.Length - targetLen; i++) {
int tmp = source.IndexOf(target, i);
if (tmp != -1) {
cnt++;
i = Math.Max(tmp + targetLen - 1, 0);
} else
break;
}
return cnt;
}
public static int Max(this int source, int num) {
return Math.Max(source, num);
}
public static int Min(this int source, int num) {
return Math.Min(source, num);
}
}
public static class MyEnumerableExtentions {
public static string ConcatWith<T>(this IEnumerable<T> source,
string separator, string format,
IFormatProvider provider = null)
where T : IFormattable {
return source.Select(x => x.ToString(format, provider))
.Aggregate((a, b) => a + separator + b);
}
public static string ConcatWith<T>(this IEnumerable<T> source,
string separator) {
return string.Join(separator, source);
}
public static void ForEach<T>(this IEnumerable<T> source,
Action<T, int> func) {
foreach (var item in source.Select((x, i) => new { val = x, idx = i }))
func(item.val, item.idx);
}
public static void ForEach<T>(this IEnumerable<T> source, Action<T> func) {
foreach (var item in source)
func(item);
}
public static void Dump<T>(this IEnumerable<T> source) {
Console.WriteLine("{ " + source.ConcatWith(", ") + " }");
}
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source) {
return source.OrderBy(x => Guid.NewGuid());
}
public static bool IsEmpty<T>(this IEnumerable<T> source) {
return !source.Any();
}
public static string MaxLengthString(this IEnumerable<string> source) {
return source.Aggregate("", (max, s) => s.Length > max.Length ? s : max);
}
public static string MinLengthString(this IEnumerable<string> source) {
return source.Aggregate(
"", (min, s) => (s.Length < min.Length || min == "") ? s : min);
}
public static IEnumerable<IEnumerable<T>>
Permutations<T>(this IEnumerable<T> source) {
if (source.Count() != 0) {
int index = 0;
foreach (var item in source) {
var allOtherItems = source.RemoveAt(index++);
foreach (var permutation in allOtherItems.Permutations()) {
yield return new[] { item }.Concat(permutation);
}
}
} else {
yield return new T[0];
}
}
public static IEnumerable<T> RemoveAt<T>(this IEnumerable<T> source,
int indexToRemove) {
int index = 0;
foreach (T item in source)
if (index++ != indexToRemove)
yield return item;
}
}
#endregion
public class Graph {
private struct Edge {
public int To;
public long Cost;
public Edge(int t, long c) {
this.To = t;
this.Cost = c;
}
}
private struct Node : IComparable<Node> {
public int Pos;
public long Cost;
public Node(int p, long c) {
this.Pos = p;
this.Cost = c;
}
public int CompareTo(Node obj) { return (int)(this.Cost - obj.Cost); }
}
private List<List<Edge>> g;
private int N { get; set; }
public Graph(int size) {
N = size;
g = new List<List<Edge>>(size);
for (int i = 0; i < size; i++)
g.Add(new List<Edge>());
}
public List<long> Dijkstra(int start = 0) {
long Inf = (long)MyMath.INF << 16;
var q = new PriorityQueue<Node>();
q.Enqueue(new Node(start, 0));
var ret = new List<long>(N);
for (int i = 0; i < N; i++)
ret.Add(Inf);
while (q.Any()) {
var tmp = q.Dequeue();
if (ret[tmp.Pos] == Inf)
ret[tmp.Pos] = tmp.Cost;
else
continue;
foreach (var e in g[tmp.Pos])
q.Enqueue(new Node(e.To, e.Cost + tmp.Cost));
}
return ret;
}
// 戻り値がnullのとき、負の閉路を含む
public List<long> BellmanFord(int start = 0) {
long Inf = (long)MyMath.INF << 16;
var ret = new List<long>(N);
for (int i = 0; i < N; i++)
ret.Add(Inf);
ret[start] = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
for (int k = 0; k < g[j].Count(); k++) {
var e = g[j][k];
if (ret[j] != Inf && ret[e.To] > ret[j] + e.Cost) {
ret[e.To] = ret[j] + e.Cost;
if (i == N - 1)
return null;
}
}
}
}
return ret;
}
public void AddDirectedEdge(int from, int to, long cost) {
g[from].Add(new Edge(to, cost));
}
public void AddUnDirectedEdge(int from, int to, int cost) {
AddDirectedEdge(from, to, cost);
AddDirectedEdge(to, from, cost);
}
}
#region Pair
public class Pair<T> {
public T First { get; set; }
public T Second { get; set; }
public Pair(T f, T s) {
First = f;
Second = s;
}
public override string ToString() {
return "(" + First + ", " + Second + ")";
}
public override int GetHashCode() {
return First.GetHashCode() ^ Second.GetHashCode();
}
public override bool Equals(object obj) {
if (ReferenceEquals(this, obj))
return true;
else if (obj == null)
return false;
var tmp = obj as Pair<T, T>;
return (object)tmp != null && First.Equals(tmp.First) &&
Second.Equals(tmp.Second);
}
}
public class Pair<T1, T2> {
public T1 First;
public T2 Second;
public Pair() {
First = default(T1);
Second = default(T2);
}
public Pair(T1 f, T2 s) {
First = f;
Second = s;
}
public override string ToString() {
return "(" + First + ", " + Second + ")";
}
public override int GetHashCode() {
return First.GetHashCode() ^ Second.GetHashCode();
}
public override bool Equals(object obj) {
if (ReferenceEquals(this, obj))
return true;
else if (obj == null)
return false;
var tmp = obj as Pair<T1, T2>;
return (object)tmp != null && First.Equals(tmp.First) &&
Second.Equals(tmp.Second);
}
}
#endregion
#region PriorityQueue
public class PriorityQueue<T> : IEnumerable<T>, ICollection, IEnumerable {
private Comparison<T> comp;
private List<T> list;
private int count;
public int Count {
get { return count; }
}
public bool IsEmpty {
get { return count == 0; }
}
public PriorityQueue(IComparer<T> comp)
: this((x, y) => comp.Compare(x, y)) {}
public PriorityQueue(IComparer<T> comp, int capacity)
: this((x, y) => comp.Compare(x, y), capacity) {}
public PriorityQueue(IComparer<T> comp, IEnumerable<T> source)
: this((x, y) => comp.Compare(x, y), source) {}
public PriorityQueue(IComparer<T> comp, int capacity, IEnumerable<T> source)
: this((x, y) => comp.Compare(x, y), source) {
list.Capacity = capacity;
}
public PriorityQueue() : this((x, y) => ((IComparable<T>)x).CompareTo(y)) {}
public PriorityQueue(int capacity)
: this((x, y) => ((IComparable<T>)x).CompareTo(y), capacity) {}
public PriorityQueue(IEnumerable<T> source)
: this((x, y) => ((IComparable<T>)x).CompareTo(y), source) {}
public PriorityQueue(int capacity, IEnumerable<T> source)
: this((x, y) => ((IComparable<T>)x).CompareTo(y), source) {
list.Capacity = capacity;
}
public PriorityQueue(Comparison<T> comparison) {
comp = comparison;
list = new List<T>();
count = 0;
}
public PriorityQueue(Comparison<T> comparison, IEnumerable<T> source)
: this(comparison) {
foreach (var x in source)
Enqueue(x);
}
public PriorityQueue(Comparison<T> comparison, int capacity)
: this(comparison) {
list.Capacity = capacity;
}
public void Enqueue(T x) // O(log n)
{
var pos = count++;
list.Add(x);
while (pos > 0) {
var p = (pos - 1) / 2;
if (comp(list[p], x) <= 0)
break;
list[pos] = list[p];
pos = p;
}
list[pos] = x;
}
public T Dequeue() // O(log n)
{
if (count == 0)
throw new InvalidOperationException();
var value = list[0];
var x = list[--count];
list.RemoveAt(count);
if (count == 0)
return value;
var pos = 0;
while (pos * 2 + 1 < count) {
var a = 2 * pos + 1;
var b = 2 * pos + 2;
if (b < count && comp(list[b], list[a]) < 0)
a = b;
if (comp(list[a], x) >= 0)
break;
list[pos] = list[a];
pos = a;
}
list[pos] = x;
return value;
}
public T Peek() { return list[0]; } // O(1)
public void Clear() {
list = new List<T>();
count = 0;
} // O(1)
public void TrimExcess() { list.TrimExcess(); } // O(1)
public bool Contains(T item) { return list.Contains(item); } // O(n)
void CopyTo(Array array, int index) {
if (array == null)
throw new ArgumentNullException();
if (index < 0)
throw new ArgumentOutOfRangeException();
var tmp = new PriorityQueue<T>(comp, list.Count);
for (var i = 0; i < count; i++)
tmp.Enqueue(list[i]);
while (!tmp.IsEmpty)
array.SetValue(tmp.Dequeue(), index++);
}
bool ICollection.IsSynchronized {
get { return false; }
}
object ICollection.SyncRoot {
get { return this; }
}
public IEnumerator<T> GetEnumerator() {
var tmp = new PriorityQueue<T>(comp, list.Count);
for (var i = 0; i < count; i++)
tmp.Enqueue(list[i]);
while (!tmp.IsEmpty)
yield return tmp.Dequeue();
}
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
void ICollection.CopyTo(Array array, int index) { CopyTo(array, index); }
int ICollection.Count {
get { return count; }
}
public bool Any() { return count > 0; }
}
#endregion
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 4,391
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var ABC = ReadSplitLong();
var A = ABC[0];
var B = ABC[1];
var C = ABC[2];
if (ABC.Any(x => x % 2 == 0))
Println(0);
else
Println(A * B);
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static void YESOrNO(bool e) => Println(e ? "YES" : "NO");
static void YesOrNo(bool e) => Println(e ? "Yes" : "No");
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var ABC = ReadSplitLong();
var A = ABC[0];
var B = ABC[1];
var C = ABC[2];
if (ABC.Any(x => x % 2 == 0))
Println(0);
else
Println(Min(Min(A * B, A * C), B * C));
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static void YESOrNO(bool e) => Println(e ? "YES" : "NO");
static void YesOrNo(bool e) => Println(e ? "Yes" : "No");
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 732
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) { Solve(); }
private const int MOD = 1000000007;
static void Solve() {
var abc = ReadAndParseIntArr();
int a = abc[0];
int b = abc[1];
int c = abc[2];
int ans = 0;
if ((a * b * c) % 2 == 0) {
ans = 0;
} else {
ans = Math.Min(c * a, Math.Min(a * b, b * c));
}
Console.WriteLine(ans);
}
#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 long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
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);
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) { Solve(); }
private const int MOD = 1000000007;
static void Solve() {
var abc = ReadAndParseIntArr();
long a = abc[0];
long b = abc[1];
long c = abc[2];
long ans = 0;
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
ans = 0;
} else {
ans = Math.Min(c * a, Math.Min(a * b, b * c));
}
Console.WriteLine(ans);
}
#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 long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
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);
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 17, 48], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 17, 109], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 106], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 15, 16, 31, 16, 12, 16, 31, 16, 17, 109], ["+", 15, 16, 31, 16, 12, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 741
| 22
|
#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 nA = Console.ReadLine().SplittedStringToInt32List();
// var n = nA[0];
// var A = nA[1];
// var an = Console.ReadLine().SplittedStringToInt32List();
// var dp = new bool[n + 1, A + 1];
// for (int i = 0; i < n; i++)
//{
//}
// Console.ReadLine();
var abc = Console.ReadLine().SplittedStringToInt32List();
if (abc.Max() % 2 == 0) {
Console.WriteLine(0);
} else {
abc.Remove(abc.Max());
Console.WriteLine(abc[0] * abc[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
}
|
#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 nA = Console.ReadLine().SplittedStringToInt32List();
// var n = nA[0];
// var A = nA[1];
// var an = Console.ReadLine().SplittedStringToInt32List();
// var dp = new bool[n + 1, A + 1];
// for (int i = 0; i < n; i++)
//{
//}
// Console.ReadLine();
var abc = Console.ReadLine().SplittedStringToInt32List();
if (abc.Max() % 2 == 0) {
Console.WriteLine(0);
} else {
abc.Remove(abc.Max());
Console.WriteLine(((long)abc[0] * (long)abc[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
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 23, 0, 24], ["+", 0, 28, 0, 23, 0, 16, 31, 74, 0, 24], ["+", 0, 28, 0, 23, 0, 16, 31, 74, 39, 199], ["+", 0, 28, 0, 23, 0, 16, 31, 74, 0, 25], ["+", 0, 28, 0, 23, 0, 16, 12, 74, 0, 24], ["+", 0, 28, 0, 23, 0, 16, 12, 74, 39, 199], ["+", 0, 28, 0, 23, 0, 16, 12, 74, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 23, 0, 25]]
| 8
| 1,293
| 8
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Console;
using static AtCoder.Util;
using static AtCoder.Cin;
using static System.Math;
using static AtCoder.MyMath;
namespace AtCoder {
class Program {
static void Main() {
var A = ReadInt();
var B = ReadInt();
var C = ReadInt();
var max = Max(A, B, C);
var hoge = ToList<long>(A, B, C);
hoge.Remove(max);
WriteLine(C.IsEven() ? 0 : hoge.Prod());
}
}
}
/* ***************** Following Contents are my common library ******** */
namespace AtCoder {
static class MyMath {
public static long ToNearestInt(this double d) {
var l = (long)Math.Floor(d);
var r = l + 1;
return r - d < d - l ? r : l;
}
public static long Factorial(this long n) => Range(1, n).Aggregate(1L,
Multiply);
public static long nPr(int n, int r) => r < 0 || r > n? 0
: FromTo(n - r + 1, n)
.Select(x => (long)x)
.Aggregate(1L, Multiply);
public static long nCr(int n, int r) => nPr(n, r) / Factorial(r);
public static long Inc(long i) => i + 1;
public static long Dec(long i) => i - 1;
public static long Plus(long i, long j) => i + j;
public static Func<long, long> Plus(long j) => i => i + j;
public static long Minus(long i, long j) => i - j;
public static Func<long, long> Minus(long j) => i => i - j;
public static long Multiply(long i, long j) => i * j;
public static Func<long, long> Multiply(long j) => i => i * j;
public static long Divide(long i, long j) => j / j;
public static Func<long, long> Divide(long j) => i => i * j;
public static long Mod(long i, long j) => i % j;
public static Func<long, long> Mod(long j) => i => i % j;
public static long Max(params long[] ns) => ns.Max();
public static bool InRange(this long x, long min, long max) => min <= x
&& x <= max;
public static bool IsEven(this int x) => x % 2 == 0;
public static bool IsOdd(this int x) => x % 2 != 1;
public static bool IsEven(this long x) => x % 2 == 0;
public static bool IsOdd(this long x) => x % 2 != 1;
}
static class Util {
public static IEnumerable<int>
ToDigits(this long n) => n.ToString().Select(x => x.ToInt());
public static IEnumerable<int> Factors(this int n) {
for (int i = 1; i <= n; i++)
if (n % i == 0)
yield return i;
}
public static IEnumerable<int> Natural() {
for (int i = 0;; i++)
yield return i;
}
public static IEnumerable<int> Positive() => Natural().Skip(1);
public static long Pow(long i, long exp) => (exp == 0) ? 1
: i * Pow(i, exp - 1);
public static HashSet<T>
ToHashSet<T>(this IEnumerable<T> source) => new HashSet<T>(source);
public static MultiSet<T>
ToMultiSet<T>(this IEnumerable<T> t) => new MultiSet<T>(t);
public static int Max(this int i, int j) => i > j? i : j;
public static bool IsPalindrome(string s) {
for (int i = 0; i < s.Length / 2; i++) {
if (s[i] != s[s.Length - 1 - i])
return false;
}
return true;
}
public readonly static VectorInt2[] Dir8 = {
new VectorInt2(-1, -1), new VectorInt2(-1, 0), new VectorInt2(-1, 1),
new VectorInt2(0, -1), new VectorInt2(0, 1), new VectorInt2(1, -1),
new VectorInt2(1, 0), new VectorInt2(1, 1)
};
public const long MODCONST = 1000000007;
public static T debug<T>(this T value) {
Console.Error.WriteLine($"debug:{value}");
return value;
}
public static T Id<T>(T t) => t;
public static long ToLong(this String s) => long.Parse(s);
public static long ToLong(this char c) => c - '0';
public static int ToInt(this String s) => int.Parse(s);
public static int ToInt(this char c) => c - '0';
public static void Times(this int n, Action action) {
for (int i = 0; i < n; i++)
action();
}
public static void Times(this long n, Action action) {
for (long i = 0; i < n; i++)
action();
}
public static IEnumerable<T> Times<T>(this int n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static IEnumerable<T> Times<T>(this long n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static Func<S, U> Then<S, T, U>(this Func<S, T> f,
Func<T, U> g) => x => g(f(x));
public static Func<S, U> Compose<S, T, U>(this Func<T, U> f,
Func<S, T> g) => x => f(g(x));
public static void Call<T>(this T t, Action<T> action) => action(t);
public static bool In<T>(this T t, IEnumerable<T> range) => range.Contains(t);
public static void WriteLine<T>(this T t) => Console.WriteLine(t);
public static T Call<S, T>(this S s, Func<S, T> func) => func(s);
public static void Each<T>(this IEnumerable<T> e, Action<T> action) {
foreach (var v in e)
action(v);
}
public static long
Prod(this IEnumerable<long> source) => source.Aggregate(Multiply);
public static IEnumerable<int> FromTo(int a,
int b) => Range(a, Max(b - a + 1, 0));
public static IEnumerable<T> Repeat<T>(T t) {
while (true)
yield return t;
}
public static IEnumerable<T> Replicate<T>(int n, T t) => Repeat(t).Take(n);
public static IEnumerable<T> Cycle<T>(this IEnumerable<T> e) {
while (true)
foreach (var v in e)
yield return v;
}
public static IEnumerable<T> Scan<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
var result = init;
foreach (var item in source) {
result = accumulator(result, item);
yield return result;
}
}
public static T[] ToArray<T>(params T[] ns) => ns;
public static List<T> ToList<T>(params T[] ns) => ns.ToList();
public static IEnumerable<T> Scan0<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
yield return init;
foreach (var item in Scan(source, init, accumulator))
yield return item;
}
public static IEnumerable<List<T>> Buffer<T>(this IEnumerable<T> source,
int length) {
while (source.Any()) {
yield return source.Take(length).ToList();
source = source.Skip(length);
}
}
public static VectorInt2 ReadVectorInt2() => new VectorInt2(ReadInt(),
ReadInt());
public static string ReplaceX(this string input, string pattern,
string replace) => Regex.Replace(input, pattern,
replace);
public static IEnumerable<int> Range(int i, int j) => Enumerable.Range(i, j);
public static IEnumerable<long> Range(long i, long j) {
for (long k = i; k < i + j; k++)
yield return k;
}
public static void Swap<T>(this IList<T> enumerable, int i, int j) {
var buf = enumerable[i];
enumerable[i] = enumerable[j];
enumerable[j] = buf;
}
public static void ReverseRange<T>(this IList<T> enumerable, int i, int j) {
int half = (j - i) / 2;
for (int k = 0; k <= half; k++)
enumerable.Swap(i + k, j - k);
}
public static bool
isEmpty<T>(this IEnumerable<T> enumerable) => !enumerable.Any();
}
static class Cin {
private static Queue<string> tokens;
static Cin() {
string line;
tokens = new Queue<string>();
while ((line = Console.ReadLine()) != null) {
foreach (var token in line.Split(' ')) {
tokens.Enqueue(token);
}
}
}
static public int ReadInt() => int.Parse(tokens.Dequeue());
static public List<int> ReadInt(long n) {
var list = new List<int>();
n.Times(() => list.Add(ReadInt()));
return list;
}
static public long ReadLong() => long.Parse(tokens.Dequeue());
static public List<long> ReadLong(long n) {
var list = new List<long>();
n.Times(() => list.Add(ReadLong()));
return list;
}
static public string ReadString() => tokens.Dequeue();
static public List<string> ReadString(long n) {
var list = new List<string>();
n.Times(() => list.Add(ReadString()));
return list;
}
static public void SayYesNo(this bool b) => (b ? "Yes" : "No").WriteLine();
}
struct VectorInt2 {
public int X { get; set; }
public int Y { get; set; }
public VectorInt2(int x, int y) {
X = x;
Y = y;
}
static public VectorInt2 operator +(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X + v2.X, v1.Y + v2.Y);
static public VectorInt2 operator -(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X - v2.X, v1.Y - v2.Y);
static public VectorInt2 operator *(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X * v2.X, v1.Y *v2.Y);
static public VectorInt2
operator *(VectorInt2 v1, int i) => new VectorInt2(v1.X * i, v1.Y *i);
static public VectorInt2
operator *(int i, VectorInt2 v2) => new VectorInt2(i * v2.X, i *v2.Y);
static public VectorInt2
operator /(VectorInt2 v1, int i) => new VectorInt2(v1.X / i, v1.Y / i);
}
class Maxer<T>
where T : IComparable<T> {
public T Value;
public Maxer(T t) { Value = t; }
public void Max(T other) {
if (Value.CompareTo(other) < 0)
Value = other;
}
}
class MultiSet<T> : IEnumerable<KeyValuePair<T, int>> {
Dictionary<T, int> dictionary = new Dictionary<T, int>();
public MultiSet(IEnumerable<T> data) {
foreach (var datum in data) {
if (dictionary.ContainsKey(datum)) {
dictionary[datum]++;
} else {
dictionary[datum] = 1;
}
}
}
public int this[T key] {
get { return dictionary.ContainsKey(key) ? dictionary[key] : 0; }
}
public MultiSet() {}
public static MultiSet<S>
ToMultiSet<S>(IEnumerable<S> source) => new MultiSet<S>(source);
public Dictionary<T, int> AsDict() => dictionary;
public IEnumerator<KeyValuePair<T, int>>
GetEnumerator() => dictionary.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Console;
using static AtCoder.Util;
using static AtCoder.Cin;
using static System.Math;
using static AtCoder.MyMath;
namespace AtCoder {
class Program {
static void Main() {
var A = ReadInt();
var B = ReadInt();
var C = ReadInt();
var max = Max(A, B, C);
var hoge = ToList<long>(A, B, C);
hoge.Remove(max);
WriteLine(ToList(A, B, C).Any(MyMath.IsEven) ? 0 : hoge.Prod());
}
}
}
/* ***************** Following Contents are my common library ******** */
namespace AtCoder {
static class MyMath {
public static long ToNearestInt(this double d) {
var l = (long)Math.Floor(d);
var r = l + 1;
return r - d < d - l ? r : l;
}
public static long Factorial(this long n) => Range(1, n).Aggregate(1L,
Multiply);
public static long nPr(int n, int r) => r < 0 || r > n? 0
: FromTo(n - r + 1, n)
.Select(x => (long)x)
.Aggregate(1L, Multiply);
public static long nCr(int n, int r) => nPr(n, r) / Factorial(r);
public static long Inc(long i) => i + 1;
public static long Dec(long i) => i - 1;
public static long Plus(long i, long j) => i + j;
public static Func<long, long> Plus(long j) => i => i + j;
public static long Minus(long i, long j) => i - j;
public static Func<long, long> Minus(long j) => i => i - j;
public static long Multiply(long i, long j) => i * j;
public static Func<long, long> Multiply(long j) => i => i * j;
public static long Divide(long i, long j) => j / j;
public static Func<long, long> Divide(long j) => i => i * j;
public static long Mod(long i, long j) => i % j;
public static Func<long, long> Mod(long j) => i => i % j;
public static long Max(params long[] ns) => ns.Max();
public static bool InRange(this long x, long min, long max) => min <= x
&& x <= max;
public static bool IsEven(this int x) => x % 2 == 0;
public static bool IsOdd(this int x) => x % 2 != 1;
public static bool IsEven(this long x) => x % 2 == 0;
public static bool IsOdd(this long x) => x % 2 != 1;
}
static class Util {
public static string
Show(this IEnumerable<char> source) => new string(source.ToArray());
public static IEnumerable<int>
ToDigits(this long n) => n.ToString().Select(x => x.ToInt());
public static IEnumerable<int> Factors(this int n) {
for (int i = 1; i <= n; i++)
if (n % i == 0)
yield return i;
}
public static IEnumerable<int> Natural() {
for (int i = 0;; i++)
yield return i;
}
public static IEnumerable<int> Positive() => Natural().Skip(1);
public static long Pow(long i, long exp) => (exp == 0) ? 1
: i * Pow(i, exp - 1);
public static HashSet<T>
ToHashSet<T>(this IEnumerable<T> source) => new HashSet<T>(source);
public static MultiSet<T>
ToMultiSet<T>(this IEnumerable<T> t) => new MultiSet<T>(t);
public static int Max(this int i, int j) => i > j? i : j;
public static bool IsPalindrome(string s) {
for (int i = 0; i < s.Length / 2; i++) {
if (s[i] != s[s.Length - 1 - i])
return false;
}
return true;
}
public readonly static VectorInt2[] Dir8 = {
new VectorInt2(-1, -1), new VectorInt2(-1, 0), new VectorInt2(-1, 1),
new VectorInt2(0, -1), new VectorInt2(0, 1), new VectorInt2(1, -1),
new VectorInt2(1, 0), new VectorInt2(1, 1)
};
public const long MODCONST = 1000000007;
public static T debug<T>(this T value) {
Console.Error.WriteLine($"debug:{value}");
return value;
}
public static T Id<T>(T t) => t;
public static long ToLong(this String s) => long.Parse(s);
public static long ToLong(this char c) => c - '0';
public static int ToInt(this String s) => int.Parse(s);
public static int ToInt(this char c) => c - '0';
public static void Times(this int n, Action action) {
for (int i = 0; i < n; i++)
action();
}
public static void Times(this long n, Action action) {
for (long i = 0; i < n; i++)
action();
}
public static IEnumerable<T> Times<T>(this int n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static IEnumerable<T> Times<T>(this long n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static Func<S, U> Then<S, T, U>(this Func<S, T> f,
Func<T, U> g) => x => g(f(x));
public static Func<S, U> Compose<S, T, U>(this Func<T, U> f,
Func<S, T> g) => x => f(g(x));
public static void Call<T>(this T t, Action<T> action) => action(t);
public static bool In<T>(this T t, IEnumerable<T> range) => range.Contains(t);
public static void WriteLine<T>(this T t) => Console.WriteLine(t);
public static T Call<S, T>(this S s, Func<S, T> func) => func(s);
public static void Each<T>(this IEnumerable<T> e, Action<T> action) {
foreach (var v in e)
action(v);
}
public static long
Prod(this IEnumerable<long> source) => source.Aggregate(Multiply);
public static IEnumerable<int> FromTo(int a,
int b) => Range(a, Max(b - a + 1, 0));
public static IEnumerable<T> Repeat<T>(T t) {
while (true)
yield return t;
}
public static IEnumerable<T> Replicate<T>(int n, T t) => Repeat(t).Take(n);
public static IEnumerable<T> Cycle<T>(this IEnumerable<T> e) {
while (true)
foreach (var v in e)
yield return v;
}
public static IEnumerable<T> Scan<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
var result = init;
foreach (var item in source) {
result = accumulator(result, item);
yield return result;
}
}
public static T[] ToArray<T>(params T[] ns) => ns;
public static List<T> ToList<T>(params T[] ns) => ns.ToList();
public static IEnumerable<T> Scan0<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
yield return init;
foreach (var item in Scan(source, init, accumulator))
yield return item;
}
public static IEnumerable<List<T>> Buffer<T>(this IEnumerable<T> source,
int length) {
while (source.Any()) {
yield return source.Take(length).ToList();
source = source.Skip(length);
}
}
public static VectorInt2 ReadVectorInt2() => new VectorInt2(ReadInt(),
ReadInt());
public static string ReplaceX(this string input, string pattern,
string replace) => Regex.Replace(input, pattern,
replace);
public static IEnumerable<int> Range(int i, int j) => Enumerable.Range(i, j);
public static IEnumerable<long> Range(long i, long j) {
for (long k = i; k < i + j; k++)
yield return k;
}
public static void Swap<T>(this IList<T> enumerable, int i, int j) {
var buf = enumerable[i];
enumerable[i] = enumerable[j];
enumerable[j] = buf;
}
public static void ReverseRange<T>(this IList<T> enumerable, int i, int j) {
int half = (j - i) / 2;
for (int k = 0; k <= half; k++)
enumerable.Swap(i + k, j - k);
}
public static bool
isEmpty<T>(this IEnumerable<T> enumerable) => !enumerable.Any();
}
static class Cin {
private static Queue<string> tokens;
static Cin() {
string line;
tokens = new Queue<string>();
while ((line = Console.ReadLine()) != null) {
foreach (var token in line.Split(' ')) {
tokens.Enqueue(token);
}
}
}
static public int ReadInt() => int.Parse(tokens.Dequeue());
static public List<int> ReadInt(long n) {
var list = new List<int>();
n.Times(() => list.Add(ReadInt()));
return list;
}
static public long ReadLong() => long.Parse(tokens.Dequeue());
static public List<long> ReadLong(long n) {
var list = new List<long>();
n.Times(() => list.Add(ReadLong()));
return list;
}
static public string ReadString() => tokens.Dequeue();
static public List<string> ReadString(long n) {
var list = new List<string>();
n.Times(() => list.Add(ReadString()));
return list;
}
static public void SayYesNo(this bool b) => (b ? "Yes" : "No").WriteLine();
}
struct VectorInt2 {
public int X { get; set; }
public int Y { get; set; }
public VectorInt2(int x, int y) {
X = x;
Y = y;
}
static public VectorInt2 operator +(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X + v2.X, v1.Y + v2.Y);
static public VectorInt2 operator -(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X - v2.X, v1.Y - v2.Y);
static public VectorInt2 operator *(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X * v2.X, v1.Y *v2.Y);
static public VectorInt2
operator *(VectorInt2 v1, int i) => new VectorInt2(v1.X * i, v1.Y *i);
static public VectorInt2
operator *(int i, VectorInt2 v2) => new VectorInt2(i * v2.X, i *v2.Y);
static public VectorInt2
operator /(VectorInt2 v1, int i) => new VectorInt2(v1.X / i, v1.Y / i);
}
class Maxer<T>
where T : IComparable<T> {
public T Value;
public Maxer(T t) { Value = t; }
public void Max(T other) {
if (Value.CompareTo(other) < 0)
Value = other;
}
}
class MultiSet<T> : IEnumerable<KeyValuePair<T, int>> {
Dictionary<T, int> dictionary = new Dictionary<T, int>();
public MultiSet(IEnumerable<T> data) {
foreach (var datum in data) {
if (dictionary.ContainsKey(datum)) {
dictionary[datum]++;
} else {
dictionary[datum] = 1;
}
}
}
public int this[T key] {
get { return dictionary.ContainsKey(key) ? dictionary[key] : 0; }
}
public MultiSet() {}
public static MultiSet<S>
ToMultiSet<S>(IEnumerable<S> source) => new MultiSet<S>(source);
public Dictionary<T, int> AsDict() => dictionary;
public IEnumerator<KeyValuePair<T, int>>
GetEnumerator() => dictionary.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}
}
|
[["+", 0, 41, 15, 213, 63, 214, 205, 213, 63, 22], ["+", 15, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22], ["+", 15, 213, 63, 214, 205, 213, 3, 4, 0, 21], ["+", 15, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 28, 0, 41, 15, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 41, 15, 213, 63, 214, 141, 22], ["+", 15, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 15, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 15, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 259], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 115], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 24], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 0, 276], ["+", 0, 195, 54, 55, 0, 220, 39, 236, 141, 22], ["+", 54, 55, 0, 220, 39, 236, 237, 238, 0, 18], ["+", 54, 55, 0, 220, 39, 236, 237, 238, 0, 199], ["+", 54, 55, 0, 220, 39, 236, 237, 238, 0, 47], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["+", 0, 235, 8, 201, 0, 195, 8, 306, 0, 221], ["+", 8, 201, 0, 195, 8, 306, 0, 230, 0, 228], ["+", 8, 201, 0, 195, 8, 306, 0, 230, 39, 199], ["+", 0, 195, 8, 306, 0, 230, 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, 195, 8, 306, 0, 230, 3, 4, 0, 25], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 0, 35]]
| 8
| 2,804
| 35
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
Array.Sort(a);
Console.WriteLine(
a[0] % 2 != 0 && a[1] % 2 != 0 && a[2] % 2 != 0 ? a[0] * a[1] : 0);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
Array.Sort(a);
Console.WriteLine(a[0] * a[1] * a[2] % 2 * a[0] * a[1]);
}
}
|
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 109], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 41, 15, 16, 31, 16, 31, 16, 17, 79], ["-", 0, 41, 15, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 28, 0, 41, 15, 16, 31, 16, 17, 98], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["-", 15, 16, 31, 16, 12, 16, 31, 16, 17, 109], ["-", 15, 16, 31, 16, 12, 16, 31, 16, 12, 203], ["-", 0, 41, 15, 16, 31, 16, 12, 16, 17, 79], ["-", 0, 41, 15, 16, 31, 16, 12, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 98], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["-", 0, 28, 0, 41, 15, 16, 12, 16, 17, 79], ["-", 0, 28, 0, 41, 15, 16, 12, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 75, 203]]
| 8
| 106
| 14
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
Array.Sort(a);
Console.WriteLine(
a[0] % 2 != 0 && a[1] % 2 != 0 && a[2] % 2 != 0 ? a[0] * a[1] : 0);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
Array.Sort(a);
Console.WriteLine(
a[0] % 2 != 0 && a[1] % 2 != 0 && a[2] % 2 != 0 ? a[0] * a[1] : 0);
}
}
|
[["+", 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, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
| 8
| 106
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static string InputPattern = "InputX";
static List<string> GetInputList() {
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3 3 3");
// 9
} else if (InputPattern == "Input2") {
WillReturn.Add("2 2 4");
// 0
} else if (InputPattern == "Input3") {
WillReturn.Add("5 3 5");
// 15
} else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null)
WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main() {
List<string> InputList = GetInputList();
int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
int A = wkArr[0];
int B = wkArr[1];
int C = wkArr[2];
//偶数の軸がある場合
if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
Console.WriteLine(0);
return;
}
// Aで分割する場合
int wkProd1 = B * C;
// Bで分割する場合
int wkProd2 = A * C;
// Cで分割する場合
int wkProd3 = A * B;
int Answer = Math.Min(wkProd1, wkProd2);
Answer = Math.Min(Answer, wkProd3);
Console.WriteLine(Answer);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
// AGC004-A-Divide a Cuboid
// http://agc004.contest.atcoder.jp/tasks/agc004_a
class Program {
static string InputPattern = "InputX";
static List<string> GetInputList() {
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3 3 3");
// 9
} else if (InputPattern == "Input2") {
WillReturn.Add("2 2 4");
// 0
} else if (InputPattern == "Input3") {
WillReturn.Add("5 3 5");
// 15
} else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null)
WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main() {
List<string> InputList = GetInputList();
long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
long A = wkArr[0];
long B = wkArr[1];
long C = wkArr[2];
//偶数の軸がある場合
if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
Console.WriteLine(0);
return;
}
// Aで分割する場合
long wkProd1 = B * C;
// Bで分割する場合
long wkProd2 = A * C;
// Cで分割する場合
long wkProd3 = A * B;
long Answer = Math.Min(wkProd1, wkProd2);
Answer = Math.Min(Answer, wkProd3);
Console.WriteLine(Answer);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 300
| 18
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Program {
public static void Main() {
// int n = int.Parse(Console.ReadLine());
int[] arr = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
List<int> l = arr.ToList();
l.Sort();
int a = l[0];
int b = l[1];
int c = l[2];
int even = 0;
foreach (var v in l) {
if (v % 2 == 0) {
even = 1;
break;
}
}
int res = 0;
if (even != 1) {
res = a * b;
}
Console.WriteLine(res);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Program {
public static void Main() {
// int n = int.Parse(Console.ReadLine());
long[] arr =
Console.ReadLine().Split().Select(e => long.Parse(e)).ToArray();
List<long> l = arr.ToList();
l.Sort();
long a = l[0];
long b = l[1];
long c = l[2];
int even = 0;
foreach (var v in l) {
if (v % 2 == 0) {
even = 1;
break;
}
}
long res = 0;
if (even != 1) {
res = a * b;
}
Console.WriteLine(res);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 163
| 14
|
using System;
using System.IO;
#region Program
namespace Program {
#region Solver
public class Solver {
static IO.StreamScanner sc =
new IO.StreamScanner(Console.OpenStandardInput());
double A;
double B;
double C;
int SIDE;
double BIGLNG;
double BIG_ONE;
double SMALL_ONE;
#region Solver
public Solver() {
A = sc.Long();
B = sc.Long();
C = sc.Long();
if (B <= A) {
if (C <= B) {
SIDE = 0;
BIGLNG = A;
} else if (C <= A) {
SIDE = 0;
BIGLNG = A;
} else {
SIDE = 2;
BIGLNG = C;
}
} else {
if (C <= A) {
SIDE = 1;
BIGLNG = B;
} else if (C <= B) {
SIDE = 1;
BIGLNG = B;
} else {
SIDE = 2;
BIGLNG = C;
}
}
}
#endregion
#region Solve
public void Solve() {
double rem = BIGLNG == Math.Truncate(BIGLNG / 2) * 2 ? 0 : 1;
if (rem == 0) {
Console.WriteLine(0);
return;
}
BIG_ONE = (SIDE == 0) ? (Math.Truncate(BIGLNG / 2) + 1) * B * C
: (SIDE == 1) ? (Math.Truncate(BIGLNG / 2) + 1) * A * C
: (Math.Truncate(BIGLNG / 2) + 1) * A * B;
SMALL_ONE = (SIDE == 0) ? Math.Truncate(BIGLNG / 2) * B * C
: (SIDE == 1) ? Math.Truncate(BIGLNG / 2) * A * C
: Math.Truncate(BIGLNG / 2) * A * B;
Console.WriteLine(BIG_ONE - SMALL_ONE);
return;
}
#endregion
}
#endregion
}
#endregion
#region Execute
class Execute {
public static void Main(string[] args) {
new Program.Solver().Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Program.IO
namespace Program.IO {
using System.Text;
using System.Globalization;
using System.Linq;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public StreamScanner(Stream stream) { str = stream; }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public long Long() {
if (isEof) {
return long.MinValue;
}
long ret = 0;
byte b = 0;
var ng = false;
do {
b = read();
} while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b) {
return ng ? -ret : ret;
} else
ret = ret * 10 + b - '0';
}
}
public long[] Long(int n) { return enumerate(n, Long); }
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public char[] Char(int n) { return enumerate(n, Char); }
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();
}
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++];
}
}
}
#endregion
|
using System;
using System.IO;
#region Program
namespace Program {
#region Solver
public class Solver {
static IO.StreamScanner sc =
new IO.StreamScanner(Console.OpenStandardInput());
decimal A;
decimal B;
decimal C;
int SIDE;
decimal BIGLNG;
decimal BIG_ONE;
decimal SMALL_ONE;
#region Solver
public Solver() {
A = sc.Long();
B = sc.Long();
C = sc.Long();
if (B <= A) {
if (C <= B) {
SIDE = 0;
BIGLNG = A;
} else if (C <= A) {
SIDE = 0;
BIGLNG = A;
} else {
SIDE = 2;
BIGLNG = C;
}
} else {
if (C <= A) {
SIDE = 1;
BIGLNG = B;
} else if (C <= B) {
SIDE = 1;
BIGLNG = B;
} else {
SIDE = 2;
BIGLNG = C;
}
}
}
#endregion
#region Solve
public void Solve() {
decimal rem = BIGLNG == Math.Truncate(BIGLNG / 2) * 2 ? 0 : 1;
if (rem == 0) {
Console.WriteLine(0);
return;
}
BIG_ONE = (SIDE == 0) ? (Math.Truncate(BIGLNG / 2) + 1) * B * C
: (SIDE == 1) ? (Math.Truncate(BIGLNG / 2) + 1) * A * C
: (Math.Truncate(BIGLNG / 2) + 1) * A * B;
SMALL_ONE = (SIDE == 0) ? Math.Truncate(BIGLNG / 2) * B * C
: (SIDE == 1) ? Math.Truncate(BIGLNG / 2) * A * C
: Math.Truncate(BIGLNG / 2) * A * B;
Console.WriteLine(Convert.ToString(BIG_ONE - SMALL_ONE));
return;
}
#endregion
}
#endregion
}
#endregion
#region Execute
class Execute {
public static void Main(string[] args) {
new Program.Solver().Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Program.IO
namespace Program.IO {
using System.Text;
using System.Globalization;
using System.Linq;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public StreamScanner(Stream stream) { str = stream; }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public long Long() {
if (isEof) {
return long.MinValue;
}
long ret = 0;
byte b = 0;
var ng = false;
do {
b = read();
} while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b) {
return ng ? -ret : ret;
} else
ret = ret * 10 + b - '0';
}
}
public long[] Long(int n) { return enumerate(n, Long); }
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public char[] Char(int n) { return enumerate(n, Char); }
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();
}
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++];
}
}
}
#endregion
|
[["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 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
| 1,103
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class _C {
void _() {
var A_B_C = _Ns();
var x = new List<int>();
x.Add(A_B_C[0]);
x.Add(A_B_C[1]);
x.Add(A_B_C[2]);
x.Sort();
x.Reverse();
long a = 0;
if (x[2] % 2 == 0) {
;
} else {
a = (long)x[1] * x[2];
}
Console.WriteLine(a);
}
static void Main(string[] args) { new _C()._(); }
#region
string _S() { return Console.ReadLine(); }
string[] _Ss() { return Console.ReadLine().Split(); }
int[] _N(int n) {
var x = new int[n];
for (var i = 0; i < n; i++) {
x[i] = int.Parse(Console.ReadLine());
}
return x;
}
int[] _Ns() {
var ss = Console.ReadLine().Split();
var x = new int[ss.Length];
for (var i = 0; i < ss.Length; i++)
x[i] = int.Parse(ss[i]);
return x;
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class _C {
void _() {
var A_B_C = _Ns();
var x = new List<int>();
x.Add(A_B_C[0]);
x.Add(A_B_C[1]);
x.Add(A_B_C[2]);
x.Sort();
x.Reverse();
long a = 0;
if ((x[0] * x[1] * x[2]) % 2 == 0) {
;
} else {
a = (long)x[1] * x[2];
}
Console.WriteLine(a);
}
static void Main(string[] args) { new _C()._(); }
#region
string _S() { return Console.ReadLine(); }
string[] _Ss() { return Console.ReadLine().Split(); }
int[] _N(int n) {
var x = new int[n];
for (var i = 0; i < n; i++) {
x[i] = int.Parse(Console.ReadLine());
}
return x;
}
int[] _Ns() {
var ss = Console.ReadLine().Split();
var x = new int[ss.Length];
for (var i = 0; i < ss.Length; i++)
x[i] = int.Parse(ss[i]);
return x;
}
#endregion
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 31, 204, 205, 22], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 17, 48], ["+", 31, 23, 0, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 317
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private struct Pair {
public int x, y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void Solve() {
int N = NextInt();
int x = NextInt();
long[] a = LineLong();
long[] b = a.ToArray();
//全部飼う
long ans = a.Sum();
for (int k = 0; k < N; k++) {
// k回魔法唱える
long cost = k * x;
for (int i = 0; i < N; i++)
b[i] = Math.Min(b[i], a[(i - k + N) % N]);
cost += b.Sum();
ans = Math.Min(ans, cost);
}
Console.WriteLine(ans);
}
public static void Main() {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static char NextChar() {
Confirm();
return char.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private struct Pair {
public int x, y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void Solve() {
int N = NextInt();
long x = NextLong();
long[] a = LineLong();
long[] b = a.ToArray();
//全部飼う
long ans = a.Sum();
for (int k = 0; k < N; k++) {
// k回魔法唱える
long cost = k * x;
for (int i = 0; i < N; i++)
b[i] = Math.Min(b[i], a[(i - k + N) % N]);
cost += b.Sum();
ans = Math.Min(ans, cost);
}
Console.WriteLine(ans);
}
public static void Main() {
// var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) {
// AutoFlush = false }; Console.SetOut(sw);
Solve();
// Console.Out.Flush();
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static char NextChar() {
Confirm();
return char.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 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, 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], ["-", 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, 230, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 45], ["-", 0, 212, 0, 230, 10, 229, 0, 11, 31, 22], ["-", 0, 230, 10, 229, 0, 11, 0, 202, 0, 32], ["-", 0, 230, 10, 229, 0, 11, 12, 211, 0, 147], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 46], ["-", 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, 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
| 568
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC004_B3 {
class Program {
static int N, x;
static void Main(string[] args) {
var t = scan;
N = t[0];
x = t[1];
var a = scan;
var b = new int[N];
for (int i = 0; i < N; i++) {
b[i] = a[i];
}
long ans = a.Sum();
for (int k = 1; k < N; k++) {
long time = (long)k * x;
for (int i = 0; i < N; i++) {
int p = (i - k < 0) ? i - k + N : i - k;
b[i] = Math.Min(b[i], a[p]);
time += b[i];
}
ans = Math.Min(ans, time);
}
Console.WriteLine(ans);
}
static int[] scan {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC004_B3 {
class Program {
static long N, x;
static void Main(string[] args) {
var t = scan;
N = t[0];
x = t[1];
var a = scan;
var b = new long[N];
for (long i = 0; i < N; i++) {
b[i] = a[i];
}
long ans = a.Sum();
for (long k = 1; k < N; k++) {
long time = k * x;
for (long i = 0; i < N; i++) {
long p = (i - k < 0) ? i - k + N : i - k;
b[i] = Math.Min(b[i], a[p]);
time += b[i];
}
ans = Math.Min(ans, time);
}
Console.WriteLine(ans);
}
static long[] scan {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
}
}
|
[["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 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, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 235, 8, 201, 0, 277, 39, 224, 39, 199], ["+", 0, 235, 8, 201, 0, 277, 39, 224, 39, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 258
| 19
|
using System;
using System.Collections.Generic;
class Solve {
public int n;
public long x;
public long[] a;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
getinput();
long[] bonus = new long[n - 1];
long ans = 0;
long temp;
for (int i = 0; i < n - 1; i++) {
bonus[i] = 0;
}
for (int i = 0; i < n; i++) {
long min;
min = a[i];
for (int j = 1; j < i + 1; j++) {
if (min > a[i - j]) {
bonus[j - 1] += min - a[i - j];
}
}
for (int j = i + 1; j < n; j++) {
if (min > a[i - j + n]) {
bonus[j - 1] += min - a[i - j + n];
}
}
}
for (int i = 0; i < n; i++) {
ans += a[i];
}
temp = ans;
for (int i = 0; i < n - 1; i++) {
temp += x;
temp -= bonus[i];
if (ans > temp) {
ans = temp;
}
}
Console.WriteLine(ans);
}
void getinput() {
string[] str = Console.ReadLine().Split(' ');
n = int.Parse(str[0]);
x = int.Parse(str[1]);
str = Console.ReadLine().Split(' ');
a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = int.Parse(str[i]);
}
}
}
|
using System;
using System.Collections.Generic;
class Solve {
public int n;
public long x;
public long[] a;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
getinput();
long[] bonus = new long[n - 1];
long ans = 0;
long temp;
for (int i = 0; i < n - 1; i++) {
bonus[i] = 0;
}
for (int i = 0; i < n; i++) {
long min;
min = a[i];
for (int j = 1; j < i + 1; j++) {
if (min > a[i - j]) {
bonus[j - 1] += min - a[i - j];
min = a[i - j];
}
}
for (int j = i + 1; j < n; j++) {
if (min > a[i - j + n]) {
bonus[j - 1] += min - a[i - j + n];
min = a[i - j + n];
}
}
}
for (int i = 0; i < n; i++) {
ans += a[i];
}
temp = ans;
for (int i = 0; i < n - 1; i++) {
temp += x;
temp -= bonus[i];
if (ans > temp) {
ans = temp;
}
}
Console.WriteLine(ans);
}
void getinput() {
string[] str = Console.ReadLine().Split(' ');
n = int.Parse(str[0]);
x = int.Parse(str[1]);
str = Console.ReadLine().Split(' ');
a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = int.Parse(str[i]);
}
}
}
|
[["+", 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, 204, 205, 22], ["+", 0, 1, 0, 11, 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, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 411
| 20
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class MainClass {
public static void Main(string[] args) {
var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
int N = a[0];
int X = a[1];
var b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
int time = 0;
var dp = new int[N, N];
int min = 400000000;
dp[0, 0] = 0;
for (int k = 0; k < N; k++) {
time = k * X;
for (int i = 0; i < N; i++) {
dp[i, k] = k == 0 ? b[i] : Math.Min(dp[i, k - 1], b[(i - k + N) % N]);
time += dp[i, k];
}
if (time <= min) {
min = time;
}
}
Console.WriteLine(min);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class MainClass {
public static void Main(string[] args) {
var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
int N = a[0];
int X = a[1];
var b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
long time = 0;
var dp = new int[N, N];
long min = long.MaxValue;
dp[0, 0] = 0;
for (int k = 0; k < N; k++) {
time = k * (long)X;
for (int i = 0; i < N; i++) {
dp[i, k] = k == 0 ? b[i] : Math.Min(dp[i, k - 1], b[(i - k + N) % N]);
time += dp[i, k];
}
if (time <= min) {
min = time;
}
}
Console.WriteLine(min);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25]]
| 8
| 248
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using CS = System.Runtime.CompilerServices;
// using System.Diagnostics;
using static System.Math;
using ll = System.Int64;
using static Contest_F.Lib_IO;
using static Contest_F.Lib_Minifunc;
namespace Contest_F {
public static class Entry {
public static void Main() {
checked {
long n, k;
Lib_IO.rm(out n, out k);
ll[] a;
ra(out a);
P<ll, ll, ll>[] edge1 = new P<ll, ll, ll>[n - 1];
for (int i = 1; i < n; i++) {
edge1[i - 1] = new P<ll, ll, ll>(a[i] - 1, i, 1);
}
ll[] prev;
var dist = Dijkstra(edge1, n, 0, out prev);
P<ll, ll>[] di = new P<ll, ll>[n];
for (int i = 0; i < n; i++) {
di[i] = new P<ll, ll>(dist[i], i);
}
di.sort(-1);
long ans = 0;
if (a[0] != 1) {
if (di[0].A == 1) {
if (k % 2 == 0)
ans = 1;
} else {
ans = 1;
}
}
UnionFind uf = new UnionFind(n);
foreach (var e in di) {
if (e.A <= k)
continue;
ll c = k;
for (long u = e.B; u >= 0; u = prev[u]) {
if (uf.IsSameGroup(0, u))
break;
uf.Unite(u, 0);
c--;
if (c == 0) {
ans++;
break;
}
}
}
Lib_IO.wm(ans);
}
}
public static long[] RestoreRoute(long[] prev, long end) {
var path = new List<long>();
for (long u = end; u >= 0; u = prev[u])
path.Add(u);
path.Reverse();
return path.ToArray();
}
public static long[] Dijkstra(IEnumerable<P<long, long, long>> inEdges,
long V, long start, out long[] prev) {
long[] dist = Enumerable.Repeat(long.MaxValue, (int)V).ToArray();
prev = Enumerable.Repeat(-1L, (int)V).ToArray();
var G = new Dictionary<long, long>[V];
for (int i = 0; i < V; i++)
G[i] = new Dictionary<long, long>();
foreach (var e in inEdges) {
if (e.A == e.B)
continue;
if (!G[e.A].ContainsKey(e.B) || e.C < G[e.A][e.B])
G[e.A][e.B] = e.C;
if (!G[e.B].ContainsKey(e.A) || e.C < G[e.B][e.A])
G[e.B][e.A] = e.C;
}
var que = new PriorityQueue<KeyValuePair<long, long>>(
V, (x, y) => (x.Key.CompareTo(y.Key)));
dist[start] = 0;
que.Enqueue(new KeyValuePair<long, long>(dist[start], start));
while (0 < que.Count) {
var q = que.Dequeue();
if (dist[q.Value] < q.Key)
continue;
foreach (var e in G[q.Value]) {
var next_cost = q.Key + e.Value;
if (dist[e.Key] <= next_cost)
continue;
dist[e.Key] = next_cost;
que.Enqueue(new KeyValuePair<long, long>(dist[e.Key], e.Key));
prev[e.Key] = q.Value;
}
}
return dist;
}
public static long[] Dijkstra(IEnumerable<P<long, long, long>> inEdges,
long V, long start) {
long[] d;
return Dijkstra(inEdges, V, start, out d);
}
public class PriorityQueue<T> {
private readonly List<T> heap;
private readonly Comparison<T> compare;
private int size;
public PriorityQueue() : this(Comparer<T>.Default) {}
public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) {}
public PriorityQueue(Comparison<T> comparison) : this(16, comparison) {}
public PriorityQueue(long capacity, Comparison<T> comparison) {
this.heap = new List<T>((int)capacity);
this.compare = comparison;
}
public void Enqueue(T item) {
this.heap.Add(item);
var i = size++;
while (i > 0) {
var p = (i - 1) >> 1;
if (compare(this.heap[p], item) <= 0)
break;
this.heap[i] = heap[p];
i = p;
}
this.heap[i] = item;
}
public T Dequeue() {
var ret = this.heap[0];
var x = this.heap[--size];
var i = 0;
while ((i << 1) + 1 < size) {
var a = (i << 1) + 1;
var b = (i << 1) + 2;
if (b < size && compare(heap[b], heap[a]) < 0)
a = b;
if (compare(heap[a], x) >= 0)
break;
heap[i] = heap[a];
i = a;
}
heap[i] = x;
heap.RemoveAt(size);
return ret;
}
public T Peek() { return heap[0]; }
public long Count {
get { return size; }
}
public bool Any() { return size > 0; }
}
public class UnionFind {
private long[] data;
public UnionFind(long size) {
data = new long[size];
for (int i = 0; i < size; i++)
data[i] = -1;
}
public bool Unite(long x, long y) {
x = Find(x);
y = Find(y);
if (x != y) {
if (data[y] < data[x]) {
var t = y;
y = x;
x = t;
}
data[x] += data[y];
data[y] = x;
}
return x != y;
}
public bool IsSameGroup(long x, long y) { return Find(x) == Find(y); }
public long Find(long x) {
return data[x] < 0 ? x : data[x] = Find(data[x]);
}
public long Size(long x) { return -data[Find(x)]; }
public Dictionary<long, long> AllSizes() {
var ret = new Dictionary<long, long>();
for (int i = 0; i < data.Length; i++)
if (data[i] < 0)
ret[i] = -data[i];
return ret;
}
}
}
#region BaseModule
public static class Lib_Minifunc {
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public const long INF1 = 1000000000000000; // 10^15
[CS.MethodImpl(256)]
public static void swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
[CS.MethodImpl(256)]
public static void swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
swap1(ref a, ref b);
} // b の方が小さければ交換
[CS.MethodImpl(256)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable {
bool r;
if (r = (a.CompareTo(b) == 1))
a = b;
return r;
} // b の方が小さければ a を更新
[CS.MethodImpl(256)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable {
bool r;
if (r = (a.CompareTo(b) == -1))
a = b;
return r;
} // b の方が大きければ a を更新
[CS.MethodImpl(256)]
public static bool inside(long i, long n) => (0 <= i && i < n);
[CS.MethodImpl(256)]
public static bool inside(long x, long y, long w,
long h) => (inside(x, w) && inside(y, h));
[CS.MethodImpl(256)]
public static T min<T>(params T[] a)
where T : IComparable {
T m = a[0];
for (int i = 1; i < a.Length; i++)
chmin(ref m, a[i]);
return m;
}
[CS.MethodImpl(256)]
public static T max<T>(params T[] a)
where T : IComparable {
T m = a[0];
for (int i = 1; i < a.Length; i++)
chmax(ref m, a[i]);
return m;
}
[CS.MethodImpl(256)]
public static long mod(long a, long m = MOD1) {
var v = a % m;
return (v < 0 ? (m < 0 ? v - m : v + m) : v);
}
[CS.MethodImpl(256)]
public static long
ceil(long a, long b) => (a % b == 0 || (a < 0 && 0 < b) || (0 < a && b < 0)
? a / b
: a / b + 1); // 整数商の切り上げ
[CS.MethodImpl(256)]
public static long round(double a) => Convert.ToInt64(a); // 四捨五入
public static string YES(bool a) => a ? "YES" : "NO";
public static string yes(bool a) => a ? "Yes" : "No";
[CS.MethodImpl(256)]
public static P<T, U> initp<T, U>(T a, U b) => new P<T, U>(a, b);
[CS.MethodImpl(256)]
public static P<T, U, V> initp<T, U, V>(T a, U b, V c) => new P<T, U, V>(a, b,
c);
[CS.MethodImpl(256)]
public static P<T, U, V, W>
initp<T, U, V, W>(T a, U b, V c, W d) => new P<T, U, V, W>(a, b, c, d);
public static T[] initc<T>(long l1)
where T : new() {
var m = new T[l1];
for (int i = 0; i < m.Length; i++)
m[i] = new T();
return m;
} // new制約は遅い
public static int[] range(long s, long c) =>
Enumerable.Range((int)s, (int)c).ToArray();
[CS.MethodImpl(256)]
public static T[] inita<T>(long l1, T v = default(T)) =>
Enumerable.Repeat(v, (int)l1).ToArray();
public static T[][] inita<T>(long l1, long l2, T v = default(T)) {
var m = new T[l1][];
for (int i = 0; i < m.Length; i++)
m[i] = inita(l2, v);
return m;
}
public static void shift(this IList<int> l, int o) {
for (int i = 0; i < l.Count; i++)
l[i] += o;
}
public static void shift(this IList<long> l, long o) {
for (int i = 0; i < l.Count; i++)
l[i] += o;
}
[CS.MethodImpl(256)]
public static bool initd<T, U>(this IDictionary<T, U> d, T k,
U v = default(U)) {
if (d.ContainsKey(k)) {
return false;
} else {
d[k] = v;
return true;
}
}
public static void sort<T>(this T[] a, int o = 1, Comparison<T> f = null)
where T : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.CompareTo(y));
break;
case -1:
Array.Sort(a, (x, y) => y.CompareTo(x));
break;
default:
break;
}
}
public static void sort<T, U>(this P<T, U>[] a, int o,
Comparison<P<T, U>> f = null)
where T : IComparable
where U : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.A.CompareTo(y.A));
break;
case -1:
Array.Sort(a, (x, y) => y.A.CompareTo(x.A));
break;
case 2:
Array.Sort(a, (x, y) => x.B.CompareTo(y.B));
break;
case -2:
Array.Sort(a, (x, y) => y.B.CompareTo(x.B));
break;
default:
break;
}
}
public static void sort<T, U, V>(this P<T, U, V>[] a, int o,
Comparison<P<T, U, V>> f = null)
where T : IComparable
where U : IComparable
where V : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.A.CompareTo(y.A));
break;
case -1:
Array.Sort(a, (x, y) => y.A.CompareTo(x.A));
break;
case 2:
Array.Sort(a, (x, y) => x.B.CompareTo(y.B));
break;
case -2:
Array.Sort(a, (x, y) => y.B.CompareTo(x.B));
break;
case 3:
Array.Sort(a, (x, y) => x.C.CompareTo(y.C));
break;
case -3:
Array.Sort(a, (x, y) => y.C.CompareTo(x.C));
break;
default:
break;
}
}
public static void sort<T, U, V, W>(this P<T, U, V, W>[] a, int o,
Comparison<P<T, U, V, W>> f = null)
where T : IComparable
where U : IComparable
where V : IComparable
where W : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.A.CompareTo(y.A));
break;
case -1:
Array.Sort(a, (x, y) => y.A.CompareTo(x.A));
break;
case 2:
Array.Sort(a, (x, y) => x.B.CompareTo(y.B));
break;
case -2:
Array.Sort(a, (x, y) => y.B.CompareTo(x.B));
break;
case 3:
Array.Sort(a, (x, y) => x.C.CompareTo(y.C));
break;
case -3:
Array.Sort(a, (x, y) => y.C.CompareTo(x.C));
break;
case 4:
Array.Sort(a, (x, y) => x.D.CompareTo(y.D));
break;
case -4:
Array.Sort(a, (x, y) => y.D.CompareTo(x.D));
break;
default:
break;
}
}
}
public struct P<T, U> {
public T A;
public U B;
public P(T a, U b) {
A = a;
B = b;
}
public static implicit
operator KeyValuePair<T, U>(P<T, U> a) => new KeyValuePair<T, U>(a.A, a.B);
public static implicit
operator P<T, U>(KeyValuePair<T, U> a) => new P<T, U>(a.Key, a.Value);
}
public struct P<T, U, V> {
public T A;
public U B;
public V C;
public P(T a, U b, V c) {
A = a;
B = b;
C = c;
}
}
public struct P<T, U, V, W> {
public T A;
public U B;
public V C;
public W D;
public P(T a, U b, V c, W d) {
A = a;
B = b;
C = c;
D = d;
}
}
public static class Lib_IO {
class Prt : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Prt(System.IO.Stream s) : base(s, new UTF8Encoding(false, true)) {}
public Prt(System.IO.Stream s, Encoding e) : base(s, e) {}
}
static Prt sw = new Prt(Console.OpenStandardOutput());
static char[] sp = new char[] { ' ' };
[CS.MethodImpl(256)]
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
[CS.MethodImpl(256)]
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
[CS.MethodImpl(256)]
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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] rm<T>(out T a) {
var z = Console.ReadLine().Split(sp, StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(z[0]);
return z;
}
public static string[] rm<T, U>(out T a, out U b) {
var z = rm<T>(out a);
b = cv<U>(z[1]);
return z;
}
public static string[] rm<T, U, V>(out T a, out U b, out V c) {
var z = rm<T, U>(out a, out b);
c = cv<V>(z[2]);
return z;
}
public static string[] rm<T, U, V, W>(out T a, out U b, out V c, out W d) {
var z = rm<T, U, V>(out a, out b, out c);
d = cv<W>(z[3]);
return z;
}
public static string[] rm<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var z = rm<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(z[4]);
return z;
}
public static string[] rm<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 z = rm<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(z[5]);
return z;
}
public static string[] ra<T>(out T[] a) {
var z = Console.ReadLine().Split(sp, StringSplitOptions.RemoveEmptyEntries);
a = new T[z.Length];
for (int i = 0; i < a.Length; i++)
a[i] = cv<T>(z[i]);
return z;
}
public static string[][] rl<T>(long n, out T[] a) {
a = new T[n];
var y = new string[n][];
for (int i = 0; i < n; i++)
y[i] = rm(out a[i]);
return y;
}
public static string[][] rl<T, U>(long n, out P<T, U>[] a) {
a = new P<T, U>[n];
var y = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
y[i] = rm(out o, out p);
a[i] = new P<T, U>(o, p);
}
return y;
}
public static string[][] rl<T, U, V>(long n, out P<T, U, V>[] a) {
a = new P<T, U, V>[n];
var y = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
y[i] = rm(out o, out p, out q);
a[i] = new P<T, U, V>(o, p, q);
}
return y;
}
public static string[][] rl<T, U, V, W>(long n, out P<T, U, V, W>[] a) {
a = new P<T, U, V, W>[n];
var y = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
y[i] = rm(out o, out p, out q, out r);
a[i] = new P<T, U, V, W>(o, p, q, r);
}
return y;
}
public static string[][] rx<T>(long n, out T[][] a) {
a = new T[n][];
var y = new string[n][];
for (int i = 0; i < n; i++)
y[i] = ra(out a[i]);
return y;
}
static void wwp(Action act) {
sw.AutoFlush = false;
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
[CS.MethodImpl(256)]
static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
public static void wm(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length - 1; i++)
Console.Write(wfm(a[i].GetType()) + " ", a[i]);
Console.WriteLine(wfm(a[a.Length - 1].GetType()), a[a.Length - 1]);
});
}
public static void wa<T>(IList<T> a) { wxa(new IList<T>[] { a }, " "); }
public static void wl<T>(IList<T> a) {
wwp(() => {
var f = wfm(typeof(T));
if (a.Count == 0) {
Console.WriteLine();
} else {
foreach (T x in a)
Console.WriteLine(f, x);
}
});
}
static void wxa<T>(IList<IList<T>> a, string s) {
wwp(() => {
var f = wfm(typeof(T));
var g = f + s;
foreach (var b in a) {
if (b.Count == 0) {
Console.WriteLine();
} else {
for (int i = 0; i < b.Count - 1; i++)
Console.Write(g, b[i]);
Console.WriteLine(f, b[b.Count - 1]);
}
}
});
}
public static void wx<T>(IList<IList<T>> a) { wxa(a, " "); }
public static void wg<T>(IList<IList<T>> a) { wxa(a, ""); }
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using CS = System.Runtime.CompilerServices;
// using System.Diagnostics;
using static System.Math;
using ll = System.Int64;
using static Contest_F.Lib_IO;
using static Contest_F.Lib_Minifunc;
namespace Contest_F {
public static class Entry {
public static void Main() {
checked {
long n, k;
Lib_IO.rm(out n, out k);
ll[] a;
ra(out a);
P<ll, ll, ll>[] edge1 = new P<ll, ll, ll>[n - 1];
for (int i = 1; i < n; i++) {
edge1[i - 1] = new P<ll, ll, ll>(a[i] - 1, i, 1);
}
ll[] prev;
var dist = Dijkstra(edge1, n, 0, out prev);
P<ll, ll>[] di = new P<ll, ll>[n];
for (int i = 0; i < n; i++) {
di[i] = new P<ll, ll>(dist[i], i);
}
di.sort(-1);
long ans = 0;
if (a[0] != 1) {
// if(di[0].A==1){
// if(k%2==0) ans = 1;
//}else{
ans = 1;
//}
}
UnionFind uf = new UnionFind(n);
foreach (var e in di) {
if (e.A <= k)
continue;
ll c = k;
for (long u = e.B; u >= 0; u = prev[u]) {
if (uf.IsSameGroup(0, u))
break;
uf.Unite(u, 0);
c--;
if (c == 0) {
ans++;
break;
}
}
}
Lib_IO.wm(ans);
}
}
public static long[] RestoreRoute(long[] prev, long end) {
var path = new List<long>();
for (long u = end; u >= 0; u = prev[u])
path.Add(u);
path.Reverse();
return path.ToArray();
}
public static long[] Dijkstra(IEnumerable<P<long, long, long>> inEdges,
long V, long start, out long[] prev) {
long[] dist = Enumerable.Repeat(long.MaxValue, (int)V).ToArray();
prev = Enumerable.Repeat(-1L, (int)V).ToArray();
var G = new Dictionary<long, long>[V];
for (int i = 0; i < V; i++)
G[i] = new Dictionary<long, long>();
foreach (var e in inEdges) {
if (e.A == e.B)
continue;
if (!G[e.A].ContainsKey(e.B) || e.C < G[e.A][e.B])
G[e.A][e.B] = e.C;
if (!G[e.B].ContainsKey(e.A) || e.C < G[e.B][e.A])
G[e.B][e.A] = e.C;
}
var que = new PriorityQueue<KeyValuePair<long, long>>(
V, (x, y) => (x.Key.CompareTo(y.Key)));
dist[start] = 0;
que.Enqueue(new KeyValuePair<long, long>(dist[start], start));
while (0 < que.Count) {
var q = que.Dequeue();
if (dist[q.Value] < q.Key)
continue;
foreach (var e in G[q.Value]) {
var next_cost = q.Key + e.Value;
if (dist[e.Key] <= next_cost)
continue;
dist[e.Key] = next_cost;
que.Enqueue(new KeyValuePair<long, long>(dist[e.Key], e.Key));
prev[e.Key] = q.Value;
}
}
return dist;
}
public static long[] Dijkstra(IEnumerable<P<long, long, long>> inEdges,
long V, long start) {
long[] d;
return Dijkstra(inEdges, V, start, out d);
}
public class PriorityQueue<T> {
private readonly List<T> heap;
private readonly Comparison<T> compare;
private int size;
public PriorityQueue() : this(Comparer<T>.Default) {}
public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) {}
public PriorityQueue(Comparison<T> comparison) : this(16, comparison) {}
public PriorityQueue(long capacity, Comparison<T> comparison) {
this.heap = new List<T>((int)capacity);
this.compare = comparison;
}
public void Enqueue(T item) {
this.heap.Add(item);
var i = size++;
while (i > 0) {
var p = (i - 1) >> 1;
if (compare(this.heap[p], item) <= 0)
break;
this.heap[i] = heap[p];
i = p;
}
this.heap[i] = item;
}
public T Dequeue() {
var ret = this.heap[0];
var x = this.heap[--size];
var i = 0;
while ((i << 1) + 1 < size) {
var a = (i << 1) + 1;
var b = (i << 1) + 2;
if (b < size && compare(heap[b], heap[a]) < 0)
a = b;
if (compare(heap[a], x) >= 0)
break;
heap[i] = heap[a];
i = a;
}
heap[i] = x;
heap.RemoveAt(size);
return ret;
}
public T Peek() { return heap[0]; }
public long Count {
get { return size; }
}
public bool Any() { return size > 0; }
}
public class UnionFind {
private long[] data;
public UnionFind(long size) {
data = new long[size];
for (int i = 0; i < size; i++)
data[i] = -1;
}
public bool Unite(long x, long y) {
x = Find(x);
y = Find(y);
if (x != y) {
if (data[y] < data[x]) {
var t = y;
y = x;
x = t;
}
data[x] += data[y];
data[y] = x;
}
return x != y;
}
public bool IsSameGroup(long x, long y) { return Find(x) == Find(y); }
public long Find(long x) {
return data[x] < 0 ? x : data[x] = Find(data[x]);
}
public long Size(long x) { return -data[Find(x)]; }
public Dictionary<long, long> AllSizes() {
var ret = new Dictionary<long, long>();
for (int i = 0; i < data.Length; i++)
if (data[i] < 0)
ret[i] = -data[i];
return ret;
}
}
}
#region BaseModule
public static class Lib_Minifunc {
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public const long INF1 = 1000000000000000; // 10^15
[CS.MethodImpl(256)]
public static void swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
[CS.MethodImpl(256)]
public static void swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
swap1(ref a, ref b);
} // b の方が小さければ交換
[CS.MethodImpl(256)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable {
bool r;
if (r = (a.CompareTo(b) == 1))
a = b;
return r;
} // b の方が小さければ a を更新
[CS.MethodImpl(256)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable {
bool r;
if (r = (a.CompareTo(b) == -1))
a = b;
return r;
} // b の方が大きければ a を更新
[CS.MethodImpl(256)]
public static bool inside(long i, long n) => (0 <= i && i < n);
[CS.MethodImpl(256)]
public static bool inside(long x, long y, long w,
long h) => (inside(x, w) && inside(y, h));
[CS.MethodImpl(256)]
public static T min<T>(params T[] a)
where T : IComparable {
T m = a[0];
for (int i = 1; i < a.Length; i++)
chmin(ref m, a[i]);
return m;
}
[CS.MethodImpl(256)]
public static T max<T>(params T[] a)
where T : IComparable {
T m = a[0];
for (int i = 1; i < a.Length; i++)
chmax(ref m, a[i]);
return m;
}
[CS.MethodImpl(256)]
public static long mod(long a, long m = MOD1) {
var v = a % m;
return (v < 0 ? (m < 0 ? v - m : v + m) : v);
}
[CS.MethodImpl(256)]
public static long
ceil(long a, long b) => (a % b == 0 || (a < 0 && 0 < b) || (0 < a && b < 0)
? a / b
: a / b + 1); // 整数商の切り上げ
[CS.MethodImpl(256)]
public static long round(double a) => Convert.ToInt64(a); // 四捨五入
public static string YES(bool a) => a ? "YES" : "NO";
public static string yes(bool a) => a ? "Yes" : "No";
[CS.MethodImpl(256)]
public static P<T, U> initp<T, U>(T a, U b) => new P<T, U>(a, b);
[CS.MethodImpl(256)]
public static P<T, U, V> initp<T, U, V>(T a, U b, V c) => new P<T, U, V>(a, b,
c);
[CS.MethodImpl(256)]
public static P<T, U, V, W>
initp<T, U, V, W>(T a, U b, V c, W d) => new P<T, U, V, W>(a, b, c, d);
public static T[] initc<T>(long l1)
where T : new() {
var m = new T[l1];
for (int i = 0; i < m.Length; i++)
m[i] = new T();
return m;
} // new制約は遅い
public static int[] range(long s, long c) =>
Enumerable.Range((int)s, (int)c).ToArray();
[CS.MethodImpl(256)]
public static T[] inita<T>(long l1, T v = default(T)) =>
Enumerable.Repeat(v, (int)l1).ToArray();
public static T[][] inita<T>(long l1, long l2, T v = default(T)) {
var m = new T[l1][];
for (int i = 0; i < m.Length; i++)
m[i] = inita(l2, v);
return m;
}
public static void shift(this IList<int> l, int o) {
for (int i = 0; i < l.Count; i++)
l[i] += o;
}
public static void shift(this IList<long> l, long o) {
for (int i = 0; i < l.Count; i++)
l[i] += o;
}
[CS.MethodImpl(256)]
public static bool initd<T, U>(this IDictionary<T, U> d, T k,
U v = default(U)) {
if (d.ContainsKey(k)) {
return false;
} else {
d[k] = v;
return true;
}
}
public static void sort<T>(this T[] a, int o = 1, Comparison<T> f = null)
where T : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.CompareTo(y));
break;
case -1:
Array.Sort(a, (x, y) => y.CompareTo(x));
break;
default:
break;
}
}
public static void sort<T, U>(this P<T, U>[] a, int o,
Comparison<P<T, U>> f = null)
where T : IComparable
where U : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.A.CompareTo(y.A));
break;
case -1:
Array.Sort(a, (x, y) => y.A.CompareTo(x.A));
break;
case 2:
Array.Sort(a, (x, y) => x.B.CompareTo(y.B));
break;
case -2:
Array.Sort(a, (x, y) => y.B.CompareTo(x.B));
break;
default:
break;
}
}
public static void sort<T, U, V>(this P<T, U, V>[] a, int o,
Comparison<P<T, U, V>> f = null)
where T : IComparable
where U : IComparable
where V : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.A.CompareTo(y.A));
break;
case -1:
Array.Sort(a, (x, y) => y.A.CompareTo(x.A));
break;
case 2:
Array.Sort(a, (x, y) => x.B.CompareTo(y.B));
break;
case -2:
Array.Sort(a, (x, y) => y.B.CompareTo(x.B));
break;
case 3:
Array.Sort(a, (x, y) => x.C.CompareTo(y.C));
break;
case -3:
Array.Sort(a, (x, y) => y.C.CompareTo(x.C));
break;
default:
break;
}
}
public static void sort<T, U, V, W>(this P<T, U, V, W>[] a, int o,
Comparison<P<T, U, V, W>> f = null)
where T : IComparable
where U : IComparable
where V : IComparable
where W : IComparable {
switch (o) {
case 0:
Array.Sort(a, f);
break;
case 1:
Array.Sort(a, (x, y) => x.A.CompareTo(y.A));
break;
case -1:
Array.Sort(a, (x, y) => y.A.CompareTo(x.A));
break;
case 2:
Array.Sort(a, (x, y) => x.B.CompareTo(y.B));
break;
case -2:
Array.Sort(a, (x, y) => y.B.CompareTo(x.B));
break;
case 3:
Array.Sort(a, (x, y) => x.C.CompareTo(y.C));
break;
case -3:
Array.Sort(a, (x, y) => y.C.CompareTo(x.C));
break;
case 4:
Array.Sort(a, (x, y) => x.D.CompareTo(y.D));
break;
case -4:
Array.Sort(a, (x, y) => y.D.CompareTo(x.D));
break;
default:
break;
}
}
}
public struct P<T, U> {
public T A;
public U B;
public P(T a, U b) {
A = a;
B = b;
}
public static implicit
operator KeyValuePair<T, U>(P<T, U> a) => new KeyValuePair<T, U>(a.A, a.B);
public static implicit
operator P<T, U>(KeyValuePair<T, U> a) => new P<T, U>(a.Key, a.Value);
}
public struct P<T, U, V> {
public T A;
public U B;
public V C;
public P(T a, U b, V c) {
A = a;
B = b;
C = c;
}
}
public struct P<T, U, V, W> {
public T A;
public U B;
public V C;
public W D;
public P(T a, U b, V c, W d) {
A = a;
B = b;
C = c;
D = d;
}
}
public static class Lib_IO {
class Prt : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Prt(System.IO.Stream s) : base(s, new UTF8Encoding(false, true)) {}
public Prt(System.IO.Stream s, Encoding e) : base(s, e) {}
}
static Prt sw = new Prt(Console.OpenStandardOutput());
static char[] sp = new char[] { ' ' };
[CS.MethodImpl(256)]
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
[CS.MethodImpl(256)]
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
[CS.MethodImpl(256)]
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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] rm<T>(out T a) {
var z = Console.ReadLine().Split(sp, StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(z[0]);
return z;
}
public static string[] rm<T, U>(out T a, out U b) {
var z = rm<T>(out a);
b = cv<U>(z[1]);
return z;
}
public static string[] rm<T, U, V>(out T a, out U b, out V c) {
var z = rm<T, U>(out a, out b);
c = cv<V>(z[2]);
return z;
}
public static string[] rm<T, U, V, W>(out T a, out U b, out V c, out W d) {
var z = rm<T, U, V>(out a, out b, out c);
d = cv<W>(z[3]);
return z;
}
public static string[] rm<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var z = rm<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(z[4]);
return z;
}
public static string[] rm<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 z = rm<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(z[5]);
return z;
}
public static string[] ra<T>(out T[] a) {
var z = Console.ReadLine().Split(sp, StringSplitOptions.RemoveEmptyEntries);
a = new T[z.Length];
for (int i = 0; i < a.Length; i++)
a[i] = cv<T>(z[i]);
return z;
}
public static string[][] rl<T>(long n, out T[] a) {
a = new T[n];
var y = new string[n][];
for (int i = 0; i < n; i++)
y[i] = rm(out a[i]);
return y;
}
public static string[][] rl<T, U>(long n, out P<T, U>[] a) {
a = new P<T, U>[n];
var y = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
y[i] = rm(out o, out p);
a[i] = new P<T, U>(o, p);
}
return y;
}
public static string[][] rl<T, U, V>(long n, out P<T, U, V>[] a) {
a = new P<T, U, V>[n];
var y = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
y[i] = rm(out o, out p, out q);
a[i] = new P<T, U, V>(o, p, q);
}
return y;
}
public static string[][] rl<T, U, V, W>(long n, out P<T, U, V, W>[] a) {
a = new P<T, U, V, W>[n];
var y = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
y[i] = rm(out o, out p, out q, out r);
a[i] = new P<T, U, V, W>(o, p, q, r);
}
return y;
}
public static string[][] rx<T>(long n, out T[][] a) {
a = new T[n][];
var y = new string[n][];
for (int i = 0; i < n; i++)
y[i] = ra(out a[i]);
return y;
}
static void wwp(Action act) {
sw.AutoFlush = false;
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
[CS.MethodImpl(256)]
static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
public static void wm(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length - 1; i++)
Console.Write(wfm(a[i].GetType()) + " ", a[i]);
Console.WriteLine(wfm(a[a.Length - 1].GetType()), a[a.Length - 1]);
});
}
public static void wa<T>(IList<T> a) { wxa(new IList<T>[] { a }, " "); }
public static void wl<T>(IList<T> a) {
wwp(() => {
var f = wfm(typeof(T));
if (a.Count == 0) {
Console.WriteLine();
} else {
foreach (T x in a)
Console.WriteLine(f, x);
}
});
}
static void wxa<T>(IList<IList<T>> a, string s) {
wwp(() => {
var f = wfm(typeof(T));
var g = f + s;
foreach (var b in a) {
if (b.Count == 0) {
Console.WriteLine();
} else {
for (int i = 0; i < b.Count - 1; i++)
Console.Write(g, b[i]);
Console.WriteLine(f, b[b.Count - 1]);
}
}
});
}
public static void wx<T>(IList<IList<T>> a) { wxa(a, " "); }
public static void wg<T>(IList<IList<T>> a) { wxa(a, ""); }
}
#endregion
}
|
[["-", 0, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 0, 196, 0, 57, 64, 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], ["-", 64, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["-", 64, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 64, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 64, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["-", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["-", 64, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 5,624
| 28
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC044A {
class Program {
static void Main(string[] args) {
int a, b, c, d, e, f;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());
d = int.Parse(Console.ReadLine());
e = b * c;
f = (a - b) * d + e;
Console.WriteLine(f);
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC044A {
class Program {
static void Main(string[] args) {
int a, b, c, d, e, f;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());
d = int.Parse(Console.ReadLine());
if (a > b) {
e = b * c;
f = (a - b) * d + e;
}
else {
f = a * c;
}
Console.WriteLine(f);
Console.ReadKey();
}
}
}
|
[["+", 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, 22], ["+", 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, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 142
| 17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC044A___高橋君とホテルイージー {
class Program {
static void Main(string[] args) {
string input1 = Console.ReadLine();
string input2 = Console.ReadLine();
string input3 = Console.ReadLine();
string input4 = Console.ReadLine();
int numberOfStay = int.Parse(input1);
int boundNumberOfStay = int.Parse(input2);
int firstHalfPrice = int.Parse(input3);
int secondtHalfPrice = int.Parse(input4);
int totalPrice = firstHalfPrice * boundNumberOfStay +
secondtHalfPrice * (numberOfStay - boundNumberOfStay);
Console.WriteLine(totalPrice.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC044A___高橋君とホテルイージー {
class Program {
static void Main(string[] args) {
string input1 = Console.ReadLine();
string input2 = Console.ReadLine();
string input3 = Console.ReadLine();
string input4 = Console.ReadLine();
int numberOfStay = int.Parse(input1);
int boundNumberOfStay = int.Parse(input2);
int firstHalfPrice = int.Parse(input3);
int secondtHalfPrice = int.Parse(input4);
int totalPrice = 0;
bool isOverBoundNum = (numberOfStay - boundNumberOfStay > 0);
if (isOverBoundNum) {
totalPrice = firstHalfPrice * boundNumberOfStay +
secondtHalfPrice * (numberOfStay - boundNumberOfStay);
} else {
totalPrice = firstHalfPrice * numberOfStay;
}
Console.WriteLine(totalPrice.ToString());
}
}
}
|
[["+", 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, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 23, 0, 24], ["+", 0, 212, 0, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 212, 0, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 212, 0, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 23, 0, 16, 17, 47], ["+", 0, 200, 0, 212, 0, 23, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 15, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 150
| 30
|
using System;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
Console.WriteLine(X * K + Y * (N - K));
}
}
|
using System;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
Console.WriteLine(N > K ? X * K + Y * (N - K) : X * N);
}
}
|
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 41, 75, 16, 17, 48], ["+", 3, 4, 0, 28, 0, 41, 75, 16, 12, 22]]
| 8
| 91
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var k = int.Parse(Console.ReadLine());
var x = int.Parse(Console.ReadLine());
var y = int.Parse(Console.ReadLine());
Console.WriteLine(x * k + y * (n - k));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var k = int.Parse(Console.ReadLine());
var x = int.Parse(Console.ReadLine());
var y = int.Parse(Console.ReadLine());
if (n <= k) {
Console.WriteLine(x * n);
} else {
Console.WriteLine(x * k + y * (n - k));
}
}
}
}
|
[["+", 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, 19], ["+", 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], ["+", 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, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 107
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
if (N <= K) {
Console.Write(X * N);
} else {
Console.Write(X * N + (N - K) * Y);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
if (N <= K) {
Console.Write(X * N);
} else {
Console.Write(X * K + (N - K) * Y);
}
System.Threading.Thread.Sleep(1000);
}
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 0, 213, 63, 214, 205, 214, 205, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 214, 205, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 214, 205, 214, 141, 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], ["+", 0, 1, 0, 213, 3, 4, 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
| 139
| 13
|
using System;
public class Hell {
public static void Main() {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
int ans = (K * X) + (N - K) * Y;
Console.WriteLine(ans);
}
}
|
using System;
public class Hell {
public static void Main() {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
int ans = 0;
if (N < K)
ans = (N * X);
else
ans = (K * X) + (N - K) * Y;
Console.WriteLine(ans);
}
}
|
[["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 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], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 1, 0, 11, 12, 23, 0, 24], ["+", 64, 1, 0, 11, 12, 23, 0, 16, 31, 22], ["+", 64, 1, 0, 11, 12, 23, 0, 16, 17, 48], ["+", 64, 1, 0, 11, 12, 23, 0, 16, 12, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 1, 0, 11, 12, 16, 31, 23, 0, 24]]
| 8
| 96
| 19
|
using System;
namespace AtCoder20170211 {
class Program {
static void Main(string[] args) {
decimal n = Convert.ToDecimal(Console.ReadLine());
decimal k = Convert.ToDecimal(Console.ReadLine());
decimal x = Convert.ToDecimal(Console.ReadLine());
decimal y = Convert.ToDecimal(Console.ReadLine());
decimal result = k * x;
if (n > k) {
result += (n - k) * y;
} else {
}
Console.WriteLine(result);
}
}
}
|
using System;
namespace AtCoder20170211 {
class Program {
static void Main(string[] args) {
decimal n = Convert.ToDecimal(Console.ReadLine());
decimal k = Convert.ToDecimal(Console.ReadLine());
decimal x = Convert.ToDecimal(Console.ReadLine());
decimal y = Convert.ToDecimal(Console.ReadLine());
decimal result = 0;
if (n > k) {
result = k * x;
result += (n - k) * y;
} else {
result = n * x;
}
Console.WriteLine(result);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 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, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 113
| 16
|
using System;
namespace ABC044_TakAndHotels {
public class MainApp {
public static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
int total = K * X + (N - K) * Y;
Console.WriteLine(total);
}
}
}
|
using System;
namespace ABC044_TakAndHotels {
public class MainApp {
public static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
int total;
if (K < N) {
total = K * X + (N - K) * Y;
} else {
total = N * X;
}
Console.WriteLine(total);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 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, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 102
| 19
|
using System;
using System.Linq;
namespace ABC {
class MainClass {
public static void Main(string[] args) {
// var a = Console.ReadLine ().Split().Select(x=>int.Parse(x)).ToArray();
int sum = 0;
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
if (N - K >= 0)
sum = X * K + Y * (N - K);
else
sum = X * K;
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Linq;
namespace ABC {
class MainClass {
public static void Main(string[] args) {
// var a = Console.ReadLine ().Split().Select(x=>int.Parse(x)).ToArray();
int sum = 0;
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
int X = int.Parse(Console.ReadLine());
int Y = int.Parse(Console.ReadLine());
if (N - K >= 0)
sum = X * K + Y * (N - K);
else
sum = X * Math.Min(N, K);
Console.WriteLine(sum);
}
}
}
|
[["+", 0, 11, 12, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 126
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
Console.WriteLine(input[0]);
Console.WriteLine(input[1]);
int N = input[0];
int A = input[1];
int[] x = new int[] { 0 };
x = x.Concat(Console.ReadLine().Split(' ').Select(int.Parse)).ToArray();
long[,,] dp = new long[N + 1, N + 1, N * A + 1];
for (int i = 0; i < N; ++i)
dp[i, 0, 0] = 1;
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= i; ++j) {
for (int k = 1; k <= N * A; ++k) {
if (k < x[i]) {
dp[i, j, k] = dp[i - 1, j, k];
} else {
dp[i, j, k] = dp[i - 1, j, k] + dp[i - 1, j - 1, k - x[i]];
}
}
}
}
long ans = 0;
for (int j = 1; j <= N; ++j) {
ans += dp[N, j, j * A];
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int N = input[0];
int A = input[1];
int[] x = new int[] { 0 };
x = x.Concat(Console.ReadLine().Split(' ').Select(int.Parse)).ToArray();
long[,,] dp = new long[N + 1, N + 1, N * A + 1];
for (int i = 0; i < N; ++i)
dp[i, 0, 0] = 1;
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= i; ++j) {
for (int k = 1; k <= N * A; ++k) {
if (k < x[i]) {
dp[i, j, k] = dp[i - 1, j, k];
} else {
dp[i, j, k] = dp[i - 1, j, k] + dp[i - 1, j - 1, k - x[i]];
}
}
}
}
long ans = 0;
for (int j = 1; j <= N; ++j) {
ans += dp[N, j, j * A];
}
Console.WriteLine(ans);
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 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, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 352
| 20
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
List<long> L = new List<long>();
if (N == S) {
L.Add(N + 1);
}
for (long b = 2; b * b <= N; b++) {
if (digSum(N, b) == S) {
L.Add(b);
}
}
for (long x = 1; x * x <= N; x++) {
// N = xb + y;
// S = x + y
long y = S - x;
if ((N - y) % x == 0) {
long b = (N - y) / x;
L.Add(b);
}
}
// Console.WriteLine(String.Join(" ",L.ToArray()));
if (L.Count == 0) {
Console.WriteLine(-1);
return;
}
Console.WriteLine(L.Min());
}
static long digSum(long n, long b) {
long ret = 0;
while (n > 0) {
ret += n % b;
n /= b;
}
return ret;
}
long N, S;
public Sol() {
N = rl();
S = rl();
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
List<long> L = new List<long>();
if (N == S) {
L.Add(N + 1);
}
for (long b = 2; b * b <= N; b++) {
if (digSum(N, b) == S) {
L.Add(b);
}
}
for (long x = 1; x * x <= N; x++) {
// N = xb + y;
// S = x + y
long y = S - x;
if ((N - y) % x == 0) {
long b = (N - y) / x;
if (b * x + y == N && x < b && y < b && x >= 0 && y >= 0)
L.Add(b);
}
}
if (L.Count == 0) {
Console.WriteLine(-1);
return;
}
Console.WriteLine(L.Min());
}
static long digSum(long n, long b) {
long ret = 0;
while (n > 0) {
ret += n % b;
n /= b;
}
return ret;
}
long N, S;
public Sol() {
N = rl();
S = rl();
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 60], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 17, 98], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 18], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 98], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 17, 18], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 12, 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, 20], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25]]
| 8
| 503
| 26
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver {
const int LIMIT = 1000000;
public void Solve() {
long n = ReadLong();
long m = ReadLong();
if (n < m) {
Write(-1);
return;
} else if (n == m) {
Write(n + 1);
return;
}
for (int i = 2; i <= LIMIT; i++) {
long s = 0;
long x = n;
while (x > 0) {
s += x % i;
x /= i;
}
if (s == m) {
Write(i);
return;
}
}
long ans = long.MaxValue;
for (int i = 1; i <= m && 1L * i * LIMIT <= n; i++) {
if ((n + i - m) % i == 0) {
long v = (n + i - m) % i;
if (i < v && m - i < v)
ans = Math.Min(ans, (n + i - m) / i);
}
}
Write(ans < long.MaxValue ? ans : -1);
}
#region Main
protected static TextReader reader;
protected static TextWriter writer;
static void Main() {
#if DEBUG
reader = new StreamReader("..\\..\\input.txt");
// reader = new StreamReader(Console.OpenStandardInput());
writer = Console.Out;
// writer = new StreamWriter("..\\..\\output.txt");
#else
reader = new StreamReader(Console.OpenStandardInput());
writer = new StreamWriter(Console.OpenStandardOutput());
// reader = new StreamReader("input.txt");
// writer = new StreamWriter("output.txt");
#endif
try {
new Solver().Solve();
// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
// thread.Start();
// thread.Join();
} catch (Exception ex) {
#if DEBUG
Console.WriteLine(ex);
#else
throw;
#endif
}
reader.Close();
writer.Close();
}
#endregion
#region Read / Write
private static Queue<string> currentLineTokens = new Queue<string>();
private static string[] ReadAndSplitLine() {
return reader.ReadLine().Split(
new[] {
' ',
'\t',
},
StringSplitOptions.RemoveEmptyEntries);
}
public static string ReadToken() {
while (currentLineTokens.Count == 0)
currentLineTokens = new Queue<string>(ReadAndSplitLine());
return currentLineTokens.Dequeue();
}
public static int ReadInt() { return int.Parse(ReadToken()); }
public static long ReadLong() { return long.Parse(ReadToken()); }
public static double ReadDouble() {
return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] ReadIntArray() {
return ReadAndSplitLine().Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return ReadAndSplitLine().Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return ReadAndSplitLine()
.Select(s => double.Parse(s, CultureInfo.InvariantCulture))
.ToArray();
}
public static int[][] ReadIntMatrix(int numberOfRows) {
int[][] matrix = new int [numberOfRows][];
for (int i = 0; i < numberOfRows; i++)
matrix[i] = ReadIntArray();
return matrix;
}
public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) {
int[][] matrix = ReadIntMatrix(numberOfRows);
int[][] ret = new int[matrix[0].Length][];
for (int i = 0; i < ret.Length; i++) {
ret[i] = new int[numberOfRows];
for (int j = 0; j < numberOfRows; j++)
ret[i][j] = matrix[j][i];
}
return ret;
}
public static string[] ReadLines(int quantity) {
string[] lines = new string[quantity];
for (int i = 0; i < quantity; i++)
lines[i] = reader.ReadLine().Trim();
return lines;
}
public static void WriteArray<T>(IEnumerable<T> array) {
writer.WriteLine(string.Join(" ", array));
}
public static void Write(params object[] array) { WriteArray(array); }
public static void WriteLines<T>(IEnumerable<T> array) {
foreach (var a in array)
writer.WriteLine(a);
}
private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> {
public new TValue this[TKey key] {
get { return ContainsKey(key) ? base[key] : default(TValue);
}
set { base[key] = value; }
}
}
private static T[] Init<T>(int size)
where T : new() {
var ret = new T[size];
for (int i = 0; i < size; i++)
ret[i] = new T();
return ret;
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver {
const int LIMIT = 1000000;
public void Solve() {
long n = ReadLong();
long m = ReadLong();
if (n < m) {
Write(-1);
return;
} else if (n == m) {
Write(n + 1);
return;
}
for (int i = 2; i <= LIMIT; i++) {
long s = 0;
long x = n;
while (x > 0) {
s += x % i;
x /= i;
}
if (s == m) {
Write(i);
return;
}
}
long ans = long.MaxValue;
for (int i = 1; i <= m && 1L * i * LIMIT <= n; i++) {
if ((n + i - m) % i == 0) {
long v = (n + i - m) / i;
if (i < v && m - i < v)
ans = Math.Min(ans, v);
}
}
Write(ans < long.MaxValue ? ans : -1);
}
#region Main
protected static TextReader reader;
protected static TextWriter writer;
static void Main() {
#if DEBUG
reader = new StreamReader("..\\..\\input.txt");
// reader = new StreamReader(Console.OpenStandardInput());
writer = Console.Out;
// writer = new StreamWriter("..\\..\\output.txt");
#else
reader = new StreamReader(Console.OpenStandardInput());
writer = new StreamWriter(Console.OpenStandardOutput());
// reader = new StreamReader("input.txt");
// writer = new StreamWriter("output.txt");
#endif
try {
new Solver().Solve();
// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
// thread.Start();
// thread.Join();
} catch (Exception ex) {
#if DEBUG
Console.WriteLine(ex);
#else
throw;
#endif
}
reader.Close();
writer.Close();
}
#endregion
#region Read / Write
private static Queue<string> currentLineTokens = new Queue<string>();
private static string[] ReadAndSplitLine() {
return reader.ReadLine().Split(
new[] {
' ',
'\t',
},
StringSplitOptions.RemoveEmptyEntries);
}
public static string ReadToken() {
while (currentLineTokens.Count == 0)
currentLineTokens = new Queue<string>(ReadAndSplitLine());
return currentLineTokens.Dequeue();
}
public static int ReadInt() { return int.Parse(ReadToken()); }
public static long ReadLong() { return long.Parse(ReadToken()); }
public static double ReadDouble() {
return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] ReadIntArray() {
return ReadAndSplitLine().Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return ReadAndSplitLine().Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return ReadAndSplitLine()
.Select(s => double.Parse(s, CultureInfo.InvariantCulture))
.ToArray();
}
public static int[][] ReadIntMatrix(int numberOfRows) {
int[][] matrix = new int [numberOfRows][];
for (int i = 0; i < numberOfRows; i++)
matrix[i] = ReadIntArray();
return matrix;
}
public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) {
int[][] matrix = ReadIntMatrix(numberOfRows);
int[][] ret = new int[matrix[0].Length][];
for (int i = 0; i < ret.Length; i++) {
ret[i] = new int[numberOfRows];
for (int j = 0; j < numberOfRows; j++)
ret[i][j] = matrix[j][i];
}
return ret;
}
public static string[] ReadLines(int quantity) {
string[] lines = new string[quantity];
for (int i = 0; i < quantity; i++)
lines[i] = reader.ReadLine().Trim();
return lines;
}
public static void WriteArray<T>(IEnumerable<T> array) {
writer.WriteLine(string.Join(" ", array));
}
public static void Write(params object[] array) { WriteArray(array); }
public static void WriteLines<T>(IEnumerable<T> array) {
foreach (var a in array)
writer.WriteLine(a);
}
private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> {
public new TValue this[TKey key] {
get { return ContainsKey(key) ? base[key] : default(TValue);
}
set { base[key] = value; }
}
}
private static T[] Init<T>(int size)
where T : new() {
var ret = new T[size];
for (int i = 0; i < size; i++)
ret[i] = new T();
return ret;
}
#endregion
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,044
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
var N = sc.Int;
var X = sc.ArrInt;
var L = sc.Int;
var nx = Create(18, () => Create(N, () => N));
var idx = 0;
for (int i = 0; i < N; i++) {
while (idx != N && X[idx] - X[i] <= L)
idx++;
nx[0][i] = idx - 1;
}
for (int i = 1; i < 18; i++)
for (var j = 0; j < N; j++)
if (nx[i - 1][j] != N)
nx[i][j] = nx[i - 1][nx[i - 1][j]];
var Q = sc.Int;
while (Q-- > 0) {
int a, b;
sc.Make(out a, out b);
a--;
b--;
var res = 0;
if (a > b)
swap(ref a, ref b);
for (int i = 17; i >= 0; i--)
if (nx[i][a] <= b) {
a = nx[i][a];
res += 1 << i;
}
WriteLine(res);
}
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
var N = sc.Int;
var X = sc.ArrInt;
var L = sc.Int;
var nx = Create(19, () => new int[N]);
var idx = 0;
for (int i = 0; i < N; i++) {
while (idx != N && X[idx] - X[i] <= L)
idx++;
nx[0][i] = idx - 1;
}
for (int i = 1; i < 19; i++)
for (var j = 0; j < N; j++)
nx[i][j] = nx[i - 1][nx[i - 1][j]];
var Q = sc.Int;
while (Q-- > 0) {
int a, b;
sc.Make(out a, out b);
a--;
b--;
var res = 0;
if (a > b)
swap(ref a, ref b);
for (int i = 18; i >= 0; i--)
if (nx[i][a] < b) {
a = nx[i][a];
res += 1 << i;
}
WriteLine(++res);
}
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
[["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 218, 8, 213, 63, 22], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 24], ["-", 0, 218, 8, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 24], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 25], ["-", 8, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 227, 0, 228], ["+", 0, 28, 0, 218, 8, 227, 39, 224, 39, 199], ["+", 0, 218, 8, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25], ["+", 0, 218, 8, 227, 39, 224, 225, 226, 0, 73], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 7, 8, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 7, 8, 57, 0, 24], ["-", 205, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 205, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 7, 8, 7, 8, 57, 15, 16, 17, 79], ["-", 0, 7, 8, 7, 8, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 7, 8, 57, 0, 25], ["-", 64, 1, 0, 11, 31, 204, 205, 204, 205, 22], ["-", 0, 11, 31, 204, 205, 204, 206, 207, 0, 70], ["-", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 11, 31, 204, 205, 204, 206, 207, 0, 73], ["-", 64, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 64, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 57, 15, 16, 17, 19], ["+", 8, 196, 0, 7, 8, 57, 15, 16, 17, 18], ["+", 0, 213, 3, 4, 0, 28, 0, 241, 0, 29]]
| 8
| 1,824
| 35
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;
public class Program {
public void Solve() {
int N = Reader.Int();
var X = Reader.IntArray(N);
int L = Reader.Int(), Q = Reader.Int();
var table = Reader.IntTable(Q);
int logN = 0;
while ((1 << logN) < N - 1)
logN++;
var next = new int [logN + 1][];
for (int i = 0; i <= logN; i++)
next[i] = new int[N];
for (int i = 0; i < N; i++)
next[0][i] = UpperBound(X, X[i] + L) - 1;
for (int p = 0; p < logN; p++)
for (int i = 0; i < N; i++)
next[p + 1][i] = next[p][next[p][i]];
var ans = new int[Q];
for (int qi = 0; qi < Q; qi++) {
int a = table[qi][0] - 1, b = table[qi][1] - 1;
if (a > b)
Swap(ref a, ref b);
int res = 0;
for (int p = logN; p >= 0 && a < b; p--)
if (next[p][a] < b) {
res += 1 << p + 1;
a = next[p + 1][a];
}
if (a < b)
res++;
ans[qi] = res;
}
Console.WriteLine(string.Join("\n", ans));
}
static void Swap<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static int UpperBound(int[] A, int val, int L = 0, int R = -1) {
if (R == -1)
R = A.Length;
while (R - L >= 1) {
int mid = (L + R) / 2;
if (A[mid] > val)
R = mid;
else
L = mid + 1;
}
return R;
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
public static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string[] Split(string s) { return s.Split(separator, op); }
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;
public class Program {
public void Solve() {
int N = Reader.Int();
var X = Reader.IntArray(N);
int L = Reader.Int(), Q = Reader.Int();
var table = Reader.IntTable(Q);
int logN = 0;
while ((1 << logN + 1) <= N - 1)
logN++;
var next = new int [logN + 1][];
for (int i = 0; i <= logN; i++)
next[i] = new int[N];
for (int i = 0; i < N; i++)
next[0][i] = UpperBound(X, X[i] + L) - 1;
for (int p = 0; p < logN; p++)
for (int i = 0; i < N; i++)
next[p + 1][i] = next[p][next[p][i]];
var ans = new int[Q];
for (int qi = 0; qi < Q; qi++) {
int a = table[qi][0] - 1, b = table[qi][1] - 1;
if (a > b)
Swap(ref a, ref b);
for (int p = logN; p >= 0; p--)
if (next[p][a] < b) {
ans[qi] += 1 << p;
a = next[p][a];
}
ans[qi]++;
}
Console.WriteLine(string.Join("\n", ans));
}
static void Swap<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static int UpperBound(int[] A, int val, int L = 0, int R = -1) {
if (R == -1)
R = A.Length;
while (R - L >= 1) {
int mid = (L + R) / 2;
if (A[mid] > val)
R = mid;
else
L = mid + 1;
}
return R;
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
public static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string[] Split(string s) { return s.Split(separator, op); }
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
[["+", 15, 16, 31, 23, 0, 16, 12, 16, 17, 72], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 98], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22], ["-", 8, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 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, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 12, 203], ["-", 205, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 205, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["-", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 1,020
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace arc_058_A {
class Program {
static void Main(string[] args) {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
int i = 0;
for (i = n[0];; i++) {
string a = i.ToString();
string sd = a;
for (int k = 0; k < n[1]; k++) {
string x = k.ToString();
sd = sd.Replace(x, "?");
}
if (a == sd) {
break;
}
}
Console.WriteLine(i - 1);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace arc_058_A {
class Program {
static void Main(string[] args) {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
int i = 0;
for (i = n[0];; i++) {
string a = i.ToString();
string sd = a;
for (int k = 0; k < n[1]; k++) {
string x = s[k].ToString();
sd = sd.Replace(x, "?");
}
if (a == sd) {
break;
}
}
Console.WriteLine(i);
Console.ReadLine();
}
}
}
|
[["+", 0, 212, 0, 213, 63, 214, 205, 204, 205, 22], ["+", 0, 213, 63, 214, 205, 204, 206, 207, 0, 70], ["+", 0, 213, 63, 214, 205, 204, 206, 207, 0, 73], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 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
| 192
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ConsoleApp1 {
public class Program {
public static void Main() {
// string s1 = Console.ReadLine();
string s1 = "1000 8";
string[] array1 = s1.Split(' ');
int nowMoney = int.Parse(array1[0]);
int arrIndex = int.Parse(array1[1]);
// string s2 = Console.ReadLine();
string s2 = "1 3 4 5 6 7 8 9";
string[] array2 = s2.Split(' ');
int result = Program.calc(nowMoney, array2);
Console.WriteLine(result);
}
public static int calc(int money, string[] unfavoriteNum) {
int result = 0;
#region 使ってよい数値を求める
List<string> templist = unfavoriteNum.ToList<string>();
List<int> favoriteNumList = new List<int>();
for (int i = 0; i < 10; i++) {
if (!templist.Contains(i.ToString())) {
favoriteNumList.Add(i);
}
}
favoriteNumList.Sort();
#endregion
// 結果を求める
bool check = false;
result = money;
int keta = money.ToString().Length;
do {
// CHECK
bool ketaCheck = true;
for (int j = 0; j < keta; j++) {
string checkStr = result.ToString().Substring(j, 1);
if (!favoriteNumList.Contains(int.Parse(checkStr))) {
ketaCheck = false;
break;
}
}
if (!ketaCheck) {
result++;
keta = result.ToString().Length;
} else {
if (money <= result) {
check = true;
} else {
result++;
keta = result.ToString().Length;
}
}
} while (!check);
return result;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ConsoleApp1 {
public class Program {
public static void Main() {
string s1 = Console.ReadLine();
// string s1 = "1000 8";
string[] array1 = s1.Split(' ');
int nowMoney = int.Parse(array1[0]);
int arrIndex = int.Parse(array1[1]);
string s2 = Console.ReadLine();
// string s2 = "1 3 4 5 6 7 8 9";
string[] array2 = s2.Split(' ');
int result = Program.calc(nowMoney, array2);
Console.WriteLine(result);
}
public static int calc(int money, string[] unfavoriteNum) {
int result = 0;
#region 使ってよい数値を求める
List<string> templist = unfavoriteNum.ToList<string>();
List<int> favoriteNumList = new List<int>();
for (int i = 0; i < 10; i++) {
if (!templist.Contains(i.ToString())) {
favoriteNumList.Add(i);
}
}
favoriteNumList.Sort();
#endregion
// 結果を求める
bool check = false;
result = money;
int keta = money.ToString().Length;
do {
// CHECK
bool ketaCheck = true;
for (int j = 0; j < keta; j++) {
string checkStr = result.ToString().Substring(j, 1);
if (!favoriteNumList.Contains(int.Parse(checkStr))) {
ketaCheck = false;
break;
}
}
if (!ketaCheck) {
result++;
keta = result.ToString().Length;
} else {
if (money <= result) {
check = true;
} else {
result++;
keta = result.ToString().Length;
}
}
} while (!check);
return result;
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 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
| 372
| 16
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
using System.Text; //テキストの高速出力に必要
class Program {
static long n = 210000;
static long[] factorials = new long[n + 1]; // i!(mod p)を先にメモ
static long[] factorialRs = new long[n + 1]; // i!^-1(mod p), pは素数
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long h = long.Parse(input[0]);
long w = long.Parse(input[1]);
long a = long.Parse(input[2]);
long b = long.Parse(input[3]);
long p = 1000000007;
long answer = 0;
factorials[0] = 1;
factorialRs[n] = DivideModFactorial(n, p);
for (long i = 1; i <= n; i++) {
factorials[i] = (factorials[i - 1] * i) % p; // i!(mod p)
factorialRs[n - i] =
(factorialRs[n + 1 - i] * (n + 1 - i)) % p; //逆元も先にメモ
}
for (int i = 0; i <= h - a; i++) //下に行く回数
{
answer = factorials[b - 1 + i];
answer %= p;
answer *= factorialRs[b - 1];
answer %= p;
answer *= factorialRs[i];
answer %= p;
answer *= factorials[w - b + h - i];
answer %= p;
answer *= factorialRs[w - b];
answer %= p;
answer *= factorialRs[h - i];
answer %= p;
}
Console.WriteLine(answer);
}
static long DivideMod(long x, long a, long p) //戻り値はx^a(mod p)
{
long num = 2;
long answer = 1;
long check = a;
long memo = x % p;
while (check > 0) {
if (check % num == num / 2) {
check -= num / 2;
answer *= memo;
answer %= p;
}
memo *= memo;
memo %= p;
num *= 2;
}
return answer;
}
static long DivideModReverse(long x, long p) //戻り値はx^-1(mod p), pは素数
{
long answer = DivideMod(x, p - 2, p);
return answer;
}
static long DivideModFactorial(long x, long p) //戻り値はx!^-1(mod p), pは素数
{
long answer = 1;
for (long i = x; i >= 2; i--) {
answer *= DivideModReverse(i, p);
answer %= p;
}
return answer;
}
static long Comb(long a, long b, long p) //戻り値は組み合わせC(a,b)のmod p
{
long answer = 1;
answer *= factorials[a];
answer %= p;
answer *= factorialRs[a - b]; //引数a-bは負にならないようにする
answer %= p;
answer *= factorialRs[b];
answer %= p;
return answer;
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
using System.Text; //テキストの高速出力に必要
class Program {
static long n = 210000;
static long[] factorials = new long[n + 1]; // i!(mod p)を先にメモ
static long[] factorialRs = new long[n + 1]; // i!^-1(mod p), pは素数
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long h = long.Parse(input[0]);
long w = long.Parse(input[1]);
long a = long.Parse(input[2]);
long b = long.Parse(input[3]);
long p = 1000000007;
long answerm = 0;
long answer = 0;
factorials[0] = 1;
factorialRs[n] = DivideModFactorial(n, p);
for (long i = 1; i <= n; i++) {
factorials[i] = (factorials[i - 1] * i) % p; // i!(mod p)
factorialRs[n - i] =
(factorialRs[n + 1 - i] * (n + 1 - i)) % p; //逆元も先にメモ
}
for (int i = 0; i < h - a; i++) //下に行く回数
{
answer = factorials[b - 1 + i];
answer %= p;
answer *= factorialRs[b - 1];
answer %= p;
answer *= factorialRs[i];
answer %= p;
answer *= factorials[w - b - 1 + h - i - 1];
answer %= p;
answer *= factorialRs[w - b - 1];
answer %= p;
answer *= factorialRs[h - i - 1];
answer %= p;
// Console.WriteLine(answer);
answerm += answer;
answerm %= p;
}
Console.WriteLine(answerm);
}
static long DivideMod(long x, long a, long p) //戻り値はx^a(mod p)
{
long num = 2;
long answer = 1;
long check = a;
long memo = x % p;
while (check > 0) {
if (check % num == num / 2) {
check -= num / 2;
answer *= memo;
answer %= p;
}
memo *= memo;
memo %= p;
num *= 2;
}
return answer;
}
static long DivideModReverse(long x, long p) //戻り値はx^-1(mod p), pは素数
{
long answer = DivideMod(x, p - 2, p);
return answer;
}
static long DivideModFactorial(long x, long p) //戻り値はx!^-1(mod p), pは素数
{
long answer = 1;
for (long i = x; i >= 2; i--) {
answer *= DivideModReverse(i, p);
answer %= p;
}
return answer;
}
static long Comb(long a, long b, long p) //戻り値は組み合わせC(a,b)のmod p
{
long answer = 1;
answer *= factorials[a];
answer %= p;
answer *= factorialRs[a - b]; //引数a-bは負にならないようにする
answer %= p;
answer *= factorialRs[b];
answer %= p;
return answer;
}
}
|
[["+", 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], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 568
| 25
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest._700problems {
class ARC_058 {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush =
false };
SetOut(sw);
Method(args);
Out.Flush();
}
static void Method(string[] args) {
long[] nxyz = ReadLongs();
long n = nxyz[0];
long[] xyz = new long[3] { nxyz[1], nxyz[2], nxyz[3] };
long x = nxyz[1];
long y = nxyz[2];
long z = nxyz[3];
long mask = 1000000000 + 7;
long[] twoPows = new long[x + y + z + 1];
twoPows[0] = 1;
for (long i = 1; i <= x + y + z; i++) {
twoPows[i] = twoPows[i - 1] * 2;
twoPows[i] %= mask;
}
long pats = twoPows[x + y + z];
long[,] dp = new long[n + 1, pats];
dp[0, 0] = 1;
for (long i = 0; i < n; i++) {
for (long j = 0; j < pats; j++) {
for (long k = 1; k <= 10; k++) {
long next = j * twoPows[k];
next += twoPows[k - 1];
next %= pats;
if ((next & twoPows[z - 1]) > 0 &&
(next & twoPows[y + z - 1]) > 0 &&
(next & twoPows[x + y + z - 1]) > 0) {
continue;
}
dp[i + 1, next] += dp[i, j];
dp[i + 1, next] %= mask;
}
}
}
long res = 0;
for (long i = 0; i < pats; i++) {
res += dp[n, i];
res %= mask;
}
long tens = 1;
for (long i = 0; i < n; i++) {
tens *= 10;
tens %= mask;
}
res = (tens - res + mask) % mask;
WriteLine(res);
}
private static string Read() { return ReadLine(); }
private static char[] ReadChars() {
return Array.ConvertAll(Read().Split(), a => a[0]);
}
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.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest._700problems {
class ARC_058 {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush =
false };
SetOut(sw);
Method(args);
Out.Flush();
}
static void Method(string[] args) {
long[] nxyz = ReadLongs();
long n = nxyz[0];
long[] xyz = new long[3] { nxyz[1], nxyz[2], nxyz[3] };
long x = nxyz[1];
long y = nxyz[2];
long z = nxyz[3];
long mask = 1000000000 + 7;
long[] twoPows = new long[21];
twoPows[0] = 1;
for (long i = 1; i <= 20; i++) {
twoPows[i] = twoPows[i - 1] * 2;
twoPows[i] %= mask;
}
long pats = twoPows[x + y + z];
long[,] dp = new long[n + 1, pats];
dp[0, 0] = 1;
for (long i = 0; i < n; i++) {
for (long j = 0; j < pats; j++) {
for (long k = 1; k <= 10; k++) {
long next = j * twoPows[k];
next += twoPows[k - 1];
next %= pats;
if ((next & twoPows[z - 1]) > 0 &&
(next & twoPows[y + z - 1]) > 0 &&
(next & twoPows[x + y + z - 1]) > 0) {
continue;
}
dp[i + 1, next] += dp[i, j];
dp[i + 1, next] %= mask;
}
}
}
long res = 0;
for (long i = 0; i < pats; i++) {
res += dp[n, i];
res %= mask;
}
long tens = 1;
for (long i = 0; i < n; i++) {
tens *= 10;
tens %= mask;
}
res = (tens - res + mask) % mask;
WriteLine(res);
}
private static string Read() { return ReadLine(); }
private static char[] ReadChars() {
return Array.ConvertAll(Read().Split(), a => a[0]);
}
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);
}
}
}
|
[["-", 225, 226, 0, 16, 31, 16, 31, 16, 31, 22], ["-", 225, 226, 0, 16, 31, 16, 31, 16, 17, 72], ["-", 225, 226, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 39, 224, 225, 226, 0, 16, 31, 16, 17, 72], ["-", 39, 224, 225, 226, 0, 16, 31, 16, 12, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 72], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 688
| 14
|
using System;
using static System.Console;
using static System.Math;
//重複を含まないようにする
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var s = ReadLine().Split(' ');
string[] Input;
string ans = "NO";
int count_5 = 0;
int count_7 = 0;
for (int i = 0; i < 3; i++) {
if (s[i].Length == 5) {
count_5++;
} else if (s[i].Length == 7) {
count_7++;
}
}
if (count_5 == 2 && count_7 == 1) {
ans = "YES";
}
WriteLine(ans);
Out.Flush();
}
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
using System;
using static System.Console;
using static System.Math;
//重複を含まないようにする
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var s = ReadLine().Split(' ');
string[] Input;
string ans = "NO";
int count_5 = 0;
int count_7 = 0;
for (int i = 0; i < 3; i++) {
if (int.Parse(s[i]) == 5) {
count_5++;
} else if (int.Parse(s[i]) == 7) {
count_7++;
}
}
if (count_5 == 2 && count_7 == 1) {
ans = "YES";
}
WriteLine(ans);
Out.Flush();
}
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
[["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 199], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 213, 63, 214, 205, 199], ["+", 75, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 75, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 57, 75, 57, 15, 16, 31, 214, 0, 131], ["-", 0, 57, 75, 57, 15, 16, 31, 214, 141, 22], ["+", 75, 57, 15, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 372
| 14
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
static void Main(string[] args) {
string a = ReadStr();
string b = ReadStr();
string c = ReadStr();
string x = a + b + c;
if (x.Equals("755") || x.Equals("575") || x.Equals("557")) {
Write("YES");
} else {
Write("NO");
}
Exit();
}
public static void Write(string str) { Console.WriteLine(str); }
public static void Write(int i) { Console.WriteLine(i); }
public static void Write(double d) { Console.WriteLine(d); }
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long Read() { return long.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static void Exit() {}
public static List<string> ReadListStr() {
return new List<string>(ReadStr().Split(" "));
}
public static List<long> ReadList() {
return ReadListStr().ConvertAll(x => long.Parse(x));
}
public static List<int> ReadListInt() {
return ReadListStr().ConvertAll(x => int.Parse(x));
}
}
}
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
static void Main(string[] args) {
List<string> ss = ReadListStr();
string a = ss[0];
string b = ss[1];
string c = ss[2];
string x = a + b + c;
if (x.Equals("755") || x.Equals("575") || x.Equals("557")) {
Write("YES");
} else {
Write("NO");
}
Exit();
}
public static void Write(string str) { Console.WriteLine(str); }
public static void Write(int i) { Console.WriteLine(i); }
public static void Write(double d) { Console.WriteLine(d); }
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long Read() { return long.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static void Exit() {}
public static List<string> ReadListStr() {
return new List<string>(ReadStr().Split(" "));
}
public static List<long> ReadList() {
return ReadListStr().ConvertAll(x => long.Parse(x));
}
public static List<int> ReadListInt() {
return ReadListStr().ConvertAll(x => int.Parse(x));
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 331
| 29
|
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;
namespace easy_Atcoder {
class Program {
static void Main(string[] args) {
// float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
// int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
// long K = long.Parse(Console.ReadLine());
int[] ABC = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// string S = Console.ReadLine();
// int s = int.Parse(Console.ReadLine());
// int i = int.Parse(Console.ReadLine());
// int n = int.Parse(Console.ReadLine());
// string A = Console.ReadLine();
// string B = Console.ReadLine();
// var s = (new string[] { Console.ReadLine(), Console.ReadLine(),
// Console.ReadLine() }).Select(int.Parse); int[] abc =
// Array.ConvertAll(Console.ReadLine().Split(),int.Parse); var X =
// Console.ReadLine(); int[,] abcd = new int[NMQ[2],4]; int[] A = new
// int[NMQ[0]]; int[] A_num = new int[NMQ[0]]; for(int i = 0;
// i<A_num.Length;i++){
// A_num[i] = 0;
// }
if (ABC[0] == 5 && ABC[1] == 7 && ABC[2] == 5) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
//最小公倍数
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
//最大公約数
static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;
namespace easy_Atcoder {
class Program {
static void Main(string[] args) {
// float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
// int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
// long K = long.Parse(Console.ReadLine());
int[] ABC = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// string S = Console.ReadLine();
// int s = int.Parse(Console.ReadLine());
// int i = int.Parse(Console.ReadLine());
// int n = int.Parse(Console.ReadLine());
// string A = Console.ReadLine();
// string B = Console.ReadLine();
// var s = (new string[] { Console.ReadLine(), Console.ReadLine(),
// Console.ReadLine() }).Select(int.Parse); int[] abc =
// Array.ConvertAll(Console.ReadLine().Split(),int.Parse); var X =
// Console.ReadLine(); int[,] abcd = new int[NMQ[2],4]; int[] A = new
// int[NMQ[0]]; int[] A_num = new int[NMQ[0]]; for(int i = 0;
// i<A_num.Length;i++){
// A_num[i] = 0;
// }
if (ABC.Count(x => x == 5) == 2 && ABC.Count(x => x == 7) == 1) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
//最小公倍数
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
//最大公約数
static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
}
}
|
[["-", 31, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 31, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 12, 16, 31, 213, 3, 4, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 15, 16, 12, 16, 31, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 179
| 29
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Happy {
class Program {
static void exc(ref int a, ref int b) {
int t = a;
a = b;
b = t;
}
static void Main(string[] args) {
string[] uinp;
uinp = Console.ReadLine().Split(new char[] { ' ' });
int a, b, c;
int.TryParse(uinp[0], out a);
int.TryParse(uinp[1], out b);
int.TryParse(uinp[2], out c);
if (a > b)
exc(ref a, ref b);
if (b > c)
exc(ref b, ref c);
if (a > b)
exc(ref a, ref b);
if ((a == 5) && (b == 7) && (c == 7))
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Happy {
class Program {
static void exc(ref int a, ref int b) {
int t = a;
a = b;
b = t;
}
static void Main(string[] args) {
string[] uinp;
uinp = Console.ReadLine().Split(new char[] { ' ' });
int a, b, c;
int.TryParse(uinp[0], out a);
int.TryParse(uinp[1], out b);
int.TryParse(uinp[2], out c);
if (a > b)
exc(ref a, ref b);
if (b > c)
exc(ref b, ref c);
if (a > b)
exc(ref a, ref b);
if ((a == 5) && (b == 5) && (c == 7))
Console.WriteLine("YES");
else
Console.WriteLine("NO");
Console.ReadLine();
}
}
}
|
[["-", 15, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 75, 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
| 222
| 8
|
using System;
public class Test {
public static void Main() {
string[] str = Console.ReadLine().Split(' ');
int a = Array.IndexOf(str, "7");
Console.WriteLine(a);
if (a == -1) {
Console.WriteLine("NO");
} else if (a == 0 && str[1].Equals("5") && str[2].Equals("5")) {
Console.WriteLine("YES");
} else if (a == 1 && str[0].Equals("5") && str[2].Equals("5")) {
Console.WriteLine("YES");
} else if (a == 2 && str[1].Equals("5") && str[0].Equals("5")) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
using System;
public class Test {
public static void Main() {
string[] str = Console.ReadLine().Split(' ');
int a = Array.IndexOf(str, "7");
if (a == -1) {
Console.WriteLine("NO");
} else if (a == 0 && str[1].Equals("5") && str[2].Equals("5")) {
Console.WriteLine("YES");
} else if (a == 1 && str[0].Equals("5") && str[2].Equals("5")) {
Console.WriteLine("YES");
} else if (a == 2 && str[1].Equals("5") && str[0].Equals("5")) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
[["-", 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
| 211
| 7
|
using System;
using System.Collections.Generic;
namespace StudyCsharp {
static class Program {
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main() {
string[] s = Console.ReadLine().Split(' ');
if (s[0] != "5") {
Console.WriteLine("NO");
return;
}
if (s[1] != "7") {
Console.WriteLine("NO");
return;
}
if (s[2] != "5") {
Console.WriteLine("NO");
return;
}
Console.WriteLine("YES");
}
}
}
|
using System;
namespace StudyCsharp {
static class Program {
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main() {
string[] s = Console.ReadLine().Split(' ');
Array.Sort(s);
if (s[0] != "5") {
Console.WriteLine("NO");
return;
}
if (s[1] != "5") {
Console.WriteLine("NO");
return;
}
if (s[2] != "7") {
Console.WriteLine("NO");
return;
}
Console.WriteLine("YES");
}
}
}
|
[["-", 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, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 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, 196, 0, 57, 15, 16, 12, 5, 0, 222], ["+", 8, 196, 0, 57, 15, 16, 12, 5, 0, 222]]
| 8
| 131
| 18
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace b {
class Program {
static void Main(string[] args) {
var x = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
var n = x[0];
var l = x[1];
var s = new List<char[]>();
for (var i = 0; i < n; i++) {
var c = Console.ReadLine().Trim().ToCharArray();
s.Add(c);
}
var o = s.OrderBy(z => z[0]).ToList();
var agg = o.Select(z => string.Join("", z));
Console.WriteLine(string.Join("", agg));
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace b {
class Program {
static void Main(string[] args) {
var x = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
var n = x[0];
var l = x[1];
var s = new List<string>();
for (var i = 0; i < n; i++) {
var c = Console.ReadLine().Trim();
s.Add(c);
}
var o = s.OrderBy(z => z).ToList();
Console.WriteLine(string.Join("", o));
}
}
}
|
[["-", 0, 230, 39, 236, 237, 238, 0, 224, 39, 199], ["-", 39, 236, 237, 238, 0, 224, 225, 226, 0, 70], ["-", 39, 236, 237, 238, 0, 224, 225, 226, 0, 73], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 218, 8, 204, 206, 207, 0, 70], ["-", 0, 218, 8, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 28, 0, 218, 8, 204, 206, 207, 0, 73], ["-", 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], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 24], ["-", 8, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 21], ["-", 0, 218, 8, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 28, 0, 218, 8, 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], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 186
| 33
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace CP {
class Atria {
static void Main(string[] args) {
int[] nl = ReadLine().Split(' ').Select(int.Parse).ToArray();
int n = nl[0];
int l = nl[1];
var ls = new List<string>();
for (int i = 0; i < n; i++) {
ls.Add(SortString(ReadLine()));
}
ls = ls.OrderBy(x => x).ToList();
WriteLine(string.Join("", ls));
}
static string SortString(string s) {
var tmp = s.ToCharArray();
Array.Sort(tmp);
return string.Concat(tmp);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace CP {
class Atria {
static void Main(string[] args) {
int[] nl = ReadLine().Split(' ').Select(int.Parse).ToArray();
int n = nl[0];
int l = nl[1];
var ls = new List<string>();
for (int i = 0; i < n; i++) {
ls.Add(ReadLine());
}
ls = ls.OrderBy(x => x).ToList();
WriteLine(string.Join("", ls));
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 213, 63, 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, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46], ["-", 0, 235, 8, 201, 0, 195, 0, 251, 0, 115], ["-", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["-", 0, 235, 8, 201, 0, 195, 54, 55, 0, 24], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 141, 22], ["-", 0, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 45], ["-", 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], ["-", 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], ["-", 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, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 37, 0, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 37, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 37, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 37, 0, 213, 3, 4, 0, 24], ["-", 0, 37, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 199
| 36
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
// List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s
// => int.Parse(s))); List<int> values = new List<int>();
string input = Console.ReadLine();
int n = int.Parse(input.Split(' ')[0]);
int m = int.Parse(input.Split(' ')[1]);
// int k = int.Parse(input.Split(' ')[2]);
List<string> ss = new List<string>();
for (int i = 0; i < n; i++) {
ss.Add(Console.ReadLine());
}
ss.Sort();
StringBuilder sb = new StringBuilder();
sb.Append(ss);
Console.WriteLine(sb.ToString());
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
// List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s
// => int.Parse(s))); List<int> values = new List<int>();
string input = Console.ReadLine();
int n = int.Parse(input.Split(' ')[0]);
int m = int.Parse(input.Split(' ')[1]);
// int k = int.Parse(input.Split(' ')[2]);
List<string> ss = new List<string>();
for (int i = 0; i < n; i++) {
ss.Add(Console.ReadLine());
}
ss.Sort();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
sb.Append(ss[i]);
}
Console.WriteLine(sb.ToString());
input = Console.ReadLine();
}
}
|
[["+", 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], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 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, 1, 0, 11, 12, 213, 3, 4, 0, 24]]
| 8
| 160
| 27
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoderBC042 {
class AtCoderBC042 {
static void Main(string[] args) { new AtCoderBC042().solve2(); }
private void solve2() {
string[] input = Console.ReadLine().Split();
int n = int.Parse(input[0]);
int l = int.Parse(input[1]);
string input2 = "";
List<string> s = new List<string>();
string[] s2 = new string[n];
string res = "";
for (int i = 0; i < n; i++) {
input2 = Console.ReadLine();
char[] c = input2.ToCharArray().OrderBy(x => x).ToArray();
s.Add(new string(c));
}
var t = s.OrderBy(x => x).ToList();
foreach (string u in t)
res += u;
Console.WriteLine(res);
} // end M.
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoderBC042 {
class AtCoderBC042 {
static void Main(string[] args) { new AtCoderBC042().solve2(); }
private void solve2() {
string[] input = Console.ReadLine().Split();
int n = int.Parse(input[0]);
int l = int.Parse(input[1]);
string input2 = "";
List<string> s = new List<string>();
string res = "";
for (int i = 0; i < n; i++) {
input2 = Console.ReadLine();
s.Add(input2);
}
var t = s.OrderBy(x => x).ToList();
foreach (string u in t)
res += u;
Console.WriteLine(res);
} // end M.
}
}
|
[["-", 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, 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, 22], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 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, 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, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 230, 0, 228], ["-", 0, 213, 3, 4, 0, 28, 0, 230, 39, 199], ["-", 3, 4, 0, 28, 0, 230, 3, 4, 0, 24], ["-", 0, 28, 0, 230, 3, 4, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 230, 3, 4, 0, 25], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 225
| 39
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
const int MAX = 10000; // 最大値
var input = Console.ReadLine();
int total = int.Parse(input.Split(' ')[0]); // 支払い金額
int numCnt = int.Parse(input.Split(' ')[1]); // 嫌いな数カウント
input = Console.ReadLine();
// 嫌いな数リスト
var hatelist = input.Replace(" ", "").ToCharArray();
for (int i = total; i < MAX; i++) {
if (i.ToString().ToArray().All(x => !hatelist.Contains(x))) {
Console.WriteLine(i.ToString());
break;
}
}
Console.ReadLine();
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
int total = int.Parse(input.Split(' ')[0]); // 支払い金額
int numCnt = int.Parse(input.Split(' ')[1]); // 嫌いな数カウント
input = Console.ReadLine();
// 嫌いな数リスト
var hatelist = input.Replace(" ", "").ToCharArray();
int i = total;
while (true) {
if (i.ToString().ToArray().All(x => !hatelist.Contains(x))) {
Console.WriteLine(i.ToString());
break;
}
i++;
}
Console.ReadLine();
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 251, 0, 154], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 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, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["+", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["+", 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
| 171
| 20
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace AGC003A {
class Program {
static void Solve() {
var s = Input.Next();
// 東西、南北は一方があったらもう一方も必要
bool possible = true;
if (s.Contains('E'))
possible = s.Contains('W');
if (s.Contains('W'))
possible = s.Contains('E');
if (s.Contains('S'))
possible = s.Contains('N');
if (s.Contains('N'))
possible = s.Contains('S');
Console.WriteLine(possible ? "Yes" : "No");
}
#region Competitive Template
public static void Main(string[] args) {
var needsFlushOutput = true;
if (needsFlushOutput) {
// 細かく出力しないようにする
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// 仮想的に標準入力をセットする
// NextLine系を使っていると使えない
// Input.SetText("");
Solve();
Console.Out.Flush();
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace AGC003A {
class Program {
static void Solve() {
var s = Input.Next();
// 東西、南北は一方があったらもう一方も必要
bool impossible = false;
if (s.Contains('E'))
impossible = impossible || !s.Contains('W');
if (s.Contains('W'))
impossible = impossible || !s.Contains('E');
if (s.Contains('S'))
impossible = impossible || !s.Contains('N');
if (s.Contains('N'))
impossible = impossible || !s.Contains('S');
Console.WriteLine(!impossible ? "Yes" : "No");
}
#region Competitive Template
public static void Main(string[] args) {
var needsFlushOutput = true;
if (needsFlushOutput) {
// 細かく出力しないようにする
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// 仮想的に標準入力をセットする
// NextLine系を使っていると使えない
// Input.SetText("");
Solve();
Console.Out.Flush();
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
#endregion
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 17, 106], ["+", 64, 1, 0, 11, 12, 16, 12, 241, 0, 111], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 15, 22], ["+", 3, 4, 0, 28, 0, 41, 15, 241, 0, 111], ["+", 3, 4, 0, 28, 0, 41, 15, 241, 0, 22]]
| 8
| 808
| 27
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
// C#7.0
string S;
void Solve() {
io.i(out S);
var aa = new AssociativeArray<char>();
aa.init(S.ToCharArray());
bool isEnable = aa.KeyNum() == 4 ||
(aa.KeyNum() == 2 &&
(aa.allContainsK('N', 'W') || aa.allContainsK('S', 'E')));
io.Yn(isEnable);
}
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
}
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
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 char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] arr() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(arr(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(arr(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(arr(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(arr(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
v4 = suitType<W>(a[3]);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void inii(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt() - 1;
a2[i] = nextInt() - 1;
}
}
public void inii(out int[,] a, int size) {
a = new int[size, size];
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++) {
a[i, j] = nextInt() - 1;
}
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) {
foreach (T v in a)
Console.WriteLine(v);
}
public void o<T>(List<T> l) {
foreach (T v in l)
sw.WriteLine(v);
}
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) {
foreach (T v in a)
Console.Write(v + " ");
Console.WriteLine("");
}
public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); }
public void Yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); }
public void yn(bool f) { Console.WriteLine(f ? "yes" : "no"); }
public void br() { Console.WriteLine(""); }
public void writeFlush() { Console.Out.Flush(); }
public string pad0<T>(T v, int n) { return v.ToString().PadLeft(n, '0'); }
}
class Mathf {
public int mod = 1000000007; // 10^9+7
public long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) {
return (n != 0) ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public T Max<T>(params T[] v) { return v.Max(); }
public T Min<T>(params T[] v) { return v.Min(); }
public double Dis(int x1, int y1, int x2, int y2) {
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
}
public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; }
public int Clamp(int n, int a, int b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Clamp(long n, long a, long b) {
return (n < a) ? a : (b < n) ? b : n;
}
public double Clamp(double n, double a, double b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Tousa(long a, long d, int n) { return a + (n - 1) * d; }
public long TousaSum(long a, long d, int n) {
return n * (2 * a + (n - 1) * d) / 2;
}
}
class AssociativeArray<T> {
public Dictionary<T, int> dic;
public void init(T[] a) {
dic = new Dictionary<T, int>();
for (int i = 0; i < a.Length; i++) {
if (!dic.ContainsKey(a[i]))
dic[a[i]] = 0;
dic[a[i]]++;
}
}
public int ValueSum() {
int s = 0;
foreach (var i in dic)
s += i.Value;
return s;
}
public int KeyNum() { return dic.Keys.Count; }
public int Max() { return dic.Values.Max(); }
public int Min() { return dic.Values.Min(); }
public T MaxKey() { return dic.First(d => d.Value == Max()).Key; }
public T MinKey() { return dic.First(d => d.Value == Min()).Key; }
public bool isContainsK(T k) { return dic.ContainsKey(k); }
public bool anyContainsK(params T[] k) {
bool f = false;
foreach (T v in k)
f |= isContainsK(v);
return f;
}
public bool allContainsK(params T[] k) {
bool f = true;
foreach (T v in k)
f &= isContainsK(v);
return f;
}
//:sort->array
}
class Time {
public bool isLeapYear(int y) {
return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
}
}
class BucketSort {
public int[] bucket;
public void Init(int[] a) {
bucket = new int[a.Max() + 1];
for (int i = 0; i < a.Length; ++i)
++bucket[a[i]];
for (int i = 0, j = 0; j < bucket.Length; ++j)
for (int k = bucket[j]; k != 0; --k, ++i)
a[i] = j;
}
}
static class StringEX {
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
}
static class CharEX {
public static int toInt(this char c) { return int.Parse(c.ToString()); }
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) {
Array.Sort(a);
return a;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
// C#7.0
string S;
void Solve() {
io.i(out S);
var aa = new AssociativeArray<char>();
aa.init(S.ToCharArray());
bool isEnable = aa.KeyNum() == 4 ||
(aa.KeyNum() == 2 &&
(aa.allContainsK('N', 'S') || aa.allContainsK('W', 'E')));
io.Yn(isEnable);
}
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
}
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
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 char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] arr() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(arr(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(arr(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(arr(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(arr(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
v4 = suitType<W>(a[3]);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void inii(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt() - 1;
a2[i] = nextInt() - 1;
}
}
public void inii(out int[,] a, int size) {
a = new int[size, size];
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++) {
a[i, j] = nextInt() - 1;
}
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) {
foreach (T v in a)
Console.WriteLine(v);
}
public void o<T>(List<T> l) {
foreach (T v in l)
sw.WriteLine(v);
}
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) {
foreach (T v in a)
Console.Write(v + " ");
Console.WriteLine("");
}
public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); }
public void Yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); }
public void yn(bool f) { Console.WriteLine(f ? "yes" : "no"); }
public void br() { Console.WriteLine(""); }
public void writeFlush() { Console.Out.Flush(); }
public string pad0<T>(T v, int n) { return v.ToString().PadLeft(n, '0'); }
}
class Mathf {
public int mod = 1000000007; // 10^9+7
public long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) {
return (n != 0) ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public T Max<T>(params T[] v) { return v.Max(); }
public T Min<T>(params T[] v) { return v.Min(); }
public double Dis(int x1, int y1, int x2, int y2) {
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
}
public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; }
public int Clamp(int n, int a, int b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Clamp(long n, long a, long b) {
return (n < a) ? a : (b < n) ? b : n;
}
public double Clamp(double n, double a, double b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Tousa(long a, long d, int n) { return a + (n - 1) * d; }
public long TousaSum(long a, long d, int n) {
return n * (2 * a + (n - 1) * d) / 2;
}
}
class AssociativeArray<T> {
public Dictionary<T, int> dic;
public void init(T[] a) {
dic = new Dictionary<T, int>();
for (int i = 0; i < a.Length; i++) {
if (!dic.ContainsKey(a[i]))
dic[a[i]] = 0;
dic[a[i]]++;
}
}
public int ValueSum() {
int s = 0;
foreach (var i in dic)
s += i.Value;
return s;
}
public int KeyNum() { return dic.Keys.Count; }
public int Max() { return dic.Values.Max(); }
public int Min() { return dic.Values.Min(); }
public T MaxKey() { return dic.First(d => d.Value == Max()).Key; }
public T MinKey() { return dic.First(d => d.Value == Min()).Key; }
public bool isContainsK(T k) { return dic.ContainsKey(k); }
public bool anyContainsK(params T[] k) {
bool f = false;
foreach (T v in k)
f |= isContainsK(v);
return f;
}
public bool allContainsK(params T[] k) {
bool f = true;
foreach (T v in k)
f &= isContainsK(v);
return f;
}
public void Show() {
foreach (var v in dic) {
Console.WriteLine(v.Key + " : " + v.Value);
}
}
//:sort->array
}
class Time {
public bool isLeapYear(int y) {
return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
}
}
class BucketSort {
public int[] bucket;
public void Init(int[] a) {
bucket = new int[a.Max() + 1];
for (int i = 0; i < a.Length; ++i)
++bucket[a[i]];
for (int i = 0, j = 0; j < bucket.Length; ++j)
for (int k = bucket[j]; k != 0; --k, ++i)
a[i] = j;
}
}
static class StringEX {
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
}
static class CharEX {
public static int toInt(this char c) { return int.Parse(c.ToString()); }
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) {
Array.Sort(a);
return a;
}
}
}
|
[["-", 31, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 31, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["-", 12, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 12, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 259], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 24], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 45], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 24], ["+", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 25], ["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 45], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 12, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 16, 12, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46]]
| 8
| 2,734
| 37
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Xml.Schema;
using System.Threading;
using System.Diagnostics.CodeAnalysis;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int BuildBitCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
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]);
}
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]);
}
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]);
}
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]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
int N = GetInt();
var A = new int [N].Select(s => GetInt()).ToArray();
var mod = 0;
long sum = 0;
for (int i = 0; i < N; i++) {
sum += (mod + A[i]) / 2;
mod = (mod + A[i]) % 2;
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Xml.Schema;
using System.Threading;
using System.Diagnostics.CodeAnalysis;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int BuildBitCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
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]);
}
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]);
}
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]);
}
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]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
int N = GetInt();
var A = new int [N].Select(s => GetInt()).ToArray();
var mod = 0;
long sum = 0;
for (int i = 0; i < N; i++) {
sum += (mod + A[i]) / 2;
if (mod == 1 && A[i] == 0)
mod = 0;
else
mod = (mod + A[i]) % 2;
}
Console.WriteLine(sum);
}
}
}
|
[["+", 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, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
| 8
| 1,934
| 18
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 100001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static List<int>[] g;
static void Solve() {
var n = Input.NextInt();
var a = new int[n + 2];
for (int i = 0; i < n; ++i) {
a[i + 1] = Input.NextInt();
}
long ans = 0;
for (int i = 1; i <= n; ++i) {
ans += a[i] / 2;
if (a[i] % 2 == 0) {
a[i] = 0;
} else {
a[i] = 1;
}
}
for (int i = 1; i <= n; ++i) {
if (a[i] == 1 && a[i + 1] == 1) {
ans++;
a[i] = 0;
a[i + 1] = 0;
}
}
Console.WriteLine(ans);
}
#region よく使う便利関数
static void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
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 long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 100001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static List<int>[] g;
static void Solve() {
var n = Input.NextInt();
var a = new int[n + 2];
for (int i = 0; i < n; ++i) {
a[i + 1] = Input.NextInt();
}
long ans = 0;
for (int i = 1; i <= n; ++i) {
ans += a[i] / 2;
if (a[i] % 2 == 0) {
a[i] = 0;
} else {
a[i] = 1;
if (a[i + 1] >= 1) {
ans++;
a[i] = 0;
a[i + 1]--;
}
}
}
Console.WriteLine(ans);
}
#region よく使う便利関数
static void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
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 long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 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, 19], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 241, 0, 29], ["-", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 20], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 2,447
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private const long INFINITY = 9223372036854775807;
public static void Main() {
int N = NextInt();
long ans = 0;
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = NextInt();
}
for (int i = 1; i < N; i++) {
if (A[i] + A[i - 1] >= 2) {
int B = A[i] + A[i - 1];
ans += B / 2;
A[i - 1] = 0;
A[i] = B % 2;
}
}
Console.WriteLine(ans);
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private const long INFINITY = 9223372036854775807;
public static void Main() {
int N = NextInt();
long ans = 0;
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = NextInt();
}
for (int i = 1; i < N; i++) {
if (A[i] + A[i - 1] >= 2) {
int B = A[i] + A[i - 1];
ans += B / 2;
A[i - 1] = 0;
A[i] = B % 2;
}
}
Console.WriteLine(ans + A[0] / 2);
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 12, 16, 31, 204, 205, 22], ["+", 0, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 12, 203]]
| 8
| 460
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var num = Add.num;
var ar = new int[num];
for (var i = 0; i < num; i++)
ar[i] = Add.num;
var res = 0;
for (var i = 0; i < num; i++) {
if (i != num - 1) {
var min = Min(ar[i], ar[i + 1]);
ar[i] -= min;
ar[i + 1] -= min;
res += min;
}
res += ar[i] / 2;
}
WriteLine(res);
}
}
public class Add {
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 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 static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var num = Add.num;
var ar = new int[num];
for (var i = 0; i < num; i++)
ar[i] = Add.num;
var res = 0L;
for (var i = 0; i < num; i++) {
res += ar[i] / 2;
ar[i] %= 2;
if (i != num - 1) {
var min = Min(ar[i], ar[i + 1]);
ar[i] -= min;
ar[i + 1] -= min;
res += min;
}
}
WriteLine(res);
}
}
public class Add {
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 const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
|
[["-", 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, 107], ["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["+", 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], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 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, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["-", 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], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 271
| 27
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
using System.Text; //テキストの高速出力に必要
class Program {
static void Main() {
long n = long.Parse(Console.ReadLine()); // long.Parseはstringをlongに変換。
long[] nums = new long[n];
long answer = 0;
for (int i = 0; i < n; i++) {
nums[i] = long.Parse(Console.ReadLine());
answer += nums[i] / 2; // 2の倍数個とる
nums[i] -= nums[i] / 2 * 2;
if (nums[i] == 1 && i < n - 1) {
if (nums[i + 1] > 0) {
nums[i + 1]--;
answer++;
}
}
}
Console.WriteLine(answer);
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
using System.Text; //テキストの高速出力に必要
class Program {
static void Main() {
long n = long.Parse(Console.ReadLine()); // long.Parseはstringをlongに変換。
long[] nums = new long[n];
long answer = 0;
for (int i = 0; i < n; i++)
nums[i] = long.Parse(Console.ReadLine());
for (int i = 0; i < n; i++) {
answer += nums[i] / 2; // 2の倍数個とる
nums[i] -= nums[i] / 2 * 2;
if (nums[i] == 1 && i + 1 < n) {
if (nums[i + 1] > 0) {
nums[i + 1]--;
answer++;
}
}
}
Console.WriteLine(answer);
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 7, 8, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 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], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 12, 203]]
| 8
| 168
| 20
|
using System;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine());
long ans = 0;
long[] a = new long[n];
a[0] = int.Parse(Console.ReadLine());
for (int i = 1; i < n; i++) {
a[i] = int.Parse(Console.ReadLine());
ans += (a[i - 1] + a[i]) / 2;
a[i] = a[i] > 0 ? ((a[i - 1] + a[i]) % 2) : 0;
}
Console.WriteLine("{0}", ans);
}
}
|
using System;
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine());
long[] a = new long[n];
a[0] = int.Parse(Console.ReadLine());
long ans = a[0] / 2;
a[0] %= 2;
for (int i = 1; i < n; i++) {
a[i] = int.Parse(Console.ReadLine());
ans += (a[i - 1] + a[i]) / 2;
a[i] = a[i] > 0 ? ((a[i - 1] + a[i]) % 2) : 0;
}
Console.WriteLine("{0}", ans);
}
}
|
[["-", 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, 224, 39, 199], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 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, 16, 31, 204, 205, 22], ["+", 0, 212, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 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, 132], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 153
| 22
|
using System;
class A {
static void Main() {
var n = int.Parse(Console.ReadLine());
long ans = 0;
int cnt = 0;
for (int i = 0; i < n; i++) {
var a = int.Parse(Console.ReadLine());
ans += a / 2;
if (a % 2 == 1) {
cnt++;
} else {
ans += cnt / 2;
cnt = 0;
}
}
ans += cnt / 2;
Console.WriteLine(ans);
}
}
|
using System;
class A {
static void Main() {
var n = int.Parse(Console.ReadLine());
long ans = 0, cnt = 0;
for (int i = 0; i < n; i++) {
var a = int.Parse(Console.ReadLine());
if (a != 0) {
cnt += a;
} else {
ans += cnt / 2;
cnt = 0;
}
}
ans += cnt / 2;
Console.WriteLine(ans);
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 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], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 113
| 18
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
//ある場所にある1を持ってきたい気持ちが生える
//いや、まず動かせるのは2つ刻みなので
int n = int.Parse(Console.ReadLine());
Console.WriteLine(Enumerable.Repeat(0, n)
.Select(_ => int.Parse(Console.ReadLine()))
.ToArray()
.Compress()
.Where((x, y) => (x ^ y & 1) == 1)
.Count() /
2);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IEnumerable<int> Compress<T>(this IEnumerable<T> enumerable)
where T : IComparable<T> {
var dict = enumerable.OrderBy(x => x)
.Distinct()
.Select((x, y) => new Tuple<T, int>(x, y))
.ToDictionary(x => x.Item1, x => x.Item2);
return enumerable.Select(x => dict[x]);
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
//ある場所にある1を持ってきたい気持ちが生える
//いや、まず動かせるのは2つ刻みなので
//奇数番目だけ独立でソート、偶数番目だけ独立でソート
//奇数番目の中の異端児は前の方に集める、偶数番目の中の異端児も前の方に…
//そうするとswapでくいってできるので、またソート…
// swapで解消できる不和は2なので、/2
//だめなの?
int n = int.Parse(Console.ReadLine());
var a = Enumerable.Repeat(0, n)
.Select(_ => int.Parse(Console.ReadLine()))
.ToList();
var ca = a.Compress().ToList();
Console.WriteLine(ca.Where((x, y) => x % 2 != y % 2).Count() / 2);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IEnumerable<int> Compress<T>(this IEnumerable<T> enumerable)
where T : IComparable<T> {
var dict = enumerable.OrderBy(x => x)
.Distinct()
.Select((x, y) => new Tuple<T, int>(x, y))
.ToDictionary(x => x.Item1, x => x.Item2);
return enumerable.Select(x => dict[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], ["+", 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], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 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], ["+", 31, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 218, 8, 16, 31, 23, 0, 24], ["-", 0, 218, 8, 16, 31, 23, 0, 16, 17, 140], ["+", 0, 28, 0, 218, 8, 16, 31, 16, 17, 109], ["+", 0, 28, 0, 218, 8, 16, 31, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 79], ["-", 8, 16, 31, 23, 0, 16, 12, 16, 17, 67], ["-", 8, 16, 31, 23, 0, 16, 12, 16, 12, 203], ["-", 0, 28, 0, 218, 8, 16, 31, 23, 0, 25], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 17, 60], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 12, 203], ["+", 0, 28, 0, 218, 8, 16, 12, 16, 17, 109], ["+", 0, 28, 0, 218, 8, 16, 12, 16, 12, 203]]
| 8
| 274
| 36
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class contest {
static void Main(string[] args) {
var num = int.Parse(Console.ReadLine());
var input = new List<int>();
var clone = new List<int>();
var dicSorted = new Dictionary<int, int>();
var dicOriginal = new Dictionary<int, int>();
int count = 0;
for (int i = 0; i < num; i++)
input.Add(int.Parse(
Console.ReadLine())); // dic.Add(int.Parse(Console.ReadLine()),i);
clone = input;
clone.Sort();
for (int i = 0; i < num; i++)
dicOriginal.Add(input[i], i);
for (int i = 0; i < num; i++)
dicSorted.Add(clone[i], i);
for (int i = 0; i < num; i += 2) {
if (dicOriginal[input[i]] % 2 != dicSorted[input[i]] % 2)
count++;
}
Console.WriteLine(count);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class contest {
static void Main(string[] args) {
var num = int.Parse(Console.ReadLine());
var input = new List<int>();
var dicSorted = new Dictionary<int, int>();
var dicOriginal = new Dictionary<int, int>();
int count = 0;
for (int i = 0; i < num; i++)
input.Add(int.Parse(
Console.ReadLine())); // dic.Add(int.Parse(Console.ReadLine()),i);
List<int> clone = new List<int>(input);
clone.Sort();
for (int i = 0; i < num; i++)
dicOriginal.Add(input[i], i);
for (int i = 0; i < num; i++)
dicSorted.Add(clone[i], i);
for (int i = 0; i < num; i += 2) {
if (dicOriginal[input[i]] % 2 != dicSorted[input[i]] % 2)
count++;
}
Console.WriteLine(count);
}
}
|
[["-", 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, 230, 0, 228], ["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25]]
| 8
| 251
| 22
|
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var n = Int32.Parse(Console.ReadLine());
var a = new List<Int64>();
var dictIdx = new Dictionary<Int64, int>();
for (int i = 0; i < n; i++) {
a.Add(Int64.Parse(Console.ReadLine()));
dictIdx.Add(a[i], i);
}
var wk = a.OrderBy(v => v).ToList();
var indices = new List<Int64>();
for (int i = 0; i < wk.Count; i++) {
indices.Add(dictIdx[wk[i]]);
}
Int64 ret = 0;
for (int i = 0; i < a.Count(); i++) {
if (i % 2 == 0 && i % 2 != indices[i] % 2)
ret++;
}
Console.WriteLine(ret <= 0 ? 0 : ret == 1 ? 1 : ret - 1);
Console.Out.Flush();
}
}
}
|
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var n = Int32.Parse(Console.ReadLine());
var a = new List<Int64>();
var dictIdx = new Dictionary<Int64, int>();
for (int i = 0; i < n; i++) {
a.Add(Int64.Parse(Console.ReadLine()));
dictIdx.Add(a[i], i);
}
var wk = a.OrderBy(v => v).ToList();
var indices = new Int64[n];
for (int i = 0; i < wk.Count; i++) {
indices[dictIdx[wk[i]]] = i;
}
Int64 ret = 0;
for (int i = 0; i < a.Count(); i++) {
if (i % 2 == 0 && indices[i] % 2 == 1)
ret++;
}
Console.WriteLine(ret);
Console.Out.Flush();
}
}
}
|
[["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 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, 11, 31, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["-", 0, 28, 0, 41, 75, 41, 15, 16, 31, 22], ["-", 0, 28, 0, 41, 75, 41, 15, 16, 17, 60], ["-", 0, 28, 0, 41, 75, 41, 15, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 41, 75, 41, 0, 101], ["-", 3, 4, 0, 28, 0, 41, 75, 41, 64, 203], ["-", 3, 4, 0, 28, 0, 41, 75, 41, 0, 102], ["-", 0, 28, 0, 41, 75, 41, 75, 16, 31, 22], ["-", 0, 28, 0, 41, 75, 41, 75, 16, 17, 33], ["-", 0, 28, 0, 41, 75, 41, 75, 16, 12, 203]]
| 8
| 292
| 36
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
int lim2 = 110000, lim3 = 2200;
var isp = new bool[lim2];
var pr1 = new SortedSet<int>();
var pr2 = new SortedDictionary<long, int>();
var dic = new SortedDictionary<long, long>();
var cnt = new SortedDictionary<long, int>();
var pr = new List<int>();
for (int i = 2; i < lim2; i++)
isp[i] = true;
pr2.Add(1, 1);
for (int i = 2; i < lim2; i++) {
if (isp[i]) {
pr.Add(i);
pr1.Add(i);
pr2.Add(i * (long)i, i);
for (long j = i * (long)i; j < lim2; j += i)
isp[j] = false;
}
}
int n = sc.Int, ans = 0, one = 0;
for (int i = 0; i < n; i++) {
long a = sc.Long, b = 1, p = 1;
foreach (var item in pr) {
if (item > lim3 || a < item)
break;
long i3 = item * (long)item * item;
int i2 = item * item;
while (a % i3 == 0)
a /= i3;
if (a % i2 == 0) {
a /= i2;
b *= i2;
p *= item;
}
if (a % item == 0) {
a /= item;
b *= item;
p *= i2;
}
if (p > 1e11) {
++ans;
goto A;
}
}
if (a * b == 1) {
one = 1;
continue;
}
if (pr2.ContainsKey(a)) {
long nor = a * b, pir = p * pr2[a];
if (pir > 1e11) {
++ans;
continue;
}
if (!dic.ContainsKey(nor))
dic.Add(nor, pir);
if (!cnt.ContainsKey(nor))
cnt.Add(nor, 1);
else
++cnt[nor];
} else if (a < lim2 && pr1.Contains((int)a)) {
if (p * a > 1e11 || p * a * a > 1e11) {
++ans;
break;
}
long nor = a * b, pir = p * a * a;
if (!dic.ContainsKey(nor))
dic.Add(nor, pir);
if (!cnt.ContainsKey(nor))
cnt.Add(nor, 1);
else
++cnt[nor];
} else
++ans;
A:
continue;
}
int half = 0;
foreach (var item in cnt) {
var pir = dic[item.Key];
int c = cnt.ContainsKey(pir) ? cnt[pir] : 0;
if (item.Value > c)
ans += item.Value;
else if (item.Value == c)
half += c;
}
sw.WriteLine(ans + one + half / 2);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
public void Multi(out int a, out int b) {
var arr = IntArr;
a = arr[0];
b = arr[1];
}
public void Multi(out int a, out int b, out int c) {
var arr = IntArr;
a = arr[0];
b = arr[1];
c = arr[2];
}
public void Multi(out int a, out string b) {
var arr = StrArr;
a = int.Parse(arr[0]);
b = arr[1];
}
public void Multi(out string a, out int b) {
var arr = StrArr;
a = arr[0];
b = int.Parse(arr[1]);
}
public void Multi(out int a, out char b) {
var arr = StrArr;
a = int.Parse(arr[0]);
b = arr[1][0];
}
public void Multi(out char a, out int b) {
var arr = StrArr;
a = arr[0][0];
b = int.Parse(arr[1]);
}
public void Multi(out long a, out long b) {
var arr = LongArr;
a = arr[0];
b = arr[1];
}
public void Multi(out long a, out int b) {
var arr = LongArr;
a = arr[0];
b = (int)arr[1];
}
public void Multi(out int a, out long b) {
var arr = LongArr;
a = (int)arr[0];
b = arr[1];
}
public void Multi(out string a, out string b) {
var arr = StrArr;
a = arr[0];
b = arr[1];
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public long[][] powmat(long[][] A, long n) {
var E = new long [A.Length][];
for (int i = 0; i < A.Length; i++) {
E[i] = new long[A.Length];
E[i][i] = 1;
}
if (n == 0)
return E;
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
var ans = new long[A.Length];
for (int i = 0; i < A.Length; i++)
for (int j = 0; j < x.Length; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
var ans = new long [A.Length][];
for (int i = 0; i < A.Length; i++) {
ans[i] = new long[B[0].Length];
for (int j = 0; j < B[0].Length; j++)
for (int k = 0; k < B.Length; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
double lim = 2 * 1e10;
int lim2 = 110000, lim3 = 2200;
var isp = new bool[lim2];
var pr1 = new SortedSet<int>();
var pr2 = new SortedDictionary<long, int>();
var dic = new SortedDictionary<long, long>();
var cnt = new SortedDictionary<long, int>();
var pr = new List<int>();
for (int i = 2; i < lim2; i++)
isp[i] = true;
pr2.Add(1, 1);
for (int i = 2; i < lim2; i++) {
if (isp[i]) {
pr.Add(i);
pr1.Add(i);
pr2.Add(i * (long)i, i);
for (long j = i * (long)i; j < lim2; j += i)
isp[j] = false;
}
}
int n = sc.Int, ans = 0, one = 0;
for (int i = 0; i < n; i++) {
long a = sc.Long, b = 1, p = 1;
foreach (var item in pr) {
if (item > lim3 || a < item)
break;
long i3 = item * (long)item * item;
int i2 = item * item;
while (a % i3 == 0)
a /= i3;
if (a % i2 == 0) {
a /= i2;
b *= i2;
p *= item;
}
if (a % item == 0) {
a /= item;
b *= item;
p *= i2;
}
if (p > lim) {
++ans;
goto A;
}
}
if (a * b == 1) {
one = 1;
continue;
}
if (pr2.ContainsKey(a)) {
long nor = a * b, pir = p * pr2[a];
if (pir > lim) {
++ans;
continue;
}
if (!dic.ContainsKey(nor))
dic.Add(nor, pir);
if (!cnt.ContainsKey(nor))
cnt.Add(nor, 1);
else
++cnt[nor];
} else if (a < lim2 && pr1.Contains((int)a)) {
if (p * a > lim || p * a * a > lim) {
++ans;
continue;
}
long nor = a * b, pir = p * a * a;
if (!dic.ContainsKey(nor))
dic.Add(nor, pir);
if (!cnt.ContainsKey(nor))
cnt.Add(nor, 1);
else
++cnt[nor];
} else
++ans;
A:
continue;
}
int half = 0;
foreach (var item in cnt) {
var pir = dic[item.Key];
int c = cnt.ContainsKey(pir) ? cnt[pir] : 0;
if (item.Value > c)
ans += item.Value;
else if (item.Value == c)
half += c;
}
sw.WriteLine(ans + one + half / 2);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
public void Multi(out int a, out int b) {
var arr = IntArr;
a = arr[0];
b = arr[1];
}
public void Multi(out int a, out int b, out int c) {
var arr = IntArr;
a = arr[0];
b = arr[1];
c = arr[2];
}
public void Multi(out int a, out string b) {
var arr = StrArr;
a = int.Parse(arr[0]);
b = arr[1];
}
public void Multi(out string a, out int b) {
var arr = StrArr;
a = arr[0];
b = int.Parse(arr[1]);
}
public void Multi(out int a, out char b) {
var arr = StrArr;
a = int.Parse(arr[0]);
b = arr[1][0];
}
public void Multi(out char a, out int b) {
var arr = StrArr;
a = arr[0][0];
b = int.Parse(arr[1]);
}
public void Multi(out long a, out long b) {
var arr = LongArr;
a = arr[0];
b = arr[1];
}
public void Multi(out long a, out int b) {
var arr = LongArr;
a = arr[0];
b = (int)arr[1];
}
public void Multi(out int a, out long b) {
var arr = LongArr;
a = (int)arr[0];
b = arr[1];
}
public void Multi(out string a, out string b) {
var arr = StrArr;
a = arr[0];
b = arr[1];
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public long[][] powmat(long[][] A, long n) {
var E = new long [A.Length][];
for (int i = 0; i < A.Length; i++) {
E[i] = new long[A.Length];
E[i][i] = 1;
}
if (n == 0)
return E;
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
var ans = new long[A.Length];
for (int i = 0; i < A.Length; i++)
for (int j = 0; j < x.Length; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
var ans = new long [A.Length][];
for (int i = 0; i < A.Length; i++) {
ans[i] = new long[B[0].Length];
for (int j = 0; j < B[0].Length; j++)
for (int k = 0; k < B.Length; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 250], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 12, 250], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 250], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 12, 250], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 12, 250], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 64, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 64, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
| 8
| 2,354
| 17
|
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Number = System.Int64;
namespace Program {
public class Solver {
public void Solve() {
var n = sc.Integer();
var a = sc.Long(n);
const long INF = 10000000001;
var primes = MathEx.Sieve(220000);
var pp = MathEx.SieveList(2200);
foreach (long p in pp)
for (int i = 0; i < n; i++)
if (a[i] % (p * p * p) == 0) {
a[i] /= p * p * p;
}
var xs = a.Distinct().ToList();
xs.Sort();
var m = xs.Count;
var cnt = new int[m];
var used = new bool[m];
for (int i = 0; i < n; i++)
cnt[xs.BinarySearch(a[i])]++;
var ans = 0;
for (int i = 0; i < m; i++) {
if (xs[i] == 1) {
ans++;
used[i] = true;
}
if (used[i])
continue;
used[i] = true;
var x = xs[i];
var y = 1L;
foreach (long p in pp) {
if (x % (p * p) == 0) {
x /= (p * p);
y = Math.Min(INF, y * p);
} else if (x % p == 0) {
x /= p;
y = Math.Min(INF, y * p);
y = Math.Min(INF, y * p);
}
}
if (x != 1) {
if (x < 200000 && primes[x]) {
y = Math.Min(INF, y * x);
y = Math.Min(INF, y * x);
} else
y = INF;
}
var pos = xs.BinarySearch(y);
if (pos < 0)
ans += cnt[i];
else {
ans += Math.Max(cnt[i], cnt[pos]);
used[pos] = true;
}
}
IO.Printer.Out.WriteLine(ans);
}
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(System.Linq.Enumerable.ToArray(ie));
}
static public string AsJoinedString<T>(this IEnumerable<T> ie,
string st = " ") {
return string.Join(st, ie);
}
static public void Main() {
var solver = new Program.Solver();
solver.Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Ex
namespace Program.IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = 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 = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture)
: double.NaN;
}
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
#region sieve
static public partial class MathEx {
static public bool[] Sieve(int p) {
var isPrime = new bool[p + 1];
for (int i = 2; i <= p; i++)
isPrime[i] = true;
for (int i = 2; i * i <= p; i++)
if (!isPrime[i])
continue;
else
for (int j = i * i; j <= p; j += i)
isPrime[j] = false;
return isPrime;
}
}
#endregion
#region sieve list
static public partial class MathEx {
static public List<int> SieveList(int p) {
var isPrime = new bool[p + 1];
for (int i = 2; i <= p; i++)
isPrime[i] = true;
for (int i = 2; i * i <= p; i++) {
if (!isPrime[i])
continue;
for (int j = i * i; j <= p; j += i)
isPrime[j] = false;
}
var ret = new List<int>();
for (int i = 0; i <= p; i++)
if (isPrime[i])
ret.Add(i);
return ret;
}
}
#endregion
|
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Number = System.Int64;
namespace Program {
public class Solver {
public void Solve() {
var n = sc.Integer();
var a = sc.Long(n);
const long INF = 10000000001;
var primes = MathEx.Sieve(220000);
var pp = MathEx.SieveList(2200);
foreach (long p in pp)
for (int i = 0; i < n; i++)
while (a[i] % (p * p * p) == 0) {
a[i] /= p * p * p;
}
Debug.WriteLine(a.AsJoinedString());
var xs = a.Distinct().ToList();
xs.Sort();
var m = xs.Count;
var cnt = new int[m];
var used = new bool[m];
for (int i = 0; i < n; i++)
cnt[xs.BinarySearch(a[i])]++;
var ans = 0;
for (int i = 0; i < m; i++) {
if (xs[i] == 1) {
ans++;
used[i] = true;
}
if (used[i])
continue;
used[i] = true;
var x = xs[i];
var y = 1L;
foreach (long p in pp) {
if (x % (p * p) == 0) {
x /= (p * p);
y = Math.Min(INF, y * p);
} else if (x % p == 0) {
x /= p;
y = Math.Min(INF, y * p);
y = Math.Min(INF, y * p);
}
}
if (x != 1) {
if (x < 200000 && primes[x]) {
y = Math.Min(INF, y * x);
y = Math.Min(INF, y * x);
} else
y = INF;
}
var pos = xs.BinarySearch(y);
if (pos < 0)
ans += cnt[i];
else {
ans += Math.Max(cnt[i], cnt[pos]);
used[pos] = true;
}
}
IO.Printer.Out.WriteLine(ans);
}
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(System.Linq.Enumerable.ToArray(ie));
}
static public string AsJoinedString<T>(this IEnumerable<T> ie,
string st = " ") {
return string.Join(st, ie);
}
static public void Main() {
var solver = new Program.Solver();
solver.Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Ex
namespace Program.IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = 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 = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture)
: double.NaN;
}
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
#region sieve
static public partial class MathEx {
static public bool[] Sieve(int p) {
var isPrime = new bool[p + 1];
for (int i = 2; i <= p; i++)
isPrime[i] = true;
for (int i = 2; i * i <= p; i++)
if (!isPrime[i])
continue;
else
for (int j = i * i; j <= p; j += i)
isPrime[j] = false;
return isPrime;
}
}
#endregion
#region sieve list
static public partial class MathEx {
static public List<int> SieveList(int p) {
var isPrime = new bool[p + 1];
for (int i = 2; i <= p; i++)
isPrime[i] = true;
for (int i = 2; i * i <= p; i++) {
if (!isPrime[i])
continue;
for (int j = i * i; j <= p; j += i)
isPrime[j] = false;
}
var ret = new List<int>();
for (int i = 0; i <= p; i++)
if (isPrime[i])
ret.Add(i);
return ret;
}
}
#endregion
|
[["-", 8, 196, 0, 210, 8, 7, 8, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 7, 8, 52, 0, 89], ["+", 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, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 1,821
| 13
|
using System;
using System.Linq;
class Program {
static void Main() {
Console.ReadLine();
var a = Console.ReadLine().Split().Select(int.Parse);
var b = Enumerable.Range(a.Min(), a.Max());
var c = b.Min(x => a.Sum(y => (y - x) * (y - x)));
Console.WriteLine(c);
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
Console.ReadLine();
var a = Console.ReadLine().Split().Select(int.Parse);
var b = Enumerable.Range(a.Min(), a.Max() - a.Min() + 1);
var c = b.Min(x => a.Sum(y => (y - x) * (y - x)));
Console.WriteLine(c);
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 101
| 8
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var n = ReadLib.ReadAsInt();
var aArr = ReadLib.ReadAsIntArray();
var min = aArr.Min();
var max = aArr.Max();
var score = Enumerable.Range(min, max - min)
.Select(i => Calculation.Score(i, aArr))
.Min();
Console.WriteLine(score);
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
}
static class Calculation {
public static long Score(int cand, int[] aArr) {
return (long)aArr.Select(i => Math.Pow(i - cand, 2)).Sum();
}
}
static class RootedTreeNodesFactory {
public class RootedTreeNode {
public int Id { get; }
public int Parent { get; }
public int Depth { get; set; }
int[] Childs { get; }
public RootedTreeNode(int id, int parent, int[] childs) {
this.Id = id;
this.Parent = parent;
this.Childs = childs;
}
}
}
static class Quick {
internal static void Calculate(int[] ts) { QuickSort(ts, 0, ts.Count() - 1); }
private static void QuickSort(int[] ts, int p, int r) {
if (p < r) {
var q = Partition(ts, p, r);
QuickSort(ts, p, q - 1);
QuickSort(ts, q + 1, r);
}
}
public static int Partition(int[] sArr, int p, int r) {
var x = sArr[r];
var i = p - 1;
for (int j = p; j < r; j++) {
if (sArr[j] <= x) {
i++;
sArr.Swap(i, j);
}
}
sArr.Swap(i + 1, r);
return i + 1;
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class WriteLib {
public static void Write<T>(IEnumerable<T> ts) {
ts.ToList().ForEach(s => Console.WriteLine(s));
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static long Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
long mod;
Math.DivRem(a, b, out mod);
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
public static long Lcm(int item1, int item2) {
return Math.BigMul(item1, item2) / Gcd(item1, item2);
}
public static ModCombination ModCombination(int maxN, int mod = 1000000007) {
return new ModCombination(maxN, mod);
}
/// <summary>a^n mod</summary>
public static int ModPow(int a, int n, int mod = 1000000007) {
var res = 1;
while (n > 0) {
if ((n & 1) == 1) {
res = (int)(Math.BigMul(res % mod, a) % mod); // resにaをかける
}
a = (int)(Math.Pow(a % mod, 2) % mod); // 次のaはa^2
n >>= 1;
}
return res;
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
/// <summary>計数ソート</summary>
public static int[] CountingSort(int[] aArr, int k) {
int[] b, c;
var n = aArr.Length;
b = new int[n];
c = Enumerable.Repeat(0, k + 1).ToArray();
for (int i = 0; i < n; i++) {
c[aArr[i]]++;
}
for (int i = 1; i <= k; i++) {
c[i] += c[i - 1];
}
for (int i = n - 1; i >= 0; i--) {
b[c[aArr[i]] - 1] = aArr[i];
c[aArr[i]]--;
}
return b;
}
}
/// <summary>無向グラフ</summary>
class UndirectedGraph {
public Dictionary<int, List<int>> Graph { get; }
/// <param name="graphArr">point1 to point2</param>
/// <param name="n">グラフの全要素数</param>
public UndirectedGraph(int[][] graphArr, int n) {
Graph = new Dictionary<int, List<int>>();
for (int i = 1; i <= n; i++) {
Graph.Add(i, new List<int>());
}
foreach (var arr in graphArr) {
Graph[arr[0]].Add(arr[1]);
Graph[arr[1]].Add(arr[0]);
}
}
}
/// <summary>DeepCopyするクラス</summary>
class DeepCopier {
BinaryFormatter b = new BinaryFormatter();
public T DeepCopy<T>(T obj) {
T result;
using (var mem = new MemoryStream()) {
b.Serialize(mem,
obj); // binaryFormatterによりobjをmemにserial化して書き出す
mem.Position = 0; // memのpotisionを先頭に戻す
result = (T)b.Deserialize(mem); // memの内容を読み取る。
}
return result;
}
}
static class MergeSort {
public static long[] Sort(long[] arr) { return Sort(arr, 0, arr.Count()); }
// rightは+1されていることに注意
private static long[] Merge(long[] sArr, int left, int mid, int right) {
var n1 = mid - left;
var n2 = right - mid;
var lArr = new long[n1 + 1];
var rArr = new long[n2 + 1];
for (int i = 0; i < n1; i++) {
lArr[i] = sArr[left + i];
}
lArr[n1] = int.MaxValue;
for (int i = 0; i < n2; i++) {
rArr[i] = sArr[mid + i];
}
rArr[n2] = int.MaxValue;
int l = 0, r = 0;
for (int k = left; k < right; k++) {
if (lArr[l] <= rArr[r]) {
sArr[k] = lArr[l];
l++;
} else {
sArr[k] = rArr[r];
r++;
}
}
return sArr; // 要素数はright - left
}
private static long[] Sort(long[] sArr, int left, int right) {
if (left + 1 < right) {
var mid = (left + right) / 2;
sArr = Sort(sArr, left, mid);
sArr = Sort(sArr, mid, right);
sArr = Merge(sArr, left, mid, right);
}
return sArr;
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)(value % mod);
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator -(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value - item2.Value;
if (value < 0) {
value += item1.Mod;
}
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
return item1 + new ModInt(item2, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
return item1 * new ModInt(item2, item1.Mod);
}
public static ModInt operator -(ModInt item1, int item2) {
return item1 - new ModInt(item2, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
/// <summary>組み合わせ</summary>
class ModCombination {
private int mod;
private int[] fac;
private int[] finv;
private int[] inv;
public ModCombination(int max, int mod = 1000000007) {
this.mod = mod;
fac = new int[max]; // modが法のn!の列
inv = new int[max]; // indexの逆元の列
finv = new int[max]; // modを法とした、invの累積の累積
fac[0] = 1;
fac[1] = 1;
finv[0] = 1;
finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = (int)(Math.BigMul(fac[i - 1], i) % mod); // factorを求める
var s = Math.BigMul(inv[mod % i], mod / i) % mod;
inv[i] = (int)(mod - s);
// iに対する逆元を求める
finv[i] = (int)(Math.BigMul(finv[i - 1], inv[i]) % mod);
}
}
/// <summary>nCk</summary>
public int Calculation(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return (int)(Math.BigMul(fac[n],
(int)(Math.BigMul(finv[k], finv[n - k]) % mod)) %
mod);
}
}
/// <summary>拡張メソッドs</summary>
static class Extention {
/// <summary>iとjを入れ替える</summary>
public static void Swap<T>(this T[] arr, int i, int j) {
var buf = arr[i];
arr[i] = arr[j];
arr[j] = buf;
}
/// <summary>
/// partition。末尾sArr[r]を基準として、左に基準より小さい数、右に基準より大きい数が存在するように配列を並び替える。
/// </summary>
/// <param name="sArr"></param>
/// <param name="p">partitionの先頭の添字</param>
/// <param name="r">partitionの末尾の添字</param>
/// <returns>partitionの基準が存在する添字</returns>
public static int Partition(this int[] sArr, int p, int r) {
var x = sArr[r];
var i = p - 1;
for (int j = p; j < r; j++) {
if (sArr[j] <= x) {
i++;
sArr.Swap(i, j);
}
}
sArr.Swap(i + 1, r);
return i + 1;
}
/// <summary>深いコピーをする</summary>
public static T DeepCopy<T>(this T obj) {
T result;
var b = new BinaryFormatter();
using (var mem = new MemoryStream()) {
b.Serialize(mem,
obj); // binaryFormatterによりobjをmemにserial化して書き出す
mem.Position = 0; // memのpotisionを先頭に戻す
result = (T)b.Deserialize(mem); // memの内容を読み取る。
}
return result;
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var n = ReadLib.ReadAsInt();
var aArr = ReadLib.ReadAsIntArray();
var min = aArr.Min();
var max = aArr.Max();
if (max - min == 0) {
Console.WriteLine(0);
} else {
var score = Enumerable.Range(min, max - min)
.Select(i => Calculation.Score(i, aArr))
.Min();
Console.WriteLine(score);
}
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
}
static class Calculation {
public static long Score(int cand, int[] aArr) {
return (long)aArr.Select(i => Math.Pow(i - cand, 2)).Sum();
}
}
static class RootedTreeNodesFactory {
public class RootedTreeNode {
public int Id { get; }
public int Parent { get; }
public int Depth { get; set; }
int[] Childs { get; }
public RootedTreeNode(int id, int parent, int[] childs) {
this.Id = id;
this.Parent = parent;
this.Childs = childs;
}
}
}
static class Quick {
internal static void Calculate(int[] ts) { QuickSort(ts, 0, ts.Count() - 1); }
private static void QuickSort(int[] ts, int p, int r) {
if (p < r) {
var q = Partition(ts, p, r);
QuickSort(ts, p, q - 1);
QuickSort(ts, q + 1, r);
}
}
public static int Partition(int[] sArr, int p, int r) {
var x = sArr[r];
var i = p - 1;
for (int j = p; j < r; j++) {
if (sArr[j] <= x) {
i++;
sArr.Swap(i, j);
}
}
sArr.Swap(i + 1, r);
return i + 1;
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class WriteLib {
public static void Write<T>(IEnumerable<T> ts) {
ts.ToList().ForEach(s => Console.WriteLine(s));
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static long Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
long mod;
Math.DivRem(a, b, out mod);
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
public static long Lcm(int item1, int item2) {
return Math.BigMul(item1, item2) / Gcd(item1, item2);
}
public static ModCombination ModCombination(int maxN, int mod = 1000000007) {
return new ModCombination(maxN, mod);
}
/// <summary>a^n mod</summary>
public static int ModPow(int a, int n, int mod = 1000000007) {
var res = 1;
while (n > 0) {
if ((n & 1) == 1) {
res = (int)(Math.BigMul(res % mod, a) % mod); // resにaをかける
}
a = (int)(Math.Pow(a % mod, 2) % mod); // 次のaはa^2
n >>= 1;
}
return res;
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
/// <summary>計数ソート</summary>
public static int[] CountingSort(int[] aArr, int k) {
int[] b, c;
var n = aArr.Length;
b = new int[n];
c = Enumerable.Repeat(0, k + 1).ToArray();
for (int i = 0; i < n; i++) {
c[aArr[i]]++;
}
for (int i = 1; i <= k; i++) {
c[i] += c[i - 1];
}
for (int i = n - 1; i >= 0; i--) {
b[c[aArr[i]] - 1] = aArr[i];
c[aArr[i]]--;
}
return b;
}
}
/// <summary>無向グラフ</summary>
class UndirectedGraph {
public Dictionary<int, List<int>> Graph { get; }
/// <param name="graphArr">point1 to point2</param>
/// <param name="n">グラフの全要素数</param>
public UndirectedGraph(int[][] graphArr, int n) {
Graph = new Dictionary<int, List<int>>();
for (int i = 1; i <= n; i++) {
Graph.Add(i, new List<int>());
}
foreach (var arr in graphArr) {
Graph[arr[0]].Add(arr[1]);
Graph[arr[1]].Add(arr[0]);
}
}
}
/// <summary>DeepCopyするクラス</summary>
class DeepCopier {
BinaryFormatter b = new BinaryFormatter();
public T DeepCopy<T>(T obj) {
T result;
using (var mem = new MemoryStream()) {
b.Serialize(mem,
obj); // binaryFormatterによりobjをmemにserial化して書き出す
mem.Position = 0; // memのpotisionを先頭に戻す
result = (T)b.Deserialize(mem); // memの内容を読み取る。
}
return result;
}
}
static class MergeSort {
public static long[] Sort(long[] arr) { return Sort(arr, 0, arr.Count()); }
// rightは+1されていることに注意
private static long[] Merge(long[] sArr, int left, int mid, int right) {
var n1 = mid - left;
var n2 = right - mid;
var lArr = new long[n1 + 1];
var rArr = new long[n2 + 1];
for (int i = 0; i < n1; i++) {
lArr[i] = sArr[left + i];
}
lArr[n1] = int.MaxValue;
for (int i = 0; i < n2; i++) {
rArr[i] = sArr[mid + i];
}
rArr[n2] = int.MaxValue;
int l = 0, r = 0;
for (int k = left; k < right; k++) {
if (lArr[l] <= rArr[r]) {
sArr[k] = lArr[l];
l++;
} else {
sArr[k] = rArr[r];
r++;
}
}
return sArr; // 要素数はright - left
}
private static long[] Sort(long[] sArr, int left, int right) {
if (left + 1 < right) {
var mid = (left + right) / 2;
sArr = Sort(sArr, left, mid);
sArr = Sort(sArr, mid, right);
sArr = Merge(sArr, left, mid, right);
}
return sArr;
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)(value % mod);
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator -(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value - item2.Value;
if (value < 0) {
value += item1.Mod;
}
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
return item1 + new ModInt(item2, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
return item1 * new ModInt(item2, item1.Mod);
}
public static ModInt operator -(ModInt item1, int item2) {
return item1 - new ModInt(item2, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
/// <summary>組み合わせ</summary>
class ModCombination {
private int mod;
private int[] fac;
private int[] finv;
private int[] inv;
public ModCombination(int max, int mod = 1000000007) {
this.mod = mod;
fac = new int[max]; // modが法のn!の列
inv = new int[max]; // indexの逆元の列
finv = new int[max]; // modを法とした、invの累積の累積
fac[0] = 1;
fac[1] = 1;
finv[0] = 1;
finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = (int)(Math.BigMul(fac[i - 1], i) % mod); // factorを求める
var s = Math.BigMul(inv[mod % i], mod / i) % mod;
inv[i] = (int)(mod - s);
// iに対する逆元を求める
finv[i] = (int)(Math.BigMul(finv[i - 1], inv[i]) % mod);
}
}
/// <summary>nCk</summary>
public int Calculation(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return (int)(Math.BigMul(fac[n],
(int)(Math.BigMul(finv[k], finv[n - k]) % mod)) %
mod);
}
}
/// <summary>拡張メソッドs</summary>
static class Extention {
/// <summary>iとjを入れ替える</summary>
public static void Swap<T>(this T[] arr, int i, int j) {
var buf = arr[i];
arr[i] = arr[j];
arr[j] = buf;
}
/// <summary>
/// partition。末尾sArr[r]を基準として、左に基準より小さい数、右に基準より大きい数が存在するように配列を並び替える。
/// </summary>
/// <param name="sArr"></param>
/// <param name="p">partitionの先頭の添字</param>
/// <param name="r">partitionの末尾の添字</param>
/// <returns>partitionの基準が存在する添字</returns>
public static int Partition(this int[] sArr, int p, int r) {
var x = sArr[r];
var i = p - 1;
for (int j = p; j < r; j++) {
if (sArr[j] <= x) {
i++;
sArr.Swap(i, j);
}
}
sArr.Swap(i + 1, r);
return i + 1;
}
/// <summary>深いコピーをする</summary>
public static T DeepCopy<T>(this T obj) {
T result;
var b = new BinaryFormatter();
using (var mem = new MemoryStream()) {
b.Serialize(mem,
obj); // binaryFormatterによりobjをmemにserial化して書き出す
mem.Position = 0; // memのpotisionを先頭に戻す
result = (T)b.Deserialize(mem); // memの内容を読み取る。
}
return result;
}
}
|
[["+", 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, 33], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 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, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 3,241
| 20
|
using System;
using System.Linq;
class A {
static void Main() {
double s = int.Parse(Console.ReadLine());
double[] a = Console.ReadLine().Split().Select(double.Parse).ToArray();
double z = 0;
for (int i = 0; i < (int)a.Length; i++) {
z += a[i];
}
double ret = Math.Round((double)z / s, MidpointRounding.AwayFromZero);
int d = (int)ret;
int ans = 0;
for (int i = 0; i < (int)s; i++) {
int u = (int)a[i] - d;
if (u < 0) {
u *= -1;
}
ans += u;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
class A {
static void Main() {
double s = int.Parse(Console.ReadLine());
double[] a = Console.ReadLine().Split().Select(double.Parse).ToArray();
double z = 0;
for (int i = 0; i < (int)s; i++) {
z += a[i];
}
double ret = Math.Round((double)z / s, MidpointRounding.AwayFromZero);
int d = (int)ret;
int ans = 0;
for (int i = 0; i < (int)s; i++) { // int u=(int)a[i]-d;if(u<0){u*=-1;}
ans += ((int)a[i] - d) * ((int)a[i] - d);
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 7, 15, 16, 12, 74, 51, 214, 205, 22], ["-", 0, 7, 15, 16, 12, 74, 51, 214, 0, 131], ["-", 0, 7, 15, 16, 12, 74, 51, 214, 141, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 74, 51, 22], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 12, 16, 31, 23, 0, 16, 31, 74, 0, 24], ["-", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 12, 16, 12, 23, 0, 16, 31, 74, 0, 24], ["+", 12, 16, 12, 23, 0, 16, 31, 74, 39, 199], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 12, 23, 0, 16, 31, 74, 51, 204, 205, 22], ["+", 0, 16, 31, 74, 51, 204, 206, 207, 0, 70], ["+", 31, 74, 51, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 31, 74, 51, 204, 206, 207, 0, 73], ["-", 64, 196, 0, 1, 0, 11, 12, 241, 0, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
| 8
| 180
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var s = ReadLine();
for (var k = 0; k < 2; k++) {
for (var i = 0; i < s.Length - k - 1; i++) {
if (k == 0 && s[i] == s[i + 1]) {
WriteLine($"{i + 1} {i + 2}");
return;
}
if (k == 1 && s[i] == s[i + 1] && s[i] == s[i + 2]) {
WriteLine($"{i + 1} {i + 3}");
return;
}
}
}
WriteLine("-1 -1");
}
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;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var s = ReadLine();
for (var k = 0; k < 2; k++) {
for (var i = 0; i < s.Length - k - 1; i++) {
if (k == 0 && s[i] == s[i + 1]) {
WriteLine($"{i + 1} {i + 2}");
return;
}
if (k == 1 && s[i] == s[i + 2]) {
WriteLine($"{i + 1} {i + 3}");
return;
}
}
}
WriteLine("-1 -1");
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
[["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 31, 16, 12, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 0, 57, 15, 16, 12, 16, 12, 204, 205, 22], ["-", 15, 16, 12, 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, 72]]
| 8
| 207
| 12
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
var cin = new Scanner2();
string s = cin.Next();
int n = s.Length;
for (int i = 0; i < n - 1; i++) {
if (s[i] == s[i + 1]) {
Console.WriteLine($"{i + 1} {i + 2}");
return;
}
}
Console.WriteLine("-1 -1");
}
}
public class Scanner2 {
private readonly char[] delimiter_ = new char[] { ' ' };
private readonly string filePath_;
private string[] buf_;
private int index_;
Func<string> reader_;
public Scanner2(string file = "") {
if (string.IsNullOrWhiteSpace(file)) {
reader_ = Console.ReadLine;
} else {
filePath_ = file;
var fs = new StreamReader(file);
reader_ = fs.ReadLine;
}
buf_ = new string[0];
index_ = 0;
}
public string Next() {
if (index_ < buf_.Length) {
return buf_[index_++];
}
string st = reader_();
while (st == "") {
st = reader_();
}
buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
if (buf_.Length == 0) {
return Next();
}
index_ = 0;
return buf_[index_++];
}
public int Int() => int.Parse(Next());
public long Long() => long.Parse(Next());
public double Double() => double.Parse(Next());
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
public void Save(string text) {
if (string.IsNullOrWhiteSpace(filePath_)) {
return;
}
File.WriteAllText(filePath_ + "_output.txt", text);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
var cin = new Scanner2();
string s = cin.Next();
int n = s.Length;
for (int i = 0; i < n - 1; i++) {
if (s[i] == s[i + 1]) {
Console.WriteLine($"{i + 1} {i + 2}");
return;
}
if (i < n - 2) {
if (s[i] == s[i + 2]) {
Console.WriteLine($"{i + 1} {i + 3}");
return;
}
}
}
Console.WriteLine("-1 -1");
}
}
public class Scanner2 {
private readonly char[] delimiter_ = new char[] { ' ' };
private readonly string filePath_;
private string[] buf_;
private int index_;
Func<string> reader_;
public Scanner2(string file = "") {
if (string.IsNullOrWhiteSpace(file)) {
reader_ = Console.ReadLine;
} else {
filePath_ = file;
var fs = new StreamReader(file);
reader_ = fs.ReadLine;
}
buf_ = new string[0];
index_ = 0;
}
public string Next() {
if (index_ < buf_.Length) {
return buf_[index_++];
}
string st = reader_();
while (st == "") {
st = reader_();
}
buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
if (buf_.Length == 0) {
return Next();
}
index_ = 0;
return buf_[index_++];
}
public int Int() => int.Parse(Next());
public long Long() => long.Parse(Next());
public double Double() => double.Parse(Next());
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
public void Save(string text) {
if (string.IsNullOrWhiteSpace(filePath_)) {
return;
}
File.WriteAllText(filePath_ + "_output.txt", text);
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 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, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 64, 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, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 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], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["+", 0, 28, 0, 283, 0, 284, 0, 16, 31, 22], ["+", 0, 28, 0, 283, 0, 284, 0, 16, 17, 72], ["+", 0, 28, 0, 283, 0, 284, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 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], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 591
| 47
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC043A {
class Program {
static void Main(string[] args) {
int S, N;
N = int.Parse(Console.ReadLine());
S = 0;
for (int i = 1; i <= 100; i++) {
Console.WriteLine(i);
S = S + i;
}
Console.WriteLine(S);
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC043A {
class Program {
static void Main(string[] args) {
int S, N, i;
N = int.Parse(Console.ReadLine());
S = 0;
for (i = 1; i <= N; i++) {
S = S + i;
}
Console.WriteLine(S);
Console.ReadKey();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 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, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 110
| 12
|
using System;
class p {
static void Main() {
int N = int.Parse(Console.ReadLine());
Console.WriteLine((1 / 2) * N * (N + 1));
}
}
|
using System;
class p {
static void Main() {
int N = int.Parse(Console.ReadLine());
Console.WriteLine((N * (N + 1)) / 2);
}
}
|
[["-", 0, 16, 31, 16, 31, 23, 0, 16, 31, 203], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 85], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["+", 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, 203]]
| 8
| 47
| 8
|
using System;
namespace helloVS {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int ans = n * (n + 1) * (2 * n + 1) / 6;
Console.WriteLine("{0}\n", ans);
}
}
}
|
using System;
namespace helloVS {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int ans = n * (n + 1) / 2;
Console.WriteLine("{0}\n", ans);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["-", 0, 212, 0, 16, 31, 16, 12, 23, 0, 24], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 31, 203], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 17, 48], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["-", 0, 212, 0, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 69
| 10
|
using System;
class S {
static void Main() {
int a = int.Parse(Console.ReadLine());
for (int i = 1; i < a; i++) {
a += i;
}
Console.WriteLine(a);
}
}
|
using System;
class S {
static void Main() {
int a = int.Parse(Console.ReadLine());
int s = 0;
for (int i = 1; i <= a; i++) {
s += i;
}
Console.WriteLine(s);
}
}
|
[["+", 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, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 55
| 11
|
using System;
using System.Collections.Generic;
namespace ABCS1 {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
int H, W, A, B;
H = int.Parse(input[0]);
W = int.Parse(input[1]);
A = int.Parse(input[2]);
B = int.Parse(input[3]);
Console.WriteLine(Solve(H, W, A, B));
}
static int Solve(int H, int W, int A, int B) {
Modulo md = new Modulo(H + W - 2, 100000007);
int ans = 0;
var y = H - A - 1;
for (int i = 0; i < W - B; i++) {
ans += md.Multiply(md.Combination(y + B + i, y),
md.Combination(A - 1 + W - B - i - 1, A - 1));
}
return ans;
}
}
class Modulo {
private readonly int M = 100000007;
private readonly int[] m_facs;
public Modulo(int n, int m) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i) {
m_facs[i] = Multiply(m_facs[i - 1], i);
}
M = m;
}
public int Multiply(int a, int b) { return (int)(Math.BigMul(a, b) % M); }
public int Factorial(int n) { return m_facs[n]; }
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Multiply(p1, p1);
return ((m % 2) == 0) ? p2 : Multiply(p2, a);
}
}
public int Divide(int a, int b) { return Multiply(a, Pow(b, M - 2)); }
public int Combination(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Factorial(n);
res = Divide(res, Factorial(r));
res = Divide(res, Factorial(n - r));
return res;
}
public int Permutation(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Factorial(n);
res = Divide(res, Factorial(n - r));
return res;
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
int H, W, A, B;
H = int.Parse(input[0]);
W = int.Parse(input[1]);
A = int.Parse(input[2]);
B = int.Parse(input[3]);
Console.WriteLine(Solve(H, W, A, B));
}
static int Solve(int H, int W, int A, int B) {
int modulo = 1000000007;
Modulo md = new Modulo(H + W - 2, modulo);
int ans = 0;
var y = H - A - 1;
for (int i = 0; i < W - B; i++) {
ans += md.Multiply(md.Combination(y + B + i, y),
md.Combination(A - 1 + W - B - i - 1, A - 1));
ans %= modulo;
}
return ans;
}
}
class Modulo {
private readonly int M = 1000000007;
private readonly int[] m_facs;
public Modulo(int n, int m) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i) {
m_facs[i] = Multiply(m_facs[i - 1], i);
}
M = m;
}
public int Multiply(int a, int b) { return (int)(Math.BigMul(a, b) % M); }
public int Factorial(int n) { return m_facs[n]; }
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Multiply(p1, p1);
return ((m % 2) == 0) ? p2 : Multiply(p2, a);
}
}
public int Divide(int a, int b) { return Multiply(a, Pow(b, M - 2)); }
public int Combination(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Factorial(n);
res = Divide(res, Factorial(r));
res = Divide(res, Factorial(n - r));
return res;
}
public int Permutation(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Factorial(n);
res = Divide(res, Factorial(n - r));
return res;
}
}
|
[["-", 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, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 36, 36, 36, 36, 0, 208, 0, 209, 0, 256], ["-", 36, 36, 36, 36, 0, 208, 0, 209, 141, 22], ["-", 36, 36, 0, 208, 0, 209, 8, 201, 0, 45], ["+", 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, 212, 0, 230, 3, 4, 0, 28, 0, 203], ["+", 0, 212, 0, 230, 3, 4, 0, 28, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46]]
| 8
| 585
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
class Program {
public Program() {}
static void Main(string[] args) { new Program().prog(); }
Scanner cin;
const int MOD = 1000000007;
const int INF = int.MaxValue;
const double EPS = 1e-7;
const double PI = 3.1415926536;
void prog() {
cin = new Scanner();
int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
{ 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
int H = cin.nextInt();
int W = cin.nextInt();
int A = cin.nextInt();
int B = cin.nextInt();
if (H == 1 || W == 1) {
Console.WriteLine(0);
return;
}
long ans = 0;
int size = Math.Max(W - 2 + H - A, A - 1 + W - B - 1) + 1;
long[] inv = new long[size];
long[] fac = new long[size];
long[] facInv = new long[size];
ModInv(W - 2 + H - A + W - B, inv, MOD);
FacInv(W - 2 + H - A + W - B, inv, fac, facInv, MOD);
for (int i = 0; i < W - B; i++) {
Console.WriteLine(i);
ans += CombiMod(W - 2 + H - A - i, H - A - 1, MOD, inv, fac, facInv) *
CombiMod(i + A - 1, i, MOD, inv, fac, facInv);
ans %= MOD;
}
Console.WriteLine(ans);
}
long CombiMod(int n, int k, int mod, long[] inv, long[] fac, long[] facInv) {
if (n == 0 && k == 0)
return 1;
if (n <= 0 || k < 0 || k > n)
return 0;
if (k == 0)
return 1;
Console.WriteLine("n:{0}, k:{1}", n, k);
return (((fac[n] * facInv[k]) % mod) * facInv[n - k]) % mod;
}
// モジュラ逆数を求める(modが素数と仮定)
void ModInv(int n, long[] inv, int mod) {
inv[0] = 0;
inv[1] = 1;
for (int i = 2; i <= n; i++) {
inv[i] = mod - ((mod / i) * inv[mod % i] % mod);
}
}
// n!をmodで割った余り
void FacInv(int n, long[] inv, long[] fac, long[] facInv, int mod) {
fac[0] = facInv[0] = 1;
for (int i = 1; i <= n; i++) {
fac[i] = (fac[i - 1] * i) % mod;
facInv[i] = (facInv[i - 1] * (int)inv[i]) % mod;
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
class Program {
public Program() {}
static void Main(string[] args) { new Program().prog(); }
Scanner cin;
const int MOD = 1000000007;
const int INF = int.MaxValue;
const double EPS = 1e-7;
const double PI = 3.1415926536;
void prog() {
cin = new Scanner();
int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
{ 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
int H = cin.nextInt();
int W = cin.nextInt();
int A = cin.nextInt();
int B = cin.nextInt();
if (H == 1 || W == 1) {
Console.WriteLine(0);
return;
}
long ans = 0;
int size = Math.Max(W - 2 + H - A, A - 1 + W - B - 1) + 1;
long[] inv = new long[size];
long[] fac = new long[size];
long[] facInv = new long[size];
ModInv(size - 1, inv, MOD);
FacInv(size - 1, inv, fac, facInv, MOD);
for (int i = 0; i < W - B; i++) {
// Console.WriteLine(i);
ans += CombiMod(W - 2 + H - A - i, H - A - 1, MOD, inv, fac, facInv) *
CombiMod(i + A - 1, i, MOD, inv, fac, facInv);
ans %= MOD;
}
Console.WriteLine(ans);
}
long CombiMod(int n, int k, int mod, long[] inv, long[] fac, long[] facInv) {
if (n == 0 && k == 0)
return 1;
if (n <= 0 || k < 0 || k > n)
return 0;
if (k == 0)
return 1;
// Console.WriteLine("n:{0}, k:{1}", n, k);
return (((fac[n] * facInv[k]) % mod) * facInv[n - k]) % mod;
}
// モジュラ逆数を求める(modが素数と仮定)
void ModInv(int n, long[] inv, int mod) {
inv[0] = 0;
inv[1] = 1;
for (int i = 2; i <= n; i++) {
// Console.WriteLine(i);
inv[i] = mod - ((mod / i) * inv[mod % i] % mod);
}
}
// n!をmodで割った余り
void FacInv(int n, long[] inv, long[] fac, long[] facInv, int mod) {
fac[0] = facInv[0] = 1;
for (int i = 1; i <= n; i++) {
fac[i] = (fac[i - 1] * i) % mod;
facInv[i] = (facInv[i - 1] * (int)inv[i]) % mod;
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
|
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 33], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 17, 33], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 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], ["-", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21]]
| 8
| 913
| 44
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
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[] A = cin.ArrayInt(N);
Array.Sort(A);
Array.Reverse(A);
int ans = 0;
for (int i = 0; i < A.Length; i += 2) {
if (A.Length > i + 1)
ans += A[i + 1];
}
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;
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[] A = cin.ArrayInt(2 * N);
Array.Sort(A);
Array.Reverse(A);
int ans = 0;
for (int i = 0; i < A.Length; i += 2) {
ans += A[i + 1];
}
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, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 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, 214, 205, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25]]
| 8
| 521
| 12
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
long[] num = longa();
long a = num[1];
long b = num[0] - num[1];
long ans = num[0];
while (true) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
ans += 2 * a / b;
if (a % b == 0) {
break;
} else {
long temp = b;
b = a % b;
a = temp;
}
// WriteLine(ans);
}
WriteLine(ans);
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
// static int square2(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// var queue = new Queue<int>(); queue.Enqueue() queue.Dequeue()
// スタック -> 深さ優先 ???
// var stack = new Stack<int>(); stack.Push(hoge) stack.Pop() stackPeek()
// stack.Count
// if (list?.Count > 0) リストが空でもnullでもない
// ソート
// list.Sort(StringComparer.Ordinal); listの(辞書順?)ソート
// StringComparer.Ordinal とは
// 出力
// foreach(var a int list){ WriteLine(a); } より
// WriteLine(string.Join("\n", list)); が速い
// var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
// Console.SetOut(sw);
// foreach(var k in list[num-1]){
// WriteLine(k);
// }
// Console.Out.Flush();
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
long[] num = longa();
long a = num[1];
long b = num[0] - num[1];
long ans = num[0];
while (true) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
// WriteLine($"{a} {b} {a/b} {a%b}");
// WriteLine(ans);
ans += b * 2 * (a / b);
// WriteLine(ans);
if (a % b == 0) {
ans -= b;
break;
} else {
long temp = b;
b = a % b;
a = temp;
}
// WriteLine(ans);
}
WriteLine(ans);
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
// static int square2(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// var queue = new Queue<int>(); queue.Enqueue() queue.Dequeue()
// スタック -> 深さ優先 ???
// var stack = new Stack<int>(); stack.Push(hoge) stack.Pop() stackPeek()
// stack.Count
// if (list?.Count > 0) リストが空でもnullでもない
// ソート
// list.Sort(StringComparer.Ordinal); listの(辞書順?)ソート
// StringComparer.Ordinal とは
// 出力
// foreach(var a int list){ WriteLine(a); } より
// WriteLine(string.Join("\n", list)); が速い
// var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
// Console.SetOut(sw);
// foreach(var k in list[num-1]){
// WriteLine(k);
// }
// Console.Out.Flush();
|
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 919
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var l = Console.ReadLine().Split(' ').Select(y => long.Parse(y)).ToArray();
var n = l[0];
var x1 = (n - l[1] > l[1]) ? n - l[1] : l[1];
var x2 = (n - l[1] <= l[1]) ? n - l[1] : l[1];
var sum = n;
long a = -1;
while (a != 0) {
a = x1 % x2;
sum += (x1 - a) * 2;
x1 = x2;
x2 = a;
}
Console.Write(sum);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var l = Console.ReadLine().Split(' ').Select(y => long.Parse(y)).ToArray();
var n = l[0];
var x1 = (n - l[1] > l[1]) ? n - l[1] : l[1];
var x2 = (n - l[1] <= l[1]) ? n - l[1] : l[1];
var sum = n;
long a = 0;
while (true) {
a = x1 % x2;
sum += (x1 - a) * 2;
if (a == 0) {
sum -= x2;
break;
}
x1 = x2;
x2 = a;
}
Console.Write(sum);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["+", 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, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 199
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine().Split();
var n = Int32.Parse(str[0]);
var x = Int32.Parse(str[1]);
Console.WriteLine(Solver.Solve(n, x));
}
}
public class Solver {
public static int Solve(int n, int x) {
var ret = x + (n - x);
ret += dfs(x, n - x);
return ret;
}
public static int dfs(int a, int b) {
if (a == 0 || b == 0)
return 0;
if (b % a == 0) {
return a * 2 * (b / a - 1) + a;
}
var ret = (2 * a) * (b / a);
if (a % (b % a) == 0)
return ret + ((b % a) * 2) * (a / (b % a)) - b % a;
ret += ((b % a) * 2) * (a / (b % a));
return ret + dfs(a % (b % a), b % a);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine().Split();
var n = UInt64.Parse(str[0]);
var x = UInt64.Parse(str[1]);
Console.WriteLine(Solver.Solve(n, x));
}
}
public class Solver {
public static UInt64 Solve(UInt64 n, UInt64 x) {
var ret = x + (n - x);
ret += dfs(x, n - x);
return ret;
}
public static UInt64 dfs(UInt64 a, UInt64 b) {
if (a == 0 || b == 0)
return 0;
if (b % a == 0) {
return a * 2 * (b / a - 1) + a;
}
var ret = (2 * a) * (b / a);
if (a % (b % a) == 0)
return ret + ((b % a) * 2) * (a / (b % a)) - b % a;
ret += ((b % a) * 2) * (a / (b % a));
return ret + dfs(a % (b % a), b % a);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 39, 22], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 22]]
| 8
| 292
| 16
|
using System;
using System.Collections.Generic;
using CompLib.Util;
public class Program {
private int N, K;
private List<int>[] E;
private int[,] Dist;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
K = sc.NextInt();
E = new List<int>[N];
for (int i = 0; i < N; i++) {
E[i] = new List<int>();
}
int[] a = new int[N - 1];
int[] b = new int[N - 1];
for (int i = 0; i < N - 1; i++) {
a[i] = sc.NextInt() - 1;
b[i] = sc.NextInt() - 1;
E[a[i]].Add(b[i]);
E[b[i]].Add(a[i]);
}
Dist = new int[N, N];
for (int i = 0; i < N; i++) {
Dist[i, i] = 0;
Go(i, i, -1);
}
int ans = int.MaxValue;
if (K % 2 == 0) {
for (int m = 0; m < N; m++) {
int cnt = 0;
for (int i = 0; i < N; i++) {
if (Dist[m, i] > K / 2)
cnt++;
}
ans = Math.Min(ans, cnt);
}
} else {
int cnt = 0;
for (int i = 0; i < N - 1; i++) {
for (int j = 0; j < N; j++) {
if (Math.Min(Dist[a[i], j], Dist[b[i], j]) > K / 2)
cnt++;
}
ans = Math.Min(ans, cnt);
}
}
Console.WriteLine(ans);
}
void Go(int root, int cur, int par) {
foreach (int to in E[cur]) {
if (par == to)
continue;
Dist[root, to] = Dist[root, cur] + 1;
Go(root, to, cur);
}
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
if (_index >= _line.Length) {
string s;
do {
s = Console.ReadLine();
} while (s.Length == 0);
_line = s.Split(Separator);
_index = 0;
}
return _line[_index++];
}
public string ReadLine() {
_index = _line.Length;
return Console.ReadLine();
}
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() {
string s = Console.ReadLine();
_line = s.Length == 0 ? new string[0] : s.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 CompLib.Util;
public class Program {
private int N, K;
private List<int>[] E;
private int[,] Dist;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
K = sc.NextInt();
E = new List<int>[N];
for (int i = 0; i < N; i++) {
E[i] = new List<int>();
}
int[] a = new int[N - 1];
int[] b = new int[N - 1];
for (int i = 0; i < N - 1; i++) {
a[i] = sc.NextInt() - 1;
b[i] = sc.NextInt() - 1;
E[a[i]].Add(b[i]);
E[b[i]].Add(a[i]);
}
Dist = new int[N, N];
for (int i = 0; i < N; i++) {
Dist[i, i] = 0;
Go(i, i, -1);
}
int ans = int.MaxValue;
if (K % 2 == 0) {
for (int m = 0; m < N; m++) {
int cnt = 0;
for (int i = 0; i < N; i++) {
if (Dist[m, i] > K / 2)
cnt++;
}
ans = Math.Min(ans, cnt);
}
} else {
for (int i = 0; i < N - 1; i++) {
int cnt = 0;
for (int j = 0; j < N; j++) {
if (Math.Min(Dist[a[i], j], Dist[b[i], j]) > K / 2)
cnt++;
}
ans = Math.Min(ans, cnt);
}
}
Console.WriteLine(ans);
}
void Go(int root, int cur, int par) {
foreach (int to in E[cur]) {
if (par == to)
continue;
Dist[root, to] = Dist[root, cur] + 1;
Go(root, to, cur);
}
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
if (_index >= _line.Length) {
string s;
do {
s = Console.ReadLine();
} while (s.Length == 0);
_line = s.Split(Separator);
_index = 0;
}
return _line[_index++];
}
public string ReadLine() {
_index = _line.Length;
return Console.ReadLine();
}
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() {
string s = Console.ReadLine();
_line = s.Length == 0 ? new string[0] : s.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();
}
}
|
[["-", 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, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 57, 75, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 75, 196, 0, 7, 8, 196, 0, 197, 0, 35]]
| 8
| 878
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.AGC_C {
class _001 {
static void Main(string[] args) {
Method(args);
ReadLine();
}
static void Method(string[] args) {
int[] nk = ReadInts();
int n = nk[0];
int k = nk[1];
List<int>[] graph = new List<int>[n];
for (int i = 0; i < n; i++)
graph[i] = new List<int>();
int[][] abs = new int [n - 1][];
for (int i = 0; i < n - 1; i++) {
abs[i] = ReadInts();
abs[i][0]--;
abs[i][1]--;
int a = abs[i][0];
int b = abs[i][1];
graph[a].Add(b);
graph[b].Add(a);
}
int res = int.MaxValue;
if (k % 2 == 0) {
int dist = k / 2;
for (int i = 0; i < n; i++) {
Queue<int[]> queue = new Queue<int[]>();
bool[] visited = new bool[n];
queue.Enqueue(new int[2] { i, 0 });
int tmp = 0;
while (queue.Count > 0) {
int[] val = queue.Dequeue();
visited[val[0]] = true;
if (val[1] > dist)
tmp++;
for (int j = 0; j < graph[val[0]].Count; j++) {
int index = graph[val[0]][j];
if (visited[index])
continue;
queue.Enqueue(new int[2] { index, val[1] + 1 });
}
}
res = Min(res, tmp);
}
} else {
int dist = (k - 1) / 2;
for (int i = 0; i < n - 1; i++) {
Queue<int[]> queue = new Queue<int[]>();
bool[] visited = new bool[n];
queue.Enqueue(new int[2] { abs[i][0], 0 });
queue.Enqueue(new int[2] { abs[i][1], 0 });
int tmp = 0;
while (queue.Count > 0) {
int[] val = queue.Dequeue();
visited[val[0]] = true;
if (val[1] > dist)
tmp++;
for (int j = 0; j < graph[val[0]].Count; j++) {
int index = graph[val[0]][j];
if (visited[index])
continue;
queue.Enqueue(new int[2] { index, val[1] + 1 });
}
}
res = Min(res, tmp);
}
}
WriteLine(res);
}
private static string Read() { return 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.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.AGC_C {
class _001 {
static void Main(string[] args) {
Method(args);
ReadLine();
}
static void Method(string[] args) {
int[] nk = ReadInts();
int n = nk[0];
int k = nk[1];
List<int>[] graph = new List<int>[n];
for (int i = 0; i < n; i++)
graph[i] = new List<int>();
int[][] abs = new int [n - 1][];
for (int i = 0; i < n - 1; i++) {
abs[i] = ReadInts();
abs[i][0]--;
abs[i][1]--;
int a = abs[i][0];
int b = abs[i][1];
graph[a].Add(b);
graph[b].Add(a);
}
int res = int.MaxValue;
if (k % 2 == 0) {
int dist = k / 2;
for (int i = 0; i < n; i++) {
Queue<int[]> queue = new Queue<int[]>();
bool[] visited = new bool[n];
queue.Enqueue(new int[2] { i, 0 });
int tmp = 0;
while (queue.Count > 0) {
int[] val = queue.Dequeue();
if (visited[val[0]])
continue;
visited[val[0]] = true;
if (val[1] > dist)
tmp++;
for (int j = 0; j < graph[val[0]].Count; j++) {
int index = graph[val[0]][j];
if (visited[index])
continue;
queue.Enqueue(new int[2] { index, val[1] + 1 });
}
}
res = Min(res, tmp);
}
} else {
int dist = (k - 1) / 2;
for (int i = 0; i < n - 1; i++) {
Queue<int[]> queue = new Queue<int[]>();
bool[] visited = new bool[n];
queue.Enqueue(new int[2] { abs[i][0], 0 });
queue.Enqueue(new int[2] { abs[i][1], 0 });
int tmp = 0;
while (queue.Count > 0) {
int[] val = queue.Dequeue();
if (visited[val[0]])
continue;
visited[val[0]] = true;
if (val[1] > dist)
tmp++;
for (int j = 0; j < graph[val[0]].Count; j++) {
int index = graph[val[0]][j];
if (visited[index])
continue;
queue.Enqueue(new int[2] { index, val[1] + 1 });
}
}
res = Min(res, tmp);
}
}
WriteLine(res);
}
private static string Read() { return 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, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 204, 205, 22], ["+", 8, 196, 0, 57, 15, 204, 206, 207, 0, 70], ["+", 15, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 52, 8, 196, 0, 57, 64, 116, 0, 35], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 197, 0, 35]]
| 8
| 842
| 24
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
class P {
static void Main() {
var nk = Console.ReadLine().Split().Select(int.Parse).ToList();
List<int>[] neighbours =
Enumerable.Repeat(0, nk[0]).Select(_ => new List<int>()).ToArray();
List<Tuple<int, int>> edges = new List<Tuple<int, int>>();
for (int i = 0; i < nk[0] - 1; i++) {
var ab =
Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToList();
neighbours[ab[0]].Add(ab[1]);
neighbours[ab[1]].Add(ab[0]);
edges.Add(new Tuple<int, int>(ab[0], ab[1]));
}
Dictionary<int, int>[] indexes =
neighbours
.Select(x => x.Select((y, z) => new Tuple<int, int>(y, z))
.ToDictionary(y => y.Item1, y => y.Item2))
.ToArray();
List<int>[][] datas =
neighbours.Select(x => new List<int>[x.Count]).ToArray();
Func<int, int, List<int>> dfs = null;
dfs = (x, from) => {
List<int> ret = new List<int>() { 1 };
for (int i = 0; i < datas[x].Length; i++) {
var dest = neighbours[x][i];
if (dest == from)
continue;
var v =
datas[x][i] != null ? datas[x][i] : (datas[x][i] = dfs(dest, x));
for (int j = 1; j <= v.Count; j++) {
if (j >= ret.Count)
ret.Add(0);
ret[j] += v[j - 1];
}
}
return ret;
};
List<int>[] dfsRes = new List<int>[nk[0]];
for (int i = 0; i < nk[0]; i++)
dfsRes[i] = dfs(i, -1);
int res = int.MaxValue;
if (nk[1] % 2 == 0) {
res = Enumerable.Range(0, nk[0]).Min(
x => dfsRes[x].Skip(nk[1] / 2 + 1).Sum());
} else {
res = edges.Min(x => datas[x.Item1][indexes[x.Item1][x.Item2]]
.Zip(datas[x.Item2][indexes[x.Item2][x.Item1]],
(y, z) => y + z)
.Skip(nk[1] / 2 + 1)
.Sum());
}
Console.WriteLine(res);
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
class P {
static void Main() {
var nk = Console.ReadLine().Split().Select(int.Parse).ToList();
List<int>[] neighbours =
Enumerable.Repeat(0, nk[0]).Select(_ => new List<int>()).ToArray();
List<Tuple<int, int>> edges = new List<Tuple<int, int>>();
for (int i = 0; i < nk[0] - 1; i++) {
var ab =
Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToList();
neighbours[ab[0]].Add(ab[1]);
neighbours[ab[1]].Add(ab[0]);
edges.Add(new Tuple<int, int>(ab[0], ab[1]));
}
Dictionary<int, int>[] indexes =
neighbours
.Select(x => x.Select((y, z) => new Tuple<int, int>(y, z))
.ToDictionary(y => y.Item1, y => y.Item2))
.ToArray();
List<int>[][] datas =
neighbours.Select(x => new List<int>[x.Count]).ToArray();
Func<int, int, List<int>> dfs = null;
dfs = (x, from) => {
List<int> ret = new List<int>() { 1 };
for (int i = 0; i < datas[x].Length; i++) {
var dest = neighbours[x][i];
if (dest == from)
continue;
var v =
datas[x][i] != null ? datas[x][i] : (datas[x][i] = dfs(dest, x));
for (int j = 1; j <= v.Count; j++) {
if (j >= ret.Count)
ret.Add(0);
ret[j] += v[j - 1];
}
}
return ret;
};
List<int>[] dfsRes = new List<int>[nk[0]];
for (int i = 0; i < nk[0]; i++)
dfsRes[i] = dfs(i, -1);
int res = int.MaxValue;
if (nk[1] % 2 == 0) {
res = Enumerable.Range(0, nk[0]).Min(
x => dfsRes[x].Skip(nk[1] / 2 + 1).Sum());
} else {
res = edges.Min(x => datas[x.Item1][indexes[x.Item1][x.Item2]]
.Skip(nk[1] / 2 + 1)
.Sum() +
datas[x.Item2][indexes[x.Item2][x.Item1]]
.Skip(nk[1] / 2 + 1)
.Sum());
}
Console.WriteLine(res);
}
}
|
[["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 31, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 204, 205, 22], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 203], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 31, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 218, 8, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 218, 8, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 218, 8, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 218, 8, 16, 31, 213, 3, 4, 0, 25], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 72], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 24], ["-", 0, 28, 0, 218, 54, 55, 0, 220, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 21], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 25], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 12, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25]]
| 8
| 745
| 27
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
const int mod = 1000000007;
const long o = 1;
static List<int>[] li;
static int[] s;
static int[][] h;
static int ans = 0;
static void Main() {
Sc sc = new Sc();
s = sc.Ia;
li = new List<int>[s[0] + 1];
int[][] q = new int[s[0] + 1][];
for (int i = 1; i <= s[0]; i++) {
li[i] = new List<int>();
}
for (int i = 1; i < s[0]; i++) {
q[i] = sc.Ia;
li[q[i][0]].Add(q[i][1]);
li[q[i][1]].Add(q[i][0]);
}
if (s[1] % 2 == 0) {
for (int i = 1; i <= s[0]; i++) {
ans = Math.Max(ans, Fu1(i, 0, 0));
}
} else {
h = new int[s[0] + 1][];
for (int i = 1; i <= s[0]; i++) {
h[i] = new int[li[i].Count];
}
for (int i = 1; i <= s[0]; i++) {
Fu2(i);
}
for (int i = 1; i < s[0]; i++) {
int p = 2;
for (int j = 0; j < h[q[i][0]].Length; j++) {
if (li[q[i][0]][j] != q[i][1]) {
p += h[q[i][0]][j];
}
}
for (int j = 0; j < h[q[i][1]].Length; j++) {
if (li[q[i][1]][j] != q[i][0]) {
p += h[q[i][1]][j];
}
}
ans = Math.Max(ans, p);
}
}
Console.WriteLine("{0}", s[0] - ans);
}
static int Fu1(int a, int b, int c) {
int p = 0;
if (c < s[1] / 2) {
for (int i = 0; i < li[a].Count; i++) {
if (li[a][i] != b) {
p += Fu1(li[a][i], a, c + 1);
}
}
}
return p + 1;
}
static void Fu2(int a) {
for (int i = 0; i < li[a].Count; i++) {
h[a][i] += Fu1(li[a][i], a, 1);
}
}
}
class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
const int mod = 1000000007;
const long o = 1;
static List<int>[] li;
static int[] s;
static int[][] h;
static int ans = 0;
static void Main() {
Sc sc = new Sc();
s = sc.Ia;
li = new List<int>[s[0] + 1];
int[][] q = new int[s[0] + 1][];
for (int i = 1; i <= s[0]; i++) {
li[i] = new List<int>();
}
for (int i = 1; i < s[0]; i++) {
q[i] = sc.Ia;
li[q[i][0]].Add(q[i][1]);
li[q[i][1]].Add(q[i][0]);
}
if (s[1] % 2 == 0) {
for (int i = 1; i <= s[0]; i++) {
ans = Math.Max(ans, Fu1(i, 0, 0));
}
} else if (s[1] == 1) {
ans = 2;
} else {
h = new int[s[0] + 1][];
for (int i = 1; i <= s[0]; i++) {
h[i] = new int[li[i].Count];
}
for (int i = 1; i <= s[0]; i++) {
Fu2(i);
}
for (int i = 1; i < s[0]; i++) {
int p = 2;
for (int j = 0; j < h[q[i][0]].Length; j++) {
if (li[q[i][0]][j] != q[i][1]) {
p += h[q[i][0]][j];
}
}
for (int j = 0; j < h[q[i][1]].Length; j++) {
if (li[q[i][1]][j] != q[i][0]) {
p += h[q[i][1]][j];
}
}
ans = Math.Max(ans, p);
}
}
Console.WriteLine("{0}", s[0] - ans);
}
static int Fu1(int a, int b, int c) {
int p = 0;
if (c < s[1] / 2) {
for (int i = 0; i < li[a].Count; i++) {
if (li[a][i] != b) {
p += Fu1(li[a][i], a, c + 1);
}
}
}
return p + 1;
}
static void Fu2(int a) {
for (int i = 0; i < li[a].Count; i++) {
h[a][i] += Fu1(li[a][i], a, 1);
}
}
}
class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 204, 205, 22], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 75, 57, 15, 16, 31, 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, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45]]
| 8
| 872
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
int n, k;
sc.Multi(out n, out k);
var edge = new List<int>[n];
var a = new int [n - 1][];
for (int i = 0; i < n; i++)
edge[i] = new List<int>();
for (int i = 0; i < n - 1; i++) {
a[i] = sc.IntArr.Select(x => x - 1).ToArray();
edge[a[i][0]].Add(a[i][1]);
edge[a[i][1]].Add(a[i][0]);
}
int lim = k >> 1;
int min = n;
var q = new Queue<int>();
if (k % 2 == 0) {
for (int i = 0; i < n; i++) {
var dist = new int[n];
for (int j = 0; j < n; j++)
dist[j] = -1;
int c = 1;
dist[i] = 0;
q.Enqueue(i);
while (q.Any()) {
int p = q.Dequeue();
if (dist[p] >= lim)
break;
foreach (var item in edge[p]) {
if (dist[item] < 0) {
dist[item] = dist[p] + 1;
++c;
q.Enqueue(item);
}
}
}
min = Math.Min(min, n - c);
}
} else {
foreach (var i in a) {
var dist = new int[n];
for (int j = 0; j < n; j++)
dist[j] = -1;
int c = 2;
dist[i[0]] = 0;
dist[i[1]] = 0;
q.Enqueue(i[0]);
while (q.Any()) {
int p = q.Dequeue();
if (dist[p] >= lim)
break;
foreach (var item in edge[p]) {
if (dist[item] < 0) {
dist[item] = dist[p] + 1;
++c;
q.Enqueue(item);
}
}
}
q.Enqueue(i[1]);
while (q.Any()) {
int p = q.Dequeue();
if (dist[p] >= lim)
break;
foreach (var item in edge[p]) {
if (dist[item] < 0) {
dist[item] = dist[p] + 1;
++c;
q.Enqueue(item);
}
}
}
min = Math.Min(min, n - c);
}
}
sw.WriteLine(min);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
T cv<T>(string inp) {
if (typeof(T).Equals(typeof(int)))
return (T)Convert.ChangeType(int.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(long)))
return (T)Convert.ChangeType(long.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(double)))
return (T)Convert.ChangeType(double.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(char)))
return (T)Convert.ChangeType(inp[0], typeof(T));
return (T)Convert.ChangeType(inp, typeof(T));
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public bool[] sieve(int n) {
var isp = new bool[n + 1];
for (int i = 2; i <= n; i++)
isp[i] = true;
for (int i = 2; i * i <= n; i++)
if (isp[i])
for (int j = i * i; j <= n; j += i)
isp[j] = false;
return isp;
}
public List<int> getprimes(int n) {
var prs = new List<int>();
var isp = sieve(n);
for (int i = 2; i <= n; i++)
if (isp[i])
prs.Add(i);
return prs;
}
public long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public long[][] powmat(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
int n = A.Length, m = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
int n = A.Length, m = B[0].Length, l = B.Length;
var ans = new long [n][];
for (int i = 0; i < n; i++) {
ans[i] = new long[m];
for (int j = 0; j < m; j++)
for (int k = 0; k < l; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long[] addmat(long[] x, long[] y) {
int n = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
ans[i] = (x[i] + y[i]) % Mod;
return ans;
}
public long[][] addmat(long[][] A, long[][] B) {
int n = A.Length, m = A[0].Length;
var ans = new long [n][];
for (int i = 0; i < n; i++)
ans[i] = addmat(A[i], B[i]);
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long inv(long a) { return powmod(a, Mod - 2); }
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
int n, k;
sc.Multi(out n, out k);
var edge = new List<int>[n];
var a = new int [n - 1][];
for (int i = 0; i < n; i++)
edge[i] = new List<int>();
for (int i = 0; i < n - 1; i++) {
a[i] = sc.IntArr.Select(x => x - 1).ToArray();
edge[a[i][0]].Add(a[i][1]);
edge[a[i][1]].Add(a[i][0]);
}
int lim = k >> 1;
int min = n;
var q = new Queue<int>();
if (k % 2 == 0) {
for (int i = 0; i < n; i++) {
var dist = new int[n];
for (int j = 0; j < n; j++)
dist[j] = -1;
int c = 1;
dist[i] = 0;
q.Enqueue(i);
while (q.Any()) {
int p = q.Dequeue();
if (dist[p] >= lim) {
q.Clear();
break;
}
foreach (var item in edge[p]) {
if (dist[item] < 0) {
dist[item] = dist[p] + 1;
++c;
q.Enqueue(item);
}
}
}
min = Math.Min(min, n - c);
}
} else {
foreach (var i in a) {
var dist = new int[n];
for (int j = 0; j < n; j++)
dist[j] = -1;
int c = 2;
dist[i[0]] = 0;
dist[i[1]] = 0;
q.Enqueue(i[0]);
while (q.Any()) {
int p = q.Dequeue();
if (dist[p] >= lim) {
q.Clear();
break;
}
foreach (var item in edge[p]) {
if (dist[item] < 0) {
dist[item] = dist[p] + 1;
++c;
q.Enqueue(item);
}
}
}
q.Enqueue(i[1]);
while (q.Any()) {
int p = q.Dequeue();
if (dist[p] >= lim) {
q.Clear();
break;
}
foreach (var item in edge[p]) {
if (dist[item] < 0) {
dist[item] = dist[p] + 1;
++c;
q.Enqueue(item);
}
}
}
min = Math.Min(min, n - c);
}
}
sw.WriteLine(min);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
T cv<T>(string inp) {
if (typeof(T).Equals(typeof(int)))
return (T)Convert.ChangeType(int.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(long)))
return (T)Convert.ChangeType(long.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(double)))
return (T)Convert.ChangeType(double.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(char)))
return (T)Convert.ChangeType(inp[0], typeof(T));
return (T)Convert.ChangeType(inp, typeof(T));
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public bool[] sieve(int n) {
var isp = new bool[n + 1];
for (int i = 2; i <= n; i++)
isp[i] = true;
for (int i = 2; i * i <= n; i++)
if (isp[i])
for (int j = i * i; j <= n; j += i)
isp[j] = false;
return isp;
}
public List<int> getprimes(int n) {
var prs = new List<int>();
var isp = sieve(n);
for (int i = 2; i <= n; i++)
if (isp[i])
prs.Add(i);
return prs;
}
public long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public long[][] powmat(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
int n = A.Length, m = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
int n = A.Length, m = B[0].Length, l = B.Length;
var ans = new long [n][];
for (int i = 0; i < n; i++) {
ans[i] = new long[m];
for (int j = 0; j < m; j++)
for (int k = 0; k < l; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long[] addmat(long[] x, long[] y) {
int n = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
ans[i] = (x[i] + y[i]) % Mod;
return ans;
}
public long[][] addmat(long[][] A, long[][] B) {
int n = A.Length, m = A[0].Length;
var ans = new long [n][];
for (int i = 0; i < n; i++)
ans[i] = addmat(A[i], B[i]);
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long inv(long a) { return powmod(a, Mod - 2); }
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
[["+", 0, 52, 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], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25]]
| 8
| 2,805
| 24
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;
public class Program {
static readonly int Mod = (int)1e9 + 7;
static void Add(ref int a, int b) {
if ((a += b) >= Mod)
a -= Mod;
}
public void Solve() {
int N = Reader.Int();
var table = Reader.IntTable(N);
int MaxVal = table.Max(t => Math.Max(t[0], t[1]));
var dp = new int[MaxVal * 2 + 2, MaxVal * 2 + 2];
foreach (var t in table)
dp[MaxVal - t[0], MaxVal - t[1]]++;
for (int a = 0; a <= MaxVal * 2; a++)
for (int b = 0; b <= MaxVal * 2; b++) {
Add(ref dp[a + 1, b], dp[a, b]);
Add(ref dp[a, b + 1], dp[a, b]);
}
InitFactorial(MaxVal * 4, Mod);
long ans = 0;
foreach (var t in table) {
ans += dp[t[0] + MaxVal, t[1] + MaxVal];
ans -= ModC((t[0] + t[1]) * 2, t[0] * 2, Mod);
}
ans = (int)(ans % Mod * ModPower(2, Mod - 2, Mod) % Mod);
Console.WriteLine(ans);
}
static long ModPower(long x, long n, long mod) // x ^ n
{
long res = 1;
while (n > 0) {
if ((n & 1) == 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
long[] Fact;
void InitFactorial(long n, long mod) {
Fact = new long[n + 1];
Fact[0] = 1 % mod;
for (long i = 1; i <= n; i++)
Fact[i] = Fact[i - 1] * i % mod;
}
long ModC(long n, long k, long mod) {
if (n < 0 || k < 0 || k > n)
return 0;
long e1, e2, e3;
long a1 = ModFactorial(n, mod, out e1);
long a2 = ModFactorial(k, mod, out e2);
long a3 = ModFactorial(n - k, mod, out e3);
if (e1 > e2 + e3)
return 0;
return a1 * ModInverse(a2 * a3 % mod, mod) % mod;
}
// n! = a * mod^e
long ModFactorial(long n, long mod, out long e) {
e = 0;
if (n == 0)
return 1;
long res = ModFactorial(n / mod, mod, out e);
e += n / mod;
if (n / mod % 2 != 0)
return res * (mod - Fact[n % mod]) % mod;
return res * Fact[n % mod] % mod;
}
long ModInverse(long N, long mod) {
long x = 0, y = 0;
N = (N % mod + mod) % mod;
ExtGCD(N, mod, ref x, ref y);
return (x % mod + mod) % mod;
}
long ExtGCD(long a, long b, ref long x, ref long y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long res = ExtGCD(b, a % b, ref y, ref x);
y -= (a / b) * x;
return res;
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
static string[] Split(string s) { return s.Split(separator, op); }
static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;
public class Program {
static readonly int Mod = (int)1e9 + 7;
static void Add(ref int a, int b) {
if ((a += b) >= Mod)
a -= Mod;
}
public void Solve() {
int N = Reader.Int();
var table = Reader.IntTable(N);
int MaxVal = table.Max(t => Math.Max(t[0], t[1]));
var dp = new int[MaxVal * 2 + 2, MaxVal * 2 + 2];
foreach (var t in table)
dp[MaxVal - t[0], MaxVal - t[1]]++;
for (int a = 0; a <= MaxVal * 2; a++)
for (int b = 0; b <= MaxVal * 2; b++) {
Add(ref dp[a + 1, b], dp[a, b]);
Add(ref dp[a, b + 1], dp[a, b]);
}
InitFactorial(MaxVal * 4, Mod);
long ans = 0;
foreach (var t in table) {
ans += dp[t[0] + MaxVal, t[1] + MaxVal];
ans -= ModC((t[0] + t[1]) * 2, t[0] * 2, Mod);
}
ans = (ans % Mod * ModPower(2, Mod - 2, Mod) % Mod + Mod) % Mod;
Console.WriteLine(ans);
}
static long ModPower(long x, long n, long mod) // x ^ n
{
long res = 1;
while (n > 0) {
if ((n & 1) == 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
long[] Fact;
void InitFactorial(long n, long mod) {
Fact = new long[n + 1];
Fact[0] = 1 % mod;
for (long i = 1; i <= n; i++)
Fact[i] = Fact[i - 1] * i % mod;
}
long ModC(long n, long k, long mod) {
if (n < 0 || k < 0 || k > n)
return 0;
long e1, e2, e3;
long a1 = ModFactorial(n, mod, out e1);
long a2 = ModFactorial(k, mod, out e2);
long a3 = ModFactorial(n - k, mod, out e3);
if (e1 > e2 + e3)
return 0;
return a1 * ModInverse(a2 * a3 % mod, mod) % mod;
}
// n! = a * mod^e
long ModFactorial(long n, long mod, out long e) {
e = 0;
if (n == 0)
return 1;
long res = ModFactorial(n / mod, mod, out e);
e += n / mod;
if (n / mod % 2 != 0)
return res * (mod - Fact[n % mod]) % mod;
return res * Fact[n % mod] % mod;
}
long ModInverse(long N, long mod) {
long x = 0, y = 0;
N = (N % mod + mod) % mod;
ExtGCD(N, mod, ref x, ref y);
return (x % mod + mod) % mod;
}
long ExtGCD(long a, long b, ref long x, ref long y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long res = ExtGCD(b, a % b, ref y, ref x);
y -= (a / b) * x;
return res;
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
static string[] Split(string s) { return s.Split(separator, op); }
static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25], ["-", 0, 1, 0, 11, 12, 74, 51, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 1,309
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var S = sc.ReadStr();
var stack = new Stack<char>();
foreach (var c in S) {
if (c == 'B') {
if (stack.Count > 0)
stack.Pop();
} else {
stack.Push(c);
}
}
var ans = new string(stack.ToArray());
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 S = sc.ReadStr();
var s = new Stack<char>();
foreach (var c in S) {
if (c == 'B') {
if (s.Count > 0)
s.Pop();
} else {
s.Push(c);
}
}
var ans = new string(s.Reverse().ToArray());
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, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["-", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["-", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25]]
| 8
| 1,084
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;
class Program {
public static void Main() {
var n = String().ToCharArray();
string s = "";
foreach (var c in n) {
if (c == 'B') {
if (s != "") {
s.Substring(0, s.Length - 1);
}
} else {
s += c.ToString();
}
}
WriteLine($"{s}");
}
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
}
public static int Int() {
if (queue.Count == 0)
Enqueue();
return int.Parse(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0)
Enqueue();
return long.Parse(queue.Dequeue());
}
public static double Double() {
if (queue.Count == 0)
Enqueue();
return double.Parse(queue.Dequeue());
}
public static string String() {
if (queue.Count == 0)
Enqueue();
return queue.Dequeue();
}
public static int[] IntArray() {
return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
}
public static long[] LongArray() {
return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
}
public static double[] DoubleArray() {
return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
}
public static string[] StringArray() { return ReadLine().Split(' '); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;
class Program {
public static void Main() {
var n = String().ToCharArray();
string s = "";
foreach (char c in n) {
if (c == 'B') {
if (s.Length > 0) {
s = s.Substring(0, s.Length - 1);
}
} else {
s += c.ToString();
}
}
WriteLine($"{s}");
}
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
}
public static int Int() {
if (queue.Count == 0)
Enqueue();
return int.Parse(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0)
Enqueue();
return long.Parse(queue.Dequeue());
}
public static double Double() {
if (queue.Count == 0)
Enqueue();
return double.Parse(queue.Dequeue());
}
public static string String() {
if (queue.Count == 0)
Enqueue();
return queue.Dequeue();
}
public static int[] IntArray() {
return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
}
public static long[] LongArray() {
return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
}
public static double[] DoubleArray() {
return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
}
public static string[] StringArray() { return ReadLine().Split(' '); }
}
|
[["-", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 39, 199], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 79], ["-", 64, 196, 0, 57, 15, 16, 12, 5, 0, 62], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32]]
| 8
| 445
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class GFG {
static public void Main() {
try {
var n = Console.ReadLine();
// var input1 = Console.ReadLine().Split(' ');
// var n = int.Parse(input1[0]);
// var L = int.Parse(input1[1]);
// var aar = Console.ReadLine().Split(' ').Select(x =>
// Int32.Parse(x)).ToArray();
UnHappy(n);
} catch (Exception ex) {
Console.Write(ex);
}
}
static void UnHappy(string n) {
var s = n.ToCharArray();
StringBuilder ans = new StringBuilder();
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'B') {
ans.Remove(ans.Length - 1, 1);
} else {
ans = ans.Append(s[i]);
}
}
Console.Write(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class GFG {
static public void Main() {
try {
var n = Console.ReadLine();
// var input1 = Console.ReadLine().Split(' ');
// var n = int.Parse(input1[0]);
// var L = int.Parse(input1[1]);
// var aar = Console.ReadLine().Split(' ').Select(x =>
// Int32.Parse(x)).ToArray();
UnHappy(n);
} catch (Exception ex) {
Console.Write(ex);
}
}
static void UnHappy(string n) {
var s = n.ToCharArray();
StringBuilder ans = new StringBuilder();
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'B') {
if (ans.Length >= 1)
ans.Remove(ans.Length - 1, 1);
} else {
ans = ans.Append(s[i]);
}
}
Console.Write(ans);
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25]]
| 8
| 161
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionB {
public static void Main(string[] args) {
// 文字列の入力
string s = Console.ReadLine();
// 整数の入力
// long n = long.Parse(Console.ReadLine());
// 文字列配列の入力
// string[] inputStrArray = Console.ReadLine().Split(' ');
// 整数配列の入力
// var inputLongArray = Console.ReadLine().Split(' ').Select(i =>
// long.Parse(i)).ToArray();
int a = s.Length;
string result = "";
for (int i = 0; i <= s.Length - 1; i++) {
if (s[i] == 'B') {
continue;
}
if (s[i] == '0') {
result += s[i];
} else if (s[i] == '1') {
result += s[i];
} else {
if (result.Length > 0) {
result = result.Remove(result.Length - 1, 1);
}
}
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionB {
public static void Main(string[] args) {
// 文字列の入力
string s = Console.ReadLine();
// 整数の入力
// long n = long.Parse(Console.ReadLine());
// 文字列配列の入力
// string[] inputStrArray = Console.ReadLine().Split(' ');
// 整数配列の入力
// var inputLongArray = Console.ReadLine().Split(' ').Select(i =>
// long.Parse(i)).ToArray();
int a = s.Length;
string result = "";
for (int i = 0; i <= s.Length - 1; i++) {
if (s[i] == '0') {
result += s[i];
} else if (s[i] == '1') {
result += s[i];
} else {
if (result.Length > 0) {
result = result.Remove(result.Length - 1, 1);
}
}
}
Console.WriteLine(result);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 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, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60]]
| 8
| 190
| 15
|
using System;
class Program {
static void Main(string[] args) {
string a, b, c;
a = Console.ReadLine(); //標準入力
// string[] str = Console.ReadLine().Split('
// ');//2つ以上のスペース区切り入力の取得 b = int.Parse(str[0]);
// //数値で受け取りたい場合は変換する c = int.Parse(str[1]);
// Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
// Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b,
// c);//改行付き出力 string a = "10B10";
string result = "";
int position = 0;
for (int i = 0; i < a.Length; i++) {
string s1 = a.Substring(i, 1);
// Console.Write(s1);
if (s1 == "0" || s1 == "1") {
result += s1;
position++;
} else {
result = result.Remove(position - 1);
position--;
}
// Console.WriteLine(result);
}
Console.WriteLine(result);
// Console.ReadKey();
}
}
|
using System;
class Program {
static void Main(string[] args) {
string a, b, c;
a = Console.ReadLine(); //標準入力
// string[] str = Console.ReadLine().Split('
// ');//2つ以上のスペース区切り入力の取得 b = int.Parse(str[0]);
// //数値で受け取りたい場合は変換する c = int.Parse(str[1]);
// Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
// Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b,
// c);//改行付き出力 string a = "10B10";
string result = "";
int position = 0;
for (int i = 0; i < a.Length; i++) {
string s1 = a.Substring(i, 1);
// Console.Write(s1);
if (s1 == "0" || s1 == "1") {
result += s1;
position++;
} else {
if (position != 0) {
result = result.Remove(position - 1);
position--;
}
}
// Console.WriteLine(result);
}
Console.WriteLine(result);
}
}
|
[["-", 0, 208, 0, 235, 8, 201, 0, 195, 8, 196], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 197], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 198], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 199, 0, 200], ["-", 0, 197, 0, 198, 39, 199, 0, 200, 0, 200], ["-", 0, 198, 39, 199, 0, 200, 0, 200, 0, 200], ["-", 39, 199, 0, 200, 0, 200, 0, 200, 0, 1], ["-", 0, 200, 0, 200, 0, 200, 0, 1, 0, 11], ["-", 0, 200, 0, 200, 0, 1, 0, 11, 31, 22], ["-", 0, 200, 0, 1, 0, 11, 31, 22, 0, 202], ["-", 0, 1, 0, 11, 31, 22, 0, 202, 12, 213], ["-", 0, 11, 31, 22, 0, 202, 12, 213, 0, 169], ["-", 31, 22, 0, 202, 12, 213, 0, 169, 0, 169], ["-", 0, 202, 12, 213, 0, 169, 0, 169, 0, 169], ["-", 12, 213, 0, 169, 0, 169, 0, 169, 0, 169], ["-", 0, 169, 0, 169, 0, 169, 0, 169, 0, 169], ["-", 0, 169, 0, 169, 0, 169, 0, 169, 0, 197], ["-", 0, 169, 0, 169, 0, 169, 0, 197, 0, 198], ["-", 0, 169, 0, 169, 0, 197, 0, 198, 39, 199], ["-", 0, 169, 0, 197, 0, 198, 39, 199, 0, 200], ["-", 0, 197, 0, 198, 39, 199, 0, 200, 0, 197], ["-", 0, 198, 39, 199, 0, 200, 0, 197, 0, 198], ["-", 39, 199, 0, 200, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 197, 0, 198, 39, 199, 0, 200], ["-", 0, 197, 0, 198, 39, 199, 0, 200, 0, 7], ["-", 0, 198, 39, 199, 0, 200, 0, 7, 10, 198], ["-", 39, 199, 0, 200, 0, 7, 10, 198, 39, 199], ["-", 0, 200, 0, 7, 10, 198, 39, 199, 0, 200], ["-", 0, 7, 10, 198, 39, 199, 0, 200, 15, 16], ["-", 10, 198, 39, 199, 0, 200, 15, 16, 31, 22], ["-", 39, 199, 0, 200, 15, 16, 31, 22, 12, 214], ["-", 0, 200, 15, 16, 31, 22, 12, 214, 26, 223], ["-", 15, 16, 31, 22, 12, 214, 26, 223, 0, 22], ["-", 31, 22, 12, 214, 26, 223, 0, 22, 8, 196], ["-", 12, 214, 26, 223, 0, 22, 8, 196, 0, 197], ["-", 26, 223, 0, 22, 8, 196, 0, 197, 0, 169], ["-", 0, 22, 8, 196, 0, 197, 0, 169, 0, 57], ["-", 8, 196, 0, 197, 0, 169, 0, 57, 0, 169], ["-", 0, 197, 0, 169, 0, 57, 0, 169, 0, 1], ["-", 0, 169, 0, 57, 0, 169, 0, 1, 0, 213], ["-", 0, 57, 0, 169, 0, 1, 0, 213, 63, 214], ["-", 0, 169, 0, 1, 0, 213, 63, 214, 3, 4], ["-", 0, 1, 0, 213, 63, 214, 3, 4, 0, 169], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 8, 196], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 197], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 198], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 199, 0, 200], ["+", 0, 197, 0, 198, 39, 199, 0, 200, 0, 200], ["+", 0, 198, 39, 199, 0, 200, 0, 200, 0, 200], ["+", 39, 199, 0, 200, 0, 200, 0, 200, 0, 1], ["+", 0, 200, 0, 200, 0, 200, 0, 1, 0, 11], ["+", 0, 200, 0, 200, 0, 1, 0, 11, 31, 22], ["+", 0, 200, 0, 1, 0, 11, 31, 22, 0, 202], ["+", 0, 1, 0, 11, 31, 22, 0, 202, 12, 213], ["+", 0, 11, 31, 22, 0, 202, 12, 213, 0, 169], ["+", 31, 22, 0, 202, 12, 213, 0, 169, 0, 169], ["+", 0, 202, 12, 213, 0, 169, 0, 169, 0, 169], ["+", 12, 213, 0, 169, 0, 169, 0, 169, 0, 169], ["+", 0, 169, 0, 169, 0, 169, 0, 169, 0, 169], ["+", 0, 169, 0, 169, 0, 169, 0, 169, 0, 197], ["+", 0, 169, 0, 169, 0, 169, 0, 197, 0, 198], ["+", 0, 169, 0, 169, 0, 197, 0, 198, 39, 199], ["+", 0, 169, 0, 197, 0, 198, 39, 199, 0, 200], ["+", 0, 197, 0, 198, 39, 199, 0, 200, 0, 197], ["+", 0, 198, 39, 199, 0, 200, 0, 197, 0, 198], ["+", 39, 199, 0, 200, 0, 197, 0, 198, 39, 199], ["+", 0, 200, 0, 197, 0, 198, 39, 199, 0, 200], ["+", 0, 197, 0, 198, 39, 199, 0, 200, 0, 7], ["+", 0, 198, 39, 199, 0, 200, 0, 7, 10, 198], ["+", 39, 199, 0, 200, 0, 7, 10, 198, 39, 199], ["+", 0, 200, 0, 7, 10, 198, 39, 199, 0, 200], ["+", 0, 7, 10, 198, 39, 199, 0, 200, 15, 16], ["+", 10, 198, 39, 199, 0, 200, 15, 16, 31, 22], ["+", 39, 199, 0, 200, 15, 16, 31, 22, 12, 214], ["+", 0, 200, 15, 16, 31, 22, 12, 214, 26, 223], ["+", 15, 16, 31, 22, 12, 214, 26, 223, 0, 22], ["+", 31, 22, 12, 214, 26, 223, 0, 22, 8, 196], ["+", 12, 214, 26, 223, 0, 22, 8, 196, 0, 197], ["+", 26, 223, 0, 22, 8, 196, 0, 197, 0, 169], ["+", 0, 22, 8, 196, 0, 197, 0, 169, 0, 57], ["+", 8, 196, 0, 197, 0, 169, 0, 57, 0, 169], ["+", 0, 197, 0, 169, 0, 57, 0, 169, 0, 1], ["+", 0, 169, 0, 57, 0, 169, 0, 1, 0, 213], ["+", 0, 57, 0, 169, 0, 1, 0, 213, 63, 214], ["+", 0, 169, 0, 1, 0, 213, 63, 214, 3, 4], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 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], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 132
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCode {
class Class1 {
static void Main(string[] args) {
string Input = Console.ReadLine();
char Command;
string Output = null;
for (int i = 0; i < Input.Length; i++) {
Command = Input[i];
if (Command == '0') {
Output += "0";
} else if (Command == '1') {
Output += "1";
} else if (Command == 'B') {
if (Output.Length != 0) {
Output = Output.Remove(Output.Length - 1);
}
}
}
Console.WriteLine(Output);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCode {
class Class1 {
static void Main(string[] args) {
string Input = Console.ReadLine();
char Command;
string Output = null;
int cnt = 0;
for (int i = 0; i < Input.Length; i++) {
Command = Input[i];
if (Command == '0') {
Output += "0";
cnt++;
} else if (Command == '1') {
Output += "1";
cnt++;
} else if (Command == 'B') {
if (cnt != 0) {
Output = Output.Remove(Output.Length - 1);
cnt--;
}
}
}
Console.WriteLine(Output);
}
}
}
|
[["+", 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, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 75, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 75, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 64, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["-", 64, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 75, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68]]
| 8
| 155
| 18
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace contest {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
string result = "";
foreach (var s in S) {
switch (s) {
case '0':
result += "0";
break;
case '1':
result += "1";
break;
case 'B':
result = result.Substring(0, result.Length - 1);
break;
}
}
Console.WriteLine(result);
Console.ReadLine();
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace contest {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
string result = "";
foreach (var s in S) {
switch (s) {
case '0':
result += "0";
break;
case '1':
result += "1";
break;
case 'B':
if (result != "") {
result = result.Substring(0, result.Length - 1);
}
break;
}
}
Console.WriteLine(result);
Console.ReadLine();
}
}
}
|
[["+", 0, 99, 8, 254, 0, 239, 0, 57, 0, 121], ["+", 0, 99, 8, 254, 0, 239, 0, 57, 0, 24], ["+", 8, 254, 0, 239, 0, 57, 15, 16, 17, 79], ["+", 0, 239, 0, 57, 15, 16, 12, 5, 0, 62], ["+", 0, 99, 8, 254, 0, 239, 0, 57, 0, 25], ["+", 8, 254, 0, 239, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 254, 0, 239, 0, 57, 64, 196, 0, 46]]
| 8
| 147
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace atcoder {
public class problem {
public static void Main(string[] args) {
string s = Console.ReadLine();
string output = "";
int slength = 0;
for (int i = 0; i < s.Length; i++) {
if (s[i] == '0')
output += "0";
else if (s[i] == '1')
output += "1";
else {
if (slength != 0)
output = output.Remove(slength - 1);
}
Console.WriteLine(output);
slength = output.Length;
}
Console.WriteLine(output);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace atcoder {
public class problem {
public static void Main(string[] args) {
string s = Console.ReadLine();
string output = "";
int slength = 0;
for (int i = 0; i < s.Length; i++) {
if (s[i] == '0')
output += "0";
else if (s[i] == '1')
output += "1";
else {
if (slength != 0)
output = output.Remove(slength - 1);
}
slength = output.Length;
}
Console.WriteLine(output);
}
}
}
|
[["-", 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
| 149
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
Stack<string> s = new Stack<string>();
foreach (var i in input) {
if (i == '1') {
s.Push(i.ToString());
}
if (i == '0') {
s.Push(i.ToString());
}
if (i == 'B' && s.Count() > 0) {
s.Pop();
}
}
var a = "";
for (var i = 0; i <= s.Count(); i++) {
a += s.Pop();
}
Console.WriteLine(string.Join("", a.Reverse()));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
Stack<string> s = new Stack<string>();
foreach (var i in input) {
if (i == '1') {
s.Push(i.ToString());
}
if (i == '0') {
s.Push(i.ToString());
}
if (i == 'B' && s.Count() > 0) {
s.Pop();
}
}
var count = s.Count();
var a = "";
for (var i = 0; i < count; i++) {
a += s.Pop();
}
Console.WriteLine(string.Join("", a.Reverse()));
}
}
|
[["+", 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], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 7, 15, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 7, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 181
| 17
|
using System;
using System.Collections.Generic;
public class Hello {
public static void Main() {
string s = Console.ReadLine();
string ans = "";
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'B') {
ans = ans.Substring(0, ans.Length - 1);
} else {
ans += s[i].ToString();
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
public class Hello {
public static void Main() {
string s = Console.ReadLine();
string ans = "";
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'B') {
if (ans.Length > 0) {
ans = ans.Substring(0, ans.Length - 1);
}
} else {
ans += s[i].ToString();
}
}
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 141, 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
| 105
| 10
|
using System;
using System.Text;
class MainClass {
public static void Main(string[] args) {
string str = Console.ReadLine();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.Length; i++) {
if (str[i] == '0' || str[i] == '1')
sb.Append(str[i]);
else
sb.Remove(sb.Length - 1, 1);
}
Console.WriteLine(sb.ToString());
}
}
|
using System;
using System.Text;
class MainClass {
public static void Main(string[] args) {
string str = Console.ReadLine();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.Length; i++) {
if (str[i] == '0' || str[i] == '1')
sb.Append(str[i]);
else if (sb.ToString() != "")
sb.Remove(sb.Length - 1, 1);
}
Console.WriteLine(sb.ToString());
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 75, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 75, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 75, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 79], ["+", 0, 57, 75, 57, 15, 16, 12, 5, 0, 62], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 75, 57, 64, 1, 0, 213, 63, 214, 205, 22]]
| 8
| 114
| 11
|
using System;
using System.IO;
namespace Atcoder {
class abc043b {
public static void Main() {
string s = Console.ReadLine();
string ans = "";
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'B') {
ans = ans.Substring(0, ans.Length - 1);
} else {
ans += s[i];
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.IO;
namespace Atcoder {
class abc043b {
public static void Main() {
string s = Console.ReadLine();
string ans = "";
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'B') {
if (ans != "") {
ans = ans.Substring(0, ans.Length - 1);
}
} else {
ans += s[i];
}
}
Console.WriteLine(ans);
}
}
}
|
[["+", 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, 17, 79], ["+", 64, 196, 0, 57, 15, 16, 12, 5, 0, 62], ["+", 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, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 102
| 9
|
using System;
using System.Collections.Generic;
using System.IO;
#region Program
namespace Program {
#region Solver
public class Solver {
static IO.StreamScanner sc =
new IO.StreamScanner(Console.OpenStandardInput());
string S;
static readonly char B = 'B';
#region Solver
public Solver() { S = sc.Scan(); }
#endregion
#region Solve
public void Solve() {
Stack<char> s = new Stack<char>();
for (int i = 0; i < S.Length; i++) {
if (S[i] != B)
s.Push(S[i]);
else if (s.Count != 0)
s.Pop();
}
char[] ca = s.ToArray();
for (int i = 0; i < s.Count; i++) {
Console.Write(ca[i]);
}
Console.WriteLine();
}
#endregion
}
#endregion
}
#endregion
#region Execute
class Execute {
public static void Main(string[] args) {
new Program.Solver().Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Program.IO
namespace Program.IO {
using System.Text;
using System.Globalization;
using System.Linq;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public StreamScanner(Stream stream) { str = stream; }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public long Long() {
if (isEof) {
return long.MinValue;
}
long ret = 0;
byte b = 0;
var ng = false;
do {
b = read();
} while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b) {
return ng ? -ret : ret;
} else
ret = ret * 10 + b - '0';
}
}
public long[] Long(int n) { return enumerate(n, Long); }
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public char[] Char(int n) { return enumerate(n, Char); }
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();
}
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++];
}
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.IO;
#region Program
namespace Program {
#region Solver
public class Solver {
static IO.StreamScanner sc =
new IO.StreamScanner(Console.OpenStandardInput());
string S;
static readonly char B = 'B';
#region Solver
public Solver() { S = sc.Scan(); }
#endregion
#region Solve
public void Solve() {
Stack<char> s = new Stack<char>();
for (int i = 0; i < S.Length; i++) {
if (S[i] != B)
s.Push(S[i]);
else if (s.Count != 0)
s.Pop();
}
char[] ca = s.ToArray();
for (int i = s.Count - 1; 0 <= i; i--) {
Console.Write(ca[i]);
}
Console.WriteLine();
}
#endregion
}
#endregion
}
#endregion
#region Execute
class Execute {
public static void Main(string[] args) {
new Program.Solver().Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Program.IO
namespace Program.IO {
using System.Text;
using System.Globalization;
using System.Linq;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public StreamScanner(Stream stream) { str = stream; }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public long Long() {
if (isEof) {
return long.MinValue;
}
long ret = 0;
byte b = 0;
var ng = false;
do {
b = read();
} while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b) {
return ng ? -ret : ret;
} else
ret = ret * 10 + b - '0';
}
}
public long[] Long(int n) { return enumerate(n, Long); }
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public char[] Char(int n) { return enumerate(n, Char); }
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();
}
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++];
}
}
}
#endregion
|
[["-", 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], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68]]
| 8
| 931
| 12
|
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var s = Console.ReadLine();
var ret = "";
for (int i = 0; i < s.Length; i++) {
if (s[i] == '0')
ret += "0";
if (s[i] == '1')
ret += "1";
if (s[i] == 'B' && ret.Length > 0)
ret = ret.Substring(0, ret.Length - 1);
}
Console.WriteLine(ret);
}
}
}
|
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var s = Console.ReadLine();
var ret = "";
for (int i = 0; i < s.Length; i++) {
if (s[i] == '0')
ret += "0";
if (s[i] == '1')
ret += "1";
if (s[i] == 'B' && ret.Length > 0)
ret = ret.Substring(0, ret.Length - 1);
}
Console.WriteLine(ret);
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
| 182
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
// 文字列の入力
// string s = Console.ReadLine();
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 文字列配列の入力
// string[] inputStrArray = Console.ReadLine().Split(' ');
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
double ans = 0;
double result = 10000;
for (int i = -100; i <= 100; i++) {
for (int j = 0; j <= n - 1; j++) {
ans += Math.Pow(inputLongArray[j] - i, 2);
}
if (ans < result) {
result = ans;
}
ans = 0;
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
// 文字列の入力
// string s = Console.ReadLine();
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 文字列配列の入力
// string[] inputStrArray = Console.ReadLine().Split(' ');
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
double result = int.MaxValue;
for (int i = -100; i <= 100; i++) {
double ans = 0;
for (int j = 0; j <= n - 1; j++) {
ans += Math.Pow(inputLongArray[j] - i, 2);
}
result = Math.Min(result, ans);
}
Console.WriteLine(result);
}
}
}
|
[["-", 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], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 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, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 185
| 33
|
using System;
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
var sa = s.Split(' ');
int[] ia = new int[n];
for (int i = 0; i < ia.Length; i++) {
ia[i] = int.Parse(sa[i]);
}
int total = 0;
for (int i = 0; i < ia.Length; i++) {
total += ia[i];
}
int ave = total / ia.Length;
int diff_total = 0;
for (int i = 0; i < ia.Length; i++) {
diff_total += (int)Math.Pow((ia[i] - ave), 2);
}
Console.WriteLine(diff_total);
}
}
|
using System;
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
var sa = s.Split(' ');
int[] ia = new int[n];
for (int i = 0; i < ia.Length; i++) {
ia[i] = int.Parse(sa[i]);
}
int total = 0;
for (int i = 0; i < ia.Length; i++) {
total += ia[i];
}
int ave = (int)Math.Round((double)total / ia.Length);
int diff_total = 0;
for (int i = 0; i < ia.Length; i++) {
diff_total += (int)Math.Pow((ia[i] - ave), 2);
}
Console.WriteLine(diff_total);
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 74, 51, 213, 3, 4, 0, 24], ["+", 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, 212, 0, 74, 51, 213, 3, 4, 0, 25]]
| 8
| 188
| 11
|
using System;
namespace Unbalanced {
class MainClass {
public static void Main(string[] args) {
var chars = Console.ReadLine().ToCharArray();
for (int i = 0; i < chars.Length; i++) {
// AAのとき
if (chars[i] == chars[i + 1]) {
Console.WriteLine(string.Format("{0} {1}", i + 1, i + 2));
return;
}
// A_Aのとき
if (chars[i] == chars[i + 2]) {
Console.WriteLine(string.Format("{0} {1}", i + 1, i + 3));
return;
}
}
Console.WriteLine("-1 -1");
}
}
}
|
using System;
namespace Unbalanced {
class MainClass {
public static void Main(string[] args) {
var chars = Console.ReadLine().ToCharArray();
for (int i = 0; i < chars.Length; i++) {
// AAのとき
if (chars.Length <= i + 1) {
break;
}
if (chars[i] == chars[i + 1]) {
Console.WriteLine(string.Format("{0} {1}", i + 1, i + 2));
return;
}
// A_Aのとき
if (chars.Length <= i + 2) {
break;
}
if (chars[i] == chars[i + 2]) {
Console.WriteLine(string.Format("{0} {1}", i + 1, i + 3));
return;
}
}
Console.WriteLine("-1 -1");
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22]]
| 8
| 145
| 28
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.