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; namespace Panasonic2020C { class Input { /// <summary> /// 1行の入力を取得する /// </summary> /// <returns>文字列</returns> public void String(out string s) { s = Console.ReadLine(); } /// <summary> /// 複数行の入力を取得 /// </summary> /// <returns>文字列の配列</returns> public void String(long rowNumber, out string[] s) { s = new String[rowNumber]; for (long i = 0; i < rowNumber; i++) { String(out s[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>int型の値</returns> public void Int(out int i) { string s; String(out s); i = int.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <param name="a"></param> public void Long(out long a) { string s; String(out s); a = long.Parse(s); } /// <summary> /// 2つの整数が1行に書かれている入力を、2つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> public void Long(out long a, out long b) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; } /// <summary> /// 3つの整数が1行に書かれている入力を、3つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(out long a, out long b, out long c) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; } /// <summary> /// 4つの整数が1行に書かれている入力を、4つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(out long a, out long b, out long c, out long d) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; d = lArr[3]; } public void Long(out long[] lArr) { lArr = Split().Select(long.Parse).ToArray(); } public void Long(long rowNumber, out long[] lArr) { lArr = new long[rowNumber]; for (long i = 0; i < rowNumber; i++) { Long(out lArr[i]); } } /// <summary> /// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> public void Long(long rowNumber, out long[] a, out long[] b) { a = new long[rowNumber]; b = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i]); } } /// <summary> /// 3つの整数が複数行に書かれている入力を、3つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i]); } } /// <summary> /// 4つの整数が複数行に書かれている入力を、4つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c, out long[] d) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; d = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i], out d[i]); } } /// <summary> /// h行w列のLongのmapを入力する /// </summary> /// <param name="h"></param> /// <param name="w"></param> /// <param name="a"></param> public void Long(long h, long w, out long[][] a) { a = new long [h][]; for (long i = 0; i < h; i++) { Long(out a[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の値</returns> public void Double(out double d) { string s; String(out s); d = double.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の配列</returns> public void Double(out double[] dArr) { dArr = Split().Select(double.Parse).ToArray(); } private IEnumerable<string> Split() { string s; String(out s); return s.Split(' '); } } class Program { public static void Main(string[] args) { Solver solver = new Solver(); solver.Solve(); } } class Solver { private Input input; public Solver() { input = new Input(); input.Long(out a, out b, out c); } private long a; private long b; private long c; public void Solve() { Console.WriteLine((c - a - b) * (c - a - b) - 4 * a * b > 0 ? "Yes" : "No"); } } }
using System; using System.Collections.Generic; using System.Linq; namespace Panasonic2020C { class Input { /// <summary> /// 1行の入力を取得する /// </summary> /// <returns>文字列</returns> public void String(out string s) { s = Console.ReadLine(); } /// <summary> /// 複数行の入力を取得 /// </summary> /// <returns>文字列の配列</returns> public void String(long rowNumber, out string[] s) { s = new String[rowNumber]; for (long i = 0; i < rowNumber; i++) { String(out s[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>int型の値</returns> public void Int(out int i) { string s; String(out s); i = int.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <param name="a"></param> public void Long(out long a) { string s; String(out s); a = long.Parse(s); } /// <summary> /// 2つの整数が1行に書かれている入力を、2つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> public void Long(out long a, out long b) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; } /// <summary> /// 3つの整数が1行に書かれている入力を、3つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(out long a, out long b, out long c) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; } /// <summary> /// 4つの整数が1行に書かれている入力を、4つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(out long a, out long b, out long c, out long d) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; d = lArr[3]; } public void Long(out long[] lArr) { lArr = Split().Select(long.Parse).ToArray(); } public void Long(long rowNumber, out long[] lArr) { lArr = new long[rowNumber]; for (long i = 0; i < rowNumber; i++) { Long(out lArr[i]); } } /// <summary> /// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> public void Long(long rowNumber, out long[] a, out long[] b) { a = new long[rowNumber]; b = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i]); } } /// <summary> /// 3つの整数が複数行に書かれている入力を、3つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i]); } } /// <summary> /// 4つの整数が複数行に書かれている入力を、4つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c, out long[] d) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; d = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i], out d[i]); } } /// <summary> /// h行w列のLongのmapを入力する /// </summary> /// <param name="h"></param> /// <param name="w"></param> /// <param name="a"></param> public void Long(long h, long w, out long[][] a) { a = new long [h][]; for (long i = 0; i < h; i++) { Long(out a[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の値</returns> public void Double(out double d) { string s; String(out s); d = double.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の配列</returns> public void Double(out double[] dArr) { dArr = Split().Select(double.Parse).ToArray(); } private IEnumerable<string> Split() { string s; String(out s); return s.Split(' '); } } class Program { public static void Main(string[] args) { Solver solver = new Solver(); solver.Solve(); } } class Solver { private Input input; public Solver() { input = new Input(); input.Long(out a, out b, out c); } private long a; private long b; private long c; public void Solve() { if (c - a - b < 0) { Console.WriteLine("No"); return; } Console.WriteLine((c - a - b) * (c - a - b) - 4 * a * b > 0 ? "Yes" : "No"); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 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, 18], ["+", 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, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 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, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
8
967
23
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) { long a, b, c; sc.Make(out a, out b, out c); if (4 * a * b < (c - a - b) * (c - a - b)) Fail("Yes"); else WriteLine("No"); } } #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; } 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) { long a, b, c; sc.Make(out a, out b, out c); if (c - a - b < 0) Fail("No"); if (4 * a * b < (c - a - b) * (c - a - b)) Fail("Yes"); else WriteLine("No"); } } #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; } public static T[] Shuffle<T>(this IList<T> A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; } public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); } } public class Scanner { public string Str => Console.ReadLine().Trim(); public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray(); public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray(); public char[][] Grid(int n) => Create(n, () => Str.ToCharArray()); public int[] ArrInt1D(int n) => Create(n, () => Int); public long[] ArrLong1D(int n) => Create(n, () => Long); public int[][] ArrInt2D(int n) => Create(n, () => ArrInt); public long[][] ArrLong2D(int n) => Create(n, () => ArrLong); private Queue<string> q = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); } public void Make<T1>(out T1 v1) => v1 = Next<T1>(); public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); } public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); } public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); } public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); } public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); } // public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, // v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, // out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3, // T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, // v3, v4); } } public class Pair<T1, T2> : IComparable<Pair<T1, T2>> { public T1 v1; public T2 v2; public Pair() {} public Pair(T1 v1, T2 v2) { this.v1 = v1; this.v2 = v2; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(Pair<T1, T2> p) { var c = Comparer<T1>.Default.Compare(v1, p.v1); if (c == 0) c = Comparer<T2>.Default.Compare(v2, p.v2); return c; } public override string ToString() => $"{v1.ToString()} {v2.ToString()}"; public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; } } public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> { public T3 v3; public Pair() : base() {} public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(Pair<T1, T2, T3> p) { var c = base.CompareTo(p); if (c == 0) c = Comparer<T3>.Default.Compare(v3, p.v3); return c; } public override string ToString() => $"{base.ToString()} {v3.ToString()}"; public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; } } #endregion
[["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 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, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 213, 63, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24]]
8
1,557
17
/* C# template******************************** 20.08.08 パナソニックプログラミングコンテスト2020. D - String Equivalence 問題文 この問題では、英小文字からなる文字列のみを考えます。 文字列 s,t は以下の条件を満たすとき 同型 であるといいます。 |s|=|t| である。任意の i,j に対し次のいずれかが成立する。si=sj かつ ti=tjsi≠sj かつ ti≠tjたとえば、abcac と zyxzx は同型ですが、abcac と ppppp は同型ではありません。 文字列 s は以下の条件を満たすとき 標準形 であるといいます。 任意の s と同型な文字列 t に対し、s≤t が成立する。ただしここで ≤ は辞書順での比較を表す。 たとえば、abcac は標準形ですが、zyxzx はそれより辞書順で小さい abcac と同型のため標準形ではありません。 整数 N が与えられます。 長さ N の標準形の文字列を全て、辞書順で昇順で出力してください。 N = 1 to 10 a aa ab aaa aab aba abb abc ... 와 같이 출력. *********************************************/ namespace temp_name { using System; using System.Linq; using System.Collections.Generic; using static System.Console; using static IOmacro.CsharpInput; using static IOmacro.CppInput; public class Run { int strLenIn; public void solve(string strNow, char max) { if (strNow.Length == strLenIn) { _writer.WriteLine(strNow); } else { for (char next = 'a'; next <= max; next++) { if (next == max) { solve(strNow + next, (char)(max + 1)); } else { solve(strNow + next, max); } } } } public void proc() { strLenIn = cin; solve("", 'a'); } } } class program { static void Main(string[] args) { // var exStdIn = new // System.IO.StreamReader(@"C:\Users\HAN\Desktop\VSC\input.txt"); // System.Console.SetIn(exStdIn); var run = new temp_name.Run(); run.proc(); } } namespace IOmacro { // 20.06.29 수정 using System; using System.Linq; using System.IO; using System.Collections.Generic; public class CsharpInput { public static StreamWriter _writer = new StreamWriter(Console.OpenStandardOutput()); public const char separator = ' '; public static string _string { get { return Console.ReadLine(); } } public static string[] _stringa { get { return (Console.ReadLine().Split(separator)); } } public static int _int { get { return int.Parse(Console.ReadLine()); } } public static int[] _inta { get { return Console.ReadLine().Split(separator).Select(int.Parse).ToArray(); } } public static long _long { get { return long.Parse(Console.ReadLine()); } } public static long[] _longa { get { return Console.ReadLine().Split(separator).Select(long.Parse).ToArray(); } } public static double _double { get { return double.Parse(Console.ReadLine()); } } public static double[] _doublea { get { return Console.ReadLine().Split(separator).Select(double.Parse).ToArray(); } } } public class CppInput { public static CppInput cin => new CppInput(); public const char separator = ' '; private static readonly Queue<string> _input = new Queue<string>(); private CppInput() {} public static implicit operator string(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return _input.Dequeue(); } public static implicit operator int(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return int.Parse(_input.Dequeue()); } public static implicit operator long(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return long.Parse(_input.Dequeue()); } public static implicit operator double(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return double.Parse(_input.Dequeue()); } } public static class CEnumerableExtension { public delegate void Function<in T>(T val); public static void foreachExtension<T>(this IEnumerable<T> enumerable, Function<T> function) { foreach (var x in enumerable) function(x); } } }
/* C# template******************************** 20.08.08 パナソニックプログラミングコンテスト2020. D - String Equivalence 問題文 この問題では、英小文字からなる文字列のみを考えます。 文字列 s,t は以下の条件を満たすとき 同型 であるといいます。 |s|=|t| である。任意の i,j に対し次のいずれかが成立する。si=sj かつ ti=tjsi≠sj かつ ti≠tjたとえば、abcac と zyxzx は同型ですが、abcac と ppppp は同型ではありません。 文字列 s は以下の条件を満たすとき 標準形 であるといいます。 任意の s と同型な文字列 t に対し、s≤t が成立する。ただしここで ≤ は辞書順での比較を表す。 たとえば、abcac は標準形ですが、zyxzx はそれより辞書順で小さい abcac と同型のため標準形ではありません。 整数 N が与えられます。 長さ N の標準形の文字列を全て、辞書順で昇順で出力してください。 N = 1 to 10 a aa ab aaa aab aba abb abc ... 와 같이 출력. *********************************************/ namespace temp_name { using System; using System.Linq; using System.Collections.Generic; using static System.Console; using static IOmacro.CsharpInput; using static IOmacro.CppInput; public class Run { int strLenIn; public void solve(string strNow, char max) { if (strNow.Length == strLenIn) { WriteLine(strNow); } else { for (char next = 'a'; next <= max; next++) { if (next == max) { solve(strNow + next, (char)(max + 1)); } else { solve(strNow + next, max); } } } } public void proc() { strLenIn = cin; Console.SetOut(_writer); solve("", 'a'); Console.Out.Flush(); } } } class program { static void Main(string[] args) { // var exStdIn = new // System.IO.StreamReader(@"C:\Users\HAN\Desktop\VSC\input.txt"); // System.Console.SetIn(exStdIn); var run = new temp_name.Run(); run.proc(); } } namespace IOmacro { // 20.08.10 수정 using System; using System.Linq; using System.IO; using System.Collections.Generic; public class CsharpInput { public static StreamWriter _writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; public const char separator = ' '; public static string _string { get { return Console.ReadLine(); } } public static string[] _stringa { get { return (Console.ReadLine().Split(separator)); } } public static int _int { get { return int.Parse(Console.ReadLine()); } } public static int[] _inta { get { return Console.ReadLine().Split(separator).Select(int.Parse).ToArray(); } } public static long _long { get { return long.Parse(Console.ReadLine()); } } public static long[] _longa { get { return Console.ReadLine().Split(separator).Select(long.Parse).ToArray(); } } public static double _double { get { return double.Parse(Console.ReadLine()); } } public static double[] _doublea { get { return Console.ReadLine().Split(separator).Select(double.Parse).ToArray(); } } } public class CppInput { public static CppInput cin => new CppInput(); public const char separator = ' '; private static readonly Queue<string> _input = new Queue<string>(); private CppInput() {} public static implicit operator string(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return _input.Dequeue(); } public static implicit operator int(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return int.Parse(_input.Dequeue()); } public static implicit operator long(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return long.Parse(_input.Dequeue()); } public static implicit operator double(CppInput _) { if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension( x => _input.Enqueue(x)); return double.Parse(_input.Dequeue()); } } public static class CEnumerableExtension { public delegate void Function<in T>(T val); public static void foreachExtension<T>(this IEnumerable<T> enumerable, Function<T> function) { foreach (var x in enumerable) function(x); } } }
[["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 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], ["+", 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], ["+", 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
759
22
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; namespace AtCoder { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static long Mod = (long)1e9 + 7; static void Main(string[] args) { SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); var N = Sarray()[0]; var q = new Queue<Tuple<string, long>>(); q.Enqueue(Tuple.Create("a", 1L)); while (true) { var d = q.Dequeue(); var lst = d.Item2 + 1; var c = d.Item1[0]; for (var j = 0; j < lst; ++j) { var nextq = Tuple.Create(d.Item1 + ((char)(c + j)).ToString(), (long)(j + 1)); q.Enqueue(nextq); } if (lst == N) break; } foreach (var d in q) WriteLine(d.Item1); Out.Flush(); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; namespace AtCoder { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static long Mod = (long)1e9 + 7; static void Main(string[] args) { SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); var N = Sarray()[0]; if (N == 1) { WriteLine("a"); Out.Flush(); return; } var q = new Queue<Tuple<string, long>>(); q.Enqueue(Tuple.Create("a", 1L)); while (true) { var d = q.Dequeue(); var lst = d.Item2 + 1; var c = d.Item1[0]; for (var j = 0; j < d.Item2 + 1; ++j) { var nextq = Tuple.Create(d.Item1 + ((char)(c + j)).ToString(), Max(d.Item2, j + 1)); q.Enqueue(nextq); } if (lst == N) break; } foreach (var d in q) WriteLine(d.Item1); Out.Flush(); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 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], ["+", 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], ["-", 0, 52, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 7, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 7, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21]]
8
307
37
using System; using System.Collections.Generic; using System.Windows; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { public class Program { private static string[] _target; private static int N; static void Main(string[] args) { N = Console.ReadLine().ToInt(); _target = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }; var s = new string[N]; Create(0, 0, s); Console.ReadLine(); } private static void Create(int currentNum, int useNum, string[] s) { if (currentNum == N) { Console.WriteLine(string.Join(string.Empty, s)); return; } for (int i = 0; i <= useNum; i++) { s[currentNum] = _target[i]; if (currentNum == 0 || s[currentNum - 1] != _target[i]) { Create(currentNum + 1, useNum + 1, s); } else { Create(currentNum + 1, useNum, s); } } } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double ToDouble(this object obj) { return double.Parse(obj.ToString()); } }
using System; using System.Collections.Generic; using System.Windows; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { public class Program { private static string[] _target; private static int N; static void Main(string[] args) { N = Console.ReadLine().ToInt(); _target = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }; var s = new string[N]; Create(0, 1, s); Console.ReadLine(); } private static void Create(int currentNum, int useNum, string[] s) { if (currentNum == N) { Console.WriteLine(string.Join(string.Empty, s)); return; } for (int i = 0; i < useNum; i++) { s[currentNum] = _target[i]; if (useNum - 1 == i) { Create(currentNum + 1, useNum + 1, s); } else { Create(currentNum + 1, useNum, s); } } } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double ToDouble(this object obj) { return double.Parse(obj.ToString()); } }
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 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, 106], ["-", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["-", 0, 57, 15, 16, 12, 16, 12, 204, 205, 22], ["-", 15, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 15, 16, 12, 16, 12, 204, 206, 207, 0, 73]]
8
340
18
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace D_PANA2020 { class MainClass { static int[] s; static int a; public static void Main(string[] args) { s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse); a = s[0]; var chara = new char[10] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }; // var anslst = new List<Dictionary<string, int>>(); // for (int i = 0; i < a; i++) // { // var myans = new Dictionary<string, int>(); // if (i == 0) // { // myans.Add("a", 1); // anslst.Add(myans); // } // else // { // var mydic = new Dictionary<string, int>(); // foreach (var item in anslst[i-1]) // { // var thiscnt = item.Value; // for (int k = 0; k <= thiscnt; k++) // { // if (k == thiscnt) // { // mydic.Add(item.Key + chara[k], thiscnt + 1); // } // else // { // mydic.Add(item.Key + chara[k], thiscnt); // } // } // } // anslst.Add(mydic); // } // } // foreach(var item in anslst[a-1]){ // WriteLine(item.Key); // } Dfs("a", 'a'); } static void Dfs(string s, char mx) { if (s.Length == a) { WriteLine(s); return; } for (char c = 'a'; c <= mx + 1; c++) { string ss = s + c; Dfs(ss, c); } } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace D_PANA2020 { class MainClass { static int[] s; static int a; public static void Main(string[] args) { s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse); a = s[0]; var chara = new char[10] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }; // var anslst = new List<Dictionary<string, int>>(); // for (int i = 0; i < a; i++) // { // var myans = new Dictionary<string, int>(); // if (i == 0) // { // myans.Add("a", 1); // anslst.Add(myans); // } // else // { // var mydic = new Dictionary<string, int>(); // foreach (var item in anslst[i-1]) // { // var thiscnt = item.Value; // for (int k = 0; k <= thiscnt; k++) // { // if (k == thiscnt) // { // mydic.Add(item.Key + chara[k], thiscnt + 1); // } // else // { // mydic.Add(item.Key + chara[k], thiscnt); // } // } // } // anslst.Add(mydic); // } // } // foreach(var item in anslst[a-1]){ // WriteLine(item.Key); // } Dfs("a", 'a'); } static void Dfs(string s, char mx) { if (s.Length == a) { WriteLine(s); return; } for (char c = 'a'; c <= mx + 1; c++) { string ss = s + c; if (c == mx + 1) { Dfs(ss, c); } else { Dfs(ss, mx); } } } } }
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 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], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 213, 63, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
8
244
20
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static System.Console; using static Program.Input; using static Program.MyMath; using static Program.Const; namespace Program { static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public const long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } public static class Program { public static void Main() { string[] charactors = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k" }; var n = ScanInt(); var s = new Queue<string>(); var i = new Queue<int>(); s.Enqueue("a"); i.Enqueue(1); while (true) { var t = s.Dequeue(); var k = i.Dequeue(); if (k > n) break; if (t.Length == n) WriteLine(t); for (int j = 0; j <= k; j++) { s.Enqueue(t + charactors[j]); i.Enqueue(j + 1); } } } } static class Input { public static void InputLine(out int a, out int b) { var input = ScanIntArray(); a = input[0]; b = input[1]; } public static void InputLine(out int a, out int b, out int c) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out int a, out int b, out int c, out int d) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out long a, out long b) { var input = ScanLongArray(); a = input[0]; b = input[1]; } public static void InputLine(out long a, out long b, out long c) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out long a, out long b, out long c, out long d) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out string a, out string b) { var input = ScanStrArray(); a = input[0]; b = input[1]; } public static int ScanInt() { return int.Parse(ReadLine()); } static public uint ScanUint() { return uint.Parse(ReadLine()); } static public double ScanDouble() { return double.Parse(ReadLine()); } static public long ScanLong() { return long.Parse(ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(ReadLine()); } static public int[] ScanIntArray() { return ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } static public string RegaxReplace(this string arg1, string pattern, string replacement) { return Regex.Replace(arg1, pattern, replacement); } } static class MyMath { static public int CountBit(this long a) { if (a == 0) return 0; int c = 1; for (; a > 1; a /= 2) if (a % 2 == 1) c++; return c; } static public int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } static public long[] CumSum(this long[] a) { var res = new long[a.Length]; long s = 0; for (int i = 0; i < a.Length; i++) res[i] = (s += a[i]); return res; } static public IEnumerable<int> PrimeFactors(this int n) { int tmp = n; for (int i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public IEnumerable<long> PrimeFactors(this long n) { var tmp = n; for (long i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public int Digit(this int n, int d) { if (d < 0) return 0; return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d); } static public int Length(this int n) { if (n < 0) return 0; return (int)Math.Log10(n) + 1; } static public int Top(this int n) { return n.Digit(n.Length() - 1); } public static bool isPrime(this int p) { if (p <= 1) return false; for (int i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static bool isPrime(this long p) { if (p <= 1) return false; for (long i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static long GCD(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) { if (b == 0) { x = 1; y = 0; return a; } var d = extGCD(b, a % b, ref y, ref x); y -= a / b * x; return d; } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static long LCM(long a, long b) { return a * b / GCD(a, b); } public static long Inv(this long a, long m = MOD) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; swap(ref a, ref b); u -= t * v; swap(ref u, ref v); } u %= m; if (u < 0) u += m; return u; } private static void swap(ref long a, ref long b) { var t = a; a = b; b = t; } public static long ModPow(long a, long n, long m = MOD) { long res = 1; while (n > 0) { if (n % 2 == 1) res = (res * a) % m; a = (a * a) % m; n >>= 1; } return res; } } static class MyLinq { public static void Sort(this string[] array) { Array.Sort(array, StringComparer.OrdinalIgnoreCase); } public static void StringSort(this List<string> list) { list.Sort(StringComparer.OrdinalIgnoreCase); } public static string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } public static IEnumerable<TItem> Distinct<TItem, TKey>(this IEnumerable<TItem> source, Func<TItem, TKey> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); var set = new HashSet<TKey>(); foreach (var item in source) if (set.Add(keySelector(item))) yield return item; } } }
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static System.Console; using static Program.Input; using static Program.MyMath; using static Program.Const; namespace Program { static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public const long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } public static class Program { public static void Main() { string[] charactors = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k" }; var n = ScanInt(); var s = new Queue<string>(); var i = new Queue<int>(); s.Enqueue("a"); i.Enqueue(0); while (true) { var t = s.Dequeue(); var k = i.Dequeue(); if (t.Length > n) break; if (t.Length == n) WriteLine(t); for (int j = 0; j <= k + 1; j++) { s.Enqueue(t + charactors[j]); i.Enqueue(j == k + 1 ? j : k); } } } } static class Input { public static void InputLine(out int a, out int b) { var input = ScanIntArray(); a = input[0]; b = input[1]; } public static void InputLine(out int a, out int b, out int c) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out int a, out int b, out int c, out int d) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out long a, out long b) { var input = ScanLongArray(); a = input[0]; b = input[1]; } public static void InputLine(out long a, out long b, out long c) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out long a, out long b, out long c, out long d) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out string a, out string b) { var input = ScanStrArray(); a = input[0]; b = input[1]; } public static int ScanInt() { return int.Parse(ReadLine()); } static public uint ScanUint() { return uint.Parse(ReadLine()); } static public double ScanDouble() { return double.Parse(ReadLine()); } static public long ScanLong() { return long.Parse(ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(ReadLine()); } static public int[] ScanIntArray() { return ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } static public string RegaxReplace(this string arg1, string pattern, string replacement) { return Regex.Replace(arg1, pattern, replacement); } } static class MyMath { static public int CountBit(this long a) { if (a == 0) return 0; int c = 1; for (; a > 1; a /= 2) if (a % 2 == 1) c++; return c; } static public int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } static public long[] CumSum(this long[] a) { var res = new long[a.Length]; long s = 0; for (int i = 0; i < a.Length; i++) res[i] = (s += a[i]); return res; } static public IEnumerable<int> PrimeFactors(this int n) { int tmp = n; for (int i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public IEnumerable<long> PrimeFactors(this long n) { var tmp = n; for (long i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public int Digit(this int n, int d) { if (d < 0) return 0; return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d); } static public int Length(this int n) { if (n < 0) return 0; return (int)Math.Log10(n) + 1; } static public int Top(this int n) { return n.Digit(n.Length() - 1); } public static bool isPrime(this int p) { if (p <= 1) return false; for (int i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static bool isPrime(this long p) { if (p <= 1) return false; for (long i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static long GCD(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) { if (b == 0) { x = 1; y = 0; return a; } var d = extGCD(b, a % b, ref y, ref x); y -= a / b * x; return d; } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static long LCM(long a, long b) { return a * b / GCD(a, b); } public static long Inv(this long a, long m = MOD) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; swap(ref a, ref b); u -= t * v; swap(ref u, ref v); } u %= m; if (u < 0) u += m; return u; } private static void swap(ref long a, ref long b) { var t = a; a = b; b = t; } public static long ModPow(long a, long n, long m = MOD) { long res = 1; while (n > 0) { if (n % 2 == 1) res = (res * a) % m; a = (a * a) % m; n >>= 1; } return res; } } static class MyLinq { public static void Sort(this string[] array) { Array.Sort(array, StringComparer.OrdinalIgnoreCase); } public static void StringSort(this List<string> list) { list.Sort(StringComparer.OrdinalIgnoreCase); } public static string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } public static IEnumerable<TItem> Distinct<TItem, TKey>(this IEnumerable<TItem> source, Func<TItem, TKey> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); var set = new HashSet<TKey>(); foreach (var item in source) if (set.Add(keySelector(item))) yield return item; } } }
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 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], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22]]
8
2,136
14
using System; using System.Collections.Generic; using System.Linq; using static System.Math; using static Panasonic2020.D.Cin; using static Panasonic2020.D.Util; using Pair = Panasonic2020.D.VTuple<long, long>; using Graph = System.Collections.Generic.List<System.Collections.Generic.List<long>>; using System.Text; namespace Panasonic2020 { public class D { public static void Main(string[] args) { DontAutoFlush(); int n = ri; string abc = "abcdefghij"; char[] cur = new char[n]; cur[0] = 'a'; Action<int, int> rec = null; rec = (depth, i) => { if (depth == n) { Console.WriteLine(cur); return; } for (int j = 0; j <= i + 1; j++) { cur[depth] = abc[j]; rec(depth + 1, j); } }; rec(1, 0); Flush(); } public struct VTuple<T1, T2> : System.IComparable<VTuple<T1, T2>>, System.IEquatable<VTuple<T1, T2>> { public T1 First; public T2 Second; public VTuple(T1 a, T2 b) { First = a; Second = b; } public int CompareTo(VTuple<T1, T2> a) { int b = Comparer<T1>.Default.Compare(First, a.First); if (b != 0) return b; return Comparer<T2>.Default.Compare(Second, a.Second); } public override bool Equals(object a) { return a is VTuple<T1, T2> && Equals((VTuple<T1, T2>)a); } public bool Equals(VTuple<T1, T2> a) { return EqualityComparer<T1>.Default.Equals(First, a.First) && EqualityComparer<T2>.Default.Equals(Second, a.Second); } public override int GetHashCode() { int a = First != null ? First.GetHashCode() : 0; int b = Second != null ? Second.GetHashCode() : 0; uint c = ((uint)a << 5) | ((uint)a >> 27); return ((int)c + a) ^ b; } } public class HashMap<K, V> : System.Collections.Generic.Dictionary<K, V> { V i; static Func<V> j = System.Linq.Expressions.Expression .Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V))) .Compile(); public HashMap() {} public HashMap(V a) { i = a; } new public V this[K a] { get { V b; if (TryGetValue(a, out b)) return b; else return base[a] = i != null ? i : j(); } set { base[a] = value; } } } public static class Util { public static readonly long INF = (long)1e17; public readonly static long MOD = (long)1e9 + 7; public readonly static int[] DXY4 = { 0, 1, 0, -1, 0 }; public readonly static int[] DXY8 = { 1, 1, 0, 1, -1, 0, -1, -1, 1 }; public static void DontAutoFlush() { var a = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(a); } public static void Flush() { Console.Out.Flush(); } public static T[] Sort<T>(T[] a) { Array.Sort<T>(a); return a; } public static T[] SortDecend<T>(T[] a) { Array.Sort<T>(a); Array.Reverse(a); return a; } public static void Swap<T>(ref T a, ref T b) { T c = a; a = b; b = c; } public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); } public static void ChMax(ref long a, long b) { if (a < b) a = b; } public static void ChMin(ref long a, long b) { if (a > b) a = b; } public static long ModAdd(long a, long b) { long c = a + b; if (c >= MOD) return c % MOD; return c; } public static long ModMul(long a, long b) { long c = a * b; if (c >= MOD) return c % MOD; return c; } public static void ChModAdd(ref long a, long b) { a += b; if (a >= MOD) a %= MOD; } public static void ChModMul(ref long a, long b) { a *= b; if (a >= MOD) a %= MOD; } public static void FillArray<T>(T[] a, T b) { int c = a.Length; for (int d = 0; d < c; d++) a[d] = b; } public static void FillArray<T>(T[,] a, T b) { int c = a.GetLength(0); int d = a.GetLength(1); for (int e = 0; e < c; e++) for (int f = 0; f < d; f++) { a[e, f] = b; } } public static void FillArray<T>(T[,,] a, T b) { int c = a.GetLength(0); int d = a.GetLength(1); int e = a.GetLength(2); for (int f = 0; f < c; f++) for (int g = 0; g < d; g++) { for (int h = 0; h < e; h++) { a[f, g, h] = b; } } } public static long[] Accumulate(long[] a) { long[] b = new long[a.Length + 1]; for (int c = 0; c < a.Length; c++) b[c + 1] = b[c] + a[c]; return b; } public static double[] Accumulate(double[] a) { double[] b = new double[a.Length + 1]; for (int c = 0; c < a.Length; c++) b[c + 1] = b[c] + a[c]; return b; } } public static class Cin { public static int ri { get { return ReadInt(); } } public static int[] ria { get { return ReadIntArray(); } } public static long rl { get { return ReadLong(); } } public static long[] rla { get { return ReadLongArray(); } } public static double rd { get { return ReadDouble(); } } public static double[] rda { get { return ReadDoubleArray(); } } public static string rs { get { return ReadString(); } } public static string[] rsa { get { return ReadStringArray(); } } public static int ReadInt() { return int.Parse(i()); } public static long ReadLong() { return long.Parse(i()); } public static double ReadDouble() { return double.Parse(i()); } public static string ReadString() { return i(); } public static int[] ReadIntArray() { g = null; return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } public static long[] ReadLongArray() { g = null; return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } public static double[] ReadDoubleArray() { g = null; return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); } public static string[] ReadStringArray() { g = null; return Console.ReadLine().Split(' '); } public static void ReadCol(out long[] a, long b) { a = new long[b]; for (int c = 0; c < b; c++) a[c] = ReadLong(); } public static void ReadCols(out long[] a, out long[] b, long c) { a = new long[c]; b = new long[c]; for (int d = 0; d < c; d++) { a[d] = ReadLong(); b[d] = ReadLong(); } } public static void ReadCols(out long[] a, out long[] b, out long[] c, long d) { a = new long[d]; b = new long[d]; c = new long[d]; for (int e = 0; e < d; e++) { a[e] = ReadLong(); b[e] = ReadLong(); c[e] = ReadLong(); } } public static int[,] ReadIntTable(int a, int b) { g = null; int[,] c = new int[a, b]; for (int d = 0; d < a; d++) for (int e = 0; e < b; e++) { c[d, e] = ReadInt(); } return c; } public static long[,] ReadLongTable(long a, long b) { g = null; long[,] c = new long[a, b]; for (int d = 0; d < a; d++) for (int e = 0; e < b; e++) { c[d, e] = ReadLong(); } return c; } public static char[,] ReadCharTable(int a, int b) { g = null; char[,] c = new char[a, b]; for (int d = 0; d < a; d++) { var e = ReadString(); for (int f = 0; f < b; f++) c[d, f] = e[f]; } return c; } static string[] g; static int h; static string i() { if (g == null || g.Length <= h) { g = Console.ReadLine().Split(' '); h = 0; } return g[h++]; } } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; using static Panasonic2020.D.Cin; using static Panasonic2020.D.Util; using Pair = Panasonic2020.D.VTuple<long, long>; using Graph = System.Collections.Generic.List<System.Collections.Generic.List<long>>; using System.Text; namespace Panasonic2020 { public class D { public static void Main(string[] args) { DontAutoFlush(); int n = ri; string abc = "abcdefghij"; char[] cur = new char[n]; cur[0] = 'a'; Action<int, int> rec = null; rec = (depth, max) => { if (depth == n) { Console.WriteLine(cur); return; } for (int j = 0; j <= max + 1; j++) { cur[depth] = abc[j]; rec(depth + 1, Max(j, max)); } }; rec(1, 0); Flush(); } public struct VTuple<T1, T2> : System.IComparable<VTuple<T1, T2>>, System.IEquatable<VTuple<T1, T2>> { public T1 First; public T2 Second; public VTuple(T1 a, T2 b) { First = a; Second = b; } public int CompareTo(VTuple<T1, T2> a) { int b = Comparer<T1>.Default.Compare(First, a.First); if (b != 0) return b; return Comparer<T2>.Default.Compare(Second, a.Second); } public override bool Equals(object a) { return a is VTuple<T1, T2> && Equals((VTuple<T1, T2>)a); } public bool Equals(VTuple<T1, T2> a) { return EqualityComparer<T1>.Default.Equals(First, a.First) && EqualityComparer<T2>.Default.Equals(Second, a.Second); } public override int GetHashCode() { int a = First != null ? First.GetHashCode() : 0; int b = Second != null ? Second.GetHashCode() : 0; uint c = ((uint)a << 5) | ((uint)a >> 27); return ((int)c + a) ^ b; } } public class HashMap<K, V> : System.Collections.Generic.Dictionary<K, V> { V i; static Func<V> j = System.Linq.Expressions.Expression .Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V))) .Compile(); public HashMap() {} public HashMap(V a) { i = a; } new public V this[K a] { get { V b; if (TryGetValue(a, out b)) return b; else return base[a] = i != null ? i : j(); } set { base[a] = value; } } } public static class Util { public static readonly long INF = (long)1e17; public readonly static long MOD = (long)1e9 + 7; public readonly static int[] DXY4 = { 0, 1, 0, -1, 0 }; public readonly static int[] DXY8 = { 1, 1, 0, 1, -1, 0, -1, -1, 1 }; public static void DontAutoFlush() { var a = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(a); } public static void Flush() { Console.Out.Flush(); } public static T[] Sort<T>(T[] a) { Array.Sort<T>(a); return a; } public static T[] SortDecend<T>(T[] a) { Array.Sort<T>(a); Array.Reverse(a); return a; } public static void Swap<T>(ref T a, ref T b) { T c = a; a = b; b = c; } public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); } public static void ChMax(ref long a, long b) { if (a < b) a = b; } public static void ChMin(ref long a, long b) { if (a > b) a = b; } public static long ModAdd(long a, long b) { long c = a + b; if (c >= MOD) return c % MOD; return c; } public static long ModMul(long a, long b) { long c = a * b; if (c >= MOD) return c % MOD; return c; } public static void ChModAdd(ref long a, long b) { a += b; if (a >= MOD) a %= MOD; } public static void ChModMul(ref long a, long b) { a *= b; if (a >= MOD) a %= MOD; } public static void FillArray<T>(T[] a, T b) { int c = a.Length; for (int d = 0; d < c; d++) a[d] = b; } public static void FillArray<T>(T[,] a, T b) { int c = a.GetLength(0); int d = a.GetLength(1); for (int e = 0; e < c; e++) for (int f = 0; f < d; f++) { a[e, f] = b; } } public static void FillArray<T>(T[,,] a, T b) { int c = a.GetLength(0); int d = a.GetLength(1); int e = a.GetLength(2); for (int f = 0; f < c; f++) for (int g = 0; g < d; g++) { for (int h = 0; h < e; h++) { a[f, g, h] = b; } } } public static long[] Accumulate(long[] a) { long[] b = new long[a.Length + 1]; for (int c = 0; c < a.Length; c++) b[c + 1] = b[c] + a[c]; return b; } public static double[] Accumulate(double[] a) { double[] b = new double[a.Length + 1]; for (int c = 0; c < a.Length; c++) b[c + 1] = b[c] + a[c]; return b; } } public static class Cin { public static int ri { get { return ReadInt(); } } public static int[] ria { get { return ReadIntArray(); } } public static long rl { get { return ReadLong(); } } public static long[] rla { get { return ReadLongArray(); } } public static double rd { get { return ReadDouble(); } } public static double[] rda { get { return ReadDoubleArray(); } } public static string rs { get { return ReadString(); } } public static string[] rsa { get { return ReadStringArray(); } } public static int ReadInt() { return int.Parse(i()); } public static long ReadLong() { return long.Parse(i()); } public static double ReadDouble() { return double.Parse(i()); } public static string ReadString() { return i(); } public static int[] ReadIntArray() { g = null; return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } public static long[] ReadLongArray() { g = null; return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } public static double[] ReadDoubleArray() { g = null; return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); } public static string[] ReadStringArray() { g = null; return Console.ReadLine().Split(' '); } public static void ReadCol(out long[] a, long b) { a = new long[b]; for (int c = 0; c < b; c++) a[c] = ReadLong(); } public static void ReadCols(out long[] a, out long[] b, long c) { a = new long[c]; b = new long[c]; for (int d = 0; d < c; d++) { a[d] = ReadLong(); b[d] = ReadLong(); } } public static void ReadCols(out long[] a, out long[] b, out long[] c, long d) { a = new long[d]; b = new long[d]; c = new long[d]; for (int e = 0; e < d; e++) { a[e] = ReadLong(); b[e] = ReadLong(); c[e] = ReadLong(); } } public static int[,] ReadIntTable(int a, int b) { g = null; int[,] c = new int[a, b]; for (int d = 0; d < a; d++) for (int e = 0; e < b; e++) { c[d, e] = ReadInt(); } return c; } public static long[,] ReadLongTable(long a, long b) { g = null; long[,] c = new long[a, b]; for (int d = 0; d < a; d++) for (int e = 0; e < b; e++) { c[d, e] = ReadLong(); } return c; } public static char[,] ReadCharTable(int a, int b) { g = null; char[,] c = new char[a, b]; for (int d = 0; d < a; d++) { var e = ReadString(); for (int f = 0; f < b; f++) c[d, f] = e[f]; } return c; } static string[] g; static int h; static string i() { if (g == null || g.Length <= h) { g = Console.ReadLine().Split(' '); h = 0; } return g[h++]; } } } }
[["-", 0, 11, 12, 218, 54, 55, 0, 220, 141, 22], ["+", 0, 11, 12, 218, 54, 55, 0, 220, 141, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 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, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
2,279
9
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static System.Console; using static Program.Input; using static Program.MyMath; using static Program.Const; namespace Program { public static class Program { public static void Main() { var s = ReadLine(); for (int i = 0; i < s.Length - 1; i += 2) { if (s[i] != 'h' || s[i + 1] != 'i') { WriteLine("No"); return; } } WriteLine("Yes"); } } static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public const long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } static class Input { public static void InputLine(out int a, out int b) { var input = ScanIntArray(); a = input[0]; b = input[1]; } public static void InputLine(out int a, out int b, out int c) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out int a, out int b, out int c, out int d) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out long a, out long b) { var input = ScanLongArray(); a = input[0]; b = input[1]; } public static void InputLine(out long a, out long b, out long c) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out long a, out long b, out long c, out long d) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out string a, out string b) { var input = ScanStrArray(); a = input[0]; b = input[1]; } public static int ScanInt() { return int.Parse(ReadLine()); } static public uint ScanUint() { return uint.Parse(ReadLine()); } static public double ScanDouble() { return double.Parse(ReadLine()); } static public long ScanLong() { return long.Parse(ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(ReadLine()); } static public int[] ScanIntArray() { return ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } static public string RegaxReplace(this string arg1, string pattern, string replacement) { return Regex.Replace(arg1, pattern, replacement); } } static class MyMath { static public int CountBit(this long a) { if (a == 0) return 0; int c = 1; for (; a > 1; a /= 2) if (a % 2 == 1) c++; return c; } static public int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } static public long[] CumSum(this long[] a) { var res = new long[a.Length]; long s = 0; for (int i = 0; i < a.Length; i++) res[i] = (s += a[i]); return res; } static public IEnumerable<int> PrimeFactors(this int n) { int tmp = n; for (int i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public IEnumerable<long> PrimeFactors(this long n) { var tmp = n; for (long i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public int Digit(this int n, int d) { if (d < 0) return 0; return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d); } static public int Length(this int n) { if (n < 0) return 0; return (int)Math.Log10(n) + 1; } static public int Top(this int n) { return n.Digit(n.Length() - 1); } public static bool isPrime(this int p) { if (p <= 1) return false; for (int i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static bool isPrime(this long p) { if (p <= 1) return false; for (long i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static long GCD(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) { if (b == 0) { x = 1; y = 0; return a; } var d = extGCD(b, a % b, ref y, ref x); y -= a / b * x; return d; } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static long LCM(long a, long b) { return a / GCD(a, b) * b; } public static long Inv(this long a, long m = MOD) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; swap(ref a, ref b); u -= t * v; swap(ref u, ref v); } u %= m; if (u < 0) u += m; return u; } private static void swap(ref long a, ref long b) { var t = a; a = b; b = t; } public static long ModPow(long a, long n, long m = MOD) { long res = 1; while (n > 0) { if (n % 2 == 1) res = (res * a) % m; a = (a * a) % m; n >>= 1; } return res; } } static class MyLinq { public static void Sort(this string[] array) { Array.Sort(array, StringComparer.OrdinalIgnoreCase); } public static void StringSort(this List<string> list) { list.Sort(StringComparer.OrdinalIgnoreCase); } public static string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } public static IEnumerable<TItem> Distinct<TItem, TKey>(this IEnumerable<TItem> source, Func<TItem, TKey> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); var set = new HashSet<TKey>(); foreach (var item in source) if (set.Add(keySelector(item))) yield return item; } } }
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static System.Console; using static Program.Input; using static Program.MyMath; using static Program.Const; namespace Program { public static class Program { public static void Main() { var s = ReadLine(); if (s.Length % 2 == 1) { WriteLine("No"); return; } for (int i = 0; i < s.Length - 1; i += 2) { if (s[i] != 'h' || s[i + 1] != 'i') { WriteLine("No"); return; } } WriteLine("Yes"); } } static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public const long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } static class Input { public static void InputLine(out int a, out int b) { var input = ScanIntArray(); a = input[0]; b = input[1]; } public static void InputLine(out int a, out int b, out int c) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out int a, out int b, out int c, out int d) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out long a, out long b) { var input = ScanLongArray(); a = input[0]; b = input[1]; } public static void InputLine(out long a, out long b, out long c) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out long a, out long b, out long c, out long d) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out string a, out string b) { var input = ScanStrArray(); a = input[0]; b = input[1]; } public static int ScanInt() { return int.Parse(ReadLine()); } static public uint ScanUint() { return uint.Parse(ReadLine()); } static public double ScanDouble() { return double.Parse(ReadLine()); } static public long ScanLong() { return long.Parse(ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(ReadLine()); } static public int[] ScanIntArray() { return ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } static public string RegaxReplace(this string arg1, string pattern, string replacement) { return Regex.Replace(arg1, pattern, replacement); } } static class MyMath { static public int CountBit(this long a) { if (a == 0) return 0; int c = 1; for (; a > 1; a /= 2) if (a % 2 == 1) c++; return c; } static public int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } static public long[] CumSum(this long[] a) { var res = new long[a.Length]; long s = 0; for (int i = 0; i < a.Length; i++) res[i] = (s += a[i]); return res; } static public IEnumerable<int> PrimeFactors(this int n) { int tmp = n; for (int i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public IEnumerable<long> PrimeFactors(this long n) { var tmp = n; for (long i = 2; i * i <= n; i++) while (tmp % i == 0) { tmp /= i; yield return i; } if (tmp != 1) yield return tmp; } static public int Digit(this int n, int d) { if (d < 0) return 0; return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d); } static public int Length(this int n) { if (n < 0) return 0; return (int)Math.Log10(n) + 1; } static public int Top(this int n) { return n.Digit(n.Length() - 1); } public static bool isPrime(this int p) { if (p <= 1) return false; for (int i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static bool isPrime(this long p) { if (p <= 1) return false; for (long i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static long GCD(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) { if (b == 0) { x = 1; y = 0; return a; } var d = extGCD(b, a % b, ref y, ref x); y -= a / b * x; return d; } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static long LCM(long a, long b) { return a / GCD(a, b) * b; } public static long Inv(this long a, long m = MOD) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; swap(ref a, ref b); u -= t * v; swap(ref u, ref v); } u %= m; if (u < 0) u += m; return u; } private static void swap(ref long a, ref long b) { var t = a; a = b; b = t; } public static long ModPow(long a, long n, long m = MOD) { long res = 1; while (n > 0) { if (n % 2 == 1) res = (res * a) % m; a = (a * a) % m; n >>= 1; } return res; } } static class MyLinq { public static void Sort(this string[] array) { Array.Sort(array, StringComparer.OrdinalIgnoreCase); } public static void StringSort(this List<string> list) { list.Sort(StringComparer.OrdinalIgnoreCase); } public static string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } public static IEnumerable<TItem> Distinct<TItem, TKey>(this IEnumerable<TItem> source, Func<TItem, TKey> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); var set = new HashSet<TKey>(); foreach (var item in source) if (set.Add(keySelector(item))) yield return item; } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 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
2,022
21
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TOPSIC { partial class Program { static void Main(string[] args) { string H = Console.ReadLine(); string ans = "Yes"; if (H.Length < 2) { ans = "No"; Console.WriteLine(ans); return; } for (int i = 0; i < H.Length; i++) { if (i % 2 == 0) { if (H[i] != 'h') { ans = "No"; break; } } else { if (H[i] != 'i') { ans = "No"; break; } } } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TOPSIC { partial class Program { static void Main(string[] args) { string H = Console.ReadLine(); string ans = "Yes"; if (H.Length < 2) { ans = "No"; Console.WriteLine(ans); return; } for (int i = 0; i < H.Length; i++) { if (i % 2 == 0) { if (H[i] != 'h') { ans = "No"; break; } } else { if (H[i] != 'i') { ans = "No"; break; } } } if (H[H.Length - 1] == 'h') { ans = "No"; } Console.WriteLine(ans); } } }
[["+", 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, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 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], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
168
23
using System; class Program { static void Main(string[] args) { string s = Console.ReadLine(); if (s.Length % 2 == 1) { Console.WriteLine("No"); return; } for (int i = 0; i < s.Length / 2; i++) { if (s[i] == 'h' && s[i + 1] == 'i') { Console.WriteLine("Yes"); return; } } Console.WriteLine("No"); } }
using System; class Program { static void Main(string[] args) { string s = Console.ReadLine(); if (s.Length % 2 == 1) { Console.WriteLine("No"); return; } for (int i = 0; i < s.Length - 1; i += 2) { if (s[i] != 'h' || s[i + 1] != 'i') { Console.WriteLine("No"); return; } } Console.WriteLine("Yes"); } }
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 85], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 7, 26, 11, 0, 202, 0, 107], ["+", 0, 195, 8, 196, 0, 7, 26, 11, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 106], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
114
17
using System; using System.Linq; namespace atcoder { class Program { static void Main() { var A = new ReadLine(); var B = A.String(); var cnt = 0; var cnt2 = 0; for (int i = 0; i < B.Length; i += 2) { if (B[i] == 'h' && B[i + 1] == 'i') { cnt += 1; } cnt2 += 2; } if (cnt2 == cnt * 2) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } class ReadLine { public int Number() { int vs = int.Parse(Console.ReadLine()); return vs; } public int[] Int() { int[] vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); return vs; } public string String() { string vs = Console.ReadLine(); return vs; } } }
using System; using System.Linq; namespace atcoder { class Program { static void Main() { var A = new ReadLine(); var B = A.String(); var cnt = 0; var cnt2 = 0; try { for (int i = 0; i < B.Length; i += 2) { if (B[i] == 'h' && B[i + 1] == 'i') { cnt += 1; } cnt2 += 1; } if (cnt2 == cnt) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } catch { Console.WriteLine("No"); } } } class ReadLine { public int Number() { int vs = int.Parse(Console.ReadLine()); return vs; } public int[] Int() { int[] vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); return vs; } public string String() { string vs = Console.ReadLine(); return vs; } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 246, 0, 247], ["+", 0, 195, 8, 196, 0, 246, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 0, 246, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 246, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 246, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 246, 0, 248, 0, 249]]
8
220
19
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; internal static class CR { public static string GetText() { return Console.ReadLine(); } public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long GetLong() { return long.Parse(Console.ReadLine()); } public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } } namespace AtCoder.A { public class Program { public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { var text = CR.GetText(); return text.Contains("hi") ? "Yes" : "No"; } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; internal static class CR { public static string GetText() { return Console.ReadLine(); } public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long GetLong() { return long.Parse(Console.ReadLine()); } public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } } namespace AtCoder.A { public class Program { public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { var text = CR.GetText(); switch (text) { case "hi": case "hihi": case "hihihi": case "hihihihi": case "hihihihihi": return "Yes"; default: return "No"; } } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 0, 37, 0, 41, 15, 213, 63, 214, 205, 22], ["-", 0, 37, 0, 41, 15, 213, 63, 214, 0, 131], ["-", 0, 37, 0, 41, 15, 213, 63, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 99, 0, 155], ["+", 8, 201, 0, 195, 8, 196, 0, 99, 51, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 99, 0, 25], ["+", 0, 195, 8, 196, 0, 99, 8, 254, 0, 45], ["+", 0, 99, 8, 254, 0, 239, 0, 264, 0, 173], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 62], ["+", 0, 99, 8, 254, 0, 239, 0, 264, 0, 102], ["-", 0, 37, 0, 41, 15, 213, 3, 4, 0, 25], ["-", 0, 195, 8, 196, 0, 37, 0, 41, 0, 101], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["+", 0, 99, 8, 254, 0, 239, 0, 37, 0, 38], ["+", 8, 254, 0, 239, 0, 37, 0, 5, 0, 62], ["+", 0, 99, 8, 254, 0, 239, 0, 37, 0, 35], ["+", 0, 99, 8, 254, 0, 239, 0, 265, 0, 162], ["+", 0, 195, 8, 196, 0, 99, 8, 254, 0, 46]]
8
206
37
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var s = Read(); Console.WriteLine(s.Contains("hi") ? "Yes" : "No"); } private static readonly Func<string> Read = () => Console.ReadLine(); private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split(); private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine()); private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine()); private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray(); private static readonly Action<string> Cw = str => Console.WriteLine(str); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var s = Read(); var rep = s.Replace("hi", ""); if (rep.Any()) { Console.WriteLine("No"); } else { Console.WriteLine("Yes"); } } private static readonly Func<string> Read = () => Console.ReadLine(); private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split(); private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine()); private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine()); private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray(); private static readonly Action<string> Cw = str => Console.WriteLine(str); } }
[["-", 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], ["-", 0, 28, 0, 41, 15, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 41, 15, 213, 3, 4, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 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], ["+", 8, 196, 0, 57, 15, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 57, 15, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 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], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
256
42
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Text; namespace A { class StartingPoint { static void Main(string[] args) { if (args?.Any() == true) { var assembly = Assembly.GetEntryAssembly(); var resourceName = "AtCoderCSharp.In.txt"; var stream = assembly.GetManifestResourceStream(resourceName); var streamReader = new StreamReader(stream, Encoding.UTF8); var str = streamReader.ReadToEnd(); var textReader = new StringReader(str); Console.SetIn(textReader); } try { foreach (var s in new Program().Solve()) { Console.WriteLine(s); } } catch (Exception e) { Console.WriteLine(e); if (args?.Any() != true) throw e; } if (args?.Any() == true) Console.ReadKey(); } } class Program { public List<int> ScanInts(int count) => Enumerable.Range(0, count).Select(_ => ScanInt).ToList(); public List<int> ScanInts(long count) => ScanInts((int)count); public List<long> ScanLongs(int count) => Enumerable.Range(0, count).Select(_ => Scan).ToList(); public List<long> ScanLongs(long count) => ScanLongs((int)count); public int ScanInt => int.Parse(Str); public long Scan => long.Parse(Str); public double ScanDouble => (double)Scan; StringBuilder sb = new StringBuilder(); public string Str => ScanStr(); public string ScanStr() { sb.Clear(); int r = 0; bool? b = null; do { r = Console.Read(); b = IsBreak(r); } while (b == true); if (b == null) throw new Exception("input error: unexpected end of stream"); do { sb.Append((char)r); r = Console.Read(); b = IsBreak(r); } while (b == false); return sb.ToString(); } bool? IsBreak(int c) { switch (c) { case -1: return null; case (int)' ': case (int)'\n': case (int)'\r': return true; default: return false; } } public IEnumerable<int> Loop(int count) => Enumerable.Range(0, count); public IEnumerable<int> Loop(int from, int to) => Enumerable.Range(from, to - from + 1); public IEnumerable<long> Loop(long count) => Loop(0, count - 1); public IEnumerable<long> Loop(long from, long to) { for (long i = from; i <= to; i++) yield return i; } public string YesNo(bool isYes) => isYes ? "Yes" : "No"; public HashSet<T> ToHashSet<T>(IEnumerable<T> ts) => new HashSet<T>(ts); public IEnumerable<string> Solve() { var s = ScanStr(); var b = false; for (int i = 0; i < s.Length - 1; i++) { if (s[i] == 'h' && s[i + 1] == 'i') { b = true; } } yield return YesNo(b); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Text; namespace A { class StartingPoint { static void Main(string[] args) { if (args?.Any() == true) { var assembly = Assembly.GetEntryAssembly(); var resourceName = "AtCoderCSharp.In.txt"; var stream = assembly.GetManifestResourceStream(resourceName); var streamReader = new StreamReader(stream, Encoding.UTF8); var str = streamReader.ReadToEnd(); var textReader = new StringReader(str); Console.SetIn(textReader); } try { foreach (var s in new Program().Solve()) { Console.WriteLine(s); } } catch (Exception e) { Console.WriteLine(e); if (args?.Any() != true) throw e; } if (args?.Any() == true) Console.ReadKey(); } } class Program { public List<int> ScanInts(int count) => Enumerable.Range(0, count).Select(_ => ScanInt).ToList(); public List<int> ScanInts(long count) => ScanInts((int)count); public List<long> ScanLongs(int count) => Enumerable.Range(0, count).Select(_ => Scan).ToList(); public List<long> ScanLongs(long count) => ScanLongs((int)count); public int ScanInt => int.Parse(Str); public long Scan => long.Parse(Str); public double ScanDouble => (double)Scan; StringBuilder sb = new StringBuilder(); public string Str => ScanStr(); public string ScanStr() { sb.Clear(); int r = 0; bool? b = null; do { r = Console.Read(); b = IsBreak(r); } while (b == true); if (b == null) throw new Exception("input error: unexpected end of stream"); do { sb.Append((char)r); r = Console.Read(); b = IsBreak(r); } while (b == false); return sb.ToString(); } bool? IsBreak(int c) { switch (c) { case -1: return null; case (int)' ': case (int)'\n': case (int)'\r': return true; default: return false; } } public IEnumerable<int> Loop(int count) => Enumerable.Range(0, count); public IEnumerable<int> Loop(int from, int to) => Enumerable.Range(from, to - from + 1); public IEnumerable<long> Loop(long count) => Loop(0, count - 1); public IEnumerable<long> Loop(long from, long to) { for (long i = from; i <= to; i++) yield return i; } public string YesNo(bool isYes) => isYes ? "Yes" : "No"; public HashSet<T> ToHashSet<T>(IEnumerable<T> ts) => new HashSet<T>(ts); public IEnumerable<string> Solve() { var s = ScanStr(); var b = s.Length % 2 == 0; for (int i = 0; i < s.Length; i++) { if (i % 2 == 0 && s[i] == 'h') continue; if (i % 2 == 1 && s[i] == 'i') continue; b = false; } yield return YesNo(b); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 0, 212, 0, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 212, 0, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 212, 0, 16, 31, 16, 31, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 109], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 60], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 8, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
729
34
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; public static long mod = 1000000007; void calc() { cin = new Scanner(); cin2 = new Func(); string s = cin.next(); string ans = "Yes"; for (int i = 0; i < s.Length; i++) { if (i % 2 == 0 && s[i] != 'h') ans = "No"; if (i % 2 == 1 && s[i] != 'i') ans = "No"; } Console.WriteLine(ans); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public static long mod = 1000000007; public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } public long mod_pow(long x, long n) { long ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = ans * x; ans %= mod; } x = x * x % mod; n >>= 1; } return ans; } public long factorial(long x) { long n = 1; if (x <= 1) return x; else { n *= (x * factorial(x - 1)); n %= mod; return n; } } public long combination(long n, long r) { if (r * 2 > n) r = n - r; long dividend = 1; long divisor = 1; for (long i = 1; i <= r; ++i) { dividend *= (n - i + 1); dividend %= mod; divisor *= i; divisor %= mod; } return (dividend * mod_pow(divisor, mod - 2)) % mod; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; public static long mod = 1000000007; void calc() { cin = new Scanner(); cin2 = new Func(); string s = cin.next(); string ans = "Yes"; if (s.Length % 2 != 0) ans = "No"; for (int i = 0; i < s.Length; i++) { if (i % 2 == 0 && s[i] != 'h') ans = "No"; if (i % 2 == 1 && s[i] != 'i') ans = "No"; } Console.WriteLine(ans); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public static long mod = 1000000007; public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } public long mod_pow(long x, long n) { long ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = ans * x; ans %= mod; } x = x * x % mod; n >>= 1; } return ans; } public long factorial(long x) { long n = 1; if (x <= 1) return x; else { n *= (x * factorial(x - 1)); n %= mod; return n; } } public long combination(long n, long r) { if (r * 2 > n) r = n - r; long dividend = 1; long divisor = 1; for (long i = 1; i <= r; ++i) { dividend *= (n - i + 1); dividend %= mod; divisor *= i; divisor %= mod; } return (dividend * mod_pow(divisor, mod - 2)) % mod; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 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, 5, 0, 62], ["+", 0, 57, 64, 1, 0, 11, 12, 5, 0, 222], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
982
16
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; 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] == 'h' && s[i + 1] == 'i') { Console.WriteLine("Yes"); return; } } Console.WriteLine("No"); } } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; 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.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; 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; if (n % 2 != 0) { Console.WriteLine("No"); return; } for (int i = 0; i < n; i += 2) { if (s[i] != 'h' || s[i + 1] != 'i') { Console.WriteLine("No"); return; } } Console.WriteLine("Yes"); } } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; 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, 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, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 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, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 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, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 7, 26, 11, 0, 202, 0, 107], ["+", 0, 195, 8, 196, 0, 7, 26, 11, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 106], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
603
36
using System; using System.Linq; using System.Collections.Generic; namespace Contest { class Program { static void Main(string[] args) { HitachiD(); } static void HitachiD() { var nt = ReadLongN(); var N = nt[0]; var T = nt[1]; var AB = ReadTupleLong((int)N); var AB1 = AB.Where(x => x.Item1 > 0).ToArray(); Array.Sort(AB1, (x, y) => (x.Item2 * y.Item1 + y.Item2) .CompareTo(y.Item2 * x.Item1 + x.Item2)); int maxj = 40; long maxt = T + 1; long[] time = Enumerable.Range(0, maxj).Select(i => maxt).ToArray(); time[0] = 0; foreach (var ab in AB1) { for (int j = maxj - 2; j >= 0; --j) { time[j + 1] = Math.Min(time[j + 1], (time[j] + 1) * (ab.Item1 + 1) + ab.Item2); } } var bs = AB.Where(x => x.Item1 == 0) .Select(x => x.Item2 + 1) .OrderBy(x => x) .ToArray(); long max = 0; for (int i = 0; i < maxj; ++i) { if (time[i] <= T) { max = Math.Max(max, i); } for (int j = 0; j < bs.Length; ++j) { var t = time[i] + bs[j]; if (t <= T) { time[i] = t; max = Math.Max(max, i + j + 1); } else { break; } } } Console.WriteLine(max); } static string ReadStr() { return Console.ReadLine(); } static string[] ReadStrN() { return Console.ReadLine().Split(' '); } static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); } static int[] ReadIntN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); } static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); } static long[] ReadLongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); } static Tuple<string, string>[] ReadTupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = ReadStrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); } static Tuple<long, long>[] ReadTupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = ReadLongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); } static Tuple<double, double>[] ReadTupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = ReadLongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); } static Dictionary<int, HashSet<int>> ReadAdjacencyList(int N, int M) { Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new HashSet<int>()); } for (int i = 0; i < M; ++i) { var ab = ReadIntN(); dict[ab[0]].Add(ab[1]); dict[ab[1]].Add(ab[0]); } return dict; } } }
using System; using System.Linq; using System.Collections.Generic; namespace Contest { class Program { static void Main(string[] args) { HitachiD(); } static void HitachiD() { var nt = ReadLongN(); var N = nt[0]; var T = nt[1]; var AB = ReadTupleLong((int)N); var AB1 = AB.Where(x => x.Item1 > 0).ToArray(); Array.Sort( AB1, (x, y) => (y.Item1 * (x.Item2 + 1)).CompareTo(x.Item1 * (y.Item2 + 1))); int maxj = 40; long maxt = T + 1; long[] time = Enumerable.Range(0, maxj).Select(i => maxt).ToArray(); time[0] = 0; foreach (var ab in AB1) { for (int j = maxj - 2; j >= 0; --j) { time[j + 1] = Math.Min(time[j + 1], (time[j] + 1) * (ab.Item1 + 1) + ab.Item2); } } var bs = AB.Where(x => x.Item1 == 0) .Select(x => x.Item2 + 1) .OrderBy(x => x) .ToArray(); int max = 0; for (int i = 0; i < maxj; ++i) { if (time[i] <= T) { max = Math.Max(max, i); } for (int j = 0; j < bs.Length; ++j) { var t = time[i] + bs[j]; if (t <= T) { time[i] = t; max = Math.Max(max, i + j + 1); } else { break; } } } Console.WriteLine(max); } static string ReadStr() { return Console.ReadLine(); } static string[] ReadStrN() { return Console.ReadLine().Split(' '); } static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); } static int[] ReadIntN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); } static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); } static long[] ReadLongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); } static Tuple<string, string>[] ReadTupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = ReadStrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); } static Tuple<long, long>[] ReadTupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = ReadLongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); } static Tuple<double, double>[] ReadTupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = ReadLongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); } static Dictionary<int, HashSet<int>> ReadAdjacencyList(int N, int M) { Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new HashSet<int>()); } for (int i = 0; i < M; ++i) { var ab = ReadIntN(); dict[ab[0]].Add(ab[1]); dict[ab[1]].Add(ab[0]); } return dict; } } }
[["-", 205, 23, 0, 16, 31, 16, 31, 214, 205, 22], ["-", 205, 23, 0, 16, 31, 16, 31, 214, 0, 131], ["-", 205, 23, 0, 16, 31, 16, 31, 214, 141, 22], ["-", 63, 214, 205, 23, 0, 16, 31, 16, 17, 48], ["-", 8, 213, 63, 214, 205, 23, 0, 16, 17, 72], ["-", 63, 214, 205, 23, 0, 16, 12, 214, 205, 22], ["+", 8, 213, 63, 214, 205, 23, 0, 16, 17, 48], ["+", 63, 214, 205, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 214, 205, 22], ["+", 205, 23, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 205, 23, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 63, 214, 205, 23, 0, 16, 12, 23, 0, 25], ["-", 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, 48], ["-", 8, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 16, 12, 214, 205, 22], ["+", 8, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
974
26
using System; using System.Linq; class Program { static void Main(string[] args) { string s = Console.ReadLine(); char[] ary = s.ToArray(); string ans = "No"; for (int i = 0; i < ary.Length - 1; i++) { ans = ary[i] != ary[i + 1] ? "Yes" : "No"; } Console.WriteLine(ans); } }
using System; using System.Linq; class Program { static void Main(string[] args) { string s = Console.ReadLine(); char[] ary = s.ToArray(); string ans = "No"; for (int i = 0; i < ary.Length - 1; i++) { if (ary[i] != ary[i + 1]) { ans = "Yes"; break; } } Console.WriteLine(ans); } }
[["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 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, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["-", 0, 1, 0, 11, 12, 41, 75, 5, 0, 62], ["-", 0, 1, 0, 11, 12, 41, 75, 5, 0, 222], ["+", 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
99
16
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class ABC157F { static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var N = NN; var K = NN; var xycList = Repeat(0, N).Select(_ => new { x = ND, y = ND, c = ND }).ToArray(); var left = 0.0; var right = 3000000.0; var centers = xycList.Select(e => new LIB_Geo2D.Vec(e.x, e.y)).ToArray(); while (right - left > LIB_Geo2D.EPS) { var mid = (right + left) / 2; var cnt = 0L; { var points = new List<LIB_Geo2D.Vec>(); var curcles = xycList .Select(e => new LIB_Geo2D.Circle() { p = new LIB_Geo2D.Vec(e.x, e.y), r2 = (mid / e.c) * (mid / e.c) }) .ToArray(); for (var i = 0; i < N; i++) { for (var j = i + 1; j < N; j++) { points.AddRange(LIB_Geo2D.Intersection(curcles[i], curcles[j])); } } foreach (var item in points.Concat(centers)) { var thisCnt = 0L; foreach (var item2 in curcles) { if (LIB_Geo2D.Distance(item, item2) <= LIB_Geo2D.EPS) ++thisCnt; } cnt = Max(cnt, thisCnt); } } if (cnt < K) left = mid; else right = mid; } Console.WriteLine(right); } static class Console_ { static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); } static long NN => long.Parse(Console_.NextString()); static double ND => double.Parse(Console_.NextString()); static string NS => Console_.NextString(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library {} namespace Library { class LIB_Geo2D { static readonly public double EPS = 1e-10; public struct Vec { public double x; public double y; public Vec(double x, double y) { this.x = x; this.y = y; } [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator +(Vec a, Vec b) => new Vec() { x = a.x + b.x, y = a.y + b.y }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator -(Vec a, Vec b) => new Vec() { x = a.x - b.x, y = a.y - b.y }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator *(Vec p, double v) => new Vec() { x = p.x * v, y = p.y * v }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator *(double v, Vec p) => p * v; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator /(Vec p, double v) => new Vec() { x = p.x / v, y = p.y / v }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator /(double v, Vec p) => p / v; } public struct Circle { public Vec p; /// <summary> /// 蜊雁セ・・2荵・ /// </summary> public double r2; /// <summary> /// 蜊雁セ・ /// </summary> public double r { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return Sqrt(r2); } private set {} } } /// <summary> /// 轤ケ縺ィ轤ケ縺ョ霍晞屬縺ョ2荵励r豎ゅa繧・ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Distance(Vec p1, Vec p2) => Norm(p2 - p1); /// <summary> /// 轤ケ縺ィ蜀・・霍晞屬縺ョ2荵励r豎ゅa繧九€りイ縺ョ蝣エ蜷医・蜀・・蜀・・縺ォ縺・k・育オカ蟇セ蛟、縺ッ荳€逡ェ霑代>蜀・・邵√∪縺ァ縺ョ霍晞屬・・ /// /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Distance(Vec p, Circle c) => Norm(p - c.p) - c.r2; /// <summary> /// 轤ケ縺ィ蜀・・霍晞屬縺ョ2荵励r豎ゅa繧九€りイ縺ョ蝣エ蜷医・蜀・・蜀・・縺ォ縺・k・育オカ蟇セ蛟、縺ッ荳€逡ェ霑代>蜀・・邵√∪縺ァ縺ョ霍晞屬・・ /// /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Distance(Circle c, Vec p) => Norm(p - c.p) - c.r2; /// <summary> /// 蜀・→蜀・・莠、轤ケ繧呈アゅa繧・ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec[] Intersection(Circle c1, Circle c2) { var p = c2.p - c1.p; var b = p.x * p.x + p.y * p.y; var a = (b + c1.r2 - c2.r2) / 2; var d = b * c1.r2 - a * a; if (d < -EPS) return new Vec[0]; if (d > EPS) { var c = Sqrt(d); var p1 = new Vec((a * p.x + p.y * c) / b + c1.p.x, (a * p.y - p.x * c) / b + c1.p.y); var p2 = new Vec((a * p.x - p.y * c) / b + c1.p.x, (a * p.y + p.x * c) / b + c1.p.y); return new[] { p1, p2 }; } return new[] { new Vec(a * p.x / b + c1.p.x, a * p.y / b + c1.p.y) }; } /// <summary> /// p縺ョ髟キ縺輔・2荵励r蠕励k /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Norm(Vec p) => p.x * p.x + p.y * p.y; /// <summary> /// 蜀・ゥ・ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Dot(Vec p1, Vec p2) => p1.x * p2.x + p1.y * p2.y; /// <summary> /// 螟也ゥ搾シ亥ケウ陦悟屁霎コ蠖「縺ョ髱「遨搾シ芽イ縺ォ縺ェ繧雁セ励k /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Cross(Vec p1, Vec p2) => p1.x * p2.y - p1.y * p2.x; /// <summary> /// 3轤ケ繧帝€壹k蜀・r霑斐☆ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Circle GetCircleFrom3Vec(Vec p1, Vec p2, Vec p3) { var A = Distance(p2, p3); var B = Distance(p1, p3); var C = Distance(p1, p2); var S = Abs(Cross(p2 - p1, p3 - p1)); var p = (A * (B + C - A) * p1 + B * (C + A - B) * p2 + C * (A + B - C) * p3) / (4 * S * S); var r = Distance(p, p1); return new Circle() { p = p, r2 = r }; } /// <summary> /// 2轤ケ繧帝€壹k蜀・r霑斐☆ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Circle GetCircleFrom2Vec(Vec p1, Vec p2) { var c = (p1 + p2) / 2; return new Circle() { p = c, r2 = Distance(p1, c) }; } /// <summary> /// 譛€蟆丞桁蜷ォ蜀・r霑斐☆ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Circle GetEncloseCircle(IEnumerable<Vec> pointList) { var pList = pointList.ToArray(); if (pList.Length < 2) throw new Exception(); var rnd = new Random(); var list = pList.OrderBy(_ => rnd.Next()).ToArray(); Func<Vec, Circle, bool> inCircle = null; inCircle = (p, c) => Distance(p, c) < EPS; { var c = GetCircleFrom2Vec(list[0], list[1]); for (var i = 2; i < list.Length; i++) { if (!inCircle(list[i], c)) { c = GetCircleFrom2Vec(list[0], list[i]); for (var j = 1; j < i; j++) { if (!inCircle(list[j], c)) { c = GetCircleFrom2Vec(list[i], list[j]); for (var k = 0; k < j; k++) { if (!inCircle(list[k], c)) { c = GetCircleFrom3Vec(list[i], list[j], list[k]); } } } } } } return c; } } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class ABC157F { static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var N = NN; var K = NN; var xycList = Repeat(0, N).Select(_ => new { x = ND, y = ND, c = ND }).ToArray(); var left = 0d; var right = 3000000d; var centers = xycList.Select(e => new LIB_Geo2D.Vec(e.x, e.y)).ToArray(); for (int xx = 0; xx < 200; ++xx) { var mid = (right + left) / 2; var cnt = 0L; { var points = new List<LIB_Geo2D.Vec>(); var curcles = xycList .Select(e => new LIB_Geo2D.Circle() { p = new LIB_Geo2D.Vec(e.x, e.y), r2 = (mid / e.c) * (mid / e.c) }) .ToArray(); for (var i = 0; i < N; i++) { for (var j = i + 1; j < N; j++) { points.AddRange(LIB_Geo2D.Intersection(curcles[i], curcles[j])); } } foreach (var item in points.Concat(centers)) { var thisCnt = 0L; foreach (var item2 in curcles) { if (LIB_Geo2D.Distance(item, item2) <= LIB_Geo2D.EPS) ++thisCnt; } cnt = Max(cnt, thisCnt); } } if (cnt < K) left = mid; else right = mid; } Console.WriteLine(right); } static class Console_ { static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); } static long NN => long.Parse(Console_.NextString()); static double ND => double.Parse(Console_.NextString()); static string NS => Console_.NextString(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library {} namespace Library { class LIB_Geo2D { static readonly public double EPS = 1e-8; public struct Vec { public double x; public double y; public Vec(double x, double y) { this.x = x; this.y = y; } [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator +(Vec a, Vec b) => new Vec() { x = a.x + b.x, y = a.y + b.y }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator -(Vec a, Vec b) => new Vec() { x = a.x - b.x, y = a.y - b.y }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator *(Vec p, double v) => new Vec() { x = p.x * v, y = p.y * v }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator *(double v, Vec p) => p * v; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator /(Vec p, double v) => new Vec() { x = p.x / v, y = p.y / v }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec operator /(double v, Vec p) => p / v; } public struct Circle { public Vec p; /// <summary> /// 蜊雁セ・・2荵・ /// </summary> public double r2; /// <summary> /// 蜊雁セ・ /// </summary> public double r { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return Sqrt(r2); } private set {} } } /// <summary> /// 轤ケ縺ィ轤ケ縺ョ霍晞屬縺ョ2荵励r豎ゅa繧・ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Distance(Vec p1, Vec p2) => Norm(p2 - p1); /// <summary> /// 轤ケ縺ィ蜀・・霍晞屬縺ョ2荵励r豎ゅa繧九€りイ縺ョ蝣エ蜷医・蜀・・蜀・・縺ォ縺・k・育オカ蟇セ蛟、縺ッ荳€逡ェ霑代>蜀・・邵√∪縺ァ縺ョ霍晞屬・・ /// /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Distance(Vec p, Circle c) => Norm(p - c.p) - c.r2; /// <summary> /// 轤ケ縺ィ蜀・・霍晞屬縺ョ2荵励r豎ゅa繧九€りイ縺ョ蝣エ蜷医・蜀・・蜀・・縺ォ縺・k・育オカ蟇セ蛟、縺ッ荳€逡ェ霑代>蜀・・邵√∪縺ァ縺ョ霍晞屬・・ /// /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Distance(Circle c, Vec p) => Norm(p - c.p) - c.r2; /// <summary> /// 蜀・→蜀・・莠、轤ケ繧呈アゅa繧・ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Vec[] Intersection(Circle c1, Circle c2) { var p = c2.p - c1.p; var b = p.x * p.x + p.y * p.y; var a = (b + c1.r2 - c2.r2) / 2; var d = b * c1.r2 - a * a; if (d < -EPS) return new Vec[0]; if (d > EPS) { var c = Sqrt(d); var p1 = new Vec((a * p.x + p.y * c) / b + c1.p.x, (a * p.y - p.x * c) / b + c1.p.y); var p2 = new Vec((a * p.x - p.y * c) / b + c1.p.x, (a * p.y + p.x * c) / b + c1.p.y); return new[] { p1, p2 }; } return new[] { new Vec(a * p.x / b + c1.p.x, a * p.y / b + c1.p.y) }; } /// <summary> /// p縺ョ髟キ縺輔・2荵励r蠕励k /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Norm(Vec p) => p.x * p.x + p.y * p.y; /// <summary> /// 蜀・ゥ・ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Dot(Vec p1, Vec p2) => p1.x * p2.x + p1.y * p2.y; /// <summary> /// 螟也ゥ搾シ亥ケウ陦悟屁霎コ蠖「縺ョ髱「遨搾シ芽イ縺ォ縺ェ繧雁セ励k /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public double Cross(Vec p1, Vec p2) => p1.x * p2.y - p1.y * p2.x; /// <summary> /// 3轤ケ繧帝€壹k蜀・r霑斐☆ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Circle GetCircleFrom3Vec(Vec p1, Vec p2, Vec p3) { var A = Distance(p2, p3); var B = Distance(p1, p3); var C = Distance(p1, p2); var S = Abs(Cross(p2 - p1, p3 - p1)); var p = (A * (B + C - A) * p1 + B * (C + A - B) * p2 + C * (A + B - C) * p3) / (4 * S * S); var r = Distance(p, p1); return new Circle() { p = p, r2 = r }; } /// <summary> /// 2轤ケ繧帝€壹k蜀・r霑斐☆ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Circle GetCircleFrom2Vec(Vec p1, Vec p2) { var c = (p1 + p2) / 2; return new Circle() { p = c, r2 = Distance(p1, c) }; } /// <summary> /// 譛€蟆丞桁蜷ォ蜀・r霑斐☆ /// </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] static public Circle GetEncloseCircle(IEnumerable<Vec> pointList) { var pList = pointList.ToArray(); if (pList.Length < 2) throw new Exception(); var rnd = new Random(); var list = pList.OrderBy(_ => rnd.Next()).ToArray(); Func<Vec, Circle, bool> inCircle = null; inCircle = (p, c) => Distance(p, c) < EPS; { var c = GetCircleFrom2Vec(list[0], list[1]); for (var i = 2; i < list.Length; i++) { if (!inCircle(list[i], c)) { c = GetCircleFrom2Vec(list[0], list[i]); for (var j = 1; j < i; j++) { if (!inCircle(list[j], c)) { c = GetCircleFrom2Vec(list[i], list[j]); for (var k = 0; k < j; k++) { if (!inCircle(list[k], c)) { c = GetCircleFrom3Vec(list[i], list[j], list[k]); } } } } } } return c; } } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 250], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 250], ["-", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 17, 33], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["-", 8, 196, 0, 52, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 52, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 52, 15, 16, 12, 214, 141, 22], ["+", 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, 203], ["+", 0, 195, 8, 196, 0, 7, 26, 241, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 250], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 250]]
8
2,403
26
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var nr = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray(); Console.WriteLine(nr[1] + 100 * (10 - nr[0])); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var nr = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray(); Console.WriteLine(nr[1] + (nr[0] > 9 ? 0 : 100 * (10 - nr[0]))); } } }
[["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 41, 15, 16, 31, 204, 205, 22], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 41, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 17, 47], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 0, 101], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 64, 203], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 0, 102], ["+", 12, 23, 0, 41, 75, 16, 12, 23, 0, 25]]
8
92
11
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var rates = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); var c = rates[0] > 9 ? 0 : (10 - rates[0]); Console.WriteLine(rates[1] - 100 * c); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var rates = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); var c = rates[0] > 9 ? 0 : (10 - rates[0]); Console.WriteLine(rates[1] + 100 * c); Console.ReadKey(); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 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
94
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionM { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var num_NK = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); int result = 0; var num_M = num_NK[0]; do { num_M = num_M / num_NK[1]; result++; } while (num_M >= num_NK[1]); Console.WriteLine(result + 1); Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionM { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var num_NK = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); int result = 0; var num_M = num_NK[0]; do { num_M = num_M / num_NK[1]; result++; } while (num_M != 0); Console.WriteLine(result); Console.Out.Flush(); } } }
[["-", 0, 195, 8, 196, 0, 82, 15, 16, 17, 20], ["-", 8, 196, 0, 82, 15, 16, 12, 204, 205, 22], ["-", 0, 82, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 82, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 82, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 82, 15, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
166
9
using System; class test { public static void Main() { var str = Console.ReadLine().Split(' '); int X = int.Parse(str[0]); int Y = int.Parse(str[1]); int count = 0; while (X / Y != 0) { X /= Y; Console.Write(X); count++; } count++; Console.Write(count); } }
using System; class test { public static void Main() { var str = Console.ReadLine().Split(' '); int X = int.Parse(str[0]); int Y = int.Parse(str[1]); int count = 0; while (X / Y != 0) { X /= Y; count++; } count++; Console.Write(count); } }
[["-", 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, 52, 8, 196, 0, 1, 0, 35]]
8
96
7
using System; using static System.Console; using static System.Math; public class Hello { public static void Main() { int[] read = inta(); long a = read[0]; long b = read[1]; long c = 1; int k = 0; while (c < a) { c *= b; k++; } WriteLine(k); } //各種読取 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; } // A/B小数点以下切上 static int divideup(int divided, int divid) { int temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } }
using System; using static System.Console; using static System.Math; public class Hello { public static void Main() { int[] read = inta(); long a = read[0]; long b = read[1]; int k = 0; while (a > 0) { a /= b; k++; } WriteLine(k); } //各種読取 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; } // A/B小数点以下切上 static int divideup(int divided, int divid) { int temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90]]
8
346
13
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string[] inputData = Console.ReadLine().Split(' '); int data = int.Parse(inputData[0]); int nCnt = int.Parse(inputData[1]); int count = 1; while (true) { int div = data / nCnt; int per = data % nCnt; if (div < nCnt) { count++; break; } data = div; count++; } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string[] inputData = Console.ReadLine().Split(' '); int data = int.Parse(inputData[0]); int nCnt = int.Parse(inputData[1]); int count = 1; while (true) { int div = data / nCnt; int per = data % nCnt; if (div < nCnt) { if (count != 1 || div != 0) { count++; } break; } data = div; count++; } Console.WriteLine(count); } } }
[["+", 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, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 106], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
8
142
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp15 { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得 long tss = long.Parse(str[1]); long count = 1; while (true) { if (tss >= long.Parse(str[0])) { if (long.Parse(str[0]) == 10 && long.Parse(str[1]) == 10) { count = 2; } break; } else { tss *= long.Parse(str[1]); } count++; } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp15 { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); long tss = long.Parse(str[1]); long count = 1; while (true) { if (tss >= long.Parse(str[0])) { if (tss == long.Parse(str[0])) { count++; } break; } else { tss *= long.Parse(str[1]); } count++; } Console.WriteLine(count); } } }
[["-", 15, 16, 31, 16, 31, 213, 63, 214, 205, 199], ["-", 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], ["-", 31, 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], ["-", 15, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 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, 29]]
8
164
19
using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace AtCorder { public static class Program { static public void Main(string[] args) { int output = 1; int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int num = input[0]; while (true) { if (num / input[1] >= input[1]) { output++; num = num / input[1]; } else { output++; break; } } Console.WriteLine(output.ToString()); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace AtCorder { public static class Program { static public void Main(string[] args) { int output = 1; int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int num = input[0]; while (true) { if (input[0] < input[1]) { break; } if (num / input[1] >= input[1]) { output++; num = num / input[1]; } else { output++; break; } } Console.WriteLine(output.ToString()); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 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, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24]]
8
137
16
using System; using System.Collections.Generic; using System.Linq; namespace AC { class Program { static void Main(string[] args) { var input = ReadArrayLong(); var N = input[0]; var K = input[1]; var ans = 1L; var chk = K; while (chk < N) { ans++; chk *= K; } Console.WriteLine(ans); Console.ReadKey(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AC { class Program { static void Main(string[] args) { var input = ReadArrayLong(); var N = input[0]; var K = input[1]; var ans = ""; while (true) { ans = N % K + ans; N /= K; if (N == 0) break; } Console.WriteLine(ans.Count()); Console.ReadKey(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 109], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 35], ["+", 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
217
35
using System; using System.Collections.Generic; using System.Linq; namespace test { class MainClass { public static void Main(string[] args) { //問題156 int n = int.Parse(Console.ReadLine()); string[] line = Console.ReadLine().Split(' '); int[] x = new int[n]; int min = 100; int max = 1; for (int i = 0; i < n; i++) { x[i] = int.Parse(line[i]); min = Math.Min(min, x[i]); max = Math.Max(max, x[i]); } int ans = 9999; for (int i = min; i <= max; i++) { int count = 0; for (int j = 0; j < n; j++) { count += (x[j] - i) * (x[j] - i); } ans = Math.Min(ans, count); } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; namespace test { class MainClass { public static void Main(string[] args) { //問題156 int n = int.Parse(Console.ReadLine()); string[] line = Console.ReadLine().Split(' '); int[] x = new int[n]; int min = 100; int max = 1; for (int i = 0; i < n; i++) { x[i] = int.Parse(line[i]); min = Math.Min(min, x[i]); max = Math.Max(max, x[i]); } long ans = 0; for (int i = min; i <= max; i++) { long count = 0; for (int j = 0; j < n; j++) { count += (x[j] - i) * (x[j] - i); } if (i == min) { ans = count; } ans = Math.Min(ans, count); } Console.WriteLine(ans); } } }
[["-", 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, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 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, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 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, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
8
228
18
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { static void Main(string[] args) { var n = ReadLineInt(); var x = ReadLineIntSpilit(); var total = 0; for (int i = 0; i <= x[x.Length - 1]; i++) { var add = 0; for (int q = 0; q < n; q++) { add += (x[q] - i) * (x[q] - i); } if (i == 1) { total = add; } else if (total > add) { total = add; } } Console.WriteLine(total); ReadLine(); } //メモ //降順 // var sort = array.OrderBy(x => -x).ToArray(); //最大公約数 static int gcd(int a, int b) { if (a > b) { return gcd(b, a); } while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } //最小公倍数 static int lcm(int a, int b) => a * b / gcd(a, b); /// <summary> /// コンビネーション /// </summary> static int nCm(int n, int m) { if (m == 0) return 1; if (n == 0) return 0; return n * nCm(n - 1, m - 1) / m; } public static string ReadLine() => Console.ReadLine(); public static int ReadLineInt() => int.Parse(Console.ReadLine()); public static long ReadLineLongInt() => long.Parse(Console.ReadLine()); public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray(); public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray(); public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray(); static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }; static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { static void Main(string[] args) { var n = ReadLineInt(); var x = ReadLineIntSpilit(); var total = int.MaxValue; for (int i = 0; i <= 100; i++) { var add = 0; for (int q = 0; q < n; q++) { add += (int)Math.Pow(x[q] - i, 2); } if (total > add) total = add; } Console.WriteLine(total); ReadLine(); } //メモ //降順 // var sort = array.OrderBy(x => -x).ToArray(); //最大公約数 static int gcd(int a, int b) { if (a > b) { return gcd(b, a); } while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } //最小公倍数 static int lcm(int a, int b) => a * b / gcd(a, b); /// <summary> /// コンビネーション /// </summary> static int nCm(int n, int m) { if (m == 0) return 1; if (n == 0) return 0; return n * nCm(n - 1, m - 1) / m; } public static string ReadLine() => Console.ReadLine(); public static int ReadLineInt() => int.Parse(Console.ReadLine()); public static long ReadLineLongInt() => long.Parse(Console.ReadLine()); public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray(); public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray(); public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray(); static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }; static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; } }
[["-", 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], ["-", 8, 196, 0, 7, 15, 16, 12, 204, 205, 22], ["-", 0, 7, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["-", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["-", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 7, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 12, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 11, 12, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 11, 12, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 74, 51, 213, 63, 214, 141, 22], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 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, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 11, 12, 74, 51, 213, 3, 4, 0, 21], ["+", 12, 74, 51, 213, 3, 4, 0, 28, 0, 203], ["-", 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, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 8, 196, 0, 57, 75, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46]]
8
688
41
using System; namespace CodingForces { static class Program { static void Main(string[] args) { Console.ReadLine(); int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); long staminaSum = 0; double coordinateSum = 0; for (int i = 0; i < nbrs.Length; i++) { coordinateSum += nbrs[i]; } double pos = Math.Round(coordinateSum / nbrs.Length); Console.WriteLine(pos); for (int i = 0; i < nbrs.Length; i++) { staminaSum += (long)Math.Pow(nbrs[i] - pos, 2); } Console.WriteLine(staminaSum); } } }
using System; namespace CodingForces { static class Program { static void Main(string[] args) { Console.ReadLine(); int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); long staminaSum = 0; double coordinateSum = 0; for (int i = 0; i < nbrs.Length; i++) { coordinateSum += nbrs[i]; } double pos = Math.Round(coordinateSum / nbrs.Length); for (int i = 0; i < nbrs.Length; i++) { staminaSum += (long)Math.Pow(nbrs[i] - pos, 2); } Console.WriteLine(staminaSum); } } }
[["-", 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
153
7
using System.Collections.Generic; using System.Linq; public class Hello { public static void Main() { hoge(); System.Console.ReadLine(); } public static void hoge() { var line = System.Console.ReadLine() .Split(' ') .Select(x => int.Parse(x)) .ToArray(); var n = line[0]; var xs = System.Console.ReadLine() .Split(' ') .Select(x => int.Parse(x)) .ToArray(); List<int> lst = new List<int>(); var min = 10000; for (int i = 0; i < 100; i++) { var sum = 0; for (int j = 0; j < n; j++) { sum += (xs[j] - (i + 1)) * (xs[j] - (i + 1)); } min = sum < min ? sum : min; } System.Console.WriteLine(min); } }
using System.Collections.Generic; using System.Linq; public class Hello { public static void Main() { hoge(); System.Console.ReadLine(); } public static void hoge() { var line = System.Console.ReadLine() .Split(' ') .Select(x => long.Parse(x)) .ToArray(); var n = line[0]; var xs = System.Console.ReadLine() .Split(' ') .Select(x => long.Parse(x)) .ToArray(); List<long> lst = new List<long>(); var min = long.MaxValue; for (long i = 0; i < 100; i++) { long sum = 0; for (long j = 0; j < n; j++) { sum += (xs[j] - (i + 1)) * (xs[j] - (i + 1)); } min = sum < min ? sum : min; } System.Console.WriteLine(min); } }
[["-", 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, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 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, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 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]]
8
224
18
using System; using System.Collections.Generic; using static System.Console; using System.Linq; using System.Text; using System.Threading.Tasks; namespace C_Rally { class Program { static void Main(string[] args) { int total = int.Parse(ReadLine()); string input = ReadLine(); string[] array = input.Split(' '); int[] n = new int[array.Length]; for (int i = 0; i < array.Length; i++) { n[i] = int.Parse(array[i]); } int result = 0; int sum = 0; for (int k = 0; k < total; k++) { sum += n[k]; } sum = sum / total; int p = 0; for (int m = 0; m < 2; m++) { for (int j = 0; j < total; j++) { if (sum < n[j]) { result += ((n[j] - sum) * (n[j] - sum)); } else { result += ((sum - n[j]) * (sum - n[j])); } } sum += m + 1; if (p == 0) { p = result; } if (p > result) { p = result; } result = 0; } WriteLine("{0}", p); ReadKey(); } } }
using System; using System.Collections.Generic; using static System.Console; using System.Linq; using System.Text; using System.Threading.Tasks; namespace C_Rally { class Program { static void Main(string[] args) { int total = int.Parse(ReadLine()); string input = ReadLine(); string[] array = input.Split(' '); int[] n = new int[array.Length]; for (int i = 0; i < array.Length; i++) { n[i] = int.Parse(array[i]); } int result = 0; int sum = 0; for (int k = 0; k < total; k++) { sum += n[k]; } sum = sum / total; int p = 0; for (int m = 0; m < 2; m++) { for (int j = 0; j < total; j++) { if (sum < n[j]) { result += ((n[j] - sum) * (n[j] - sum)); } else { result += ((sum - n[j]) * (sum - n[j])); } } sum += m + 1; if (result == 0) { break; } if (p == 0) { p = result; } if (p > result) { p = result; } result = 0; } WriteLine("{0}", p); ReadKey(); } } }
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 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
312
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder_solve { class Program { static void Main(string[] args) { double n = double.Parse(Console.ReadLine()); string[] data = Console.ReadLine().Split(); double sum = 0; double ans = 0; for (long i = 0; i < n; i++) { sum += double.Parse(data[i]); } double p = sum / n; Console.WriteLine(p); p = Math.Round(p, MidpointRounding.AwayFromZero); Console.WriteLine(p); for (long i = 0; i < n; i++) { ans += (double.Parse(data[i]) - p) * (double.Parse(data[i]) - p); } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder_solve { class Program { static void Main(string[] args) { double n = double.Parse(Console.ReadLine()); string[] data = Console.ReadLine().Split(); double sum = 0; double ans = 0; for (long i = 0; i < n; i++) { sum += double.Parse(data[i]); } double p = sum / n; p = Math.Round(p, MidpointRounding.AwayFromZero); for (long i = 0; i < n; i++) { ans += (double.Parse(data[i]) - p) * (double.Parse(data[i]) - p); } Console.WriteLine(ans); } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
8
200
14
using System.Linq; using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); Console.WriteLine(getAns(n, a)); } static int getAns(int n, int[] a) { var amax = a.Max(); var amin = a.Min(); var ans = int.MaxValue; for (int i = amin; i <= amax; i++) { var t = 0; for (int j = 0; j < n; j++) t += (a[j] - i) * (a[j] - i); if (t < ans) Console.WriteLine(i); } return ans; } }
using static System.Math; using System.Linq; using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); Console.WriteLine(getAns(n, a)); } static int getAns(int n, int[] a) { var amax = a.Max(); var amin = a.Min(); var ans = int.MaxValue; for (int i = amin; i <= amax; i++) { var t = 0; for (int j = 0; j < n; j++) t += (a[j] - i) * (a[j] - i); ans = Min(ans, t); } return ans; } }
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 115], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 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, 231, 0, 233], ["-", 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, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["-", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 213, 63, 22], ["-", 64, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21]]
8
197
20
using System; using System.Numerics; using System.Linq; using System.Collections.Generic; using System.Text; using System.Collections; namespace debug { class main { static void Main(string[] args) { //問題クラスを展開 ProgramE a = new ProgramE(); a.main(); //実行する } } class ProgramA { public void main() { //入力 string[] input = Console.ReadLine().Split(' '); int m = int.Parse(input[0]); int n = int.Parse(input[1]); //偶数同士の組み合わせと奇数同士の組み合わせなので、mC2とnC2を求める Console.WriteLine((m - 1) * m / 2 + n * (n - 1) / 2); } } class ProgramB { public void main() { //入力 string s = Console.ReadLine(); int len = s.Length; for (int i = 0; i < (len - 1) / 2; i++) { //回文かみる if (s[i] != s[(len - 1) - i]) { Console.WriteLine("No"); return; } //前半が回文かみる if (s[i] != s[(len - 1) / 2 - i]) { Console.WriteLine("No"); return; } //後半が回文かみる if (s[(len + 3) / 2 + i] != s[len - 1 - i]) { Console.WriteLine("No"); return; } } Console.WriteLine("Yes"); } } class ProgramC { public void main() { //入力 double l = double.Parse(Console.ReadLine()); // a=b=c=l/3のとき最大 Console.WriteLine((l / 3.0) * (l / 3.0) * (l / 3.0)); } } class ProgramD { public void main() { //入力 long n = long.Parse(Console.ReadLine()); string[] a = Console.ReadLine().Split(' '); long[] num = new long[n]; long sum = 0; //それぞれ数がいくつあるか数える for (int i = 0; i < n; i++) { long temp = long.Parse(a[i]); num[temp - 1]++; } //とりあえずすべての数え方を見る for (int i = 0; i < n; i++) { sum += num[i] * (num[i] - 1) / 2; } // 1つずつ禁止されたときに場合を除く(n-1する)。答を出力 for (int i = 0; i < n; i++) { long temp = long.Parse(a[i]); Console.WriteLine(sum - num[temp - 1] + 1); } } } class ProgramE { public void main() { //入力 string[] input = Console.ReadLine().Split(' '); int h = int.Parse(input[0]); int w = int.Parse(input[1]); int k = int.Parse(input[2]); //チョコの場所と白の位置把握 int[,] choco = new int[h, w]; int count = 0; for (int i = 0; i < h; i++) { string input2 = Console.ReadLine(); for (int j = 0; j < w; j++) { choco[i, j] = input2[j] - '0'; if (choco[i, j] == 1) count++; } } //白がk個以下なら切る必要はない if (count <= k) { Console.WriteLine("0"); return; } //切る回数 int ans = 100000000; int sum = 0; //縦の切り口を決める for (int i = 0; i < (1 << (h - 1)); i++) { sum = 0; int[] comb = new int[h]; //まずは横の切り口を記録 for (int j = 0; j < h - 1; j++) sum += (i >> j) & 1; //切る数を足す if (ans <= sum) continue; //貪欲法で縦の切る回数を数える for (int j = 0; j < w; j++) { int part = 0; int flag = 0; //それぞれの部分で分けながらカウントしていく for (int l = 0; l < h; l++) { comb[part] += choco[l, j]; if (comb[part] > k) { flag = 1; } part += (i >> l) & 1; } //もしk超えてしまったら出す if (flag == 1) { part = 0; //リセット for (int l = 0; l < h; l++) comb[l] = 0; //その列だけ再構成 for (int l = 0; l < h; l++) { comb[part] += choco[l, j]; part += (i >> l) & 1; } //以上に多いなら大きなカウントする for (int l = 0; l <= part; l++) { if (comb[l] > k) sum += 1000000; } if (j != 0) sum++; } } //最小更新 if (ans > sum) ans = sum; } Console.WriteLine(ans); } } class ProgramF { public void main() { string[] s = Console.ReadLine().Split(' '); int n = int.Parse(s[0]); int num = int.Parse(s[1]); long MOD = 998244353; string[] a = Console.ReadLine().Split(' '); long[,] dp = new long[n + 1, num + 1]; //初項設定 dp[0, 0] = 1; // i番目までで、選び方によって出てくる和(j)を求める for (int i = 0; i < n; i++) for (int j = 0; j < num + 1; j++) { long temp = j + long.Parse(a[i]); // 3001以上は答にならないので省く //入れる場合は、Tとして選んでかつその和に組み込むのでそのまま足す。 if (temp <= num) { dp[i + 1, temp] += dp[i, j]; dp[i + 1, temp] %= MOD; } //いれない場合は集合として成立しているのでそのi番目を選ぼうが選ばなかろうが部分として考えなければよい。よって、2倍して拡張 dp[i + 1, j] += (dp[i, j] * 2) % MOD; dp[i + 1, j] %= MOD; } //答はdp[n,num]で出てくる Console.WriteLine(dp[n, num]); } } }
using System; using System.Numerics; using System.Linq; using System.Collections.Generic; using System.Text; using System.Collections; namespace debug { class main { static void Main(string[] args) { //問題クラスを展開 ProgramE a = new ProgramE(); a.main(); //実行する } } class ProgramA { public void main() { //入力 string[] input = Console.ReadLine().Split(' '); int m = int.Parse(input[0]); int n = int.Parse(input[1]); //偶数同士の組み合わせと奇数同士の組み合わせなので、mC2とnC2を求める Console.WriteLine((m - 1) * m / 2 + n * (n - 1) / 2); } } class ProgramB { public void main() { //入力 string s = Console.ReadLine(); int len = s.Length; for (int i = 0; i < (len - 1) / 2; i++) { //回文かみる if (s[i] != s[(len - 1) - i]) { Console.WriteLine("No"); return; } //前半が回文かみる if (s[i] != s[(len - 1) / 2 - i]) { Console.WriteLine("No"); return; } //後半が回文かみる if (s[(len + 3) / 2 + i] != s[len - 1 - i]) { Console.WriteLine("No"); return; } } Console.WriteLine("Yes"); } } class ProgramC { public void main() { //入力 double l = double.Parse(Console.ReadLine()); // a=b=c=l/3のとき最大 Console.WriteLine((l / 3.0) * (l / 3.0) * (l / 3.0)); } } class ProgramD { public void main() { //入力 long n = long.Parse(Console.ReadLine()); string[] a = Console.ReadLine().Split(' '); long[] num = new long[n]; long sum = 0; //それぞれ数がいくつあるか数える for (int i = 0; i < n; i++) { long temp = long.Parse(a[i]); num[temp - 1]++; } //とりあえずすべての数え方を見る for (int i = 0; i < n; i++) { sum += num[i] * (num[i] - 1) / 2; } // 1つずつ禁止されたときに場合を除く(n-1する)。答を出力 for (int i = 0; i < n; i++) { long temp = long.Parse(a[i]); Console.WriteLine(sum - num[temp - 1] + 1); } } } class ProgramE { public void main() { //入力 string[] input = Console.ReadLine().Split(' '); int h = int.Parse(input[0]); int w = int.Parse(input[1]); int k = int.Parse(input[2]); //チョコの場所と白の位置把握 int[,] choco = new int[h, w]; int count = 0; for (int i = 0; i < h; i++) { string input2 = Console.ReadLine(); for (int j = 0; j < w; j++) { choco[i, j] = input2[j] - '0'; if (choco[i, j] == 1) count++; } } //白がk個以下なら切る必要はない if (count <= k) { Console.WriteLine("0"); return; } //切る回数 int ans = 1000000; int sum = 0; //縦の切り口を決める for (int i = 0; i < (1 << (h - 1)); i++) { sum = 0; int[] comb = new int[h]; //まずは横の切り口を記録 for (int j = 0; j < h - 1; j++) sum += (i >> j) & 1; //切る数を足す if (ans <= sum) continue; //貪欲法で縦の切る回数を数える for (int j = 0; j < w; j++) { int part = 0; int flag = 0; //それぞれの部分で分けながらカウントしていく for (int l = 0; l < h; l++) { comb[part] += choco[l, j]; if (comb[part] > k) { if (j != 0) flag = 1; else flag = 2; } part += (i >> l) & 1; } //もしk超えてしまったら出す if (flag == 1) { part = 0; //リセット for (int l = 0; l < h; l++) comb[l] = 0; //その列だけ再構成 for (int l = 0; l < h; l++) { comb[part] += choco[l, j]; part += (i >> l) & 1; } //条件を満たさないなら省く for (int l = 0; l <= part; l++) { if (comb[l] > k) sum += 1000000; } sum++; } if (flag == 2) { sum = 1000000; break; } } //最小更新 if (ans > sum) ans = sum; } Console.WriteLine(ans); } } class ProgramF { public void main() { string[] s = Console.ReadLine().Split(' '); int n = int.Parse(s[0]); int num = int.Parse(s[1]); long MOD = 998244353; string[] a = Console.ReadLine().Split(' '); long[,] dp = new long[n + 1, num + 1]; //初項設定 dp[0, 0] = 1; // i番目までで、選び方によって出てくる和(j)を求める for (int i = 0; i < n; i++) for (int j = 0; j < num + 1; j++) { long temp = j + long.Parse(a[i]); // 3001以上は答にならないので省く //入れる場合は、Tとして選んでかつその和に組み込むのでそのまま足す。 if (temp <= num) { dp[i + 1, temp] += dp[i, j]; dp[i + 1, temp] %= MOD; } //いれない場合は集合として成立しているのでそのi番目を選ぼうが選ばなかろうが部分として考えなければよい。よって、2倍して拡張 dp[i + 1, j] += (dp[i, j] * 2) % MOD; dp[i + 1, j] %= MOD; } //答はdp[n,num]で出てくる Console.WriteLine(dp[n, num]); } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 79], ["+", 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, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 64, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 57, 75, 1, 0, 11, 12, 203], ["+", 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, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
8
1,256
29
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading.Tasks; using System.Globalization; using System.Collections; namespace Atcoder { class Program { public static List<int>[] Togo; public static UnionFind find; static void Main(string[] args) { StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput()); int h = scan.Integer(); int w = scan.Integer(); int k = scan.Integer(); int[,] s = scan.StringToInt(h, w); int max = 1 << (h - 1); int min = int.MaxValue; for (int i = 0; i < max; i++) { List<int[]> ds = new List<int[]>(); int defkaisu = 0; int[] buf = new int[w]; for (int j = 0; j < h - 1; j++) { for (int l = 0; l < w; l++) { buf[l] += s[j, l]; } if ((i & (1 << j)) == (1 << j)) { defkaisu++; ds.Add(buf); buf = new int[w]; } } for (int l = 0; l < w; l++) { buf[l] += s[h - 1, l]; } ds.Add(buf); min = Math.Min(min, solve(ds.ToArray(), k, defkaisu)); } Console.WriteLine(min); } static int solve(int[][] s, int k, int defkaisu) { int w = s[0].Length; int h = s.GetLength(0); int[] buf = new int[h]; int kaisu = defkaisu; for (int j = 0; j < w; j++) { for (int i = 0; i < h; i++) { if (s[i][j] > k) { return int.MaxValue; } if (j > 0) { if (buf[i] + s[i][j] > k) { for (int l = 0; l < h; l++) { buf[l] = s[l][j]; } kaisu++; } else { buf[i] += s[i][j]; } } else { for (int l = 0; l < h; l++) { buf[l] = s[l][j]; } } // j=0で↑をやり過ごしているならカットは不要 } } return kaisu; } static List<int> solve(int n, int ima) // nokoriだけ { if (ima == 0) { for (int i = 0; i < Togo[n].Count; i++) { var buf = solve(Togo[n][i], 1); for (int j = 0; j < buf.Count; j++) { find.Unite(n, buf[j]); } } return null; } else if (ima == 3) { var buf = new List<int>(); buf.Add(n); return buf; } else { var ret = new List<int>(); for (int i = 0; i < Togo[n].Count; i++) { var buf = solve(Togo[n][i], ima++); ret.AddRange(buf); } return ret; } } static long Syakutori( int[] a, long k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上 { long sum = 0; int right = 0; long ans = 0; for (int left = 0; left < a.Length; left++) { while (right < a.Length && sum < k) { sum += a[right]; right++; } if (k <= sum) { ans += a.Length - right + 1; } if (left == right) { right++; } else { sum -= a[left]; } } return ans; } static int[] zalgo(String s) { int n = s.Length; int[] ret = new int[n]; ret[0] = n; int i = 1, j = 0; while (i < n) { while (i + j < n && s[j] == s[i + j]) ++j; ret[i] = j; if (j == 0) { ++i; continue; } int k = 1; while (i + k < n && k + ret[k] < j) { ret[i + k] = ret[k]; ++k; } i += k; j -= k; } return ret; } static int gcd(int a, int b) { if (a % b == 0) { return b; } return gcd(b, a % b); } static int[] yousogotoplus(int[] a, int[] b) { int[] c = new int[a.Length]; for (int i = 0; i < a.Length; i++) { c[i] = a[i] + b[i]; } return c; } static int[] yousogotoplus(int[] a, int[,] b, int l) { int[] c = new int[a.Length]; for (int i = 0; i < a.Length; i++) { c[i] = a[i] + b[l, i]; } return c; } static int[] yousogotoplus(int[,] a, int l) { int[] c = new int[a.GetLength(1)]; for (int i = 0; i < a.GetLength(1); i++) { c[i] = a[l, i]; } return c; } static long solve(int mae, int ushiro, long[,] dp, int[] a, bool taro) { if (dp[mae, ushiro] > long.MinValue) { return dp[mae, ushiro]; } if (ushiro - mae == 1) { if (taro) { dp[mae, ushiro] = a[mae]; return dp[mae, ushiro]; } else { dp[mae, ushiro] = -a[mae]; return dp[mae, ushiro]; } } if (taro) { long max = Math.Max(a[mae] + solve(mae + 1, ushiro, dp, a, !taro), a[ushiro - 1] + solve(mae, ushiro - 1, dp, a, !taro)); dp[mae, ushiro] = max; return dp[mae, ushiro]; } else { long min = Math.Min(-a[mae] + solve(mae + 1, ushiro, dp, a, !taro), -a[ushiro - 1] + solve(mae, ushiro - 1, dp, a, !taro)); dp[mae, ushiro] = min; return dp[mae, ushiro]; } } static int nibutan(int med, int[] a) // med以上が何個あるか { int mae = 0; int ato = a.Length; while (true) { if (ato - mae <= 1) { return mae; } int mid = (mae + ato) / 2; if (a[mid] > med) { ato = mid; } if (a[mid] <= med) { mae = mid; } } } static int binary_search(int key, int[] moto) { int ng = -1; int ok = moto.Length; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key, moto)) { ok = mid; } else { ng = mid; } } return ok; } static bool isOK(int index, int key, int[] moto) { return moto[index] >= key; } public static int h; public static int w; public static int BFS(int height, int width, char[,] map) { int[] dx = new int[] { -1, 0, 0, 1 }; int[] dy = new int[] { 0, 1, -1, 0 }; bool[,] visited = new bool[h, w]; int[,] len = new int[h, w]; var queue = new Queue<Tuple<int, int>>(); queue.Enqueue(new Tuple<int, int>(height, width)); int max = 0; visited[height, width] = true; while (queue.Count > 0) { var now = queue.Dequeue(); for (int i = 0; i < 4; i++) { int ny = now.Item1 + dy[i]; int nx = now.Item2 + dx[i]; if (ny >= h || ny < 0 || nx >= w || nx < 0) continue; if (visited[ny, nx] || map[ny, nx] == '#') continue; visited[ny, nx] = true; len[ny, nx] = len[now.Item1, now.Item2] + 1; max = Math.Max(max, len[ny, nx]); queue.Enqueue(new Tuple<int, int>(ny, nx)); } } return max; } } public class StreamScanner { public StreamScanner(Stream stream) { str = stream; } private 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) throw new EndOfStreamException(); if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } public char[] Char(int n) { char[] kore = new char[n]; for (int i = 0; i < n; i++) { kore[i] = Char(); } return kore; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public long Long() { long ret = 0; byte b = 0; var ng = false; do b = read(); while (b != '-' && (b < '0' || '9' < b)); if (b == '-') { ng = true; b = read(); } for (; true; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; else ret = ret * 10 + b - '0'; } } public long[] Long(int n) { long[] kore = new long[n]; for (int i = 0; i < n; i++) { kore[i] = Long(); } return kore; } public int Integer() { return (int)Long(); } public int[] Integer(int n) { int[] kore = new int[n]; for (int i = 0; i < n; i++) { kore[i] = (int)Long(); } return kore; } public int[,] Integer(int h, int w) { int[,] kore = new int[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { kore[i, j] = (int)Long(); } } return kore; } public int[] StringToInt(int n) { char[] s = Scan().ToCharArray(); int[] kore = new int[n]; for (int i = 0; i < n; i++) { kore[i] = s[i] - '0'; } return kore; } public int[,] StringToInt(int h, int w) { int[,] kore = new int[h, w]; for (int i = 0; i < h; i++) { char[] s = Scan().ToCharArray(); for (int j = 0; j < w; j++) { kore[i, j] = s[j] - '0'; } } return kore; } public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } public class UnionFind { public int[] data; public UnionFind(int size) { data = new int[size]; for (int i = 0; i < size; i++) data[i] = -1; } public bool Unite(int x, int y) { x = Root(x); y = Root(y); if (x != y) { if (data[y] < data[x]) { var tmp = y; y = x; x = tmp; } data[x] += data[y]; data[y] = x; } return x != y; } public bool IsSameGroup(int x, int y) { return Root(x) == Root(y); } public int Root(int x) { return data[x] < 0 ? x : data[x] = Root(data[x]); } } public class Mlong { private static long mod = 1000000007; public long num; public Mlong(long num) { this.num = num; } public override int GetHashCode() { return num.GetHashCode(); } public override bool Equals(object obj) { return num.Equals(obj); } public static Mlong operator +(Mlong x, Mlong y) { return new Mlong((x.num + y.num) % mod); } public static Mlong operator -(Mlong x, Mlong y) { return new Mlong((x.num - y.num + mod) % mod); } public static Mlong operator *(Mlong x, Mlong y) { return new Mlong((long)(((1L * x.num) * y.num) % mod)); } public Mlong hutujyo(Mlong x) { return new Mlong(num / x.num); } public Mlong modjyo(Mlong x) { return num * x.Pow(mod - 2); } public static implicit operator Mlong(long x) { return new Mlong(x); } public static Mlong operator %(Mlong x, Mlong y) { return new Mlong(x.num % y.num); } public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; } public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; } public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; } public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; } public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; } public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; } public Mlong Pow(Mlong n) { if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mlong buf = Pow(n.hutujyo(2)); return (buf * buf) % mod; } public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); } public static Mlong Comb(Mlong n, Mlong a) { Mlong buf1 = 1; Mlong buf2 = 1; for (long i = 0; i < a; i++) { buf1 *= n - i; buf2 *= (i + 1); } return buf1.modjyo(buf2); } public static void WriteLine(Mlong x) { Console.WriteLine(x.num); } } public class Mint { private static int mod = 1000000007; public int num; public Mint(int Num) { num = Num; } public override int GetHashCode() { return num.GetHashCode(); } public override bool Equals(object obj) { return num.Equals(obj); } public static Mint operator +(Mint x, Mint y) { return new Mint((x.num + y.num) % mod); } public static Mint operator -(Mint x, Mint y) { return new Mint((x.num - y.num + mod) % mod); } public static Mint operator *(Mint x, Mint y) { return new Mint((int)(((1L * x.num) * y.num) % mod)); } public Mint hutujyo(Mint x) { return new Mint(num / x.num); } public Mint modjyo(Mint x) { return num * x.Pow(mod - 2); } public static implicit operator Mint(int x) { return new Mint(x); } public static Mint[] Toarray(int[] x) { Mint[] buf = new Mint[x.Length]; for (int i = 0; i < x.Length; i++) { buf[i] = x[i]; } return buf; } public static explicit operator int(Mint x) { return x.num; } public static Mint operator %(Mint x, Mint y) { return new Mint(x.num % y.num); } public static bool operator ==(Mint x, Mint y) { return x.num == y.num; } public static bool operator !=(Mint x, Mint y) { return x.num != y.num; } public static bool operator<(Mint x, Mint y) { return x.num < y.num; } public static bool operator>(Mint x, Mint y) { return x.num > y.num; } public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; } public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; } public Mint Pow(Mint n) { if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mint buf = Pow(n.hutujyo(2)); return (buf * buf) % mod; } public static Mint Pow(Mint a, Mint n) { return a.Pow(n); } public static Mint Comb(Mint n, Mint a) { Mint buf1 = 1; Mint buf2 = 1; for (int i = 0; i < a; i++) { buf1 *= n - i; buf2 *= (i + 1); } return buf1.modjyo(buf2); } public static void WriteLine(Mint x) { Console.WriteLine(x.num); } } public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) {} public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) {} public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading.Tasks; using System.Globalization; using System.Collections; namespace Atcoder { class Program { public static List<int>[] Togo; public static UnionFind find; static void Main(string[] args) { StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput()); int h = scan.Integer(); int w = scan.Integer(); int k = scan.Integer(); int[,] s = scan.StringToInt(h, w); int max = 1 << (h - 1); int min = int.MaxValue; for (int i = 0; i < max; i++) { List<int[]> ds = new List<int[]>(); int defkaisu = 0; int[] buf = new int[w]; for (int j = 0; j < h - 1; j++) { for (int l = 0; l < w; l++) { buf[l] += s[j, l]; } if ((i & (1 << j)) == (1 << j)) { defkaisu++; ds.Add(buf); buf = new int[w]; } } for (int l = 0; l < w; l++) { buf[l] += s[h - 1, l]; } ds.Add(buf); min = Math.Min(min, solve(ds.ToArray(), k, defkaisu)); } Console.WriteLine(min); } static int solve(int[][] s, int k, int defkaisu) { int w = s[0].Length; int h = s.GetLength(0); int[] buf = new int[h]; int kaisu = defkaisu; bool done = false; for (int j = 0; j < w; j++) { done = false; for (int i = 0; i < h; i++) { if (done) { continue; } if (s[i][j] > k) { return int.MaxValue; } if (j > 0) { if (buf[i] + s[i][j] > k) { for (int l = 0; l < h; l++) { buf[l] = s[l][j]; } kaisu++; done = true; } else { buf[i] += s[i][j]; } } else { for (int l = 0; l < h; l++) { buf[l] = s[l][j]; } } // j=0で↑をやり過ごしているならカットは不要 } } return kaisu; } static List<int> solve(int n, int ima) // nokoriだけ { if (ima == 0) { for (int i = 0; i < Togo[n].Count; i++) { var buf = solve(Togo[n][i], 1); for (int j = 0; j < buf.Count; j++) { find.Unite(n, buf[j]); } } return null; } else if (ima == 3) { var buf = new List<int>(); buf.Add(n); return buf; } else { var ret = new List<int>(); for (int i = 0; i < Togo[n].Count; i++) { var buf = solve(Togo[n][i], ima++); ret.AddRange(buf); } return ret; } } static long Syakutori( int[] a, long k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上 { long sum = 0; int right = 0; long ans = 0; for (int left = 0; left < a.Length; left++) { while (right < a.Length && sum < k) { sum += a[right]; right++; } if (k <= sum) { ans += a.Length - right + 1; } if (left == right) { right++; } else { sum -= a[left]; } } return ans; } static int[] zalgo(String s) { int n = s.Length; int[] ret = new int[n]; ret[0] = n; int i = 1, j = 0; while (i < n) { while (i + j < n && s[j] == s[i + j]) ++j; ret[i] = j; if (j == 0) { ++i; continue; } int k = 1; while (i + k < n && k + ret[k] < j) { ret[i + k] = ret[k]; ++k; } i += k; j -= k; } return ret; } static int gcd(int a, int b) { if (a % b == 0) { return b; } return gcd(b, a % b); } static int[] yousogotoplus(int[] a, int[] b) { int[] c = new int[a.Length]; for (int i = 0; i < a.Length; i++) { c[i] = a[i] + b[i]; } return c; } static int[] yousogotoplus(int[] a, int[,] b, int l) { int[] c = new int[a.Length]; for (int i = 0; i < a.Length; i++) { c[i] = a[i] + b[l, i]; } return c; } static int[] yousogotoplus(int[,] a, int l) { int[] c = new int[a.GetLength(1)]; for (int i = 0; i < a.GetLength(1); i++) { c[i] = a[l, i]; } return c; } static long solve(int mae, int ushiro, long[,] dp, int[] a, bool taro) { if (dp[mae, ushiro] > long.MinValue) { return dp[mae, ushiro]; } if (ushiro - mae == 1) { if (taro) { dp[mae, ushiro] = a[mae]; return dp[mae, ushiro]; } else { dp[mae, ushiro] = -a[mae]; return dp[mae, ushiro]; } } if (taro) { long max = Math.Max(a[mae] + solve(mae + 1, ushiro, dp, a, !taro), a[ushiro - 1] + solve(mae, ushiro - 1, dp, a, !taro)); dp[mae, ushiro] = max; return dp[mae, ushiro]; } else { long min = Math.Min(-a[mae] + solve(mae + 1, ushiro, dp, a, !taro), -a[ushiro - 1] + solve(mae, ushiro - 1, dp, a, !taro)); dp[mae, ushiro] = min; return dp[mae, ushiro]; } } static int nibutan(int med, int[] a) // med以上が何個あるか { int mae = 0; int ato = a.Length; while (true) { if (ato - mae <= 1) { return mae; } int mid = (mae + ato) / 2; if (a[mid] > med) { ato = mid; } if (a[mid] <= med) { mae = mid; } } } static int binary_search(int key, int[] moto) { int ng = -1; int ok = moto.Length; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key, moto)) { ok = mid; } else { ng = mid; } } return ok; } static bool isOK(int index, int key, int[] moto) { return moto[index] >= key; } public static int h; public static int w; public static int BFS(int height, int width, char[,] map) { int[] dx = new int[] { -1, 0, 0, 1 }; int[] dy = new int[] { 0, 1, -1, 0 }; bool[,] visited = new bool[h, w]; int[,] len = new int[h, w]; var queue = new Queue<Tuple<int, int>>(); queue.Enqueue(new Tuple<int, int>(height, width)); int max = 0; visited[height, width] = true; while (queue.Count > 0) { var now = queue.Dequeue(); for (int i = 0; i < 4; i++) { int ny = now.Item1 + dy[i]; int nx = now.Item2 + dx[i]; if (ny >= h || ny < 0 || nx >= w || nx < 0) continue; if (visited[ny, nx] || map[ny, nx] == '#') continue; visited[ny, nx] = true; len[ny, nx] = len[now.Item1, now.Item2] + 1; max = Math.Max(max, len[ny, nx]); queue.Enqueue(new Tuple<int, int>(ny, nx)); } } return max; } } public class StreamScanner { public StreamScanner(Stream stream) { str = stream; } private 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) throw new EndOfStreamException(); if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } public char[] Char(int n) { char[] kore = new char[n]; for (int i = 0; i < n; i++) { kore[i] = Char(); } return kore; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public long Long() { long ret = 0; byte b = 0; var ng = false; do b = read(); while (b != '-' && (b < '0' || '9' < b)); if (b == '-') { ng = true; b = read(); } for (; true; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; else ret = ret * 10 + b - '0'; } } public long[] Long(int n) { long[] kore = new long[n]; for (int i = 0; i < n; i++) { kore[i] = Long(); } return kore; } public int Integer() { return (int)Long(); } public int[] Integer(int n) { int[] kore = new int[n]; for (int i = 0; i < n; i++) { kore[i] = (int)Long(); } return kore; } public int[,] Integer(int h, int w) { int[,] kore = new int[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { kore[i, j] = (int)Long(); } } return kore; } public int[] StringToInt(int n) { char[] s = Scan().ToCharArray(); int[] kore = new int[n]; for (int i = 0; i < n; i++) { kore[i] = s[i] - '0'; } return kore; } public int[,] StringToInt(int h, int w) { int[,] kore = new int[h, w]; for (int i = 0; i < h; i++) { char[] s = Scan().ToCharArray(); for (int j = 0; j < w; j++) { kore[i, j] = s[j] - '0'; } } return kore; } public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } public class UnionFind { public int[] data; public UnionFind(int size) { data = new int[size]; for (int i = 0; i < size; i++) data[i] = -1; } public bool Unite(int x, int y) { x = Root(x); y = Root(y); if (x != y) { if (data[y] < data[x]) { var tmp = y; y = x; x = tmp; } data[x] += data[y]; data[y] = x; } return x != y; } public bool IsSameGroup(int x, int y) { return Root(x) == Root(y); } public int Root(int x) { return data[x] < 0 ? x : data[x] = Root(data[x]); } } public class Mlong { private static long mod = 1000000007; public long num; public Mlong(long num) { this.num = num; } public override int GetHashCode() { return num.GetHashCode(); } public override bool Equals(object obj) { return num.Equals(obj); } public static Mlong operator +(Mlong x, Mlong y) { return new Mlong((x.num + y.num) % mod); } public static Mlong operator -(Mlong x, Mlong y) { return new Mlong((x.num - y.num + mod) % mod); } public static Mlong operator *(Mlong x, Mlong y) { return new Mlong((long)(((1L * x.num) * y.num) % mod)); } public Mlong hutujyo(Mlong x) { return new Mlong(num / x.num); } public Mlong modjyo(Mlong x) { return num * x.Pow(mod - 2); } public static implicit operator Mlong(long x) { return new Mlong(x); } public static Mlong operator %(Mlong x, Mlong y) { return new Mlong(x.num % y.num); } public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; } public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; } public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; } public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; } public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; } public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; } public Mlong Pow(Mlong n) { if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mlong buf = Pow(n.hutujyo(2)); return (buf * buf) % mod; } public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); } public static Mlong Comb(Mlong n, Mlong a) { Mlong buf1 = 1; Mlong buf2 = 1; for (long i = 0; i < a; i++) { buf1 *= n - i; buf2 *= (i + 1); } return buf1.modjyo(buf2); } public static void WriteLine(Mlong x) { Console.WriteLine(x.num); } } public class Mint { private static int mod = 1000000007; public int num; public Mint(int Num) { num = Num; } public override int GetHashCode() { return num.GetHashCode(); } public override bool Equals(object obj) { return num.Equals(obj); } public static Mint operator +(Mint x, Mint y) { return new Mint((x.num + y.num) % mod); } public static Mint operator -(Mint x, Mint y) { return new Mint((x.num - y.num + mod) % mod); } public static Mint operator *(Mint x, Mint y) { return new Mint((int)(((1L * x.num) * y.num) % mod)); } public Mint hutujyo(Mint x) { return new Mint(num / x.num); } public Mint modjyo(Mint x) { return num * x.Pow(mod - 2); } public static implicit operator Mint(int x) { return new Mint(x); } public static Mint[] Toarray(int[] x) { Mint[] buf = new Mint[x.Length]; for (int i = 0; i < x.Length; i++) { buf[i] = x[i]; } return buf; } public static explicit operator int(Mint x) { return x.num; } public static Mint operator %(Mint x, Mint y) { return new Mint(x.num % y.num); } public static bool operator ==(Mint x, Mint y) { return x.num == y.num; } public static bool operator !=(Mint x, Mint y) { return x.num != y.num; } public static bool operator<(Mint x, Mint y) { return x.num < y.num; } public static bool operator>(Mint x, Mint y) { return x.num > y.num; } public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; } public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; } public Mint Pow(Mint n) { if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mint buf = Pow(n.hutujyo(2)); return (buf * buf) % mod; } public static Mint Pow(Mint a, Mint n) { return a.Pow(n); } public static Mint Comb(Mint n, Mint a) { Mint buf1 = 1; Mint buf2 = 1; for (int i = 0; i < a; i++) { buf1 *= n - i; buf2 *= (i + 1); } return buf1.modjyo(buf2); } public static void WriteLine(Mint x) { Console.WriteLine(x.num); } } public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) {} public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) {} public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } }
[["+", 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, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 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], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146]]
8
4,607
21
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Numerics; using static System.Math; using static System.Array; using static AtCoder.Tool; using static AtCoder.CalcL; namespace AtCoder { class AC { const int MOD = 1000000007; // const int MOD = 998244353; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dI = { 0, 1, 0, -1 }; static readonly int[] dJ = { 1, 0, -1, 0 }; static List<List<int>> G = new List<List<int>>(); // static List<List<Edge>> G = new List<List<Edge>>(); // static List<Edge> E = new List<Edge>(); static void Main(string[] args) { // var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = // false }; Console.SetOut(sw); var cin = new Scanner(); var input = cin.ReadSplitInt(); int H = input[0]; int W = input[1]; int K = input[2]; var map = new string[H]; for (var i = 0; i < H; i++) { map[i] = Console.ReadLine(); } long ans = INF; for (var b = 0; b < (1 << (H - 1)); b++) { var div = new bool[H - 1]; int k = 0; long nans = 0; for (var i = 0; i < H - 1; i++) { if ((b & (1 << i)) != 0) { div[i] = true; k++; nans++; } else { div[i] = false; } } var cn = new long[k + 1]; var nx = new long[k + 1]; for (var i = 0; i < W; i++) { int cur = 0; bool d = false; for (var j = 0; j < H; j++) { if (map[j][i] == '1') { cn[cur]++; nx[cur]++; } if (j == H - 1 || (j != H - 1 && div[j])) { if (cn[cur] > K) { nans++; d = true; break; } cur++; } } // Console.WriteLine(string.Join(",", nx)); // if (d) Console.WriteLine("div"); for (var j = 0; j < k + 1; j++) { if (nx[j] > K) { nans = INF; } if (d) cn[j] = nx[j]; nx[j] = 0; } // Console.WriteLine(string.Join(",", div)); } // Console.WriteLine(nans); ans = Min(ans, nans); } Console.WriteLine(ans); // Console.Out.Flush(); } struct Edge { public int from; public int to; public long dist; public Edge(int t, long c) { from = -1; to = t; dist = c; } public Edge(int f, int t, long c) { from = f; to = t; dist = c; } } } public class Scanner { public int[] ReadSplitInt() { return ConvertAll(Console.ReadLine().Split(), int.Parse); } public long[] ReadSplitLong() { return ConvertAll(Console.ReadLine().Split(), long.Parse); } public double[] ReadSplit_Double() { return ConvertAll(Console.ReadLine().Split(), double.Parse); } } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { for (var i = 0; i < array.Length; i++) { array[i] = initialvalue; } } static public void Swap<T>(ref T a, ref T b) { T keep = a; a = b; b = keep; } static public void Display<T>(T[,] array2d, int n, int m) { for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { Console.Write($"{array2d[i, j]} "); } Console.WriteLine(); } } static public long LPow(int a, int b) { return (long)Pow(a, b); } } static public class CalcI { public static int Gcd(int a, int b) { if (a * b == 0) { return Max(a, b); } return a % b == 0 ? b : Gcd(b, a % b); } public static int Lcm(int a, int b) { int g = Gcd(a, b); return a / g * b; } public static int Ceil(int n, int div) { return (n + div - 1) / div; } } static public class CalcL { public static long Gcd(long a, long b) { if (a * b == 0) { return Max(a, b); } return a % b == 0 ? b : Gcd(b, a % b); } public static long Lcm(long a, long b) { long g = Gcd(a, b); return a / g * b; } public static long Ceil(long n, long div) { return (n + div - 1) / div; } } class Modulo { private int M; private readonly long[] m_facs; public long Mul(long a, long b) { return ((a * b) % M); } public Modulo(long n, int m) { M = m; m_facs = new long[n + 1]; m_facs[0] = 1; for (long i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public long Fac(long n) { return m_facs[n]; } public long Pow(long a, long m) { switch (m) { case 0: return 1L; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public long Div(long a, long b) { return Mul(a, Pow(b, M - 2)); } public long Ncr(long n, long r) { if (n < r) { return 0; } if (n == r) { return 1; } long res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Numerics; using static System.Math; using static System.Array; using static AtCoder.Tool; using static AtCoder.CalcL; namespace AtCoder { class AC { const int MOD = 1000000007; // const int MOD = 998244353; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dI = { 0, 1, 0, -1 }; static readonly int[] dJ = { 1, 0, -1, 0 }; static List<List<int>> G = new List<List<int>>(); // static List<List<Edge>> G = new List<List<Edge>>(); // static List<Edge> E = new List<Edge>(); static void Main(string[] args) { // var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = // false }; Console.SetOut(sw); var cin = new Scanner(); var input = cin.ReadSplitInt(); int H = input[0]; int W = input[1]; long K = input[2]; var map = new string[H]; for (var i = 0; i < H; i++) { map[i] = Console.ReadLine(); } long ans = SINF; for (var b = 0; b < (1 << (H - 1)); b++) { var div = new bool[H - 1]; int k = 0; long nans = 0; for (var i = 0; i < H - 1; i++) { if ((b & (1 << i)) != 0) { div[i] = true; k++; nans++; } else { div[i] = false; } } var cn = new long[k + 1]; var nx = new long[k + 1]; for (var i = 0; i < W; i++) { int cur = 0; bool d = false; for (var j = 0; j < H; j++) { if (map[j][i] == '1') { cn[cur]++; nx[cur]++; } if (j == H - 1 || (j != H - 1 && div[j])) { if (cn[cur] > K) { d = true; } cur++; } } if (d) nans++; /*Console.WriteLine(string.Join(",", nx)); if (d) Console.WriteLine("div");*/ for (var j = 0; j < k + 1; j++) { if (nx[j] > K) { nans = SINF; break; } if (d) cn[j] = nx[j]; nx[j] = 0; } // Console.WriteLine(string.Join(",", div)); } // Console.WriteLine(nans); ans = Min(ans, nans); } Console.WriteLine(ans); // Console.Out.Flush(); } struct Edge { public int from; public int to; public long dist; public Edge(int t, long c) { from = -1; to = t; dist = c; } public Edge(int f, int t, long c) { from = f; to = t; dist = c; } } } public class Scanner { public int[] ReadSplitInt() { return ConvertAll(Console.ReadLine().Split(), int.Parse); } public long[] ReadSplitLong() { return ConvertAll(Console.ReadLine().Split(), long.Parse); } public double[] ReadSplit_Double() { return ConvertAll(Console.ReadLine().Split(), double.Parse); } } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { for (var i = 0; i < array.Length; i++) { array[i] = initialvalue; } } static public void Swap<T>(ref T a, ref T b) { T keep = a; a = b; b = keep; } static public void Display<T>(T[,] array2d, int n, int m) { for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { Console.Write($"{array2d[i, j]} "); } Console.WriteLine(); } } static public long LPow(int a, int b) { return (long)Pow(a, b); } } static public class CalcI { public static int Gcd(int a, int b) { if (a * b == 0) { return Max(a, b); } return a % b == 0 ? b : Gcd(b, a % b); } public static int Lcm(int a, int b) { int g = Gcd(a, b); return a / g * b; } public static int Ceil(int n, int div) { return (n + div - 1) / div; } } static public class CalcL { public static long Gcd(long a, long b) { if (a * b == 0) { return Max(a, b); } return a % b == 0 ? b : Gcd(b, a % b); } public static long Lcm(long a, long b) { long g = Gcd(a, b); return a / g * b; } public static long Ceil(long n, long div) { return (n + div - 1) / div; } } class Modulo { private int M; private readonly long[] m_facs; public long Mul(long a, long b) { return ((a * b) % M); } public Modulo(long n, int m) { M = m; m_facs = new long[n + 1]; m_facs[0] = 1; for (long i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public long Fac(long n) { return m_facs[n]; } public long Pow(long a, long m) { switch (m) { case 0: return 1L; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public long Div(long a, long b) { return Mul(a, Pow(b, M - 2)); } public long Ncr(long n, long r) { if (n < r) { return 0; } if (n == r) { return 1; } long res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } }
[["-", 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, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 15, 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], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 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
1,406
20
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long mod = 1000000007; static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static int H; static int W; static int K; static char[][] S; static void Solve() { Multi(out H, out W, out K); S = GetCharJaggedArray(H); var ans = int.MaxValue; // Hの各高さにグリッドを入れるかの全探索 O(2^9) for (int bit = 0; bit < (1 << H - 1); bit++) { var n = numofbits(bit) + 1; var sum = Enumerable.Repeat(0, n).ToArray(); var temp = Enumerable.Repeat(0, n).ToArray(); var num = 0; //各列の個数を数え上げる for (int x = 0; x < W; x++) { int hoge = 0; int i = 0; for (int y = 0; y < H; y++) { if (S[y][x] == '1') hoge++; if (((bit >> y) & 1) == 1) { temp[i] = hoge; hoge = 0; i++; } } temp[i] = hoge; if (temp.Any(t => t > K)) break; for (int j = 0; j < n; j++) { sum[i] += temp[i]; } if (sum.Any(s => s > K)) { num++; for (int j = 0; j < n; j++) { sum[j] = temp[j]; } } } ans = Math.Min(ans, num + n - 1); } Console.WriteLine(ans); } static int numofbits(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); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long mod = 1000000007; static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static int H; static int W; static int K; static char[][] S; static void Solve() { Multi(out H, out W, out K); S = GetCharJaggedArray(H); var ans = int.MaxValue; // Hの各高さにグリッドを入れるかの全探索 O(2^9) for (int bit = 0; bit < (1 << H - 1); bit++) { var n = numofbits(bit) + 1; var sum = Enumerable.Repeat(0, n).ToArray(); var temp = Enumerable.Repeat(0, n).ToArray(); var num = 0; var ok = true; //各列の個数を数え上げる for (int x = 0; x < W; x++) { int hoge = 0; int i = 0; for (int y = 0; y < H; y++) { if (S[y][x] == '1') hoge++; if (((bit >> y) & 1) == 1) { temp[i] = hoge; hoge = 0; i++; } } temp[i] = hoge; if (temp.Any(t => t > K)) { ok = false; break; } for (int j = 0; j < n; j++) { sum[j] += temp[j]; } if (sum.Any(s => s > K)) { num++; for (int j = 0; j < n; j++) { sum[j] = temp[j]; } } } if (ok) ans = Math.Min(ans, num + n - 1); } Console.WriteLine(ans); } static int numofbits(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); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } }
[["+", 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, 211, 0, 146], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 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, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25]]
8
1,858
19
using System; using System.Collections.Generic; using System.Linq; using CompLib.Util; public class Program { private int H, W, K; private string[] S; public void Solve() { var sc = new Scanner(); H = sc.NextInt(); W = sc.NextInt(); K = sc.NextInt(); S = new string[H]; for (int i = 0; i < H; i++) { S[i] = sc.Next(); } int ans = int.MaxValue; int l = 1 << (H - 1); for (int i = 0; i < l; i++) { ans = Math.Min(ans, Cnt(i)); // Console.WriteLine(i); } Console.WriteLine(ans); } int Cnt(int l) { int res = 0; List<int> cut = new List<int>(); for (int i = 0; i < H - 1; i++) { if ((l & (1 << i)) > 0) { res++; cut.Add(i + 1); } } cut.Add(H); // j< cut[i]が追加される var white = new int[cut.Count]; for (int j = 0; j < W; j++) { int index = 0; for (int i = 0; i < H; i++) { if (i >= cut[index]) index++; if (S[i][j] == '1') white[index]++; } if (white.Any(num => num > K)) { res++; white = new int[cut.Count]; index = 0; for (int i = 0; i < H; i++) { if (i >= cut[index]) index++; if (S[i][j] == '1') white[index]++; } } } return res; } 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() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using CompLib.Util; public class Program { private int H, W, K; private string[] S; public void Solve() { var sc = new Scanner(); H = sc.NextInt(); W = sc.NextInt(); K = sc.NextInt(); S = new string[H]; for (int i = 0; i < H; i++) { S[i] = sc.Next(); } int ans = int.MaxValue; int l = 1 << (H - 1); for (int i = 0; i < l; i++) { ans = Math.Min(ans, Cnt(i)); // Console.WriteLine(i); } Console.WriteLine(ans); } int Cnt(int l) { int res = 0; List<int> cut = new List<int>(); for (int i = 0; i < H - 1; i++) { if ((l & (1 << i)) > 0) { res++; cut.Add(i + 1); } } cut.Add(H); // j< cut[i]が追加される var white = new int[cut.Count]; for (int j = 0; j < W; j++) { int index = 0; for (int i = 0; i < H; i++) { if (i >= cut[index]) index++; if (S[i][j] == '1') white[index]++; } if (white.Any(num => num > K)) { res++; white = new int[cut.Count]; index = 0; for (int i = 0; i < H; i++) { if (i >= cut[index]) index++; if (S[i][j] == '1') white[index]++; } if (white.Any(num => num > K)) { return int.MaxValue; } } } return res; } 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() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 15, 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, 47], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 12, 22], ["+", 64, 196, 0, 57, 15, 213, 3, 4, 0, 25], ["+", 8, 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, 37, 0, 38], ["+", 0, 57, 64, 196, 0, 37, 0, 214, 205, 199], ["+", 0, 57, 64, 196, 0, 37, 0, 214, 0, 131], ["+", 0, 57, 64, 196, 0, 37, 0, 214, 141, 22], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
741
20
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { var cin = new Scanner2(); int h = cin.Int(); int w = cin.Int(); int k = cin.Int(); var s = new string[h]; for (int i = 0; i < h; i++) { s[i] = cin.Next(); } int hh = h - 1; int ww = w - 1; long ans = h * w; for (int i = 0; i < 1 << hh; i++) { var hs = new List<int>(); hs.Add(0); for (int j = 0; j < hh; j++) { if (((1 << j) & i) != 0) { hs.Add(j + 1); } } hs.Add(h); var cnt = new int[hs.Count - 1]; long temp = hs.Count - 2; int width = 1; for (int l = 0; l < w; l++) { for (int j = 0; j < hs.Count - 1; j++) { int st = hs[j]; int en = hs[j + 1]; for (int kk = st; kk < en; kk++) { if (s[kk][l] == '1') { cnt[j]++; } } } bool ok = true; for (int j = 0; j < hs.Count - 1; j++) { if (cnt[j] > k) { ok = false; break; } } if (ok == false) { if (width == 1) { break; } else { l--; width = 1; ++temp; for (int j = 0; j < hs.Count - 1; j++) { cnt[j] = 0; } } } else { ++width; } } ans = Math.Min(ans, temp); /* temp = hs.Count - 2; width = 1; for (int l = w - 1; l >= 0; l--) { for (int j = 0; j < hs.Count - 1; j++) { int st = hs[j]; int en = hs[j + 1]; for (int kk = st; kk < en; kk++) { if (s[kk][l] == '1') { cnt[j]++; } } } bool ok = true; for (int j = 0; j < hs.Count - 1; j++) { if (cnt[j] > k) { ok = false; break; } } if (ok == false) { if (width == 1) { break; } else { l++; width = 1; ++temp; for (int j = 0; j < hs.Count - 1; j++) { cnt[j] = 0; } } } else { ++width; } } ans = Math.Min(ans, temp); */ } Console.WriteLine(ans); } public static int PopCount(ulong bits) { bits = ((bits & 0xaaaaaaaaaaaaaaaa) >> 1) + (bits & 0x5555555555555555); bits = ((bits & 0xcccccccccccccccc) >> 2) + (bits & 0x3333333333333333); bits = ((bits & 0xf0f0f0f0f0f0f0f0) >> 4) + (bits & 0x0f0f0f0f0f0f0f0f); bits = ((bits & 0xff00ff00ff00ff00) >> 8) + (bits & 0x00ff00ff00ff00ff); bits = ((bits & 0xffff0000ffff0000) >> 16) + (bits & 0x0000ffff0000ffff); bits = ((bits & 0xffffffff00000000) >> 32) + (bits & 0x00000000ffffffff); return (int)bits; } } public static class Helper { public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Min(array[index], value); public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Max(array[index], value); public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Min(array[index], value); public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Max(array[index], value); public static T[] Array<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToArray(); public static List<T> List<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToList(); } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; 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.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { var cin = new Scanner2(); int h = cin.Int(); int w = cin.Int(); int k = cin.Int(); var s = new string[h]; for (int i = 0; i < h; i++) { s[i] = cin.Next(); } int hh = h - 1; int ww = w - 1; long ans = h * w; for (int i = 0; i < 1 << hh; i++) { var hs = new List<int>(); hs.Add(0); for (int j = 0; j < hh; j++) { if (((1 << j) & i) != 0) { hs.Add(j + 1); } } hs.Add(h); var cnt = new int[hs.Count - 1]; long temp = hs.Count - 2; int width = 1; bool okok = true; for (int l = 0; l < w; l++) { for (int j = 0; j < hs.Count - 1; j++) { int st = hs[j]; int en = hs[j + 1]; for (int kk = st; kk < en; kk++) { if (s[kk][l] == '1') { cnt[j]++; } } } bool ok = true; for (int j = 0; j < hs.Count - 1; j++) { if (cnt[j] > k) { ok = false; break; } } if (ok == false) { if (width == 1) { okok = false; break; } else { l--; width = 1; ++temp; for (int j = 0; j < hs.Count - 1; j++) { cnt[j] = 0; } } } else { ++width; } } if (okok) { ans = Math.Min(ans, temp); } /* temp = hs.Count - 2; width = 1; for (int l = w - 1; l >= 0; l--) { for (int j = 0; j < hs.Count - 1; j++) { int st = hs[j]; int en = hs[j + 1]; for (int kk = st; kk < en; kk++) { if (s[kk][l] == '1') { cnt[j]++; } } } bool ok = true; for (int j = 0; j < hs.Count - 1; j++) { if (cnt[j] > k) { ok = false; break; } } if (ok == false) { if (width == 1) { break; } else { l++; width = 1; ++temp; for (int j = 0; j < hs.Count - 1; j++) { cnt[j] = 0; } } } else { ++width; } } ans = Math.Min(ans, temp); */ } Console.WriteLine(ans); } public static int PopCount(ulong bits) { bits = ((bits & 0xaaaaaaaaaaaaaaaa) >> 1) + (bits & 0x5555555555555555); bits = ((bits & 0xcccccccccccccccc) >> 2) + (bits & 0x3333333333333333); bits = ((bits & 0xf0f0f0f0f0f0f0f0) >> 4) + (bits & 0x0f0f0f0f0f0f0f0f); bits = ((bits & 0xff00ff00ff00ff00) >> 8) + (bits & 0x00ff00ff00ff00ff); bits = ((bits & 0xffff0000ffff0000) >> 16) + (bits & 0x0000ffff0000ffff); bits = ((bits & 0xffffffff00000000) >> 32) + (bits & 0x00000000ffffffff); return (int)bits; } } public static class Helper { public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Min(array[index], value); public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Max(array[index], value); public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Min(array[index], value); public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Max(array[index], value); public static T[] Array<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToArray(); public static List<T> List<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToList(); } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; 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); } } }
[["+", 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, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
1,326
15
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { var cin = new Scanner2(); int n = cin.Int(); int s = cin.Int(); var a = cin.ArrayInt(n); long P = 998244353; var dp = new long[s + 1]; for (int i = 0; i < n; i++) { var dst = new long[s + 1]; for (int j = 0; j <= s; j++) { if (dp[j] == 0) { continue; } if (j + a[i] <= s) { dst[j + a[i]] += (dp[j] * (j + a[i] == s ? (n - i) : 1)) % P; dst[j + a[i]] %= P; } dst[j] += dp[j]; } if (a[i] <= s) { dst[a[i]] += ((1 + i) * (a[i] == s ? (n - i) : 1)) % P; dst[a[i]] %= P; } dp = dst; } var ans = dp[s]; Console.WriteLine(ans); } } public struct ModInt { public static long P { get; set; } = (long)1e9 + 7; public static ModInt Pow(ModInt value, long k) { return Pow(value.Value, k); } public static ModInt Pow(long value, long k) { long ret = 1; for (k %= P - 1; k > 0; k >>= 1, value = value * value % P) { if ((k & 1) == 1) { ret = ret * value % P; } } return new ModInt(ret); } public static ModInt Inverse(ModInt value) { return Pow(value, P - 2); } public long Value; public ModInt(long value) { value %= P; if (value < 0) { value += P; } Value = value; } public static ModInt operator +(ModInt lhs, ModInt rhs) { lhs.Value += rhs.Value; if (lhs.Value >= P) { lhs.Value -= P; } return lhs; } public static ModInt operator -(ModInt lhs, ModInt rhs) { lhs.Value -= rhs.Value; if (lhs.Value < 0) { lhs.Value += P; } return lhs; } public static ModInt operator *(ModInt lhs, ModInt rhs) { return new ModInt(lhs.Value * rhs.Value % P); } public static ModInt operator /(ModInt lhs, ModInt rhs) { long exp = P - 2; while (exp > 0) { if (exp % 2 > 0) { lhs *= rhs; } rhs *= rhs; exp /= 2; } return lhs; } public static implicit operator ModInt(long n) { n %= P; if (n < 0) { n += P; } return new ModInt(n); } public override string ToString() { return Value.ToString(); } } public static class Helper { public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Min(array[index], value); public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Max(array[index], value); public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Min(array[index], value); public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Max(array[index], value); public static T[] Array<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToArray(); public static List<T> List<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToList(); } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; 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.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { var cin = new Scanner2(); int n = cin.Int(); int s = cin.Int(); var a = cin.ArrayInt(n); long P = 998244353; var dp = new long[s + 1]; for (int i = 0; i < n; i++) { var dst = new long[s + 1]; for (int j = 0; j <= s; j++) { if (dp[j] == 0) { continue; } if (j + a[i] <= s) { dst[j + a[i]] += (dp[j] * (j + a[i] == s ? (n - i) : 1)) % P; dst[j + a[i]] %= P; } dst[j] = (dst[j] +dp[j]) % P; } if (a[i] <= s) { dst[a[i]] += ((1 + i) * (a[i] == s ? (n - i) : 1)) % P; dst[a[i]] %= P; } dp = dst; } var ans = dp[s]; Console.WriteLine(ans); } } public struct ModInt { public static long P { get; set; } = (long)1e9 + 7; public static ModInt Pow(ModInt value, long k) { return Pow(value.Value, k); } public static ModInt Pow(long value, long k) { long ret = 1; for (k %= P - 1; k > 0; k >>= 1, value = value * value % P) { if ((k & 1) == 1) { ret = ret * value % P; } } return new ModInt(ret); } public static ModInt Inverse(ModInt value) { return Pow(value, P - 2); } public long Value; public ModInt(long value) { value %= P; if (value < 0) { value += P; } Value = value; } public static ModInt operator +(ModInt lhs, ModInt rhs) { lhs.Value += rhs.Value; if (lhs.Value >= P) { lhs.Value -= P; } return lhs; } public static ModInt operator -(ModInt lhs, ModInt rhs) { lhs.Value -= rhs.Value; if (lhs.Value < 0) { lhs.Value += P; } return lhs; } public static ModInt operator *(ModInt lhs, ModInt rhs) { return new ModInt(lhs.Value * rhs.Value % P); } public static ModInt operator /(ModInt lhs, ModInt rhs) { long exp = P - 2; while (exp > 0) { if (exp % 2 > 0) { lhs *= rhs; } rhs *= rhs; exp /= 2; } return lhs; } public static implicit operator ModInt(long n) { n %= P; if (n < 0) { n += P; } return new ModInt(n); } public override string ToString() { return Value.ToString(); } } public static class Helper { public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Min(array[index], value); public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int> => array[index] = Math.Max(array[index], value); public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Min(array[index], value); public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long> => array[index] = Math.Max(array[index], value); public static T[] Array<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToArray(); public static List<T> List<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToList(); } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; 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, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
8
1,421
11
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoders { class Program { static void Main(string[] args) { var inputArray = retreiveLongArray(); var inputCount = 2; // 不正な入力は処理しない if (inputArray.Length != inputCount) { Console.WriteLine("invalid input"); return; } var H = (int)inputArray[0]; var W = (int)inputArray[0]; var map = new bool[H, W]; for (int h = 0; h < H; h++) { var inp = retreiveStringArray()[0]; for (int w = 0; w < W; w++) { map[h, w] = inp[w] == '.'; } } var flip = new int[H, W]; flip[0, 0] = 0; for (int h = 0; h < H; h++) { for (int w = 0; w < W; w++) { if (h == 0 && w == 0) { continue; } var hRoot = int.MaxValue; if (h > 0) { var plus = map[h - 1, w] == map[h, w] ? 0 : 1; hRoot = flip[h - 1, w] + plus; } var wRoot = int.MaxValue; if (w > 0) { var plus = map[h, w - 1] == map[h, w] ? 0 : 1; wRoot = flip[h, w - 1] + plus; } flip[h, w] = Math.Min(hRoot, wRoot); } } //答えの出力 var ans = (flip[H - 1, W - 1] + 1) / 2; if (!map[0, 0]) { ans++; } Console.WriteLine(ans); } /// <summary> /// スペースで区切られた文字列配列の入力を受け取る /// </summary> /// <returns></returns> private static string[] retreiveStringArray() { var inputArray = Console.ReadLine().Split(' '); return inputArray; } /// <summary> /// スペースで区切られた整数配列の入力を受け取る /// </summary> /// <returns></returns> private static long[] retreiveLongArray() { var inputArray = Console.ReadLine().Split(' '); var longArray = inputArray.Select(s => long.Parse(s)); return longArray.ToArray(); } /// <summary> /// 2組みずつの入力データ(数値)からTuppleListを作成する /// </summary> /// <param name="N"></param> /// <returns></returns> private static List<Tuple<long, long>> createLongTuppleList(long N) { var inpList = new List<Tuple<long, long>>(); for (int i = 0; i < N; i++) { var inp = retreiveLongArray(); var item1 = inp[0]; var item2 = inp[1]; inpList.Add(new Tuple<long, long>(item1, item2)); } return inpList; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoders { class Program { static void Main(string[] args) { var inputArray = retreiveLongArray(); var inputCount = 2; // 不正な入力は処理しない if (inputArray.Length != inputCount) { Console.WriteLine("invalid input"); return; } var H = (int)inputArray[0]; var W = (int)inputArray[1]; var map = new bool[H, W]; for (int h = 0; h < H; h++) { var inp = retreiveStringArray()[0]; for (int w = 0; w < W; w++) { map[h, w] = inp[w] == '.'; } } var flip = new int[H, W]; flip[0, 0] = 0; for (int h = 0; h < H; h++) { for (int w = 0; w < W; w++) { if (h == 0 && w == 0) { continue; } var hRoot = int.MaxValue; if (h > 0) { var plus = map[h - 1, w] == map[h, w] ? 0 : 1; hRoot = flip[h - 1, w] + plus; } var wRoot = int.MaxValue; if (w > 0) { var plus = map[h, w - 1] == map[h, w] ? 0 : 1; wRoot = flip[h, w - 1] + plus; } flip[h, w] = Math.Min(hRoot, wRoot); } } //答えの出力 var ans = (flip[H - 1, W - 1] + 1) / 2; if (!map[0, 0] && !map[H - 1, W - 1]) { ans++; } Console.WriteLine(ans); } /// <summary> /// スペースで区切られた文字列配列の入力を受け取る /// </summary> /// <returns></returns> private static string[] retreiveStringArray() { var inputArray = Console.ReadLine().Split(' '); return inputArray; } /// <summary> /// スペースで区切られた整数配列の入力を受け取る /// </summary> /// <returns></returns> private static long[] retreiveLongArray() { var inputArray = Console.ReadLine().Split(' '); var longArray = inputArray.Select(s => long.Parse(s)); return longArray.ToArray(); } /// <summary> /// 2組みずつの入力データ(数値)からTuppleListを作成する /// </summary> /// <param name="N"></param> /// <returns></returns> private static List<Tuple<long, long>> createLongTuppleList(long N) { var inpList = new List<Tuple<long, long>>(); for (int i = 0; i < N; i++) { var inp = retreiveLongArray(); var item1 = inp[0]; var item2 = inp[1]; inpList.Add(new Tuple<long, long>(item1, item2)); } return inpList; } } }
[["-", 0, 74, 51, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 74, 51, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 241, 0, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 111], ["+", 0, 57, 15, 16, 12, 241, 0, 204, 205, 22], ["+", 15, 16, 12, 241, 0, 204, 206, 207, 0, 70], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 15, 16, 12, 241, 0, 204, 206, 207, 0, 21]]
8
584
14
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var HW = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray(); var H = HW[0]; var W = HW[1]; var maps = new char [H][]; var memo = new int [H][]; for (var i = 0; i < H; i++) { maps[i] = Console.ReadLine().ToCharArray(); memo[i] = maps[i].Select(c => int.MaxValue).ToArray(); } Console.WriteLine(Search(maps, H, W, 0, 0, 0, memo)); } static int Search(char[][] maps, int H, int W, int y, int x, int cnt, int[][] memo) { if (maps[y][x] == '#') cnt++; if (memo[y][x] <= cnt) { return int.MaxValue; } memo[y][x] = cnt; if (H == y + 1 && W == x + 1) { return cnt; } var cnt1 = int.MaxValue; var cnt2 = int.MaxValue; if (y + 1 < H) { cnt1 = Search(maps, H, W, y + 1, x, cnt, memo); } if (x + 1 < W) { cnt2 = Search(maps, H, W, y, x + 1, cnt, memo); } return Math.Min(cnt1, cnt2); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var HW = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray(); var H = HW[0]; var W = HW[1]; var maps = new char [H][]; var memo = new int [H][]; for (var i = 0; i < H; i++) { maps[i] = Console.ReadLine().ToCharArray(); memo[i] = maps[i].Select(c => int.MaxValue).ToArray(); } Console.WriteLine(Search(maps, H, W, 0, 0, 0, memo, '.')); } static int Search(char[][] maps, int H, int W, int y, int x, int cnt, int[][] memo, char prev) { if (prev == '.' && maps[y][x] == '#') cnt++; if (memo[y][x] <= cnt) { return int.MaxValue; } memo[y][x] = cnt; if (H == y + 1 && W == x + 1) { return cnt; } var cnt1 = int.MaxValue; var cnt2 = int.MaxValue; if (y + 1 < H) { cnt1 = Search(maps, H, W, y + 1, x, cnt, memo, maps[y][x]); } if (x + 1 < W) { cnt2 = Search(maps, H, W, y, x + 1, cnt, memo, maps[y][x]); } return Math.Min(cnt1, cnt2); } } }
[["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 21], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 141, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 12, 252, 0, 104], ["+", 0, 57, 15, 16, 31, 16, 12, 252, 0, 253], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 204, 205, 204, 205, 22], ["+", 0, 28, 0, 204, 205, 204, 206, 207, 0, 70], ["+", 0, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 28, 0, 204, 205, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
8
385
29
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace B { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var n = int.Parse(Console.ReadLine()); var ai = Console.ReadLine().Trim().Select(x => x - '1').ToArray(); var isContain1 = ai.Contains(1); if (!isContain1) ai = ai.Select(x => x /= 2).ToArray(); var isOdd = IsOdd(ai); if (isContain1) Console.WriteLine(isOdd ? 1 : 0); else Console.WriteLine(isOdd ? 2 : 0); } static bool IsOdd(int[] items) { var binCoef = new int[items.Length]; var n = items.Length - 1; for (int i = 0, j = binCoef.Length - 1; i < j; i++, j--) { binCoef[i] = binCoef[j] = n == (i | (n - i)) ? 1 : 0; } var t = 0; for (var i = 0; i < binCoef.Length; i++) { if (binCoef[i] % 2 == 1) { if (items[i] % 2 == 1) t++; } else { if (items[i] % 2 == 0) t--; } } return t % 2 == 1; } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace B { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var n = int.Parse(Console.ReadLine()); var ai = Console.ReadLine().Trim().Select(x => x - '1').ToArray(); var isContain1 = ai.Contains(1); if (!isContain1) ai = ai.Select(x => x /= 2).ToArray(); var isOdd = IsOdd(ai); if (isContain1) Console.WriteLine(isOdd ? 1 : 0); else Console.WriteLine(isOdd ? 2 : 0); } static bool IsOdd(int[] items) { var binCoef = new int[items.Length]; var n = items.Length - 1; for (int i = 0, j = binCoef.Length - 1; i < j; i++, j--) { binCoef[i] = binCoef[j] = n == (i | (n - i)) ? 1 : 0; } var t = 0; for (var i = 0; i < binCoef.Length; i++) { if (binCoef[i] % 2 == 1) { if (items[i] % 2 == 1) t++; } } return t % 2 == 1; } } }
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["-", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 75, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 75, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["-", 75, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["-", 75, 196, 0, 57, 64, 1, 0, 223, 0, 68], ["-", 0, 57, 75, 196, 0, 57, 64, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
8
357
17
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace CSharp { static class Program { static void Main(string[] args) { int[] array = new[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; int k = ReadInt(); int ans = array.OrderBy(x => x).ElementAt(k - 1); Console.WriteLine(ans); } #region Helpers static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray(); static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray(); static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count) .Select(_ => int.Parse(Console.ReadLine())) .ToArray(); static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count) .Select(_ => long.Parse(Console.ReadLine())) .ToArray(); static string ReadString() => Console.ReadLine(); static int ReadInt() => int.Parse(Console.ReadLine()); static long ReadLong() => long.Parse(Console.ReadLine()); static void ReadInt(out int first) { var array = ReadIntArray(); first = array[0]; } static void ReadInt(out int first, out int second) { var array = ReadIntArray(); first = array[0]; second = array[1]; } static void ReadInt(out int first, out int second, out int third) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadInt(out int first, out int second, out int third, out int fourth) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } static void ReadLong(out long first) { var array = ReadLongArray(); first = array[0]; } static void ReadLong(out long first, out long second) { var array = ReadLongArray(); first = array[0]; second = array[1]; } static void ReadLong(out long first, out long second, out long third) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadLong(out long first, out long second, out long third, out long fourth) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } #endregion } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace CSharp { static class Program { static void Main(string[] args) { int[] array = new[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; int k = ReadInt(); int ans = array[k - 1]; Console.WriteLine(ans); } #region Helpers static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray(); static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray(); static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count) .Select(_ => int.Parse(Console.ReadLine())) .ToArray(); static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count) .Select(_ => long.Parse(Console.ReadLine())) .ToArray(); static string ReadString() => Console.ReadLine(); static int ReadInt() => int.Parse(Console.ReadLine()); static long ReadLong() => long.Parse(Console.ReadLine()); static void ReadInt(out int first) { var array = ReadIntArray(); first = array[0]; } static void ReadInt(out int first, out int second) { var array = ReadIntArray(); first = array[0]; second = array[1]; } static void ReadInt(out int first, out int second, out int third) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadInt(out int first, out int second, out int third, out int fourth) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } static void ReadLong(out long first) { var array = ReadLongArray(); first = array[0]; } static void ReadLong(out long first, out long second) { var array = ReadLongArray(); first = array[0]; second = array[1]; } static void ReadLong(out long first, out long second, out long third) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadLong(out long first, out long second, out long third, out long fourth) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } #endregion } }
[["-", 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, 204, 206, 207, 0, 70], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73]]
8
669
13
using System; namespace KthTerm { class Program { static void Main(string[] args) { String S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51,"; String[] splitted = S.Split(' '); int K = int.Parse(Console.ReadLine()); Console.WriteLine(splitted[K - 1].Substring(0, 1)); } } }
using System; namespace KthTerm { class Program { static void Main(string[] args) { String S = "1 1 1 2 1 2 1 5 2 2 1 5 1 2 1 14 1 5 1 5 2 2 1 15 2 2 5 4 1 4 1 51"; String[] splitted = S.Split(' '); int K = int.Parse(Console.ReadLine()); Console.WriteLine(splitted[K - 1]); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 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], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
76
9
using System; class Suuretu { static void Main() { int input = int.Parse(Console.ReadLine()); int[] Arr = new int[32] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; Console.WriteLine(Arr[input]); } }
using System; class Suuretu { static void Main() { int input = int.Parse(Console.ReadLine()); int inputA = input - 1; int[] Arr = new int[32] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; Console.WriteLine(Arr[inputA]); } }
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22]]
8
114
9
using System; class main { public static void Main(string[] args) { string[] s = Console.ReadLine().Split(" "); decimal a = decimal.Parse(s[0]); decimal b = decimal.Parse(s[1]); decimal ans = Math.Ceiling(a * b / 2); Console.WriteLine(ans); } }
using System; class main { public static void Main(string[] args) { string[] s = Console.ReadLine().Split(" "); decimal a = decimal.Parse(s[0]); decimal b = decimal.Parse(s[1]); decimal ans = Math.Ceiling(a * b / 2); if (a == 1 || b == 1) ans = 1; Console.WriteLine(ans); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
84
14
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; namespace FertiLib.Contest.B { static class Program { public static void Solve(Scanner cin) { var (h, w) = cin.ReadValue<long, long>(); Console.WriteLine((h * w + 1) / 2); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO"); public static void YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No"); public static void yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no"); public static bool Chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) >= 0) return false; a = b; return true; } public static bool Chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) <= 0) return false; a = b; return true; } } static class Util { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; namespace FertiLib.Contest.B { static class Program { public static void Solve(Scanner cin) { var (h, w) = cin.ReadValue<long, long>(); if (h == 1 || w == 1) Console.WriteLine(1); else Console.WriteLine((h * w + 1) / 2); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO"); public static void YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No"); public static void yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no"); public static bool Chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) >= 0) return false; a = b; return true; } public static bool Chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) <= 0) return false; a = b; return true; } } static class Util { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
8
2,658
18
using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var arr = Console.ReadLine().Split(); var H = long.Parse(arr[0]); var W = long.Parse(arr[1]); var answer = H * W % 2 == 0 ? H * W / 2 : H * W / 2 + 1; var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(answer); Console.Out.Flush(); } }
using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var arr = Console.ReadLine().Split(); var H = long.Parse(arr[0]); var W = long.Parse(arr[1]); long answer = H == 1 || W == 1 ? 1 : (H * W + 1) / 2; var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(answer); Console.Out.Flush(); } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 41, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 17, 60], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 106], ["-", 0, 212, 0, 41, 15, 16, 31, 16, 17, 109], ["-", 0, 212, 0, 41, 15, 16, 31, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 12, 203], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 12, 203], ["-", 0, 212, 0, 41, 64, 16, 31, 16, 31, 22], ["-", 0, 212, 0, 41, 64, 16, 31, 16, 17, 48], ["-", 0, 212, 0, 41, 64, 16, 31, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 41, 64, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 41, 64, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["+", 0, 212, 0, 41, 75, 16, 31, 23, 0, 24], ["-", 0, 212, 0, 41, 75, 16, 31, 16, 17, 85], ["-", 0, 212, 0, 41, 75, 16, 31, 16, 12, 203], ["+", 0, 212, 0, 41, 75, 16, 31, 23, 0, 25], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 17, 85], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 12, 203]]
8
132
19
using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var arr = Console.ReadLine().Split(); var H = long.Parse(arr[0]); var W = long.Parse(arr[1]); var answer = H * W % 2 == 0 ? H * W / 2 : H * W / 2 + 1; var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(answer); Console.Out.Flush(); } }
using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var arr = Console.ReadLine().Split(); var H = long.Parse(arr[0]); var W = long.Parse(arr[1]); long answer; if (H == 1 || W == 1) answer = 1; else answer = H * W % 2 == 0 ? H * W / 2 : H * W / 2 + 1; var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(answer); Console.Out.Flush(); } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 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], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
8
132
19
using System; using System.Linq; namespace AtCorder { class Program { static void Main(string[] args) { // かず double[] N = Console.ReadLine().Split(' ').ToArray().Select(double.Parse).ToArray(); if (N[0] == 1 || N[1] == 1) { Console.WriteLine("1"); } else if (N[1] * N[0] % 2 == 0) { Console.WriteLine(Math.Floor(N[1] * N[0] / 2)); } else { Console.WriteLine(Math.Floor((N[1] * N[0] / 2) + 1)); } } } }
using System; using System.Linq; namespace AtCorder { class Program { static void Main(string[] args) { // かず long[] N = Console.ReadLine().Split(' ').ToArray().Select(long.Parse).ToArray(); if (N[0] == 1 || N[1] == 1) { Console.WriteLine("1"); } else if (N[1] * N[0] % 2 == 0) { Console.WriteLine(String.Format("{0}", N[1] * N[0] / 2)); } else { Console.WriteLine(String.Format("{0}", (N[1] * N[0] / 2) + 1)); } } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21]]
8
158
20
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { try { SetOut(sw); Solve.Answer(); Out.Flush(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { var ab = IO.RSLong; var ans = ab[0] * ab[1] / 2; if (ab[0] % 2 == 1 && ab[1] % 2 == 1) ans++; WriteLine(ans); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { try { SetOut(sw); Solve.Answer(); Out.Flush(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { var ab = IO.RSLong; if (ab[0] == 1 || ab[1] == 1) { WriteLine(1); return; } var ans = ab[0] * ab[1] / 2; if (ab[0] % 2 == 1 && ab[1] % 2 == 1) ans++; WriteLine(ans); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
514
25
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { // 入力 string[] sS = System.Console.ReadLine().Trim().Split(' '); decimal iH = decimal.Parse(sS[0]); decimal iW = decimal.Parse(sS[1]); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // 解析 decimal iOut = Math.Truncate(((iH * iW) + 1M) / 2M); // 出力 System.Console.WriteLine("{0}", iOut.ToString().Trim()); sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("続行するには何かキーを押してください..."); Console.ReadKey(); #endif } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { // 入力 string[] sS = System.Console.ReadLine().Trim().Split(' '); decimal iH = decimal.Parse(sS[0]); decimal iW = decimal.Parse(sS[1]); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // 解析 decimal iOut = Math.Truncate(((iH * iW) + 1M) / 2M); if (iH == 1M || iW == 1M) { iOut = 1M; } // 出力 System.Console.WriteLine("{0}", iOut.ToString().Trim()); sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("続行するには何かキーを押してください..."); Console.ReadKey(); #endif } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 250], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 250], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 250], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
200
16
using System; using System.Collections.Generic; using System.IO.Pipes; namespace cswork { class Program { 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()); } } public Program() {} static void Main(string[] args) { new Program().Omame(); } Scanner cin; const int MAXIN = 1024; bool[] used = new bool[MAXIN]; int[] perm = new int[MAXIN]; List<int[]> permList = new List<int[]>(); public void Permutation(int pos, int n, int length) { if (pos == n) { permList.Add((int[])perm.Clone()); } for (int i = 0; i < n; i++) { if (!used[i]) { perm[pos] = i; used[i] = true; Permutation(pos + 1, n, length); used[i] = false; } } } void Omame() { cin = new Scanner(); long H = cin.nextLong(); long W = cin.nextLong(); long N = H * W; if (N % 2 == 0) { Console.WriteLine(N / 2); } else { Console.WriteLine(N / 2 + 1); } } } }
using System; using System.Collections.Generic; using System.IO.Pipes; namespace cswork { class Program { 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()); } } public Program() {} static void Main(string[] args) { new Program().Omame(); } Scanner cin; const int MAXIN = 1024; bool[] used = new bool[MAXIN]; int[] perm = new int[MAXIN]; List<int[]> permList = new List<int[]>(); public void Permutation(int pos, int n, int length) { if (pos == n) { permList.Add((int[])perm.Clone()); } for (int i = 0; i < n; i++) { if (!used[i]) { perm[pos] = i; used[i] = true; Permutation(pos + 1, n, length); used[i] = false; } } } void Omame() { cin = new Scanner(); long H = cin.nextLong(); long W = cin.nextLong(); long N = H * W; if (H == 1 || W == 1) { Console.WriteLine(1); } else if (N % 2 == 0) { Console.WriteLine(N / 2); } else { Console.WriteLine(N / 2 + 1); } } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24]]
8
432
20
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; namespace AtCoder { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static readonly long Mod = 1000000000 + 7; static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); var HW = Sarray(); var H = HW[0]; var W = HW[1]; long ans = (long)(Math.Ceiling(W / 2.0) * Math.Ceiling(H / 2.0) + Math.Floor(W / 2.0) * Math.Floor(H / 2.0)); WriteLine(ans.ToString()); // Out.Flush(); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; namespace AtCoder { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static readonly long Mod = 1000000000 + 7; static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); var HW = Sarray(); var H = HW[0]; var W = HW[1]; long ans = (long)(Math.Ceiling(W / 2.0) * Math.Ceiling(H / 2.0) + Math.Floor(W / 2.0) * Math.Floor(H / 2.0)); if (1 == H || 1 == W) ans = 1; WriteLine(ans.ToString()); // Out.Flush(); } } }
[["+", 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, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
204
14
using System; class ProgramB { static void Main(string[] args) { //入力 string[] input = Console.ReadLine().Split(' '); long h = long.Parse(input[0]); long w = long.Parse(input[1]); if (h % 2 == 1 && w % 2 == 1) Console.WriteLine(h * w / 2 + 1); else Console.WriteLine(h * w / 2); } }
using System; class ProgramB { static void Main(string[] args) { //入力 string[] input = Console.ReadLine().Split(' '); long h = long.Parse(input[0]); long w = long.Parse(input[1]); if (h == 1 || w == 1) Console.WriteLine("1"); else if (h % 2 == 1 && w % 2 == 1) Console.WriteLine(h * w / 2 + 1); else Console.WriteLine(h * w / 2); } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 16, 31, 16, 31, 22]]
8
102
20
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace B___Bishop { class Program { static void Main(string[] args) { var H_W = Console.ReadLine().Split().Select(long.Parse).ToArray(); long H = H_W[0], W = H_W[1]; Console.WriteLine((W / 2 + W % 2) * (H / 2 + H % 2) + (W / 2) * (H / 2)); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace B___Bishop { class Program { static void Main(string[] args) { var H_W = Console.ReadLine().Split().Select(long.Parse).ToArray(); long H = H_W[0], W = H_W[1]; Console.WriteLine(H_W.Any(x => x == 1) ? 1 : (W / 2 + W % 2) * (H / 2 + H % 2) + (W / 2) * (H / 2)); } } }
[["+", 0, 28, 0, 41, 15, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 41, 15, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 41, 15, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 15, 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, 60], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 12, 203], ["+", 0, 28, 0, 41, 15, 213, 3, 4, 0, 25], ["+", 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, 41, 75, 16, 31, 16, 31, 23, 0, 24]]
8
122
13
using System; namespace tst { class Program { public static void Main() { string[] In = Console.ReadLine().Split(' '); int h = int.Parse(In[0]); int w = int.Parse(In[1]); long res = 0; if (h % 2 == 0) { long temp = h / 2; res = temp * w; } else { if (w % 2 == 0) { long temp = w / 2; res = temp * h; } else { int hp = h / 2; int wp = w / 2; int sub = hp + wp + 1; h++; w++; long temp = w / 2; res = temp * h - sub; } } Console.WriteLine(res); } } }
using System; namespace tst { class Program { public static void Main() { string[] In = Console.ReadLine().Split(' '); int h = int.Parse(In[0]); int w = int.Parse(In[1]); long res = 0; if (h == 1 || w == 1) { res = 1; } else { if (h % 2 == 0) { long temp = h / 2; res = temp * w; } else { if (w % 2 == 0) { long temp = w / 2; res = temp * h; } else { int hp = h / 2; int wp = w / 2; int sub = hp + wp + 1; h++; w++; long temp = w / 2; res = temp * h - sub; } } } Console.WriteLine(res); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 75, 196, 0, 46]]
8
171
19
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; using System.Linq; using E = System.Linq.Enumerable; internal partial class Solver { public void Run() { var h = nl(); var w = nl(); long ans = (h - h / 2) * (w - w / 2) + (h / 2) * (w / 2); cout.WriteLine(ans); } } // PREWRITEN CODE BEGINS FROM HERE internal partial class Solver : Scanner { public static void Main(string[] args) { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver(Console.In, Console.Out).Run(); Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } internal static class LinqPadExtension { [Conditional("DEBUG")] public static void Dump<T>(this T obj) { #if DEBUG LINQPad.Extensions.Dump(obj); #endif } } public class Scanner { private readonly TextReader Reader; private readonly CultureInfo ci = CultureInfo.InvariantCulture; private readonly char[] buffer = new char[2 * 1024]; private int cursor = 0, length = 0; private string Token; private readonly StringBuilder sb = new StringBuilder(1024); public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return checked((int)NextLong()); } public long NextLong() { var s = Next(); long r = 0; int i = 0; bool negative = false; if (s[i] == '-') { negative = true; i++; } for (; i < s.Length; i++) { r = r * 10 + (s[i] - '0'); #if DEBUG if (!char.IsDigit(s[i])) throw new FormatException(); #endif } return negative ? -r : r; } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (Token == null) { if (!StockToken()) { throw new InvalidOperationException(); } } var token = Token; Token = null; return token; } public bool HasNext() { if (Token != null) { return true; } return StockToken(); } private bool StockToken() { while (true) { sb.Clear(); while (true) { if (cursor >= length) { cursor = 0; if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) { break; } } var c = buffer[cursor++]; if (33 <= c && c <= 126) { sb.Append(c); } else { if (sb.Length > 0) break; } } if (sb.Length > 0) { Token = sb.ToString(); return true; } return false; } } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; using System.Linq; using E = System.Linq.Enumerable; internal partial class Solver { public void Run() { var h = nl(); var w = nl(); if (w == 1 || h == 1) { cout.WriteLine(1); } else { long ans = (h - h / 2) * (w - w / 2) + (h / 2) * (w / 2); cout.WriteLine(ans); } } } // PREWRITEN CODE BEGINS FROM HERE internal partial class Solver : Scanner { public static void Main(string[] args) { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver(Console.In, Console.Out).Run(); Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } internal static class LinqPadExtension { [Conditional("DEBUG")] public static void Dump<T>(this T obj) { #if DEBUG LINQPad.Extensions.Dump(obj); #endif } } public class Scanner { private readonly TextReader Reader; private readonly CultureInfo ci = CultureInfo.InvariantCulture; private readonly char[] buffer = new char[2 * 1024]; private int cursor = 0, length = 0; private string Token; private readonly StringBuilder sb = new StringBuilder(1024); public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return checked((int)NextLong()); } public long NextLong() { var s = Next(); long r = 0; int i = 0; bool negative = false; if (s[i] == '-') { negative = true; i++; } for (; i < s.Length; i++) { r = r * 10 + (s[i] - '0'); #if DEBUG if (!char.IsDigit(s[i])) throw new FormatException(); #endif } return negative ? -r : r; } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (Token == null) { if (!StockToken()) { throw new InvalidOperationException(); } } var token = Token; Token = null; return token; } public bool HasNext() { if (Token != null) { return true; } return StockToken(); } private bool StockToken() { while (true) { sb.Clear(); while (true) { if (cursor >= length) { cursor = 0; if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) { break; } } var c = buffer[cursor++]; if (33 <= c && c <= 126) { sb.Append(c); } else { if (sb.Length > 0) break; } } if (sb.Length > 0) { Token = sb.ToString(); return true; } return false; } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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
1,124
22
using System; using static System.Console; using System.Linq; namespace AC { public class shiokara { static void Main(string[] args) { long[] ban = ReadLine().Split(' ').Select(long.Parse).ToArray(); long ans = ban[1] * (ban[0] / 2); if (ban[0] % 2 == 1) { if (ban[1] % 2 == 1) ans += ban[1] / 2 + 1; else ans += ban[1] / 2; } WriteLine(ans); } } }
using System; using static System.Console; using System.Linq; namespace AC { public class shiokara { static void Main(string[] args) { long[] ban = ReadLine().Split(' ').Select(long.Parse).ToArray(); long ans = ban[1] * (ban[0] / 2); if (ban[0] == 1 || ban[1] == 1) { WriteLine(1); return; } if (ban[0] % 2 == 1) { if (ban[1] % 2 == 1) ans += ban[1] / 2 + 1; else ans += ban[1] / 2; } WriteLine(ans); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73]]
8
128
25
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace CSharp { static class Program { static void Main(string[] args) { long h, w; ReadLong(out h, out w); long ans = (h * w) / 2 + (h * w) % 2; Console.WriteLine(ans); } #region Helpers static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray(); static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray(); static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count) .Select(_ => int.Parse(Console.ReadLine())) .ToArray(); static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count) .Select(_ => long.Parse(Console.ReadLine())) .ToArray(); static string ReadString() => Console.ReadLine(); static int ReadInt() => int.Parse(Console.ReadLine()); static long ReadLong() => long.Parse(Console.ReadLine()); static void ReadInt(out int first) { var array = ReadIntArray(); first = array[0]; } static void ReadInt(out int first, out int second) { var array = ReadIntArray(); first = array[0]; second = array[1]; } static void ReadInt(out int first, out int second, out int third) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadInt(out int first, out int second, out int third, out int fourth) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } static void ReadLong(out long first) { var array = ReadLongArray(); first = array[0]; } static void ReadLong(out long first, out long second) { var array = ReadLongArray(); first = array[0]; second = array[1]; } static void ReadLong(out long first, out long second, out long third) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadLong(out long first, out long second, out long third, out long fourth) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } #endregion } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace CSharp { static class Program { static void Main(string[] args) { long h, w; ReadLong(out h, out w); long ans = h == 1 || w == 1 ? 1 : (h * w) / 2 + (h * w) % 2; Console.WriteLine(ans); } #region Helpers static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray(); static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray(); static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count) .Select(_ => int.Parse(Console.ReadLine())) .ToArray(); static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count) .Select(_ => long.Parse(Console.ReadLine())) .ToArray(); static string ReadString() => Console.ReadLine(); static int ReadInt() => int.Parse(Console.ReadLine()); static long ReadLong() => long.Parse(Console.ReadLine()); static void ReadInt(out int first) { var array = ReadIntArray(); first = array[0]; } static void ReadInt(out int first, out int second) { var array = ReadIntArray(); first = array[0]; second = array[1]; } static void ReadInt(out int first, out int second, out int third) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadInt(out int first, out int second, out int third, out int fourth) { var array = ReadIntArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } static void ReadLong(out long first) { var array = ReadLongArray(); first = array[0]; } static void ReadLong(out long first, out long second) { var array = ReadLongArray(); first = array[0]; second = array[1]; } static void ReadLong(out long first, out long second, out long third) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; } static void ReadLong(out long first, out long second, out long third, out long fourth) { var array = ReadLongArray(); first = array[0]; second = array[1]; third = array[2]; fourth = array[3]; } #endregion } }
[["+", 0, 212, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 17, 60], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 106], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 17, 60], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102]]
8
602
10
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { //[summary]B - Bishop var line = ReadLine(); var H = line[0]; var W = line[1]; if (H == 1 | W == 1) { Console.WriteLine(1); } else { if (H % 2 == 1) { Console.WriteLine(H * W / 2 + 1); } else { Console.WriteLine(H * W / 2); } } } static List<long> ReadLine() { var line = Console.ReadLine(); var arr = line.Split(' '); return arr.Select(x => long.Parse(x)).ToList(); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { //[summary]B - Bishop var line = ReadLine(); var H = line[0]; var W = line[1]; if (H == 1 | W == 1) { Console.WriteLine(1); } else if (H % 2 == 1 && W % 2 == 1) { Console.WriteLine(H * W / 2 + 1); } else { Console.WriteLine(H * W / 2); } } static List<long> ReadLine() { var line = Console.ReadLine(); var arr = line.Split(' '); return arr.Select(x => long.Parse(x)).ToList(); } } }
[["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 57, 15, 16, 31, 16, 31, 16, 17, 109], ["+", 75, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["+", 75, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 57, 75, 196, 0, 57, 75, 196, 0, 46]]
8
167
8
using System; using System.Collections.Generic; using System.Windows; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { public class Program { static void Main(string[] args) { var r = Console.ReadLine().Split(' '); var H = r[0].ToDecimal(); var W = r[1].ToDecimal(); if (W == 0) { Console.WriteLine(0); return; } var a = Math.Floor((H * W) / 2); var ans = a + ((H * W) % 2 == 0 ? 0 : 1); Console.WriteLine(ans); Console.ReadLine(); } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } }
using System; using System.Collections.Generic; using System.Windows; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { public class Program { static void Main(string[] args) { var r = Console.ReadLine().Split(' '); var H = r[0].ToDecimal(); var W = r[1].ToDecimal(); if (W == 0) { Console.WriteLine(0); return; } if (H == 1 || W == 1) { Console.WriteLine(1); return; } var a = Math.Floor((H * W) / 2); var ans = a + ((H * W) % 2 == 0 ? 0 : 1); Console.WriteLine(ans); Console.ReadLine(); } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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], ["+", 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
211
21
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 練習1 { class Program { static void Main(string[] args) { var line = Console.ReadLine().Split(' '); var lines = new decimal[2]; for (var i = 0; i < line.Length; i++) { lines[i] = decimal.Parse(line[i]); } var count = lines[0] * lines[1]; var counts = Math.Ceiling(count / 2); Console.WriteLine(counts); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 練習1 { class Program { static void Main(string[] args) { var line = Console.ReadLine().Split(' '); var lines = new decimal[2]; for (var i = 0; i < line.Length; i++) { lines[i] = decimal.Parse(line[i]); } var count = lines[0] * lines[1]; var counts = Math.Ceiling(count / 2); if ((lines[0] == 1) || (lines[1] == 1)) counts = 1; Console.WriteLine(counts); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["+", 15, 16, 12, 23, 0, 16, 31, 204, 205, 22], ["+", 12, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
136
24
using System; class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int b = int.Parse(input[0]); int c = int.Parse(input[1]); //出力 Console.WriteLine(bishop(b, c)); } static int bishop(int x, int y) { if (x == 1 || y == 1) return 1; if (x % 2 == 0 || y % 2 == 0) return x * y / 2; return (x * y + 1) / 2; } }
using System; class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); long b = long.Parse(input[0]); long c = long.Parse(input[1]); //出力 Console.WriteLine(bishop(b, c)); } static long bishop(long x, long y) { if (x == 1 || y == 1) return 1; if (x % 2 == 0 || y % 2 == 0) return x * y / 2; return (x * y + 1) / 2; } }
[["-", 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, 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
132
14
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { string[] line = Console.ReadLine().Split(' '); long H = long.Parse(line[0]); long W = long.Parse(line[1]); if ((H * W) % 2 == 0) { Console.WriteLine((W * H) / 2); } else { Console.WriteLine((W * H) / 2 + 1); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { string[] line = Console.ReadLine().Split(' '); long H = long.Parse(line[0]); long W = long.Parse(line[1]); if (H == 1 || W == 1) { Console.WriteLine(1); } else if ((H * W) % 2 == 0) { Console.WriteLine((W * H) / 2); } else { Console.WriteLine((W * H) / 2 + 1); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 16, 31, 23, 0, 24]]
8
131
20
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; public class Hello { static public int mod = 1000000007; public static void Main() { long[] num = longa(); long ans = num[0] * num[1] / 2; long aaa = num[0] * num[1]; WriteLine(aaa - 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); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; public class Hello { static public int mod = 1000000007; public static void Main() { long[] num = longa(); long ans = num[0] * num[1] / 2; long aaa = num[0] * num[1]; if (num[0] == 1 || num[1] == 1) { WriteLine(1); } else { WriteLine(aaa - 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); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 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
815
26
using System; using System.Collections.Generic; using System.Linq; using System.Text; // using System.Numerics; using System.Runtime.CompilerServices; using System.Diagnostics; using ll=System.Int64; using static Contest_B.Lib_IO; using static Contest_B.Lib_Minifunc; public static class Contest_B { public static void Main() { checked{ long h, w; Lib_IO.rm(out h, out w); ll x = ceiling(w,2); ll y = w/2; long ans = (x+y)*(ll)(h/2)+(h%2==0?0:x); Lib_IO.wm(ans); } } #region BaseModule public static class Lib_Minifunc{ [MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; } [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 の方が小さければ交換 [MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b の方が小さければ a を更新 [MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b の方が大きければ a を更新 [MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n); [MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h)); [MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min(); [MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max(); [MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+m:v); } [MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0?a/b:a/b+1); // 整数商の切り上げ [MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b); [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); [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); [MethodImpl(256)] public static bool initd<T,U>(Dictionary<T,U> d, T k) { if(d.ContainsKey(k)) { return false; } else { d[k] = default(U); return true; } } public static T[] inita<T>(long len1) where T : new() { var m = new T[len1]; for (int i=0;i<m.Length;i++) m[i] = new T(); return m; } public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; } public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; } public const long MOD1 = 1000000007; // 10^9+7 public const double EPS1 = 1e-8; public const long INF1 = 1000000000000000; // 10^15 } 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[] {' '}; [MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U)); [MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T)); [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 = z.Select(cv<T>).ToArray(); 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); } [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)); 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) { 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 System.Runtime.CompilerServices; using System.Diagnostics; using ll=System.Int64; using static Contest_B.Lib_IO; using static Contest_B.Lib_Minifunc; public static class Contest_B { public static void Main() { checked{ long h, w; Lib_IO.rm(out h, out w); if(h==1||w==1){ wm(1); return; } ll x = ceiling(w,2); ll y = w/2; long ans = (x+y)*(ll)(h/2)+(h%2==0?0:x); Lib_IO.wm(ans); } } #region BaseModule public static class Lib_Minifunc{ [MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; } [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 の方が小さければ交換 [MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b の方が小さければ a を更新 [MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b の方が大きければ a を更新 [MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n); [MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h)); [MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min(); [MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max(); [MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+m:v); } [MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0?a/b:a/b+1); // 整数商の切り上げ [MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b); [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); [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); [MethodImpl(256)] public static bool initd<T,U>(Dictionary<T,U> d, T k) { if(d.ContainsKey(k)) { return false; } else { d[k] = default(U); return true; } } public static T[] inita<T>(long len1) where T : new() { var m = new T[len1]; for (int i=0;i<m.Length;i++) m[i] = new T(); return m; } public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; } public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; } public const long MOD1 = 1000000007; // 10^9+7 public const double EPS1 = 1e-8; public const long INF1 = 1000000000000000; // 10^15 } 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[] {' '}; [MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U)); [MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T)); [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 = z.Select(cv<T>).ToArray(); 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); } [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)); 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) { 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 }
[["+", 8, 196, 0, 287, 0, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 287, 0, 196, 0, 57, 0, 24], ["+", 0, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 287, 0, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 287, 0, 196, 0, 57, 0, 25], ["+", 0, 287, 0, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 287, 0, 196, 0, 57, 64, 196, 0, 46]]
8
2,943
19
using System; namespace Sample { class Sample { static void Main() { var line = System.Console.ReadLine(); string[] arr = line.Split(' '); long a = long.Parse(arr[0]); long b = long.Parse(arr[1]); if ((a % 2 == 1) && (b % 2 == 1)) { // 奇数+奇数 Console.WriteLine(a * b / 2 + 1); } else { Console.WriteLine(a * b / 2); } } } }
using System; namespace Sample { class Sample { static void Main() { var line = System.Console.ReadLine(); string[] arr = line.Split(' '); long a = long.Parse(arr[0]); long b = long.Parse(arr[1]); if (a == 1 || b == 1) { Console.WriteLine(1); } else if ((a % 2 == 1) && (b % 2 == 1)) { // 奇数+奇数 Console.WriteLine(a * b / 2 + 1); } else { Console.WriteLine(a * b / 2); } } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 23, 0, 24]]
8
117
20
using System; using static System.Console; class Program { static void Main(string[] args) { long H, W, re; string[] str = ReadLine().Split(' '); H = long.Parse(str[0]); W = long.Parse(str[1]); if (H % 2 == 0) { re = W * (H / 2); } else if (W % 2 == 0) { re = H * (W / 2); } else { re = W * ((H - 1) / 2) + ((W + 1) / 2); } WriteLine($"{re}"); } }
using System; using static System.Console; class Program { static void Main(string[] args) { long H, W, re; string[] str = ReadLine().Split(' '); H = long.Parse(str[0]); W = long.Parse(str[1]); if (H == 1 || W == 1) { re = 1; } else if (H % 2 == 0) { re = W * (H / 2); } else if (W % 2 == 0) { re = H * (W / 2); } else { re = (W * ((H - 1) / 2)) + ((W + 1) / 2); } WriteLine($"{re}"); } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
8
148
19
using System; namespace Bishop { class Program { static void Main(string[] args) { String input = Console.ReadLine(); String[] splitted = input.Split(' '); long H = long.Parse(splitted[0]); long W = long.Parse(splitted[1]); long answer = 0; answer = Math.Max(H * W / 2, (H * W + 1) / 2); Console.WriteLine(answer); } } }
using System; namespace Bishop { class Program { static void Main(string[] args) { String input = Console.ReadLine(); String[] splitted = input.Split(' '); long H = long.Parse(splitted[0]); long W = long.Parse(splitted[1]); long answer = 0; if (H == 1 || W == 1) { answer = 1; } else { answer = Math.Max(H * W / 2, (H * W + 1) / 2); } Console.WriteLine(answer); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
106
19
using System; using System.Linq; namespace AtCoderPanasonicContest2020 { class Program { static void Main(string[] args) { var inputs = ReadIntArray(); long hmax = inputs[0] % 2 == 0 ? inputs[0] / 2 : inputs[0] / 2 + 1; long hmin = inputs[0] / 2; long wmax = inputs[1] % 2 == 0 ? inputs[1] / 2 : inputs[1] / 2 + 1; long wmin = inputs[1] / 2; var result = hmax * wmax + hmin * wmin; Console.WriteLine(result); } public static int ReadInt() => int.Parse(Console.ReadLine()); public static int[] ReadIntArray() => Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); public static long ReadLong() => long.Parse(Console.ReadLine()); public static long[] ReadLongArray() => Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); public static string ReadString() => Console.ReadLine(); public static string[] ReadStringArray() => Console.ReadLine().Split(); } }
using System; using System.Linq; namespace AtCoderPanasonicContest2020 { class Program { static void Main(string[] args) { var inputs = ReadIntArray(); long hmax = inputs[0] % 2 == 0 ? inputs[0] / 2 : inputs[0] / 2 + 1; long hmin = inputs[0] / 2; long wmax = inputs[1] % 2 == 0 ? inputs[1] / 2 : inputs[1] / 2 + 1; long wmin = inputs[1] / 2; var result = hmax * wmax + hmin * wmin; if (inputs[0] == 1 || inputs[1] == 1) { Console.WriteLine(1); } else { Console.WriteLine(result); } } public static int ReadInt() => int.Parse(Console.ReadLine()); public static int[] ReadIntArray() => Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); public static long ReadLong() => long.Parse(Console.ReadLine()); public static long[] ReadLongArray() => Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); public static string ReadString() => Console.ReadLine(); public static string[] ReadStringArray() => Console.ReadLine().Split(); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
266
28
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace AtcoderExpress { class Program { static void Main(string[] args) { // var W = long.Parse(Console.ReadLine()); var HW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); var H = HW[0]; var W = HW[1]; // Array.Sort(A); if ((H % 2 == 1 && W % 2 == 0) || (H % 2 == 0 && W % 2 == 1)) { Console.WriteLine((H * W) / 2); } else { Console.WriteLine((H * W + 1) / 2); } } } }
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace AtcoderExpress { class Program { static void Main(string[] args) { // var W = long.Parse(Console.ReadLine()); var HW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); var H = HW[0]; var W = HW[1]; // Array.Sort(A); if (H == 1 || W == 1) { Console.WriteLine(1); } else if ((H % 2 == 1 && W % 2 == 0) || (H % 2 == 0 && W % 2 == 1)) { Console.WriteLine((H * W) / 2); } else { Console.WriteLine((H * W + 1) / 2); } } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 23, 0, 24]]
8
164
20
using System; using System.Linq; using System.Collections.Generic; using System.Collections; class Program { static void Main(string[] args) { var sol = new Solve(); sol.Exec(); } } class Solve { public void Exec() { var l = Console.ReadLine().Split().Select(long.Parse).ToArray(); long H = l[0], W = l[1]; var w1 = W % 2 == 0 ? W / 2 : W / 2 + 1; var w2 = W / 2; var h1 = H % 2 == 0 ? H / 2 : H / 2 + 1; var h2 = H - h1; var ans = w1 * h1 + w2 * h2; Console.WriteLine(ans); } }
using System; using System.Linq; using System.Collections.Generic; using System.Collections; class Program { static void Main(string[] args) { var sol = new Solve(); sol.Exec(); } } class Solve { public void Exec() { var l = Console.ReadLine().Split().Select(long.Parse).ToArray(); long H = l[0], W = l[1]; var w1 = W % 2 == 0 ? W / 2 : W / 2 + 1; var w2 = W / 2; var h1 = H % 2 == 0 ? H / 2 : H / 2 + 1; var h2 = H - h1; var ans = w1 * h1 + w2 * h2; Console.WriteLine(H == 1 || W == 1 ? 1 : ans); } }
[["+", 0, 28, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 17, 60], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 106], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 17, 60], ["+", 0, 28, 0, 41, 15, 16, 12, 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]]
8
169
10
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 Solve { public Solve() {} public static int Main() { new Solve().calc(); return 0; } Scanner cin; void calc() { cin = new Scanner(); long H = cin.nextLong(); long W = cin.nextLong(); bool dividableBy2 = H % 2 == 0 || W % 2 == 0; long result = H * W / 2; if (!dividableBy2) { result++; } Console.WriteLine(result.ToString()); } } class Modulo { private const int M = 1000000007; private readonly int[] m_facs; public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % M); } public Modulo(int n) { m_facs = new int[n + 1]; m_facs[0] = 1; for (int i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public int Fac(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 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public int Div(int a, int b) { return Mul(a, Pow(b, M - 2)); } public int Ncr(int n, int r) { if (n < r) { return 0; } if (n == r) { return 1; } int res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } 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 Solve { public Solve() {} public static int Main() { new Solve().calc(); return 0; } Scanner cin; void calc() { cin = new Scanner(); long H = cin.nextLong(); long W = cin.nextLong(); if (H == 1 || W == 1) { Console.WriteLine("1"); return; } bool dividableBy2 = H % 2 == 0 || W % 2 == 0; long result = H * W / 2; if (!dividableBy2) { result++; } Console.WriteLine(result.ToString()); } } class Modulo { private const int M = 1000000007; private readonly int[] m_facs; public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % M); } public Modulo(int n) { m_facs = new int[n + 1]; m_facs[0] = 1; for (int i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public int Fac(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 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public int Div(int a, int b) { return Mul(a, Pow(b, M - 2)); } public int Ncr(int n, int r) { if (n < r) { return 0; } if (n == r) { return 1; } int res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } 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; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 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
791
23
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; class Program { static int testN = 3; static long mod = 1000000007; // static long mod =998244353; static System.IO.StringReader sr; static void Main(string[] args) { char[] cs = new char[] { ' ' }; // char[] cs = new char[] { ' ', ',' }; // int n = int.Parse(Console.ReadLine()); // int val = int.Parse(Console.ReadLine()); // int[] vals = parseAry(Console.ReadLine().Split(cs)); // string str = Console.ReadLine(); // string[] strs = Console.ReadLine().Split(cs); // string res = ""; long res = 0; int[] vals = parseAry(Console.ReadLine().Split(cs)); long x = vals[1]; long y = vals[0]; res = (x * y) / 2; if ((x % 2 == 1) && (y % 2 == 1)) { res++; } Console.WriteLine(res); return; } // 文字列strをindex番目からdで上書き static string strOverWrite(string str, int i, string s) { return str.Remove(i, s.Length).Insert(i, s); } // String[] -----> int[] static int[] parseAry(string[] str) { int[] nums = new int[str.Length]; for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); } return nums; } // String[] -----> long[] static long[] parseAryL(string[] str) { long[] nums = new long[str.Length]; for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); } return nums; } //文字列を1文字ずつString[]に入れる static string[] strAry(String str) { string[] re = new string[str.Length]; for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); } return re; } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; class Program { static int testN = 3; static long mod = 1000000007; // static long mod =998244353; static System.IO.StringReader sr; static void Main(string[] args) { char[] cs = new char[] { ' ' }; // char[] cs = new char[] { ' ', ',' }; // int n = int.Parse(Console.ReadLine()); // int val = int.Parse(Console.ReadLine()); // int[] vals = parseAry(Console.ReadLine().Split(cs)); // string str = Console.ReadLine(); // string[] strs = Console.ReadLine().Split(cs); // string res = ""; long res = 0; int[] vals = parseAry(Console.ReadLine().Split(cs)); long x = vals[1]; long y = vals[0]; res = (x * y) / 2; if ((x % 2 == 1) && (y % 2 == 1)) { res++; } if (x == 1 || y == 1) { res = 1; } Console.WriteLine(res); return; } // 文字列strをindex番目からdで上書き static string strOverWrite(string str, int i, string s) { return str.Remove(i, s.Length).Insert(i, s); } // String[] -----> int[] static int[] parseAry(string[] str) { int[] nums = new int[str.Length]; for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); } return nums; } // String[] -----> long[] static long[] parseAryL(string[] str) { long[] nums = new long[str.Length]; for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); } return nums; } //文字列を1文字ずつString[]に入れる static string[] strAry(String str) { string[] re = new string[str.Length]; for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); } return re; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
386
16
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var HW = ReadLongs(); if (HW[0] * HW[1] % 2 == 0) { WriteLine(HW[0] * HW[1] / 2); } else { WriteLine(HW[0] * HW[1] / 2 + 1); } } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } 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.Numerics; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var HW = ReadLongs(); if (HW[0] == 1 || HW[1] == 1) { WriteLine("1"); } else if (HW[0] * HW[1] % 2 == 0) { WriteLine(HW[0] * HW[1] / 2); } else { WriteLine(HW[0] * HW[1] / 2 + 1); } } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } 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, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 15, 16, 31, 16, 31, 16, 31, 204, 205, 22], ["+", 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]]
8
288
26
using System; using System.Collections.Generic; using System.Diagnostics.Tracing; using System.Linq; using System.Net.NetworkInformation; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Extensions; using DSA; using static System.Math; using static Extensions.MathExtension; using static Extensions.ConsoleInputExtension; using static Extensions.ConsoleOutputExtension; class Solver { public void Solve() { // Solve Code Here long h = Cin, w = Cin; Coutln(w * (h >> 1) + ((w + 1) >> 1) * (h & 1)); } // Other Functions Here } // Other Classes Here #if !DEBUG class EntryPoint { static void Main(string[] args) { new Solver().Solve(); Flush(); } } #endif namespace DSA { public class PriorityQueue<T> { private readonly List<Tuple<int, T>> _list = new List<Tuple<int, T>>(); public int Count => _list.Count; public PriorityQueue() {} public void Push(T item, int priority) { _list.Add(Tuple.Create(priority, item)); int itemIndex = Count - 1, parentIndex; while ((parentIndex = GetParentIndex(itemIndex)) != -1 && priority > _list[parentIndex].Item1) { Swap(itemIndex, parentIndex); itemIndex = parentIndex; } } private int GetParentIndex(int index) { if (index == 0) return -1; return ((index + 1) >> 1) - 1; } private Tuple<int, int> GetChildrenIndex(int index) { var item2 = (index + 1) << 1; var item1 = item2 - 1; return Tuple.Create(item1, item2); } public T Pop() { if (Count <= 0) throw new IndexOutOfRangeException(); var item = _list[0].Item2; _list[0] = _list[Count - 1]; _list.RemoveAt(Count - 1); int index = 0; Tuple<int, int> childrenIndex = GetChildrenIndex(index); while (childrenIndex.Item1 < Count || childrenIndex.Item2 < Count) { if (childrenIndex.Item2 >= Count || _list[childrenIndex.Item1].Item1 > _list[childrenIndex.Item2].Item1) { if (_list[childrenIndex.Item1].Item1 <= _list[index].Item1) return item; Swap(index, childrenIndex.Item1); index = childrenIndex.Item1; } else { if (_list[childrenIndex.Item2].Item1 <= _list[index].Item1) return item; Swap(index, childrenIndex.Item2); index = childrenIndex.Item2; } childrenIndex = GetChildrenIndex(index); } return item; } public T Peek() { return _list[0].Item2; } private void Swap(int index1, int index2) { var tmp = _list[index1]; _list[index1] = _list[index2]; _list[index2] = tmp; } } public class UnionFind { private readonly int[] _array; public UnionFind(int size) { _array = new int[size]; for (int i = 0; i < size; i++) { _array[i] = i; } } public int GetRootNode(int n) { if (_array[n] == n) return n; return _array[n] = GetRootNode(_array[n]); } public void UnionGroup(int a, int b) { var rootA = GetRootNode(a); var rootB = GetRootNode(b); if (rootA == rootB) return; _array[rootA] = rootB; } public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b); public bool IsRoot(int n) => _array[n] == n; } public delegate T SegTreeCombiner<T>(T item1, T item2); public class SegTree<T> { private readonly T _defaultItem; private readonly SegTreeCombiner<T> _func; private T[] List; private int size; public SegTree(T[] list, T defaultItem, SegTreeCombiner<T> func) { _defaultItem = defaultItem; _func = func; size = 1; while (size < list.Length) size <<= 1; List = new T[2 * size - 1]; for (int i = 0; i < list.Length; i++) List[i + size - 1] = list[i]; for (int i = list.Length; i < size; i++) List[i + size - 1] = defaultItem; for (int i = size - 1 - 1; i >= 0; i--) { List[i] = _func(List[2 * i + 1], List[2 * i + 2]); } } public void Update(int index, T value) { index += size - 1; List[index] = value; while (index > 0) { index = (index - 1) >> 1; List[index] = _func(List[2 * index + 1], List[2 * index + 2]); } } public T Query(int a, int b) { return Query(a, b, 0, 0, size); } private T Query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return _defaultItem; if (a <= l && r <= b) return List[k]; return _func(Query(a, b, k * 2 + 1, l, (l + r) >> 1), Query(a, b, k * 2 + 2, (l + r) >> 1, r)); } } public static class BinarySearch { public delegate bool Terms<T>(T i); public static int UpperBound(int initLeft, int initRight, Terms<int> term) { // TODO:範囲内に条件を満たす区間が存在しない場合に対応する int left = initLeft - 1, right = initRight; while (right - left > 1) { int mid = (left + right) >> 1; if (mid != initLeft - 1 && term(mid)) left = mid; else right = mid; } return left; } public static long UpperBound(long initLeft, long initRight, Terms<long> term) { long left = initLeft - 1, right = initRight; while (right - left > 1) { long mid = (left + right) >> 1; if (mid != initLeft - 1 && term(mid)) left = mid; else right = mid; } return left; } public static int LowerBound(int initLeft, int initRight, Terms<int> term) { int left = initLeft - 1, right = initRight; while (right - left > 1) { int mid = (left + right) >> 1; if (mid != initRight && term(mid)) right = mid; else left = mid; } return right; } public static long LowerBound(long initLeft, long initRight, Terms<long> term) { long left = initLeft - 1, right = initRight; while (right - left > 1) { long mid = (left + right) >> 1; if (term(mid)) right = mid; else left = mid; } return right; } } } struct ModInt { public long Value { get; } public static long Mod { get; set; } = 1000000000L + 7; public ModInt(long l) { long value = l % Mod; while (value < 0) value += Mod; Value = value % Mod; } public static implicit operator long(ModInt m) { return m.Value; } public static implicit operator ModInt(long l) { return new ModInt(l); } public static ModInt operator +(ModInt a, ModInt b) { return new ModInt(a.Value + b.Value); } public static ModInt operator -(ModInt a, ModInt b) { return new ModInt(a.Value - b.Value); } public static ModInt operator *(ModInt a, ModInt b) { return new ModInt(a.Value * b.Value); } public static ModInt operator /(ModInt a, ModInt b) { return new ModInt(a * b.Inverse()); } public override string ToString() { return Value.ToString(); } } static class ModIntMath { public static ModInt Pow(this ModInt a, ModInt b) { var pow = b.Value; var m = a; ModInt ans = new ModInt(1); while (pow != 0) { if ((pow & 1) == 1) { ans *= m; } pow >>= 1; m *= m; } return ans; } public static ModInt Inverse(this ModInt m) { return m.Pow((ModInt)(ModInt.Mod - 2)); } } namespace Extensions { public class ConsoleInputExtension { private static readonly ConsoleInputExtension _cin = new ConsoleInputExtension(); public static ConsoleInputExtension Cin => _cin; private static readonly Queue<string> _inputQueue = new Queue<string>(); private ConsoleInputExtension() {} public static implicit operator string(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return _inputQueue.Dequeue(); } public static implicit operator int(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return int.Parse(_inputQueue.Dequeue()); } public static implicit operator long(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return long.Parse(_inputQueue.Dequeue()); } public static implicit operator float(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return float.Parse(_inputQueue.Dequeue()); } public static implicit operator double(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return double.Parse(_inputQueue.Dequeue()); } } public static class ConsoleOutputExtension { private static StringBuilder _builder = new StringBuilder(); public static void Cout(object o) { _builder.Append(o); } public static void CoutF(object o) { _builder.Append(o); Flush(); } public static void Coutln(object o) { _builder.Append(o); _builder.Append('\n'); } public static void Coutln() { _builder.Append('\n'); } public static void CoutlnF(object o) { _builder.Append(o); _builder.Append('\n'); Flush(); } public static void Flush() { Console.Write(_builder.ToString()); _builder.Clear(); } } public static class MathExtension { //最小公倍数 public static int LCM(int num1, int num2) { var gcd = GCD(num1, num2); return num1 * (num2 / gcd); } public static long LCM(long num1, long num2) { var gcd = GCD(num1, num2); return num1 * (num2 / gcd); } //最大公約数 public static int GCD(int num1, int num2) { int a = Math.Max(num1, num2); int b = Math.Min(num1, num2); if (b == 0) return a; int mod; while ((mod = a % b) != 0) { a = b; b = mod; } return b; } public static long GCD(long num1, long num2) { long a = Math.Max(num1, num2); long b = Math.Min(num1, num2); if (b == 0) return a; long mod; while ((mod = a % b) != 0) { a = b; b = mod; } return b; } } public static class EnumerableExtension { public delegate void Function<in T>(T val); public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function) { foreach (var x in enumerable) { function(x); } } } }
using System; using System.Collections.Generic; using System.Diagnostics.Tracing; using System.Linq; using System.Net.NetworkInformation; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Extensions; using DSA; using static System.Math; using static Extensions.MathExtension; using static Extensions.ConsoleInputExtension; using static Extensions.ConsoleOutputExtension; class Solver { public void Solve() { // Solve Code Here long h = Cin, w = Cin; if (h == 1 || w == 1) Coutln(1); else Coutln(w * (h >> 1) + ((w + 1) >> 1) * (h & 1)); } // Other Functions Here } // Other Classes Here #if !DEBUG class EntryPoint { static void Main(string[] args) { new Solver().Solve(); Flush(); } } #endif namespace DSA { public class PriorityQueue<T> { private readonly List<Tuple<int, T>> _list = new List<Tuple<int, T>>(); public int Count => _list.Count; public PriorityQueue() {} public void Push(T item, int priority) { _list.Add(Tuple.Create(priority, item)); int itemIndex = Count - 1, parentIndex; while ((parentIndex = GetParentIndex(itemIndex)) != -1 && priority > _list[parentIndex].Item1) { Swap(itemIndex, parentIndex); itemIndex = parentIndex; } } private int GetParentIndex(int index) { if (index == 0) return -1; return ((index + 1) >> 1) - 1; } private Tuple<int, int> GetChildrenIndex(int index) { var item2 = (index + 1) << 1; var item1 = item2 - 1; return Tuple.Create(item1, item2); } public T Pop() { if (Count <= 0) throw new IndexOutOfRangeException(); var item = _list[0].Item2; _list[0] = _list[Count - 1]; _list.RemoveAt(Count - 1); int index = 0; Tuple<int, int> childrenIndex = GetChildrenIndex(index); while (childrenIndex.Item1 < Count || childrenIndex.Item2 < Count) { if (childrenIndex.Item2 >= Count || _list[childrenIndex.Item1].Item1 > _list[childrenIndex.Item2].Item1) { if (_list[childrenIndex.Item1].Item1 <= _list[index].Item1) return item; Swap(index, childrenIndex.Item1); index = childrenIndex.Item1; } else { if (_list[childrenIndex.Item2].Item1 <= _list[index].Item1) return item; Swap(index, childrenIndex.Item2); index = childrenIndex.Item2; } childrenIndex = GetChildrenIndex(index); } return item; } public T Peek() { return _list[0].Item2; } private void Swap(int index1, int index2) { var tmp = _list[index1]; _list[index1] = _list[index2]; _list[index2] = tmp; } } public class UnionFind { private readonly int[] _array; public UnionFind(int size) { _array = new int[size]; for (int i = 0; i < size; i++) { _array[i] = i; } } public int GetRootNode(int n) { if (_array[n] == n) return n; return _array[n] = GetRootNode(_array[n]); } public void UnionGroup(int a, int b) { var rootA = GetRootNode(a); var rootB = GetRootNode(b); if (rootA == rootB) return; _array[rootA] = rootB; } public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b); public bool IsRoot(int n) => _array[n] == n; } public delegate T SegTreeCombiner<T>(T item1, T item2); public class SegTree<T> { private readonly T _defaultItem; private readonly SegTreeCombiner<T> _func; private T[] List; private int size; public SegTree(T[] list, T defaultItem, SegTreeCombiner<T> func) { _defaultItem = defaultItem; _func = func; size = 1; while (size < list.Length) size <<= 1; List = new T[2 * size - 1]; for (int i = 0; i < list.Length; i++) List[i + size - 1] = list[i]; for (int i = list.Length; i < size; i++) List[i + size - 1] = defaultItem; for (int i = size - 1 - 1; i >= 0; i--) { List[i] = _func(List[2 * i + 1], List[2 * i + 2]); } } public void Update(int index, T value) { index += size - 1; List[index] = value; while (index > 0) { index = (index - 1) >> 1; List[index] = _func(List[2 * index + 1], List[2 * index + 2]); } } public T Query(int a, int b) { return Query(a, b, 0, 0, size); } private T Query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return _defaultItem; if (a <= l && r <= b) return List[k]; return _func(Query(a, b, k * 2 + 1, l, (l + r) >> 1), Query(a, b, k * 2 + 2, (l + r) >> 1, r)); } } public static class BinarySearch { public delegate bool Terms<T>(T i); public static int UpperBound(int initLeft, int initRight, Terms<int> term) { // TODO:範囲内に条件を満たす区間が存在しない場合に対応する int left = initLeft - 1, right = initRight; while (right - left > 1) { int mid = (left + right) >> 1; if (mid != initLeft - 1 && term(mid)) left = mid; else right = mid; } return left; } public static long UpperBound(long initLeft, long initRight, Terms<long> term) { long left = initLeft - 1, right = initRight; while (right - left > 1) { long mid = (left + right) >> 1; if (mid != initLeft - 1 && term(mid)) left = mid; else right = mid; } return left; } public static int LowerBound(int initLeft, int initRight, Terms<int> term) { int left = initLeft - 1, right = initRight; while (right - left > 1) { int mid = (left + right) >> 1; if (mid != initRight && term(mid)) right = mid; else left = mid; } return right; } public static long LowerBound(long initLeft, long initRight, Terms<long> term) { long left = initLeft - 1, right = initRight; while (right - left > 1) { long mid = (left + right) >> 1; if (term(mid)) right = mid; else left = mid; } return right; } } } struct ModInt { public long Value { get; } public static long Mod { get; set; } = 1000000000L + 7; public ModInt(long l) { long value = l % Mod; while (value < 0) value += Mod; Value = value % Mod; } public static implicit operator long(ModInt m) { return m.Value; } public static implicit operator ModInt(long l) { return new ModInt(l); } public static ModInt operator +(ModInt a, ModInt b) { return new ModInt(a.Value + b.Value); } public static ModInt operator -(ModInt a, ModInt b) { return new ModInt(a.Value - b.Value); } public static ModInt operator *(ModInt a, ModInt b) { return new ModInt(a.Value * b.Value); } public static ModInt operator /(ModInt a, ModInt b) { return new ModInt(a * b.Inverse()); } public override string ToString() { return Value.ToString(); } } static class ModIntMath { public static ModInt Pow(this ModInt a, ModInt b) { var pow = b.Value; var m = a; ModInt ans = new ModInt(1); while (pow != 0) { if ((pow & 1) == 1) { ans *= m; } pow >>= 1; m *= m; } return ans; } public static ModInt Inverse(this ModInt m) { return m.Pow((ModInt)(ModInt.Mod - 2)); } } namespace Extensions { public class ConsoleInputExtension { private static readonly ConsoleInputExtension _cin = new ConsoleInputExtension(); public static ConsoleInputExtension Cin => _cin; private static readonly Queue<string> _inputQueue = new Queue<string>(); private ConsoleInputExtension() {} public static implicit operator string(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return _inputQueue.Dequeue(); } public static implicit operator int(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return int.Parse(_inputQueue.Dequeue()); } public static implicit operator long(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return long.Parse(_inputQueue.Dequeue()); } public static implicit operator float(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return float.Parse(_inputQueue.Dequeue()); } public static implicit operator double(ConsoleInputExtension _) { if (_inputQueue.Count == 0) Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val)); return double.Parse(_inputQueue.Dequeue()); } } public static class ConsoleOutputExtension { private static StringBuilder _builder = new StringBuilder(); public static void Cout(object o) { _builder.Append(o); } public static void CoutF(object o) { _builder.Append(o); Flush(); } public static void Coutln(object o) { _builder.Append(o); _builder.Append('\n'); } public static void Coutln() { _builder.Append('\n'); } public static void CoutlnF(object o) { _builder.Append(o); _builder.Append('\n'); Flush(); } public static void Flush() { Console.Write(_builder.ToString()); _builder.Clear(); } } public static class MathExtension { //最小公倍数 public static int LCM(int num1, int num2) { var gcd = GCD(num1, num2); return num1 * (num2 / gcd); } public static long LCM(long num1, long num2) { var gcd = GCD(num1, num2); return num1 * (num2 / gcd); } //最大公約数 public static int GCD(int num1, int num2) { int a = Math.Max(num1, num2); int b = Math.Min(num1, num2); if (b == 0) return a; int mod; while ((mod = a % b) != 0) { a = b; b = mod; } return b; } public static long GCD(long num1, long num2) { long a = Math.Max(num1, num2); long b = Math.Min(num1, num2); if (b == 0) return a; long mod; while ((mod = a % b) != 0) { a = b; b = mod; } return b; } } public static class EnumerableExtension { public delegate void Function<in T>(T val); public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function) { foreach (var x in enumerable) { function(x); } } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 213, 63, 22]]
8
2,569
16
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Numerics; namespace Panasonic2020.B { using static Util; public class Solver : SolverBase { public void Run() { long H, W; ReadLong2(out H, out W); if (W % 2 == 0 || H % 2 == 0) { WriteLine(H * W / 2); } else { WriteLine((H * W + 1) / 2); } } #if !MYHOME static void Main(string[] args) { new Solver().Run(); } #endif } public static class Util { public static int Gcd(int a, int b) { if (a < b) // 引数を入替えて自分を呼び出す return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public readonly static long MOD = 1000000007; public static string DumpToString<T>(IEnumerable<T> array) where T : IFormattable { var sb = new StringBuilder(); foreach (var item in array) { sb.Append(item); sb.Append(", "); } return sb.ToString(); } public static void InitArray<T>(T[] ary, T value) { for (int i = 0; i < ary.Length; i++) { ary[i] = value; } } public static void InitDP2<T>(T[,] dp, T value) { for (int i = 0; i < dp.GetLength(0); i++) { for (int j = 0; j < dp.GetLength(1); j++) { dp[i, j] = value; } } } public static void InitDP3<T>(T[,,] dp, T value) { for (int i = 0; i < dp.GetLength(0); i++) { for (int j = 0; j < dp.GetLength(1); j++) { for (int k = 0; k < dp.GetLength(2); k++) { dp[i, j, k] = value; } } } } public static T Max<T>(params T[] nums) where T : IComparable { if (nums.Length == 0) return default(T); T max = nums[0]; for (int i = 1; i < nums.Length; i++) { max = max.CompareTo(nums[i]) > 0 ? max : nums[i]; } return max; } public static T Min<T>(params T[] nums) where T : IComparable { if (nums.Length == 0) return default(T); T min = nums[0]; for (int i = 1; i < nums.Length; i++) { min = min.CompareTo(nums[i]) < 0 ? min : nums[i]; } return min; } /// <summary> /// ソート済み配列 ary に同じ値の要素が含まれている? /// ※ソート順は昇順/降順どちらでもよい /// </summary> public static bool HasDuplicateInSortedArray<T>(T[] ary) where T : IComparable, IComparable<T> { if (ary.Length <= 1) return false; var lastNum = ary[ary.Length - 1]; foreach (var n in ary) { if (lastNum.CompareTo(n) == 0) { return true; } else { lastNum = n; } } return false; } public static bool ReplaceIfBigger<T>(ref T r, T v) where T : IComparable { if (r.CompareTo(v) < 0) { r = v; return true; } else { return false; } } public static bool ReplaceIfSmaller<T>(ref T r, T v) where T : IComparable { if (0 < r.CompareTo(v)) { r = v; return true; } else { return false; } } /// <summary> /// dic[key]にadderを加算する。keyが存在しなかった場合はdic[key]=adder /// をセットする。 /// </summary> public static void AddTo<TKey>(this Dictionary<TKey, int> dic, TKey key, int adder) { if (dic.ContainsKey(key)) { dic[key] += adder; } else { dic[key] = adder; } } /// <summary> /// 文字列 s が chars に含まれる文字を含んでいるか? /// </summary> public static bool ContainsAny(this string s, char[] chars) { for (int j = 0; j < s.Length; j++) { if (chars.Contains(s[j])) return true; } return false; } /// <summary> /// 二分探索 /// ※条件を満たす最小のidxを返す /// ※満たすものがない場合は ary.Length を返す /// ※『aryの先頭側が条件を満たさない、末尾側が条件を満たす』という前提 /// ただし、IsOK(...)の戻り値を逆転させれば、逆でも同じことが可能。 /// </summary> /// <param name="ary">探索対象配列 ★ソート済みであること</param> /// <param name="key">探索値 /// ※これ以上の値を持つ(IsOKがtrueを返す)最小のindexを返す</param> public static int BinarySearch<T>(T[] ary, T key) where T : IComparable, IComparable<T> { int left = -1; int right = ary.Length; while (1 < right - left) { var mid = left + (right - left) / 2; if (IsOK(ary, mid, key)) { right = mid; } else { left = mid; } } // left は条件を満たさない最大の値、right // は条件を満たす最小の値になっている return right; } public static bool IsOK<T>(T[] ary, int idx, T key) where T : IComparable, IComparable<T> { // key <= ary[idx] と同じ意味 return key.CompareTo(ary[idx]) <= 0; } } public class SolverBase { virtual protected string ReadLine() => Console.ReadLine(); virtual protected string ReadString() => ReadLine(); virtual protected int ReadInt() => int.Parse(ReadLine()); virtual protected long ReadLong() => long.Parse(ReadLine()); virtual protected string[] ReadStringArray() => ReadLine().Split(' '); virtual protected char[] ReadCharArray() => ReadLine() .Split(' ') .Select<string, char>( s => s[0]) .ToArray(); virtual protected int[] ReadIntArray() => ReadLine() .Split(' ') .Select<string, int>( s => int.Parse(s)) .ToArray(); virtual protected void ReadInt2(out int a, out int b) { var ary = ReadIntArray(); a = ary[0]; b = ary[1]; } virtual protected void ReadInt3(out int a, out int b, out int c) { var ary = ReadIntArray(); a = ary[0]; b = ary[1]; c = ary[2]; } virtual protected void ReadInt4(out int a, out int b, out int c, out int d) { var ary = ReadIntArray(); a = ary[0]; b = ary[1]; c = ary[2]; d = ary[3]; } virtual protected long[] ReadLongArray() => ReadLine() .Split(' ') .Select<string, long>( s => long.Parse(s)) .ToArray(); virtual protected void ReadLong2(out long a, out long b) { var ary = ReadLongArray(); a = ary[0]; b = ary[1]; } virtual protected void ReadLong3(out long a, out long b, out long c) { var ary = ReadLongArray(); a = ary[0]; b = ary[1]; c = ary[2]; } virtual protected void ReadLong4(out long a, out long b, out long c, out long d) { var ary = ReadLongArray(); a = ary[0]; b = ary[1]; c = ary[2]; d = ary[3]; } virtual protected double[] ReadDoubleArray() => ReadLine() .Split(' ') .Select<string, double>( s => double.Parse(s)) .ToArray(); virtual protected void WriteLine(string line) => Console.WriteLine(line); virtual protected void WriteLine(double d) => Console.WriteLine($"{d:F9}"); virtual protected void WriteLine<T>(T value) where T : IFormattable => Console.WriteLine(value); virtual protected void WriteGrid(IEnumerable<IEnumerable<char>> arrayOfArray) { var sb = new StringBuilder(); foreach (var a in arrayOfArray) { foreach (var c in a) { sb.Append(c); } sb.AppendLine(); } WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void Dump(string s) => Console.WriteLine(s); [Conditional("DEBUG")] protected void Dump(char c) => Console.WriteLine(c); [Conditional("DEBUG")] protected void Dump(int x) => Console.WriteLine(x); [Conditional("DEBUG")] protected void Dump(double d) => Console.WriteLine($"{d:F9}"); [Conditional("DEBUG")] protected void Dump<T>(IEnumerable<T> array) where T : IFormattable { string s = Util.DumpToString(array); // Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。 Console.WriteLine(s); //_writer.WriteLine(s); } [Conditional("DEBUG")] protected void DumpGrid(IEnumerable<IEnumerable<char>> arrayOfArray) { var sb = new StringBuilder(); foreach (var a in arrayOfArray) { foreach (var c in a) { sb.Append(c); } sb.AppendLine(); } // Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。 Console.WriteLine(sb.ToString()); //_writer.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpGrid<T>(IEnumerable<IEnumerable<T>> arrayOfArray) where T : IFormattable { var sb = new StringBuilder(); foreach (var a in arrayOfArray) { sb.AppendLine(Util.DumpToString(a)); } // Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。 Console.WriteLine(sb.ToString()); //_writer.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpGrid(bool[,] grid) { var sb = new StringBuilder(); for (int i = 0; i < grid.GetLength(0); i++) { for (int j = 0; j < grid.GetLength(1); j++) { sb.Append(grid[i, j] ? "x " : ". "); } sb.AppendLine(); } Console.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpGrid(char[,] grid) { var sb = new StringBuilder(); for (int i = 0; i < grid.GetLength(0); i++) { for (int j = 0; j < grid.GetLength(1); j++) { sb.Append(grid[i, j]); sb.Append(" "); } sb.AppendLine(); } Console.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpDP<T>(T[,] dp) where T : IFormattable { var sb = new StringBuilder(); for (int i = 0; i < dp.GetLength(0); i++) { for (int j = 0; j < dp.GetLength(1); j++) { sb.Append(dp[i, j]); sb.Append(", "); } sb.AppendLine(); } Console.WriteLine(sb.ToString()); } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Numerics; namespace Panasonic2020.B { using static Util; public class Solver : SolverBase { public void Run() { long H, W; ReadLong2(out H, out W); if (W == 1 || H == 1) { WriteLine(1); } else if (W % 2 == 0 || H % 2 == 0) { WriteLine(H * W / 2); } else { WriteLine((H * W + 1) / 2); } } #if !MYHOME static void Main(string[] args) { new Solver().Run(); } #endif } public static class Util { public static int Gcd(int a, int b) { if (a < b) // 引数を入替えて自分を呼び出す return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public readonly static long MOD = 1000000007; public static string DumpToString<T>(IEnumerable<T> array) where T : IFormattable { var sb = new StringBuilder(); foreach (var item in array) { sb.Append(item); sb.Append(", "); } return sb.ToString(); } public static void InitArray<T>(T[] ary, T value) { for (int i = 0; i < ary.Length; i++) { ary[i] = value; } } public static void InitDP2<T>(T[,] dp, T value) { for (int i = 0; i < dp.GetLength(0); i++) { for (int j = 0; j < dp.GetLength(1); j++) { dp[i, j] = value; } } } public static void InitDP3<T>(T[,,] dp, T value) { for (int i = 0; i < dp.GetLength(0); i++) { for (int j = 0; j < dp.GetLength(1); j++) { for (int k = 0; k < dp.GetLength(2); k++) { dp[i, j, k] = value; } } } } public static T Max<T>(params T[] nums) where T : IComparable { if (nums.Length == 0) return default(T); T max = nums[0]; for (int i = 1; i < nums.Length; i++) { max = max.CompareTo(nums[i]) > 0 ? max : nums[i]; } return max; } public static T Min<T>(params T[] nums) where T : IComparable { if (nums.Length == 0) return default(T); T min = nums[0]; for (int i = 1; i < nums.Length; i++) { min = min.CompareTo(nums[i]) < 0 ? min : nums[i]; } return min; } /// <summary> /// ソート済み配列 ary に同じ値の要素が含まれている? /// ※ソート順は昇順/降順どちらでもよい /// </summary> public static bool HasDuplicateInSortedArray<T>(T[] ary) where T : IComparable, IComparable<T> { if (ary.Length <= 1) return false; var lastNum = ary[ary.Length - 1]; foreach (var n in ary) { if (lastNum.CompareTo(n) == 0) { return true; } else { lastNum = n; } } return false; } public static bool ReplaceIfBigger<T>(ref T r, T v) where T : IComparable { if (r.CompareTo(v) < 0) { r = v; return true; } else { return false; } } public static bool ReplaceIfSmaller<T>(ref T r, T v) where T : IComparable { if (0 < r.CompareTo(v)) { r = v; return true; } else { return false; } } /// <summary> /// dic[key]にadderを加算する。keyが存在しなかった場合はdic[key]=adder /// をセットする。 /// </summary> public static void AddTo<TKey>(this Dictionary<TKey, int> dic, TKey key, int adder) { if (dic.ContainsKey(key)) { dic[key] += adder; } else { dic[key] = adder; } } /// <summary> /// 文字列 s が chars に含まれる文字を含んでいるか? /// </summary> public static bool ContainsAny(this string s, char[] chars) { for (int j = 0; j < s.Length; j++) { if (chars.Contains(s[j])) return true; } return false; } /// <summary> /// 二分探索 /// ※条件を満たす最小のidxを返す /// ※満たすものがない場合は ary.Length を返す /// ※『aryの先頭側が条件を満たさない、末尾側が条件を満たす』という前提 /// ただし、IsOK(...)の戻り値を逆転させれば、逆でも同じことが可能。 /// </summary> /// <param name="ary">探索対象配列 ★ソート済みであること</param> /// <param name="key">探索値 /// ※これ以上の値を持つ(IsOKがtrueを返す)最小のindexを返す</param> public static int BinarySearch<T>(T[] ary, T key) where T : IComparable, IComparable<T> { int left = -1; int right = ary.Length; while (1 < right - left) { var mid = left + (right - left) / 2; if (IsOK(ary, mid, key)) { right = mid; } else { left = mid; } } // left は条件を満たさない最大の値、right // は条件を満たす最小の値になっている return right; } public static bool IsOK<T>(T[] ary, int idx, T key) where T : IComparable, IComparable<T> { // key <= ary[idx] と同じ意味 return key.CompareTo(ary[idx]) <= 0; } } public class SolverBase { virtual protected string ReadLine() => Console.ReadLine(); virtual protected string ReadString() => ReadLine(); virtual protected int ReadInt() => int.Parse(ReadLine()); virtual protected long ReadLong() => long.Parse(ReadLine()); virtual protected string[] ReadStringArray() => ReadLine().Split(' '); virtual protected char[] ReadCharArray() => ReadLine() .Split(' ') .Select<string, char>( s => s[0]) .ToArray(); virtual protected int[] ReadIntArray() => ReadLine() .Split(' ') .Select<string, int>( s => int.Parse(s)) .ToArray(); virtual protected void ReadInt2(out int a, out int b) { var ary = ReadIntArray(); a = ary[0]; b = ary[1]; } virtual protected void ReadInt3(out int a, out int b, out int c) { var ary = ReadIntArray(); a = ary[0]; b = ary[1]; c = ary[2]; } virtual protected void ReadInt4(out int a, out int b, out int c, out int d) { var ary = ReadIntArray(); a = ary[0]; b = ary[1]; c = ary[2]; d = ary[3]; } virtual protected long[] ReadLongArray() => ReadLine() .Split(' ') .Select<string, long>( s => long.Parse(s)) .ToArray(); virtual protected void ReadLong2(out long a, out long b) { var ary = ReadLongArray(); a = ary[0]; b = ary[1]; } virtual protected void ReadLong3(out long a, out long b, out long c) { var ary = ReadLongArray(); a = ary[0]; b = ary[1]; c = ary[2]; } virtual protected void ReadLong4(out long a, out long b, out long c, out long d) { var ary = ReadLongArray(); a = ary[0]; b = ary[1]; c = ary[2]; d = ary[3]; } virtual protected double[] ReadDoubleArray() => ReadLine() .Split(' ') .Select<string, double>( s => double.Parse(s)) .ToArray(); virtual protected void WriteLine(string line) => Console.WriteLine(line); virtual protected void WriteLine(double d) => Console.WriteLine($"{d:F9}"); virtual protected void WriteLine<T>(T value) where T : IFormattable => Console.WriteLine(value); virtual protected void WriteGrid(IEnumerable<IEnumerable<char>> arrayOfArray) { var sb = new StringBuilder(); foreach (var a in arrayOfArray) { foreach (var c in a) { sb.Append(c); } sb.AppendLine(); } WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void Dump(string s) => Console.WriteLine(s); [Conditional("DEBUG")] protected void Dump(char c) => Console.WriteLine(c); [Conditional("DEBUG")] protected void Dump(int x) => Console.WriteLine(x); [Conditional("DEBUG")] protected void Dump(double d) => Console.WriteLine($"{d:F9}"); [Conditional("DEBUG")] protected void Dump<T>(IEnumerable<T> array) where T : IFormattable { string s = Util.DumpToString(array); // Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。 Console.WriteLine(s); //_writer.WriteLine(s); } [Conditional("DEBUG")] protected void DumpGrid(IEnumerable<IEnumerable<char>> arrayOfArray) { var sb = new StringBuilder(); foreach (var a in arrayOfArray) { foreach (var c in a) { sb.Append(c); } sb.AppendLine(); } // Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。 Console.WriteLine(sb.ToString()); //_writer.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpGrid<T>(IEnumerable<IEnumerable<T>> arrayOfArray) where T : IFormattable { var sb = new StringBuilder(); foreach (var a in arrayOfArray) { sb.AppendLine(Util.DumpToString(a)); } // Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。 Console.WriteLine(sb.ToString()); //_writer.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpGrid(bool[,] grid) { var sb = new StringBuilder(); for (int i = 0; i < grid.GetLength(0); i++) { for (int j = 0; j < grid.GetLength(1); j++) { sb.Append(grid[i, j] ? "x " : ". "); } sb.AppendLine(); } Console.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpGrid(char[,] grid) { var sb = new StringBuilder(); for (int i = 0; i < grid.GetLength(0); i++) { for (int j = 0; j < grid.GetLength(1); j++) { sb.Append(grid[i, j]); sb.Append(" "); } sb.AppendLine(); } Console.WriteLine(sb.ToString()); } [Conditional("DEBUG")] protected void DumpDP<T>(T[,] dp) where T : IFormattable { var sb = new StringBuilder(); for (int i = 0; i < dp.GetLength(0); i++) { for (int j = 0; j < dp.GetLength(1); j++) { sb.Append(dp[i, j]); sb.Append(", "); } sb.AppendLine(); } Console.WriteLine(sb.ToString()); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 16, 31, 16, 31, 22]]
8
2,347
18
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.Panasonic2020 { class B { 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) { int[] hw = ReadInts(); long h = hw[0]; long w = hw[1]; if (w % 2 == 1) { if (h % 2 == 1) { WriteLine((h * w + 1) / 2); } else { WriteLine(h * w / 2); } } else { WriteLine(h * w / 2); } } 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.Panasonic2020 { class B { 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) { int[] hw = ReadInts(); long h = hw[0]; long w = hw[1]; if (h == 1 || w == 1) { WriteLine(1); return; } if (w % 2 == 1) { if (h % 2 == 1) { WriteLine((h * w + 1) / 2); } else { WriteLine(h * w / 2); } } else { WriteLine(h * w / 2); } } 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); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24]]
8
364
19
using System; using System.Linq; public class AtCoder_Pana_B { public static void Main() { long[] line1 = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); long h = line1[0]; long w = line1[1]; if (h % 2 == 0) { Console.WriteLine(h * w / 2); } else { Console.WriteLine((h - 1) * w / 2 + (w + 1) / 2); } } }
using System; using System.Linq; public class AtCoder_Pana_B { public static void Main() { long[] line1 = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); long h = line1[0]; long w = line1[1]; if (h == 1 || w == 1) { Console.WriteLine(1); } else if (h % 2 == 0) { Console.WriteLine(h * w / 2); } else { Console.WriteLine((h - 1) * w / 2 + (w + 1) / 2); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22]]
8
118
20
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var h = long.Parse(input[0]); var w = long.Parse(input[1]); if ((h * w) % 2 == 0) { Console.WriteLine((h * w / 2)); } else { Console.WriteLine((h * w / 2) + 1); } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var h = long.Parse(input[0]); var w = long.Parse(input[1]); if (h == 1 || w == 1) { Console.WriteLine(1); } else { if ((h * w) % 2 == 0) { Console.WriteLine((h * w / 2)); } else { Console.WriteLine((h * w / 2) + 1); } } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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], ["+", 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, 75, 196, 0, 46]]
8
122
22
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; static void Main() { Sc sc = new Sc(); var s = sc.La; var p = ((s[0]) / 2) * s[1]; if (s[0] % 2 == 1) { p += (s[1] + 1) / 2; } Console.WriteLine("{0}", p); } } public 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(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<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; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; static void Main() { Sc sc = new Sc(); var s = sc.La; if (s[0] == 1 || s[1] == 1) { Console.WriteLine(1); return; } var p = ((s[0]) / 2) * s[1]; if (s[0] % 2 == 1) { p += (s[1] + 1) / 2; } Console.WriteLine("{0}", p); } } public 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(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<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; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 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], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
1,097
27
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { var hw = Console.ReadLine().Split().Select(long.Parse).ToArray(); Console.WriteLine((hw[0] * hw[1] + 1) / 2); } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { var hw = Console.ReadLine().Split().Select(long.Parse).ToArray(); if (hw[0] == 1 || hw[1] == 1) { Console.WriteLine(1); return; } Console.WriteLine((hw[0] * hw[1] + 1) / 2); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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], ["+", 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, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
8
141
27
using System; using System.Collections.Generic; using static System.Math; using System.Linq; using System.Text; class DandA { static void Main(string[] args) { long[] hw = ReadLineLongArray(); long rtn = (hw[0] * hw[1]) / 2; if ((hw[0] % 2 == 1 && hw[1] % 2 == 1)) { rtn++; } Console.WriteLine(rtn); } static string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"; static string[] strAry = new string[] { "L", "R", "U", "D" }; static int[] intArray = new int[10]; static List<int> intList = new List<int>(); static Dictionary<string, int> myTable = new Dictionary<string, int>(); static HashSet<int>[] rtnArrAb = null; static HashSet<int>[] rtnArrCd = null; static long[,] Combi = new long[2001, 2001]; static long div = 1000000007; static int[] atest = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; static private string ReadLineStr() { return Console.ReadLine(); } static private int ReadLineInt() { return int.Parse(Console.ReadLine()); } static private long ReadLineLong() { return long.Parse(Console.ReadLine()); } static private double ReadLineDouble() { return double.Parse(Console.ReadLine()); } static private string[] ReadLineStrArray() { return Console.ReadLine().Trim().Split(); } static private int[] ReadLineIntArray() { return Console.ReadLine() .Trim() .Split() .Select(a => int.Parse(a)) .ToArray(); } static private long[] ReadLineLongArray() { return Console.ReadLine() .Trim() .Split() .Select(a => long.Parse(a)) .ToArray(); } static private double[] ReadLineDoubleArray() { return Console.ReadLine() .Trim() .Split() .Select(a => double.Parse(a)) .ToArray(); } static private decimal[] ReadLineDecimalArray() { return Console.ReadLine() .Trim() .Split() .Select(a => decimal.Parse(a)) .ToArray(); } static private List<int> ReadLineIntList() { return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList(); } static private List<long> ReadLineLongList() { return Console.ReadLine() .Trim() .Split() .Select(a => long.Parse(a)) .ToList(); } static private string[][] ReadMLineStrArray(int arg) { return new int [arg].Select(_ => Console.ReadLine().Split()).ToArray(); } static private int[][] ReadMLineIntArray(int arg) { return new int [arg] .Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()) .ToArray(); } static private bool IsPrime(int num) { if (num < 2) return false; if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = Math.Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } static private string IntToNString(int x, int n) { var nstring = ""; var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; int r = 1; int q = x; while (q > 0) { r = q % n; nstring += numbers[r]; q = q / n; } return string.Join("", nstring.Reverse()); } static private long Gcd(long m, long n) { long temp; while (m % n != 0) { temp = n; n = m % n; m = temp; } return n; } static private long Combination(long n, long r) { if (n < r) { return 0; } if (n == r || r == 0) { return 1; } else if (Combi[n, r] == 0) { Combi[n, r] = (Combination(n - 1, r - 1) + Combination(n - 1, r)) % div; } return Combi[n, r]; } }
using System; using System.Collections.Generic; using static System.Math; using System.Linq; using System.Text; class DandA { static void Main(string[] args) { long[] hw = ReadLineLongArray(); if ((hw[0] == 1 || hw[1] == 1)) { Console.WriteLine(1); return; } long rtn = (hw[0] * hw[1]) / 2; if ((hw[0] % 2 == 1 && hw[1] % 2 == 1)) { rtn++; } Console.WriteLine(rtn); } static string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"; static string[] strAry = new string[] { "L", "R", "U", "D" }; static int[] intArray = new int[10]; static List<int> intList = new List<int>(); static Dictionary<string, int> myTable = new Dictionary<string, int>(); static HashSet<int>[] rtnArrAb = null; static HashSet<int>[] rtnArrCd = null; static long[,] Combi = new long[2001, 2001]; static long div = 1000000007; static int[] atest = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; static private string ReadLineStr() { return Console.ReadLine(); } static private int ReadLineInt() { return int.Parse(Console.ReadLine()); } static private long ReadLineLong() { return long.Parse(Console.ReadLine()); } static private double ReadLineDouble() { return double.Parse(Console.ReadLine()); } static private string[] ReadLineStrArray() { return Console.ReadLine().Trim().Split(); } static private int[] ReadLineIntArray() { return Console.ReadLine() .Trim() .Split() .Select(a => int.Parse(a)) .ToArray(); } static private long[] ReadLineLongArray() { return Console.ReadLine() .Trim() .Split() .Select(a => long.Parse(a)) .ToArray(); } static private double[] ReadLineDoubleArray() { return Console.ReadLine() .Trim() .Split() .Select(a => double.Parse(a)) .ToArray(); } static private decimal[] ReadLineDecimalArray() { return Console.ReadLine() .Trim() .Split() .Select(a => decimal.Parse(a)) .ToArray(); } static private List<int> ReadLineIntList() { return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList(); } static private List<long> ReadLineLongList() { return Console.ReadLine() .Trim() .Split() .Select(a => long.Parse(a)) .ToList(); } static private string[][] ReadMLineStrArray(int arg) { return new int [arg].Select(_ => Console.ReadLine().Split()).ToArray(); } static private int[][] ReadMLineIntArray(int arg) { return new int [arg] .Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()) .ToArray(); } static private bool IsPrime(int num) { if (num < 2) return false; if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = Math.Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } static private string IntToNString(int x, int n) { var nstring = ""; var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; int r = 1; int q = x; while (q > 0) { r = q % n; nstring += numbers[r]; q = q / n; } return string.Join("", nstring.Reverse()); } static private long Gcd(long m, long n) { long temp; while (m % n != 0) { temp = n; n = m % n; m = temp; } return n; } static private long Combination(long n, long r) { if (n < r) { return 0; } if (n == r || r == 0) { return 1; } else if (Combi[n, r] == 0) { Combi[n, r] = (Combination(n - 1, r - 1) + Combination(n - 1, r)) % div; } return Combi[n, r]; } }
[["+", 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, 23, 0, 24], ["+", 15, 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], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 23, 0, 16, 17, 106], ["+", 15, 23, 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], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
1,101
29
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var H = (ulong)sc.ReadLong(); var W = (ulong)sc.ReadLong(); var ans = (H * W + 1) / 2; 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 H = sc.ReadLong(); var W = sc.ReadLong(); if (H == 1 || W == 1) { Console.WriteLine(1); return; } var ans = (H * W + 1) / 2; Console.WriteLine(ans); } static Scanner sc = new Scanner(); } class Scanner { string[] S = new string[0]; int Index = 0; char[] Separators = new char[] { ' ' }; public string Next() { if (this.Index < this.S.Length) return this.S[this.Index++]; var line = ""; while (line == "") line = Console.ReadLine(); this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries); if (this.S.Length == 0) return this.Next(); this.Index = 0; return this.S[this.Index++]; } public string ReadStr() { return this.Next(); } public char ReadChar() { return this.Next()[0]; } public int ReadInt() { return int.Parse(this.Next()); } public uint ReadUInt() { return uint.Parse(this.Next()); } public long ReadLong() { return long.Parse(this.Next()); } public double ReadDouble() { return double.Parse(this.Next()); } public Tuple<int, int> ReadTup(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add); } public Tuple<long, long> ReadTupLong(int add = 0) { return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add); } public Tuple<int, int, int> ReadTup3(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public Tuple<int, int, int, int> ReadTup4(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public int[] ReadIntArray(int n) { var array = new int[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadInt(); } return array; } public long[] ReadLongArray(int n) { var array = new long[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadLong(); } return array; } public double[] ReadDoubleArray(int n) { var array = new double[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadDouble(); } return array; } public char[] ReadCharArray(int n) { var array = new char[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadChar(); } return array; } public string[] ReadStrArray(int n) { var array = new string[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadStr(); } return array; } public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) { var array = new Tuple<long, long>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTupLong(add); } return array; } public Tuple<int, int>[] ReadTupArray(int n, int add = 0) { var array = new Tuple<int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup(add); } return array; } public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) { var array = new Tuple<int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup3(add); } return array; } public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) { var array = new Tuple<int, int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup4(add); } return array; } }
[["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
1,045
27
using System; using System.Linq; using System.Collections.Generic; using System.IO; namespace atcorder2 { class Program { public static long Read() { return long.Parse(Console.ReadLine()); } public static long[] Reads() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var input = Reads(); var w = input[0]; var h = input[1]; if (w * h % 2 == 0) Console.WriteLine(w * h / 2); else Console.WriteLine((w * h + 1) / 2); Console.Out.Flush(); } } }
using System; using System.Linq; using System.Collections.Generic; using System.IO; namespace atcorder2 { class Program { public static long Read() { return long.Parse(Console.ReadLine()); } public static long[] Reads() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var input = Reads(); var w = input[0]; var h = input[1]; if (h == 1 || w == 1) Console.WriteLine(1); else if (w * h % 2 == 0) Console.WriteLine(w * h / 2); else Console.WriteLine((w * h + 1) / 2); Console.Out.Flush(); } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24]]
8
184
18
using System; using CompLib.Util; public class Program { public void Solve() { var sc = new Scanner(); var h = sc.NextLong(); var w = sc.NextLong(); var l = h * w; Console.WriteLine((l + 1) / 2); } 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() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
using System; using CompLib.Util; public class Program { public void Solve() { var sc = new Scanner(); var h = sc.NextLong(); var w = sc.NextLong(); if (h == 1 || w == 1) { Console.WriteLine(1); return; } var l = h * w; Console.WriteLine((l + 1) / 2); } 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() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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], ["+", 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
394
21
using System; using System.Linq; using System.Collections.Generic; using E = System.Linq.Enumerable; public class Program { public static void Main() { var hw = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); var h = hw[0]; var w = hw[1]; var k = (h / 2 + h % 2) * (w / 2 + w % 2) + (h / 2) * (w / 2); Console.WriteLine(k); } }
using System; using System.Linq; using System.Collections.Generic; using E = System.Linq.Enumerable; public class Program { public static void Main() { var hw = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); var h = hw[0]; var w = hw[1]; var k = h == 1 || w == 1 ? 1 : (h / 2 + h % 2) * (w / 2 + w % 2) + (h / 2) * (w / 2); Console.WriteLine(k); } }
[["+", 0, 212, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 17, 60], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 106], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 17, 60], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102]]
8
124
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace panasonic2020_b { class Program { static void Main(string[] args) { var H = CIn.ReadInt(); var W = CIn.ReadInt(); Console.WriteLine(((long)H * W + 1) / 2); } } static class CIn { private static readonly Queue<string> fieldBuffer = new Queue<string>(); public static string Read() { if (fieldBuffer.Count == 0) { foreach (var field in Console.ReadLine().Split()) { fieldBuffer.Enqueue(field); } } return fieldBuffer.Dequeue(); } public static int ReadInt() => int.Parse(Read()); public static long ReadLong() => long.Parse(Read()); public static double ReadDouble() => double.Parse(Read()); public static string[] ReadStringArray(int n) { var array = new string[n]; for (var i = 0; i < n; i++) { array[i] = Read(); } return array; } public static int[] ReadIntArray(int n) { var array = new int[n]; for (var i = 0; i < n; i++) { array[i] = ReadInt(); } return array; } public static long[] ReadLongArray(int n) { var array = new long[n]; for (var i = 0; i < n; i++) { array[i] = ReadLong(); } return array; } public static double[] ReadDoubleArray(int n) { var array = new double[n]; for (var i = 0; i < n; i++) { array[i] = ReadDouble(); } return array; } public static char[,] ReadCharMatrix(int h, int w) { var array = new char[h, w]; for (var i = 0; i < h; i++) { var l = Console.ReadLine().ToCharArray(); for (var j = 0; j < w; j++) { array[i, j] = l[j]; } } return array; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace panasonic2020_b { class Program { static void Main(string[] args) { var H = CIn.ReadInt(); var W = CIn.ReadInt(); if (H == 1 || W == 1) { Console.WriteLine(1); return; } Console.WriteLine(((long)H * W + 1) / 2); } } static class CIn { private static readonly Queue<string> fieldBuffer = new Queue<string>(); public static string Read() { if (fieldBuffer.Count == 0) { foreach (var field in Console.ReadLine().Split()) { fieldBuffer.Enqueue(field); } } return fieldBuffer.Dequeue(); } public static int ReadInt() => int.Parse(Read()); public static long ReadLong() => long.Parse(Read()); public static double ReadDouble() => double.Parse(Read()); public static string[] ReadStringArray(int n) { var array = new string[n]; for (var i = 0; i < n; i++) { array[i] = Read(); } return array; } public static int[] ReadIntArray(int n) { var array = new int[n]; for (var i = 0; i < n; i++) { array[i] = ReadInt(); } return array; } public static long[] ReadLongArray(int n) { var array = new long[n]; for (var i = 0; i < n; i++) { array[i] = ReadLong(); } return array; } public static double[] ReadDoubleArray(int n) { var array = new double[n]; for (var i = 0; i < n; i++) { array[i] = ReadDouble(); } return array; } public static char[,] ReadCharMatrix(int h, int w) { var array = new char[h, w]; for (var i = 0; i < h; i++) { var l = Console.ReadLine().ToCharArray(); for (var j = 0; j < w; j++) { array[i, j] = l[j]; } } return array; } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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, 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], ["+", 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, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
8
484
21
using System; using System.Linq; using System.Collections.Generic; namespace Contest { class Program { static void Main(string[] args) { Panasonic.B(); } class Panasonic { public static void A() { var A = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; var K = Read.Int(); Console.WriteLine(A[K - 1]); } public static void B() { var H = Read.Long(); var W = Read.Long(); Console.WriteLine((H * W + 1) / 2); } public static void C() { var A = Read.Long(); var B = Read.Long(); var C = Read.Long(); var cba = (C - B - A); var large = cba > 0 && (C - B - A) * (C - B - A) - 4 * A * B > 0; Console.WriteLine(large ? "Yes" : "No"); } public static void D() {} public static void E() {} public static void F() {} } class Util { public static readonly long P = 1000000007; public static T[,] Gen<T>(int r, int c, T v) { var matrix = new T[r, c]; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { matrix[i, j] = v; } } return matrix; } public static long Sum(long[] array) { return Sum(array, array.Length); } public static long Sum(long[] array, int n) { long total = 0; for (int i = 0; i < n; ++i) { total += array[i]; } return total; } public static long Count(long[] array, long x) { return Count(array, x, array.Length); } public static long Count(long[] array, long x, int n) { long total = 0; for (int i = 0; i < n; ++i) { total += (array[i] == x ? 1 : 0); } return total; } public static long[] ASum(long[] array) { var res = new long[array.Length + 1]; for (int i = 0; i < array.Length; ++i) { res[i + 1] = res[i] + array[i]; } return res; } public static long GCD(long a, long b) { while (b > 0) { var c = a % b; a = b; b = c; } return a; } public static bool IsPrime(long x) { var fact = Factorize(x); return fact.Count == 1 && fact.Values.ElementAt(0) == 1; } public static Dictionary<long, int> Factorize(long x) { var dict = new Dictionary<long, int>(); long minp = 2; while (x > 1) { bool ok = false; for (long p = minp; p * p <= x; ++p) { if (x % p == 0) { if (!dict.ContainsKey(p)) { dict.Add(p, 0); } dict[p]++; minp = p; x /= p; ok = true; break; } } if (!ok) { if (!dict.ContainsKey(x)) { dict.Add(x, 0); } dict[x]++; break; } } return dict; } public static long Inverse(long a, long p) { long b = p, c = 1, d = 0, e = 0, f = 0; while (b != 0) { e = a / b; f = b; b = a - e * b; a = f; f = d; d = c - e * d; c = f; } c %= p; return c + (c < 0 ? p : 0); } public static long[] Facts(int n, long p) { var facts = new long[n + 1]; facts[0] = 1; for (int i = 1; i <= n; ++i) { facts[i] = (i * facts[i - 1]) % p; } return facts; } public static Func<int, int, long> Combin(int n, long P) { var fact = Facts(n, P); var inv = fact.Select(x => Inverse(x, P)).ToArray(); return (N, M) => { if (N < 0 || N < M || M < 0) { return 0; } return (((fact[N] * inv[M]) % P) * inv[N - M]) % P; }; } public static Func<int, int, long> CombinLarge(int mMax, long p) { var inv = Enumerable.Range(0, mMax + 1) .Select(x => Util.Inverse(x, Util.P)) .ToArray(); return (n, m) => { long mult = 1; for (int i = 1; i <= m; ++i) { mult = (((mult * (n + 1 - i)) % Util.P) * inv[i]) % Util.P; } return mult; }; } /// <summary> /// Calc 2^n mod p /// </summary> public static long Power2(long n, long p) { return Power(2, n, p); } public static long Power(long a, long n, long p) { long res = 1; long mult = a; for (int i = 0; i < 40; ++i) { if ((n & ((long)1 << i)) > 0) { res = (res * mult) % p; } mult = (mult * mult) % p; } return res; } /// <summary> /// Thanks to yambe2002-san /// </summary> public class BST<T> where T : IComparable { public class Node { public T V; public Node L, R; public int Count; public Node(T v) { V = v; Count = 1; } } static Random _rnd = new Random(); public static int Count(Node t) { return t == null ? 0 : t.Count; } static Node Update(Node t) { t.Count = Count(t.L) + Count(t.R) + 1; return t; } public static Node Merge(Node l, Node r) { if (l == null || r == null) return l == null ? r : l; if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) { l.R = Merge(l.R, r); return Update(l); } else { r.L = Merge(l, r.L); return Update(r); } } public static Tuple<Node, Node> Split(Node t, int k) { if (t == null) return new Tuple<Node, Node>(null, null); if (k <= Count(t.L)) { var s = Split(t.L, k); t.L = s.Item2; return new Tuple<Node, Node>(s.Item1, Update(t)); } else { var s = Split(t.R, k - Count(t.L) - 1); t.R = s.Item1; return new Tuple<Node, Node>(Update(t), s.Item2); } } public static Node Remove(Node t, T v) { if (Find(t, v) == null) return t; return RemoveAt(t, LowerBound(t, v)); } public static Node RemoveAt(Node t, int k) { var s = Split(t, k); var s2 = Split(s.Item2, 1); return Merge(s.Item1, s2.Item2); } public static bool Contains(Node t, T v) { return Find(t, v) != null; } public static Node Find(Node t, T v) { while (t != null) { var cmp = t.V.CompareTo(v); if (cmp > 0) t = t.L; else if (cmp < 0) t = t.R; else break; } return t; } public static Node FindByIndex(Node t, int idx) { if (t == null) return null; var currentIdx = Count(t) - Count(t.R) - 1; while (t != null) { if (currentIdx == idx) return t; if (currentIdx > idx) { t = t.L; currentIdx -= (Count(t == null ? null : t.R) + 1); } else { t = t.R; currentIdx += (Count(t == null ? null : t.L) + 1); } } return null; } public static int UpperBound(Node t, T v) { var torg = t; if (t == null) return -1; var ret = Int32.MaxValue; var idx = Count(t) - Count(t.R) - 1; while (t != null) { var cmp = t.V.CompareTo(v); if (cmp > 0) { ret = Math.Min(ret, idx); t = t.L; idx -= (Count(t == null ? null : t.R) + 1); } else if (cmp <= 0) { t = t.R; idx += (Count(t == null ? null : t.L) + 1); } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static int LowerBound(Node t, T v) { var torg = t; if (t == null) return -1; var idx = Count(t) - Count(t.R) - 1; var ret = Int32.MaxValue; while (t != null) { var cmp = t.V.CompareTo(v); if (cmp >= 0) { if (cmp == 0) ret = Math.Min(ret, idx); t = t.L; if (t == null) ret = Math.Min(ret, idx); idx -= t == null ? 0 : (Count(t.R) + 1); } else if (cmp < 0) { t = t.R; idx += (Count(t == null ? null : t.L) + 1); if (t == null) return idx; } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static Node Insert(Node t, T v) { var ub = LowerBound(t, v); return InsertByIdx(t, ub, v); } static Node InsertByIdx(Node t, int k, T v) { var s = Split(t, k); return Merge(Merge(s.Item1, new Node(v)), s.Item2); } public static IEnumerable<T> Enumerate(Node t) { var ret = new List<T>(); Enumerate(t, ret); return ret; } static void Enumerate(Node t, List<T> ret) { if (t == null) return; Enumerate(t.L, ret); ret.Add(t.V); Enumerate(t.R, ret); } } public class Set<T> where T : IComparable { protected BST<T>.Node _root; public T this[int idx] { get { return ElementAt(idx); } } public int Count() { return BST<T>.Count(_root); } public virtual void Insert(T v) { if (_root == null) _root = new BST<T>.Node(v); else { if (BST<T>.Find(_root, v) != null) return; _root = BST<T>.Insert(_root, v); } } public void Clear() { _root = null; } public void Remove(T v) { _root = BST<T>.Remove(_root, v); } public bool Contains(T v) { return BST<T>.Contains(_root, v); } public T ElementAt(int k) { var node = BST<T>.FindByIndex(_root, k); if (node == null) throw new IndexOutOfRangeException(); return node.V; } public int Count(T v) { return BST<T>.UpperBound(_root, v) - BST<T>.LowerBound(_root, v); } public int LowerBound(T v) { return BST<T>.LowerBound(_root, v); } public int UpperBound(T v) { return BST<T>.UpperBound(_root, v); } public Tuple<int, int> EqualRange(T v) { if (!Contains(v)) return new Tuple<int, int>(-1, -1); return new Tuple<int, int>(BST<T>.LowerBound(_root, v), BST<T>.UpperBound(_root, v) - 1); } public List<T> ToList() { return new List<T>(BST<T>.Enumerate(_root)); } } public class MultiSet<T> : Set<T> where T : IComparable { public override void Insert(T v) { if (_root == null) { _root = new BST<T>.Node(v); } else { _root = BST<T>.Insert(_root, v); } } } } static class Read { static Queue<string> queue = new Queue<string>(); static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } } public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); } public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); } public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); } public static int[] IntN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); } public static long[] LongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); } public static string[] StrN() { return Console.ReadLine().Split(' '); } public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); } public static long[,] LongMatrix(int r, int c) { var mat = new long[r, c]; for (int i = 0; i < r; ++i) { var x = Read.LongN(); for (int j = 0; j < c; ++j) { mat[i, j] = x[j]; } } return mat; } public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M) { Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new HashSet<int>()); } for (int i = 0; i < M; ++i) { var ab = Read.IntN(); dict[ab[0]].Add(ab[1]); dict[ab[1]].Add(ab[0]); } return dict; } } } }
using System; using System.Linq; using System.Collections.Generic; namespace Contest { class Program { static void Main(string[] args) { Panasonic.B(); } class Panasonic { public static void A() { var A = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; var K = Read.Int(); Console.WriteLine(A[K - 1]); } public static void B() { var H = Read.Long(); var W = Read.Long(); if (H == 1 || W == 1) { Console.WriteLine(1); return; } Console.WriteLine((H * W + 1) / 2); } public static void C() { var A = Read.Long(); var B = Read.Long(); var C = Read.Long(); var cba = (C - B - A); var large = cba > 0 && (C - B - A) * (C - B - A) - 4 * A * B > 0; Console.WriteLine(large ? "Yes" : "No"); } public static void D() {} public static void E() {} public static void F() {} } class Util { public static readonly long P = 1000000007; public static T[,] Gen<T>(int r, int c, T v) { var matrix = new T[r, c]; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { matrix[i, j] = v; } } return matrix; } public static long Sum(long[] array) { return Sum(array, array.Length); } public static long Sum(long[] array, int n) { long total = 0; for (int i = 0; i < n; ++i) { total += array[i]; } return total; } public static long Count(long[] array, long x) { return Count(array, x, array.Length); } public static long Count(long[] array, long x, int n) { long total = 0; for (int i = 0; i < n; ++i) { total += (array[i] == x ? 1 : 0); } return total; } public static long[] ASum(long[] array) { var res = new long[array.Length + 1]; for (int i = 0; i < array.Length; ++i) { res[i + 1] = res[i] + array[i]; } return res; } public static long GCD(long a, long b) { while (b > 0) { var c = a % b; a = b; b = c; } return a; } public static bool IsPrime(long x) { var fact = Factorize(x); return fact.Count == 1 && fact.Values.ElementAt(0) == 1; } public static Dictionary<long, int> Factorize(long x) { var dict = new Dictionary<long, int>(); long minp = 2; while (x > 1) { bool ok = false; for (long p = minp; p * p <= x; ++p) { if (x % p == 0) { if (!dict.ContainsKey(p)) { dict.Add(p, 0); } dict[p]++; minp = p; x /= p; ok = true; break; } } if (!ok) { if (!dict.ContainsKey(x)) { dict.Add(x, 0); } dict[x]++; break; } } return dict; } public static long Inverse(long a, long p) { long b = p, c = 1, d = 0, e = 0, f = 0; while (b != 0) { e = a / b; f = b; b = a - e * b; a = f; f = d; d = c - e * d; c = f; } c %= p; return c + (c < 0 ? p : 0); } public static long[] Facts(int n, long p) { var facts = new long[n + 1]; facts[0] = 1; for (int i = 1; i <= n; ++i) { facts[i] = (i * facts[i - 1]) % p; } return facts; } public static Func<int, int, long> Combin(int n, long P) { var fact = Facts(n, P); var inv = fact.Select(x => Inverse(x, P)).ToArray(); return (N, M) => { if (N < 0 || N < M || M < 0) { return 0; } return (((fact[N] * inv[M]) % P) * inv[N - M]) % P; }; } public static Func<int, int, long> CombinLarge(int mMax, long p) { var inv = Enumerable.Range(0, mMax + 1) .Select(x => Util.Inverse(x, Util.P)) .ToArray(); return (n, m) => { long mult = 1; for (int i = 1; i <= m; ++i) { mult = (((mult * (n + 1 - i)) % Util.P) * inv[i]) % Util.P; } return mult; }; } /// <summary> /// Calc 2^n mod p /// </summary> public static long Power2(long n, long p) { return Power(2, n, p); } public static long Power(long a, long n, long p) { long res = 1; long mult = a; for (int i = 0; i < 40; ++i) { if ((n & ((long)1 << i)) > 0) { res = (res * mult) % p; } mult = (mult * mult) % p; } return res; } /// <summary> /// Thanks to yambe2002-san /// </summary> public class BST<T> where T : IComparable { public class Node { public T V; public Node L, R; public int Count; public Node(T v) { V = v; Count = 1; } } static Random _rnd = new Random(); public static int Count(Node t) { return t == null ? 0 : t.Count; } static Node Update(Node t) { t.Count = Count(t.L) + Count(t.R) + 1; return t; } public static Node Merge(Node l, Node r) { if (l == null || r == null) return l == null ? r : l; if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) { l.R = Merge(l.R, r); return Update(l); } else { r.L = Merge(l, r.L); return Update(r); } } public static Tuple<Node, Node> Split(Node t, int k) { if (t == null) return new Tuple<Node, Node>(null, null); if (k <= Count(t.L)) { var s = Split(t.L, k); t.L = s.Item2; return new Tuple<Node, Node>(s.Item1, Update(t)); } else { var s = Split(t.R, k - Count(t.L) - 1); t.R = s.Item1; return new Tuple<Node, Node>(Update(t), s.Item2); } } public static Node Remove(Node t, T v) { if (Find(t, v) == null) return t; return RemoveAt(t, LowerBound(t, v)); } public static Node RemoveAt(Node t, int k) { var s = Split(t, k); var s2 = Split(s.Item2, 1); return Merge(s.Item1, s2.Item2); } public static bool Contains(Node t, T v) { return Find(t, v) != null; } public static Node Find(Node t, T v) { while (t != null) { var cmp = t.V.CompareTo(v); if (cmp > 0) t = t.L; else if (cmp < 0) t = t.R; else break; } return t; } public static Node FindByIndex(Node t, int idx) { if (t == null) return null; var currentIdx = Count(t) - Count(t.R) - 1; while (t != null) { if (currentIdx == idx) return t; if (currentIdx > idx) { t = t.L; currentIdx -= (Count(t == null ? null : t.R) + 1); } else { t = t.R; currentIdx += (Count(t == null ? null : t.L) + 1); } } return null; } public static int UpperBound(Node t, T v) { var torg = t; if (t == null) return -1; var ret = Int32.MaxValue; var idx = Count(t) - Count(t.R) - 1; while (t != null) { var cmp = t.V.CompareTo(v); if (cmp > 0) { ret = Math.Min(ret, idx); t = t.L; idx -= (Count(t == null ? null : t.R) + 1); } else if (cmp <= 0) { t = t.R; idx += (Count(t == null ? null : t.L) + 1); } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static int LowerBound(Node t, T v) { var torg = t; if (t == null) return -1; var idx = Count(t) - Count(t.R) - 1; var ret = Int32.MaxValue; while (t != null) { var cmp = t.V.CompareTo(v); if (cmp >= 0) { if (cmp == 0) ret = Math.Min(ret, idx); t = t.L; if (t == null) ret = Math.Min(ret, idx); idx -= t == null ? 0 : (Count(t.R) + 1); } else if (cmp < 0) { t = t.R; idx += (Count(t == null ? null : t.L) + 1); if (t == null) return idx; } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static Node Insert(Node t, T v) { var ub = LowerBound(t, v); return InsertByIdx(t, ub, v); } static Node InsertByIdx(Node t, int k, T v) { var s = Split(t, k); return Merge(Merge(s.Item1, new Node(v)), s.Item2); } public static IEnumerable<T> Enumerate(Node t) { var ret = new List<T>(); Enumerate(t, ret); return ret; } static void Enumerate(Node t, List<T> ret) { if (t == null) return; Enumerate(t.L, ret); ret.Add(t.V); Enumerate(t.R, ret); } } public class Set<T> where T : IComparable { protected BST<T>.Node _root; public T this[int idx] { get { return ElementAt(idx); } } public int Count() { return BST<T>.Count(_root); } public virtual void Insert(T v) { if (_root == null) _root = new BST<T>.Node(v); else { if (BST<T>.Find(_root, v) != null) return; _root = BST<T>.Insert(_root, v); } } public void Clear() { _root = null; } public void Remove(T v) { _root = BST<T>.Remove(_root, v); } public bool Contains(T v) { return BST<T>.Contains(_root, v); } public T ElementAt(int k) { var node = BST<T>.FindByIndex(_root, k); if (node == null) throw new IndexOutOfRangeException(); return node.V; } public int Count(T v) { return BST<T>.UpperBound(_root, v) - BST<T>.LowerBound(_root, v); } public int LowerBound(T v) { return BST<T>.LowerBound(_root, v); } public int UpperBound(T v) { return BST<T>.UpperBound(_root, v); } public Tuple<int, int> EqualRange(T v) { if (!Contains(v)) return new Tuple<int, int>(-1, -1); return new Tuple<int, int>(BST<T>.LowerBound(_root, v), BST<T>.UpperBound(_root, v) - 1); } public List<T> ToList() { return new List<T>(BST<T>.Enumerate(_root)); } } public class MultiSet<T> : Set<T> where T : IComparable { public override void Insert(T v) { if (_root == null) { _root = new BST<T>.Node(v); } else { _root = BST<T>.Insert(_root, v); } } } } static class Read { static Queue<string> queue = new Queue<string>(); static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } } public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); } public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); } public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); } public static int[] IntN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); } public static long[] LongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); } public static string[] StrN() { return Console.ReadLine().Split(' '); } public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); } public static long[,] LongMatrix(int r, int c) { var mat = new long[r, c]; for (int i = 0; i < r; ++i) { var x = Read.LongN(); for (int j = 0; j < c; ++j) { mat[i, j] = x[j]; } } return mat; } public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M) { Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new HashSet<int>()); } for (int i = 0; i < M; ++i) { var ab = Read.IntN(); dict[ab[0]].Add(ab[1]); dict[ab[1]].Add(ab[0]); } return dict; } } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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, 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], ["+", 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, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
8
3,848
21
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System; using System.Collections.Generic; using System.Linq; namespace ClassLibrary1 { public class ListNode { public int val; public ListNode next; public ListNode(int x) { val = x; } } public class Class1 { // static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, // long>, long>(); static long mod = 1000000007; static long[] factorial = new long[1000001]; static long[] invFactorial = new long[1000001]; private static void calcFanctorial(long N) { factorial[0] = 1; for (int i = 1; i < N + 1; i++) { factorial[i] = factorial[i - 1] * i; factorial[i] %= mod; } invFactorial[N] = inv(factorial[N]); for (int i = (int)N; i > 0; i--) { invFactorial[i - 1] = invFactorial[i] * i % mod; } } static void Main(string[] args) { var N = ReadLongArr(); long res = (N[1] * N[0]) / 2; res += (N[1] * N[0]) % 2; Console.WriteLine(res); } class Tree { public HashSet<long> conn = new HashSet<long>(); } static long bin(long a, long x, long n) { long y = a; long res = 1; while (x > 0) { if (x % 2 == 1) { res = res * y % n; } x /= 2; y = y * y % n; } return res; } int cmp(string a, string b) { for (var i = 0; i < Math.Min(a.Length, b.Length); i++) if (a[i] < b[i]) return -1; else if (a[i] > b[i]) return 1; if (a.Length == b.Length) return 0; if (a.Length > b.Length) return 1; else return -1; } private static long nCm(long n, long m) { if (n < m) return 0; if (m < 0) return 0; return (factorial[n] * invFactorial[m] % mod) * invFactorial[n - m] % mod; } private static long nCm2(long n, long m) { if (n < m) return 0; if (m < 0) return 0; long res = 1; for (long i = n; i > n - m; i--) { res *= i; res %= mod; } return res * invFactorial[m] % mod; } public static long pow(long a, long b, long mod) { a %= mod; if (b <= 0) return 1; var t = pow(a, b / 2, mod); if ((b & 1) == 0) return t * t % mod; return t * t % mod * a % mod; } public static long Lcm(long a, long b) { return a * b % mod * inv(Gcd(a, b)) % mod; } public static long Lcm(long[] a) { List<long> vect = new List<long>(); long lcm = 1; for (int i = 0; i < a.Count(); i++) { var factor = a[i] / GcdVector(vect, a[i]); vect.Add(factor); lcm = lcm * factor % mod; } return lcm; } static long GcdVector(List<long> a, long b) { long ma = 1; for (int i = 0; i < a.Count; i++) ma = ma * a[i] % b; return Gcd(b, ma); } public static long Gcd(long a, long b) { if (a < b) // 引数を入替えて自分を呼び出す return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public static long pow(long a, long b) => pow(a, b, mod); public static long inv(long a) => pow(a, mod - 2); private static char[][] ReadCharMatrix(long h) { char[][] mtx = new char [h][]; for (int i = 0; i < h; i++) { var s = ReadString(); mtx[i] = s.ToCharArray(); } return mtx; } private static int[][] CreateIntMatrix(long h, long w) { int[][] mtx = new int [h][]; for (int i = 0; i < h; i++) { mtx[i] = new int[w]; } return mtx; } private static string ReadString() { return Console.ReadLine(); } private static string[] ReadStringArr() { return Console.ReadLine().Split(' '); } private static long ReadLong() { return long.Parse(Console.ReadLine()); } private static long[] ReadLongArr() { string[] s = ReadStringArr(); long[] l = new long[s.Length]; for (int i = 0; i < l.Length; i++) { l[i] = long.Parse(s[i]); } return l; } } class StringComparator2 : IComparer<string> { int IComparer<string>.Compare(string a, string b) { int length = Math.Min(a.Length, b.Length); // Console.WriteLine("Comparing with length {0}", length); for (int i = 0; i < length; i++) { if (a[i] < b[i]) { // Console.WriteLine("returning -1"); return -1; } else if (a[i] > b[i]) return 1; } if (a.Length < b.Length) return -1; if (a.Length > b.Length) return 1; // Console.WriteLine("Why are we at the end?"); return 0; } } 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.Linq; using System.Text; using System.Threading.Tasks; using System; using System.Collections.Generic; using System.Linq; namespace ClassLibrary1 { public class ListNode { public int val; public ListNode next; public ListNode(int x) { val = x; } } public class Class1 { // static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, // long>, long>(); static long mod = 1000000007; static long[] factorial = new long[1000001]; static long[] invFactorial = new long[1000001]; private static void calcFanctorial(long N) { factorial[0] = 1; for (int i = 1; i < N + 1; i++) { factorial[i] = factorial[i - 1] * i; factorial[i] %= mod; } invFactorial[N] = inv(factorial[N]); for (int i = (int)N; i > 0; i--) { invFactorial[i - 1] = invFactorial[i] * i % mod; } } static void Main(string[] args) { var N = ReadLongArr(); if (N[0] == 1 || N[1] == 1) { Console.WriteLine(1); return; } long res = (N[1] * N[0]) / 2; res += (N[1] * N[0]) % 2; Console.WriteLine(res); } class Tree { public HashSet<long> conn = new HashSet<long>(); } static long bin(long a, long x, long n) { long y = a; long res = 1; while (x > 0) { if (x % 2 == 1) { res = res * y % n; } x /= 2; y = y * y % n; } return res; } int cmp(string a, string b) { for (var i = 0; i < Math.Min(a.Length, b.Length); i++) if (a[i] < b[i]) return -1; else if (a[i] > b[i]) return 1; if (a.Length == b.Length) return 0; if (a.Length > b.Length) return 1; else return -1; } private static long nCm(long n, long m) { if (n < m) return 0; if (m < 0) return 0; return (factorial[n] * invFactorial[m] % mod) * invFactorial[n - m] % mod; } private static long nCm2(long n, long m) { if (n < m) return 0; if (m < 0) return 0; long res = 1; for (long i = n; i > n - m; i--) { res *= i; res %= mod; } return res * invFactorial[m] % mod; } public static long pow(long a, long b, long mod) { a %= mod; if (b <= 0) return 1; var t = pow(a, b / 2, mod); if ((b & 1) == 0) return t * t % mod; return t * t % mod * a % mod; } public static long Lcm(long a, long b) { return a * b % mod * inv(Gcd(a, b)) % mod; } public static long Lcm(long[] a) { List<long> vect = new List<long>(); long lcm = 1; for (int i = 0; i < a.Count(); i++) { var factor = a[i] / GcdVector(vect, a[i]); vect.Add(factor); lcm = lcm * factor % mod; } return lcm; } static long GcdVector(List<long> a, long b) { long ma = 1; for (int i = 0; i < a.Count; i++) ma = ma * a[i] % b; return Gcd(b, ma); } public static long Gcd(long a, long b) { if (a < b) // 引数を入替えて自分を呼び出す return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public static long pow(long a, long b) => pow(a, b, mod); public static long inv(long a) => pow(a, mod - 2); private static char[][] ReadCharMatrix(long h) { char[][] mtx = new char [h][]; for (int i = 0; i < h; i++) { var s = ReadString(); mtx[i] = s.ToCharArray(); } return mtx; } private static int[][] CreateIntMatrix(long h, long w) { int[][] mtx = new int [h][]; for (int i = 0; i < h; i++) { mtx[i] = new int[w]; } return mtx; } private static string ReadString() { return Console.ReadLine(); } private static string[] ReadStringArr() { return Console.ReadLine().Split(' '); } private static long ReadLong() { return long.Parse(Console.ReadLine()); } private static long[] ReadLongArr() { string[] s = ReadStringArr(); long[] l = new long[s.Length]; for (int i = 0; i < l.Length; i++) { l[i] = long.Parse(s[i]); } return l; } } class StringComparator2 : IComparer<string> { int IComparer<string>.Compare(string a, string b) { int length = Math.Min(a.Length, b.Length); // Console.WriteLine("Comparing with length {0}", length); for (int i = 0; i < length; i++) { if (a[i] < b[i]) { // Console.WriteLine("returning -1"); return -1; } else if (a[i] > b[i]) return 1; } if (a.Length < b.Length) return -1; if (a.Length > b.Length) return 1; // Console.WriteLine("Why are we at the end?"); return 0; } } 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; } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 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], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
1,849
27
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace Main { class Program { static void Main(string[] args) { //ここから // string[] str = Console.ReadLine().Split(' '); // int n = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); long h = long.Parse(str[0]); long w = long.Parse(str[1]); if (h * w % 2 == 0) { Console.WriteLine(h * w / 2); } else { Console.WriteLine(h * w / 2 + 1); } //ここまで } } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace Main { class Program { static void Main(string[] args) { //ここから // string[] str = Console.ReadLine().Split(' '); // int n = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); long h = long.Parse(str[0]); long w = long.Parse(str[1]); if (h == 1 || w == 1) { Console.WriteLine(1); } else if (h * w % 2 == 0) { Console.WriteLine(h * w / 2); } else { Console.WriteLine(h * w / 2 + 1); } //ここまで } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 16, 31, 16, 31, 22]]
8
126
20
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 = 1000001; static long[] fac = new long[MAX]; static long[] finv = new long[MAX]; static long[] inv = new long[MAX]; static void Solve() { long h = Input.NextInt(); long w = Input.NextInt(); bool heven = h % 2 == 0; bool weven = w % 2 == 0; long ans = 0; if (heven && weven) { ans = h * w / 2; } else if (!heven && !weven) { ans = h * w / 2 + 1; } else { ans = h * w / 2; } Console.WriteLine(ans); } #region よく使う便利関数 private static Dictionary<long, int> Factorize(long n) { var dic = new Dictionary<long, int>(); for (long i = 2; i * i <= n; ++i) { while (n % i == 0) { if (!dic.ContainsKey(i)) { dic.Add(i, 0); } dic[i]++; n /= i; } } if (n != 1) { dic.Add(n, 1); } return dic; } 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 = 1000001; static long[] fac = new long[MAX]; static long[] finv = new long[MAX]; static long[] inv = new long[MAX]; static void Solve() { long h = Input.NextInt(); long w = Input.NextInt(); bool heven = h % 2 == 0; bool weven = w % 2 == 0; long ans = 0; if (h == 1 || w == 1) { ans = 1; } else if (heven && weven) { ans = h * w / 2; } else if (!heven && !weven) { ans = h * w / 2 + 1; } else { ans = h * w / 2; } Console.WriteLine(ans); } #region よく使う便利関数 private static Dictionary<long, int> Factorize(long n) { var dic = new Dictionary<long, int>(); for (long i = 2; i * i <= n; ++i) { while (n % i == 0) { if (!dic.ContainsKey(i)) { dic.Add(i, 0); } dic[i]++; n /= i; } } if (n != 1) { dic.Add(n, 1); } return dic; } 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; } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24]]
8
2,470
17
using System; using System.Collections.Generic; using System.Linq; public class AtCoderB { static void Main() { long h; long w; { var line = Console.ReadLine(); var words = line.Split(' '); h = long.Parse(words[0]); w = long.Parse(words[1]); } long answer = (h * w + 1) / 2; Console.WriteLine(answer); } }
using System; using System.Collections.Generic; using System.Linq; public class AtCoderB { static void Main() { long h; long w; { var line = Console.ReadLine(); var words = line.Split(' '); h = long.Parse(words[0]); w = long.Parse(words[1]); } long answer = (h * w + 1) / 2; if (w == 1 || h == 1) { answer = 1; } Console.WriteLine(answer); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
100
16
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; using System.IO; class readint { public readint(out int i) { i = int.Parse(Console.ReadLine()); } public readint(out int a, out int b) { int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray(); a = sp[0]; b = sp[1]; } public readint(out int a, out int b, out int c) { int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; } public readint(out int a, out int b, out int c, out int d) { int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; d = sp[3]; } } class readlong { public readlong(out long i) { i = long.Parse(Console.ReadLine()); } public readlong(out long a, out long b) { long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray(); a = sp[0]; b = sp[1]; } public readlong(out long a, out long b, out long c) { long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; } public readlong(out long a, out long b, out long c, out long d) { long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; d = sp[3]; } } class modMWorld { public static long M = (int)Math.Pow(10, 9) + 7; //必要な演算は、加減乗除、nCk,n!,a^n public static long add(long a, long b) { long sum = a + b; sum += M; return sum % M; } public static long sub(long a, long b) { long dif = a - b; dif += M * 2; return dif % M; } public static long mul(long a, long b) { long product = a; product *= b; return product % M; } public static long div(long a, long b) { return mul(a, Pow(b, M - 2)); } /// <summary> /// a^m modMを求める /// </summary> /// <param name="a"></param> /// <param name="m"></param> /// <returns></returns> public static long Pow(long a, long m) { switch (m) { case 0: return 1; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = mul(p1, p1); return ((m % 2) == 0) ? p2 : mul(p2, a); } } public static long kaijou(long n) { //! long output = 1; for (int i = 0; i < n; i++) { output = mul(output, n - i); } return output; } public static long nCk(long n, long k) { long output = 1; for (int i = 1; i <= k; i++) { output = mul(output, n - (i - 1)); output = div(output, i); } return output; } } class Util { public static int[] readintarr() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); } public static long[] readlongarr() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } /// <summary> /// nの約数を小さい順のリストで返します。 /// </summary> /// <param name="n"></param> /// <returns></returns> public static List<int> make_divisor(int n) { List<int> output = new List<int>(); for (int i = 1; i <= Math.Sqrt(n) + 1; i++) { if (n % i == 0) { output.Add(i); if (i * i != n) { output.Add(n / i); } } } output.Sort(); return output; } // iの素因数分解をします public static List<int> soinsuuBunkai(int n) { //素因数分解をします List<int> output = new List<int>(); int target = n; for (int i = 2; i <= 1 + Math.Sqrt(target); i += 2) { while (target % i == 0) { target /= i; output.Add(i); } if (i == 2) i--; } if (target > 1) { output.Add(target); } return output; } public static List<long> soinsuuBunkai(long n) { List<long> output = new List<long>(); long target = n; for (int i = 2; i <= 1 + Math.Sqrt(target); i += 2) { while (target % i == 0) { target /= i; output.Add(i); } if (i == 2) i--; } if (target > 1) { output.Add(target); } return output; } /// <summary> /// 2引数の最大公約数を返します。longです。 /// </summary> /// <param name="a">long 引数1</param> /// <param name="b">long 引数2</param> /// <returns></returns> public static long GCD(long a, long b) { if (a < b) swap(ref a, ref b); if (a % b == 0) return b; return GCD(b, a % b); } /// <summary> /// 2引数の最大公約数を返します。intです。 /// </summary> /// <param name="a">int 引数1</param> /// <param name="b">int 引数2</param> /// <returns></returns> public static int GCD(int a, int b) { // if (a < b) // swap(ref a, ref b); if (a % b == 0) return b; return GCD(b, a % b); } /// <summary> /// 2つの変数の中身を交換する。型はなんでもいい /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="b"></param> public static void swap<T>(ref T a, ref T b) { T temp = b; b = a; a = temp; } /// <summary> /// 2引数の最大公約数を返します。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long LCM(long a, long b) { return a * b / GCD(a, b); } /// <summary> /// 2引数の最大公約数を返します。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long LCM(int a, int b) { return Math.BigMul(a, b) / GCD(a, b); } public static int M = (int)(Math.Pow(10, 9)) + 7; private static int[] factorial_modM; public static long nCr(long n, long r) { long output = 1; for (int i = 1; i <= r; i++) { output *= (n + 1 - i); output /= (i); } return output; } /// <summary> /// 2引数の積 mod Mを求める。Mは10億7。 /// 変えられるよ。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static int Multiple_modM(int a, int b) { return (int)(Math.BigMul(a, b) % M); } /// <summary> /// n! modMまたはnCmを求めるための準備を行う。引数は最大値。 /// </summary> /// <param name="n"></param> public static void factorial_modM_Prepare(int n) { factorial_modM = new int[n + 1]; factorial_modM[0] = 1; for (int i = 1; i <= n; ++i) { factorial_modM[i] = Multiple_modM(factorial_modM[i - 1], i); } } /// <summary> /// n! mod M を返す。やる前にfactorial_modM_Prepare(n)を実行しといてね。 /// </summary> /// <param name="n"></param> /// <returns></returns> public static int Factorial(int n) { return factorial_modM[n]; } /// <summary> /// a^m modMを求める /// </summary> /// <param name="a"></param> /// <param name="m"></param> /// <returns></returns> public static 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 = Multiple_modM(p1, p1); return ((m % 2) == 0) ? p2 : Multiple_modM(p2, a); } } /// <summary> /// a / m Mod M を求める。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static int Div(int a, int b) { return Multiple_modM(a, Pow(b, M - 2)); } /// <summary> /// nCr mod M を求める。やる前にfactorial_modM_Prepare(n)を実行しといてね。 /// </summary> /// <param name="n"></param> /// <param name="r"></param> /// <returns></returns> public static int nCr_modM(int n, int r) { if (r < 0) return 0; if (n < r) { return 0; } if (n == r) { return 1; } int res = Factorial(n); res = Div(res, Factorial(r)); res = Div(res, Factorial(n - r)); return res; } } /// <summary> /// Union-Find木を定義する。コンストラクタの指定は、頂点の番号。 /// おすすめとしては、UnionFind<T>[] で宣言してしまう。 /// 配列で宣言したあと、コンストラクタ使ってnewするのを忘れないでね。 /// コンストラクタのitemは、そのノード固有のIDになるので、絶対必要です /// </summary> /// <typeparam name="T">int固定でいいよね。</typeparam> class UnionFind<T> { public int tree_height; public UnionFind<T> parent; public T item { get; private set; } public UnionFind(T item) { tree_height = 0; parent = this; this.item = item; } /// <summary> /// 一番上の親を探す。 /// 探しながら繋がり方を最適化している。 /// UnionFindの頂点そのものを返すので、==での比較が可能。 /// </summary> /// <returns></returns> public UnionFind<T> FindAdam() { if (parent == this) return this; else { UnionFind<T> ParentOfParent = parent.FindAdam(); parent = ParentOfParent; //縦長な構成をつなぎ直している return ParentOfParent; } } /// <summary> /// unionfind2つを一つにつなぐ。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static void Unite(UnionFind<T> a, UnionFind<T> b) { UnionFind<T> ParentOfA = a.FindAdam(); UnionFind<T> ParentOfB = b.FindAdam(); if (ParentOfA.tree_height < ParentOfB.tree_height) { ParentOfA.parent = ParentOfB; ParentOfB.tree_height = Math.Max(ParentOfA.tree_height + 1, ParentOfB.tree_height); } else { ParentOfB.parent = ParentOfA; ParentOfA.tree_height = Math.Max(ParentOfB.tree_height + 1, ParentOfA.tree_height); } } } // Treap 平衡二分木 class Treap<T> where T : IComparable { private class Node { private static Random g_rand = new Random(); private readonly int m_rank = g_rand.Next(); private readonly T m_value; private Node m_lch; private Node m_rch; private int m_count; public Node(T value) { m_value = value; m_count = 1; } private static int Count(Node node) { return (node != null) ? node.m_count : 0; } private Node Update() { m_count = Count(m_lch) + Count(m_rch) + 1; return this; } public static Node Merge(Node a, Node b) { if (a == null) { return b; } if (b == null) { return a; } if (a.m_rank < b.m_rank) { a.m_rch = Merge(a.m_rch, b); return a.Update(); } else { b.m_lch = Merge(a, b.m_lch); return b.Update(); } } public static Tuple<Node, Node> Split(Node t, int k) { if (t == null) { return new Tuple<Node, Node>(null, null); } if (k <= Count(t.m_lch)) { var pair = Split(t.m_lch, k); t.m_lch = pair.Item2; return new Tuple<Node, Node>(pair.Item1, t.Update()); } else { var pair = Split(t.m_rch, k - Count(t.m_lch) - 1); t.m_rch = pair.Item1; return new Tuple<Node, Node>(t.Update(), pair.Item2); } } public int FindIndex(T value) { int L = Count(m_lch); if (value.CompareTo(m_value) < 0) { return (m_lch != null) ? m_lch.FindIndex(value) : 0; } else if (value.CompareTo(m_value) > 0) { return (m_rch != null) ? m_rch.FindIndex(value) + L + 1 : L + 1; } else { return L; } } public T this[int i] { get { int L = Count(m_lch); if (i < L) { return m_lch[i]; } else if (i > L) { return m_rch[i - L - 1]; } else { return m_value; } } } } private Node node; public void Insert(T value) { if (node != null) { int k = node.FindIndex(value); var pair = Node.Split(node, k); node = Node.Merge(Node.Merge(pair.Item1, new Node(value)), pair.Item2); } else { node = new Node(value); } } public int FindIndex(T value) { return node.FindIndex(value); } public T this[int i] { get { return node[i]; } } } /// <summary> /// 使い方:Permutation.next(配列) で次の配列を返す /// 配列を受け取って、その配列の要素を全部使った組み合わせのうち、辞書順で次のものを返します。 /// もし、次のがない場合、空の配列を返します。 /// /// </summary> /// <typeparam name="T"></typeparam> class Permutation<T> where T : IComparable { public static T[] next(T[] letters) { int pivot = -1; for (int i = letters.Length - 2; i >= 0; i--) { if (letters[i].CompareTo(letters[i + 1]) < 0) { pivot = i; break; } } if (pivot == -1) { return new T[0]; } int big_min = letters.Length - 1; T big_min_T = letters[letters.Length - 1]; for (int i = letters.Length - 1; i > pivot; i--) { // big_min_Tより小さいかつ、pivotのより大きい if (letters[pivot].CompareTo(letters[i]) > 0 && letters[pivot].CompareTo(big_min_T) < 0) { big_min_T = letters[i]; big_min = i; } } T temp = letters[pivot]; letters[pivot] = letters[big_min]; letters[big_min] = temp; Array.Sort(letters, pivot + 1, letters.Length - pivot - 1); return letters; } } /// <summary> /// 使い方 : Combination /// .AllCombination(使える文字を、小さい順から配列にしたもの,ほしい文字数) /// 使える文字を、小さい順から配列にしたものを重複ありで組み合わせて、stringのlistで出力する /// /// </summary> /// <typeparam name="T"></typeparam> class Combination<T> where T : IComparable { private static bool stop = false; public static List<string> AllCombination(T[] letters, int n) { // n桁ですよね。 List<string> outlist = new List<string>(); T[] state = new T[n]; for (int i = 0; i < n; i++) { state[i] = letters[0]; } outlist.Add(String.Join(" ", state)); while (true) { next_keta(ref state, state.Length - 1, letters); if (stop) break; outlist.Add(string.Join(" ", state)); } return outlist; } public static T[] next_keta(ref T[] state, int keta, T[] letters) { if (keta == -1) { stop = true; return new T[0]; } if (state[keta].CompareTo(letters[letters.Length - 1]) == 0) { //見た桁を最初の要素にする処理を state[keta] = letters[0]; return next_keta(ref state, keta - 1, letters); } else { int ketaindex = 0; for (int i = 0; i < letters.Length; i++) { if (state[keta].CompareTo(letters[i]) == 0) { ketaindex = i; break; } } state[keta] = letters[ketaindex + 1]; return state; } } } namespace CompLib.Collections { #region PriorityQueue /// <summary> /// 指定した型のインスタンスを最も価値が低い順に取り出すことが可能な可変サイズのコレクションを表します. /// </summary> /// <typeparam name="T">優先度付きキュー内の要素の型を指定します.</typeparam> /// <remarks>内部的にはバイナリヒープによって実装されています.</remarks> public class PriorityQueue<T> { readonly List<T> heap = new List<T>(); readonly Comparison<T> cmp; /// <summary> /// デフォルトの比較子を使用してインスタンスを初期化します. /// </summary> /// <remarks>この操作は O(1) で実行されます.</remarks> public PriorityQueue() { cmp = Comparer<T>.Default.Compare; } /// <summary> /// デリゲートで表されるような比較関数を使用してインスタンスを初期化します. /// </summary> /// <param name="comparison"></param> /// <remarks>この操作は O(1) で実行されます.</remarks> public PriorityQueue(Comparison<T> comparison) { cmp = comparison; } /// <summary> /// 指定された比較子を使用してインスタンスを初期化します. /// </summary> /// <param name="comparer"></param> /// <remarks>この操作は O(1) で実行されます.</remarks> public PriorityQueue(IComparer<T> comparer) { cmp = comparer.Compare; } /// <summary> /// 優先度付きキューに要素を追加します. /// </summary> /// <param name="item">優先度付きキューに追加される要素</param> /// <remarks>最悪計算量 O(log N) で実行されます.</remarks> public void Enqueue(T item) { var pos = heap.Count; heap.Add(item); while (pos > 0) { var par = (pos - 1) / 2; if (cmp(heap[par], item) <= 0) break; heap[pos] = heap[par]; pos = par; } heap[pos] = item; } /// <summary> /// 優先度付きキューから最も価値が低い要素を削除し,返します. /// </summary> /// <returns>優先度付きキューから削除された要素.</returns> /// <remarks>最悪計算量 O(log N) で実行されます.</remarks> public T Dequeue() { var ret = heap[0]; var pos = 0; var x = heap[heap.Count - 1]; while (pos * 2 + 1 < heap.Count - 1) { var lch = pos * 2 + 1; var rch = pos * 2 + 2; if (rch < heap.Count - 1 && cmp(heap[rch], heap[lch]) < 0) lch = rch; if (cmp(heap[lch], x) >= 0) break; heap[pos] = heap[lch]; pos = lch; } heap[pos] = x; heap.RemoveAt(heap.Count - 1); return ret; } /// <summary> /// 優先度付きキューに含まれる最も価値が低い要素を削除せずに返します. /// </summary> /// <returns>優先度付きキューに含まれる最も価値が低い要素.</returns> /// <remarks>この操作は O(1) で実行されます.</remarks> public T Peek() { return heap[0]; } /// <summary> /// 優先度付きキュー内の要素の数を取得します. /// </summary> /// <returns>優先度付キュー内にある要素の数</returns> /// <remarks>最悪計算量 O(1) で実行されます.</remarks> public int Count { get { return heap.Count; } } /// <summary> /// 優先度付きキュー内に要素が存在するかどうかを O(1) で判定します. /// </summary> /// <returns>優先度付キュー内にある要素が存在するならば /// true,そうでなければ false.</returns> <remarks>この操作は O(1) /// で実行されます.</remarks> public bool Any() { return heap.Count > 0; } /// <summary> /// 優先度付きキューに含まれる要素を昇順に並べて返します. /// </summary> /// <remarks>この操作は計算量 O(N log N)で実行されます.</remarks> public T[] Items { get { var ret = heap.ToArray(); Array.Sort(ret, cmp); return ret; } } } #endregion } /// <summary> /// SEGTREEは1-BASE運用でございます /// よろしくおねがいします /// あと絶対コンストラクタ使ってね /// </summary> /// <typeparam name="T"></typeparam> class Segtree<T> { int n; //高さ T[] tree; //本体 Func<T, T, T> f; //更新関数。a -> b -> ab使ったなにか T exnum; //初期値 int count; /// <summary> /// !!!WARNING!!! 1-BASEです。 /// </summary> /// <param name="m">要素の数の最大値。200001とか入れておくとよい</param> /// <param name="f">2引数の関数</param> /// <param /// name="ex">葉に書いてある値の初期値。fの関数に影響を与えない数値、零元とかにしておくべき。バグり散らかす。</param> public Segtree(int m, Func<T, T, T> f, T ex) { this.count = 0; this.f = f; this.exnum = ex; n = 1; while (n < m) n <<= 1; tree = new T[(n << 1) - 1]; for (int i = 0; i < tree.Length; i++) tree[i] = ex; } public Segtree(int m, T ini, Func<T, T, T> f, T ex) : this(m, f, ex) { this.count = 0; for (int i = 0; i < m; ++i) tree[i + n - 1] = ini; all_update(); } /// <summary> /// j番目の値をxにする。計算し直さないので、 /// 入れ替えた後はall_update();を使おう /// </summary> /// <param name="j">番目</param> /// <param name="x">更新後の値</param> public void assign_without_update(int j, T x) { tree[j + n - 1] = x; } /// <summary> /// j番目の値をxにする。計算し直すので、ちょっと計算時間がかかる /// </summary> /// <param name="j">番目</param> /// <param name="x">更新後の値</param> public void update(int j, T x) // j番目をxにする { int i = j + n - 1; tree[i] = x; while (i > 0) { i = (i - 1) >> 1; tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]); } this.count++; } /// <summary> /// 木を全部計算し直す。多分NlogN。違うかも知れないから /// よかったら教えて /// </summary> public void all_update() { for (int i = n - 2; i >= 0; i--) tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]); } public T look(int i) { return tree[i + n - 1]; } /// <summary> /// j番目を消す。 /// </summary> /// <param name="j"></param> public void delete (int j) { int i = j + n - 1; tree[i] = exnum; int moved = 0; while (true) { tree[i + 1] = tree[i]; T check = tree[i]; moved++; if (moved + j + 2 > count) { break; } } all_update(); } // [s, t) /// <summary> /// s番目からt - 1 番目までの結果を返す。t番目は含まない。 /// これも当然のように1-BASE. /// </summary> /// <param name="s"></param> /// <param name="t"></param> /// <returns></returns> public T run(int s, int t) { return query(s, t, 0, 0, n); } T query(int s, int t, int k, int l, int r) { if (r <= s || t <= l) return exnum; if (s <= l && r <= t) return tree[k]; return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1), query(s, t, (k + 1) << 1, (l + r) >> 1, r)); } } public class pair<T> { public T A; public T B; public pair() {} public pair(T A, T B) { this.A = A; this.B = B; } } public class chouten { public int N; public List<int> node; public chouten(int n) { this.N = n; this.node = new List<int>(); } } public class ABC { // long[] sp = Console.ReadLine().Split().Select(long // .Parse).ToArray(); int[] sp = // Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = // int.Parse(Console.ReadLine()); // CompLib.Collections.PriorityQueue<?> //文字列比較のcomparer // StringComparer.OrdinalIgnoreCase public static void Main() { int H, W; new readint(out H, out W); long mul; mul = H; mul *= W; if (mul % 2 == 0) { Console.WriteLine(mul / 2); } else { Console.WriteLine((mul + 1) / 2); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; using System.IO; class readint { public readint(out int i) { i = int.Parse(Console.ReadLine()); } public readint(out int a, out int b) { int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray(); a = sp[0]; b = sp[1]; } public readint(out int a, out int b, out int c) { int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; } public readint(out int a, out int b, out int c, out int d) { int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; d = sp[3]; } } class readlong { public readlong(out long i) { i = long.Parse(Console.ReadLine()); } public readlong(out long a, out long b) { long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray(); a = sp[0]; b = sp[1]; } public readlong(out long a, out long b, out long c) { long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; } public readlong(out long a, out long b, out long c, out long d) { long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray(); a = sp[0]; b = sp[1]; c = sp[2]; d = sp[3]; } } class modMWorld { public static long M = (int)Math.Pow(10, 9) + 7; //必要な演算は、加減乗除、nCk,n!,a^n public static long add(long a, long b) { long sum = a + b; sum += M; return sum % M; } public static long sub(long a, long b) { long dif = a - b; dif += M * 2; return dif % M; } public static long mul(long a, long b) { long product = a; product *= b; return product % M; } public static long div(long a, long b) { return mul(a, Pow(b, M - 2)); } /// <summary> /// a^m modMを求める /// </summary> /// <param name="a"></param> /// <param name="m"></param> /// <returns></returns> public static long Pow(long a, long m) { switch (m) { case 0: return 1; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = mul(p1, p1); return ((m % 2) == 0) ? p2 : mul(p2, a); } } public static long kaijou(long n) { //! long output = 1; for (int i = 0; i < n; i++) { output = mul(output, n - i); } return output; } public static long nCk(long n, long k) { long output = 1; for (int i = 1; i <= k; i++) { output = mul(output, n - (i - 1)); output = div(output, i); } return output; } } class Util { public static int[] readintarr() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); } public static long[] readlongarr() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } /// <summary> /// nの約数を小さい順のリストで返します。 /// </summary> /// <param name="n"></param> /// <returns></returns> public static List<int> make_divisor(int n) { List<int> output = new List<int>(); for (int i = 1; i <= Math.Sqrt(n) + 1; i++) { if (n % i == 0) { output.Add(i); if (i * i != n) { output.Add(n / i); } } } output.Sort(); return output; } // iの素因数分解をします public static List<int> soinsuuBunkai(int n) { //素因数分解をします List<int> output = new List<int>(); int target = n; for (int i = 2; i <= 1 + Math.Sqrt(target); i += 2) { while (target % i == 0) { target /= i; output.Add(i); } if (i == 2) i--; } if (target > 1) { output.Add(target); } return output; } public static List<long> soinsuuBunkai(long n) { List<long> output = new List<long>(); long target = n; for (int i = 2; i <= 1 + Math.Sqrt(target); i += 2) { while (target % i == 0) { target /= i; output.Add(i); } if (i == 2) i--; } if (target > 1) { output.Add(target); } return output; } /// <summary> /// 2引数の最大公約数を返します。longです。 /// </summary> /// <param name="a">long 引数1</param> /// <param name="b">long 引数2</param> /// <returns></returns> public static long GCD(long a, long b) { if (a < b) swap(ref a, ref b); if (a % b == 0) return b; return GCD(b, a % b); } /// <summary> /// 2引数の最大公約数を返します。intです。 /// </summary> /// <param name="a">int 引数1</param> /// <param name="b">int 引数2</param> /// <returns></returns> public static int GCD(int a, int b) { // if (a < b) // swap(ref a, ref b); if (a % b == 0) return b; return GCD(b, a % b); } /// <summary> /// 2つの変数の中身を交換する。型はなんでもいい /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="b"></param> public static void swap<T>(ref T a, ref T b) { T temp = b; b = a; a = temp; } /// <summary> /// 2引数の最大公約数を返します。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long LCM(long a, long b) { return a * b / GCD(a, b); } /// <summary> /// 2引数の最大公約数を返します。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long LCM(int a, int b) { return Math.BigMul(a, b) / GCD(a, b); } public static int M = (int)(Math.Pow(10, 9)) + 7; private static int[] factorial_modM; public static long nCr(long n, long r) { long output = 1; for (int i = 1; i <= r; i++) { output *= (n + 1 - i); output /= (i); } return output; } /// <summary> /// 2引数の積 mod Mを求める。Mは10億7。 /// 変えられるよ。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static int Multiple_modM(int a, int b) { return (int)(Math.BigMul(a, b) % M); } /// <summary> /// n! modMまたはnCmを求めるための準備を行う。引数は最大値。 /// </summary> /// <param name="n"></param> public static void factorial_modM_Prepare(int n) { factorial_modM = new int[n + 1]; factorial_modM[0] = 1; for (int i = 1; i <= n; ++i) { factorial_modM[i] = Multiple_modM(factorial_modM[i - 1], i); } } /// <summary> /// n! mod M を返す。やる前にfactorial_modM_Prepare(n)を実行しといてね。 /// </summary> /// <param name="n"></param> /// <returns></returns> public static int Factorial(int n) { return factorial_modM[n]; } /// <summary> /// a^m modMを求める /// </summary> /// <param name="a"></param> /// <param name="m"></param> /// <returns></returns> public static 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 = Multiple_modM(p1, p1); return ((m % 2) == 0) ? p2 : Multiple_modM(p2, a); } } /// <summary> /// a / m Mod M を求める。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static int Div(int a, int b) { return Multiple_modM(a, Pow(b, M - 2)); } /// <summary> /// nCr mod M を求める。やる前にfactorial_modM_Prepare(n)を実行しといてね。 /// </summary> /// <param name="n"></param> /// <param name="r"></param> /// <returns></returns> public static int nCr_modM(int n, int r) { if (r < 0) return 0; if (n < r) { return 0; } if (n == r) { return 1; } int res = Factorial(n); res = Div(res, Factorial(r)); res = Div(res, Factorial(n - r)); return res; } } /// <summary> /// Union-Find木を定義する。コンストラクタの指定は、頂点の番号。 /// おすすめとしては、UnionFind<T>[] で宣言してしまう。 /// 配列で宣言したあと、コンストラクタ使ってnewするのを忘れないでね。 /// コンストラクタのitemは、そのノード固有のIDになるので、絶対必要です /// </summary> /// <typeparam name="T">int固定でいいよね。</typeparam> class UnionFind<T> { public int tree_height; public UnionFind<T> parent; public T item { get; private set; } public UnionFind(T item) { tree_height = 0; parent = this; this.item = item; } /// <summary> /// 一番上の親を探す。 /// 探しながら繋がり方を最適化している。 /// UnionFindの頂点そのものを返すので、==での比較が可能。 /// </summary> /// <returns></returns> public UnionFind<T> FindAdam() { if (parent == this) return this; else { UnionFind<T> ParentOfParent = parent.FindAdam(); parent = ParentOfParent; //縦長な構成をつなぎ直している return ParentOfParent; } } /// <summary> /// unionfind2つを一つにつなぐ。 /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static void Unite(UnionFind<T> a, UnionFind<T> b) { UnionFind<T> ParentOfA = a.FindAdam(); UnionFind<T> ParentOfB = b.FindAdam(); if (ParentOfA.tree_height < ParentOfB.tree_height) { ParentOfA.parent = ParentOfB; ParentOfB.tree_height = Math.Max(ParentOfA.tree_height + 1, ParentOfB.tree_height); } else { ParentOfB.parent = ParentOfA; ParentOfA.tree_height = Math.Max(ParentOfB.tree_height + 1, ParentOfA.tree_height); } } } // Treap 平衡二分木 class Treap<T> where T : IComparable { private class Node { private static Random g_rand = new Random(); private readonly int m_rank = g_rand.Next(); private readonly T m_value; private Node m_lch; private Node m_rch; private int m_count; public Node(T value) { m_value = value; m_count = 1; } private static int Count(Node node) { return (node != null) ? node.m_count : 0; } private Node Update() { m_count = Count(m_lch) + Count(m_rch) + 1; return this; } public static Node Merge(Node a, Node b) { if (a == null) { return b; } if (b == null) { return a; } if (a.m_rank < b.m_rank) { a.m_rch = Merge(a.m_rch, b); return a.Update(); } else { b.m_lch = Merge(a, b.m_lch); return b.Update(); } } public static Tuple<Node, Node> Split(Node t, int k) { if (t == null) { return new Tuple<Node, Node>(null, null); } if (k <= Count(t.m_lch)) { var pair = Split(t.m_lch, k); t.m_lch = pair.Item2; return new Tuple<Node, Node>(pair.Item1, t.Update()); } else { var pair = Split(t.m_rch, k - Count(t.m_lch) - 1); t.m_rch = pair.Item1; return new Tuple<Node, Node>(t.Update(), pair.Item2); } } public int FindIndex(T value) { int L = Count(m_lch); if (value.CompareTo(m_value) < 0) { return (m_lch != null) ? m_lch.FindIndex(value) : 0; } else if (value.CompareTo(m_value) > 0) { return (m_rch != null) ? m_rch.FindIndex(value) + L + 1 : L + 1; } else { return L; } } public T this[int i] { get { int L = Count(m_lch); if (i < L) { return m_lch[i]; } else if (i > L) { return m_rch[i - L - 1]; } else { return m_value; } } } } private Node node; public void Insert(T value) { if (node != null) { int k = node.FindIndex(value); var pair = Node.Split(node, k); node = Node.Merge(Node.Merge(pair.Item1, new Node(value)), pair.Item2); } else { node = new Node(value); } } public int FindIndex(T value) { return node.FindIndex(value); } public T this[int i] { get { return node[i]; } } } /// <summary> /// 使い方:Permutation.next(配列) で次の配列を返す /// 配列を受け取って、その配列の要素を全部使った組み合わせのうち、辞書順で次のものを返します。 /// もし、次のがない場合、空の配列を返します。 /// /// </summary> /// <typeparam name="T"></typeparam> class Permutation<T> where T : IComparable { public static T[] next(T[] letters) { int pivot = -1; for (int i = letters.Length - 2; i >= 0; i--) { if (letters[i].CompareTo(letters[i + 1]) < 0) { pivot = i; break; } } if (pivot == -1) { return new T[0]; } int big_min = letters.Length - 1; T big_min_T = letters[letters.Length - 1]; for (int i = letters.Length - 1; i > pivot; i--) { // big_min_Tより小さいかつ、pivotのより大きい if (letters[pivot].CompareTo(letters[i]) > 0 && letters[pivot].CompareTo(big_min_T) < 0) { big_min_T = letters[i]; big_min = i; } } T temp = letters[pivot]; letters[pivot] = letters[big_min]; letters[big_min] = temp; Array.Sort(letters, pivot + 1, letters.Length - pivot - 1); return letters; } } /// <summary> /// 使い方 : Combination /// .AllCombination(使える文字を、小さい順から配列にしたもの,ほしい文字数) /// 使える文字を、小さい順から配列にしたものを重複ありで組み合わせて、stringのlistで出力する /// /// </summary> /// <typeparam name="T"></typeparam> class Combination<T> where T : IComparable { private static bool stop = false; public static List<string> AllCombination(T[] letters, int n) { // n桁ですよね。 List<string> outlist = new List<string>(); T[] state = new T[n]; for (int i = 0; i < n; i++) { state[i] = letters[0]; } outlist.Add(String.Join(" ", state)); while (true) { next_keta(ref state, state.Length - 1, letters); if (stop) break; outlist.Add(string.Join(" ", state)); } return outlist; } public static T[] next_keta(ref T[] state, int keta, T[] letters) { if (keta == -1) { stop = true; return new T[0]; } if (state[keta].CompareTo(letters[letters.Length - 1]) == 0) { //見た桁を最初の要素にする処理を state[keta] = letters[0]; return next_keta(ref state, keta - 1, letters); } else { int ketaindex = 0; for (int i = 0; i < letters.Length; i++) { if (state[keta].CompareTo(letters[i]) == 0) { ketaindex = i; break; } } state[keta] = letters[ketaindex + 1]; return state; } } } namespace CompLib.Collections { #region PriorityQueue /// <summary> /// 指定した型のインスタンスを最も価値が低い順に取り出すことが可能な可変サイズのコレクションを表します. /// </summary> /// <typeparam name="T">優先度付きキュー内の要素の型を指定します.</typeparam> /// <remarks>内部的にはバイナリヒープによって実装されています.</remarks> public class PriorityQueue<T> { readonly List<T> heap = new List<T>(); readonly Comparison<T> cmp; /// <summary> /// デフォルトの比較子を使用してインスタンスを初期化します. /// </summary> /// <remarks>この操作は O(1) で実行されます.</remarks> public PriorityQueue() { cmp = Comparer<T>.Default.Compare; } /// <summary> /// デリゲートで表されるような比較関数を使用してインスタンスを初期化します. /// </summary> /// <param name="comparison"></param> /// <remarks>この操作は O(1) で実行されます.</remarks> public PriorityQueue(Comparison<T> comparison) { cmp = comparison; } /// <summary> /// 指定された比較子を使用してインスタンスを初期化します. /// </summary> /// <param name="comparer"></param> /// <remarks>この操作は O(1) で実行されます.</remarks> public PriorityQueue(IComparer<T> comparer) { cmp = comparer.Compare; } /// <summary> /// 優先度付きキューに要素を追加します. /// </summary> /// <param name="item">優先度付きキューに追加される要素</param> /// <remarks>最悪計算量 O(log N) で実行されます.</remarks> public void Enqueue(T item) { var pos = heap.Count; heap.Add(item); while (pos > 0) { var par = (pos - 1) / 2; if (cmp(heap[par], item) <= 0) break; heap[pos] = heap[par]; pos = par; } heap[pos] = item; } /// <summary> /// 優先度付きキューから最も価値が低い要素を削除し,返します. /// </summary> /// <returns>優先度付きキューから削除された要素.</returns> /// <remarks>最悪計算量 O(log N) で実行されます.</remarks> public T Dequeue() { var ret = heap[0]; var pos = 0; var x = heap[heap.Count - 1]; while (pos * 2 + 1 < heap.Count - 1) { var lch = pos * 2 + 1; var rch = pos * 2 + 2; if (rch < heap.Count - 1 && cmp(heap[rch], heap[lch]) < 0) lch = rch; if (cmp(heap[lch], x) >= 0) break; heap[pos] = heap[lch]; pos = lch; } heap[pos] = x; heap.RemoveAt(heap.Count - 1); return ret; } /// <summary> /// 優先度付きキューに含まれる最も価値が低い要素を削除せずに返します. /// </summary> /// <returns>優先度付きキューに含まれる最も価値が低い要素.</returns> /// <remarks>この操作は O(1) で実行されます.</remarks> public T Peek() { return heap[0]; } /// <summary> /// 優先度付きキュー内の要素の数を取得します. /// </summary> /// <returns>優先度付キュー内にある要素の数</returns> /// <remarks>最悪計算量 O(1) で実行されます.</remarks> public int Count { get { return heap.Count; } } /// <summary> /// 優先度付きキュー内に要素が存在するかどうかを O(1) で判定します. /// </summary> /// <returns>優先度付キュー内にある要素が存在するならば /// true,そうでなければ false.</returns> <remarks>この操作は O(1) /// で実行されます.</remarks> public bool Any() { return heap.Count > 0; } /// <summary> /// 優先度付きキューに含まれる要素を昇順に並べて返します. /// </summary> /// <remarks>この操作は計算量 O(N log N)で実行されます.</remarks> public T[] Items { get { var ret = heap.ToArray(); Array.Sort(ret, cmp); return ret; } } } #endregion } /// <summary> /// SEGTREEは1-BASE運用でございます /// よろしくおねがいします /// あと絶対コンストラクタ使ってね /// </summary> /// <typeparam name="T"></typeparam> class Segtree<T> { int n; //高さ T[] tree; //本体 Func<T, T, T> f; //更新関数。a -> b -> ab使ったなにか T exnum; //初期値 int count; /// <summary> /// !!!WARNING!!! 1-BASEです。 /// </summary> /// <param name="m">要素の数の最大値。200001とか入れておくとよい</param> /// <param name="f">2引数の関数</param> /// <param /// name="ex">葉に書いてある値の初期値。fの関数に影響を与えない数値、零元とかにしておくべき。バグり散らかす。</param> public Segtree(int m, Func<T, T, T> f, T ex) { this.count = 0; this.f = f; this.exnum = ex; n = 1; while (n < m) n <<= 1; tree = new T[(n << 1) - 1]; for (int i = 0; i < tree.Length; i++) tree[i] = ex; } public Segtree(int m, T ini, Func<T, T, T> f, T ex) : this(m, f, ex) { this.count = 0; for (int i = 0; i < m; ++i) tree[i + n - 1] = ini; all_update(); } /// <summary> /// j番目の値をxにする。計算し直さないので、 /// 入れ替えた後はall_update();を使おう /// </summary> /// <param name="j">番目</param> /// <param name="x">更新後の値</param> public void assign_without_update(int j, T x) { tree[j + n - 1] = x; } /// <summary> /// j番目の値をxにする。計算し直すので、ちょっと計算時間がかかる /// </summary> /// <param name="j">番目</param> /// <param name="x">更新後の値</param> public void update(int j, T x) // j番目をxにする { int i = j + n - 1; tree[i] = x; while (i > 0) { i = (i - 1) >> 1; tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]); } this.count++; } /// <summary> /// 木を全部計算し直す。多分NlogN。違うかも知れないから /// よかったら教えて /// </summary> public void all_update() { for (int i = n - 2; i >= 0; i--) tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]); } public T look(int i) { return tree[i + n - 1]; } /// <summary> /// j番目を消す。 /// </summary> /// <param name="j"></param> public void delete (int j) { int i = j + n - 1; tree[i] = exnum; int moved = 0; while (true) { tree[i + 1] = tree[i]; T check = tree[i]; moved++; if (moved + j + 2 > count) { break; } } all_update(); } // [s, t) /// <summary> /// s番目からt - 1 番目までの結果を返す。t番目は含まない。 /// これも当然のように1-BASE. /// </summary> /// <param name="s"></param> /// <param name="t"></param> /// <returns></returns> public T run(int s, int t) { return query(s, t, 0, 0, n); } T query(int s, int t, int k, int l, int r) { if (r <= s || t <= l) return exnum; if (s <= l && r <= t) return tree[k]; return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1), query(s, t, (k + 1) << 1, (l + r) >> 1, r)); } } public class pair<T> { public T A; public T B; public pair() {} public pair(T A, T B) { this.A = A; this.B = B; } } public class chouten { public int N; public List<int> node; public chouten(int n) { this.N = n; this.node = new List<int>(); } } public class ABC { // long[] sp = Console.ReadLine().Split().Select(long // .Parse).ToArray(); int[] sp = // Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = // int.Parse(Console.ReadLine()); // CompLib.Collections.PriorityQueue<?> //文字列比較のcomparer // StringComparer.OrdinalIgnoreCase public static void Main() { int H, W; new readint(out H, out W); if (H == 1 || W == 1) { Console.WriteLine(1); } else { long mul; mul = H; mul *= W; if (mul % 2 == 0) { Console.WriteLine(mul / 2); } else { Console.WriteLine((mul + 1) / 2); } } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 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, 57, 75, 196, 0, 57, 75, 196, 0, 46]]
8
4,382
22
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long mod = 1000000007; static void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; } static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static void Solve() { long H; long W; Multi(out H, out W); var ans = H * W % 2L == 0L ? H * W / 2L : H * W / 2L + 1L; Console.WriteLine(ans); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public void WriteObjects<T>(IList<T> values) { var num = values.Count; for (int i = 0; i < num; i++) { Console.Write(values[i]); if (i < num - 1) { Console.Write(" "); } } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long mod = 1000000007; static void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; } static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static void Solve() { long H; long W; Multi(out H, out W); var ans = (H == 1 || W == 1) ? 1 : H * W % 2L == 0L ? H * W / 2L : H * W / 2L + 1L; Console.WriteLine(ans); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public void WriteObjects<T>(IList<T> values) { var num = values.Count; for (int i = 0; i < num; i++) { Console.Write(values[i]); if (i < num - 1) { Console.Write(" "); } } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } } }
[["+", 0, 200, 0, 212, 0, 41, 15, 23, 0, 24], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 17, 60], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 12, 203], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 17, 106], ["+", 0, 41, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 41, 15, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 41, 15, 23, 0, 16, 12, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 41, 15, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102]]
8
1,172
12