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; class Program { static void Main() { string[] input = Console.ReadLine().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int sockets = 1; int count = 0; while (true) { sockets += A - 1; count++; if (sockets >= B) { break; } } Console.WriteLine(count); } }
using System; class Program { static void Main() { string[] input = Console.ReadLine().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int sockets = 1; int count = 0; while (true) { if (sockets >= B) { break; } sockets += A - 1; count++; } Console.WriteLine(count); } }
[["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29]]
8
100
18
using System; using System.Collections.Generic; using System.Text; using System.Numerics; using System.IO; namespace SolutionCS { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int A = int.Parse(s[0]); int B = int.Parse(s[1]); int ans = 1; B -= A; while (B > 0) { B -= (A - 1); ans++; } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Text; using System.Numerics; using System.IO; namespace SolutionCS { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int A = int.Parse(s[0]); int B = int.Parse(s[1]); if (B <= 1) { Console.WriteLine(0); return; } int ans = 1; B -= A; while (B > 0) { B -= (A - 1); ans++; } Console.WriteLine(ans); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 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
123
17
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass { public const long Giri = 1000000007; public static void Main(string[] args) { string[] w = Input(); int a = int.Parse(w[0]); int b = int.Parse(w[1]); int r = a; int cnt = 1; while (r < b) { r += a; r -= 1; cnt++; } Console.WriteLine(cnt); } public static long GCD(long a, long b) { if (b == 1) return a; long p = b / a; return GCD(a, b - a * p); } public static string[] Input() { return Console.ReadLine().Split(' '); } public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass { public const long Giri = 1000000007; public static void Main(string[] args) { string[] w = Input(); int a = int.Parse(w[0]); int b = int.Parse(w[1]); if (b == 1) { Console.WriteLine(0); return; } int r = a; int cnt = 1; while (r < b) { r += a; r -= 1; cnt++; } Console.WriteLine(cnt); } public static long GCD(long a, long b) { if (b == 1) return a; long p = b / a; return GCD(a, b - a * p); } public static string[] Input() { return Console.ReadLine().Split(' '); } public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 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
215
17
using System; using System.Linq; class Program { static void Main(string[] args) { int[] AB = new int[2]; AB = Console.ReadLine().Split().Select(int.Parse).ToArray(); int concent_count = 1; int i = 0; while (AB[1] > concent_count) { i++; concent_count = i * AB[0]; } Console.WriteLine(i); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int[] AB = new int[2]; AB = Console.ReadLine().Split().Select(int.Parse).ToArray(); int concent_count = 1; int i = 0; while (AB[1] > concent_count) { i++; concent_count = i * AB[0] - 1 * i + 1; } Console.WriteLine(i); } }
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 16, 12, 16, 31, 203], ["+", 0, 11, 12, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 11, 12, 16, 31, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
8
97
13
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var ab = ReadInts(); var tap_count = 0; var outlet_count = 1; while (true) { tap_count++; outlet_count += ab[0] - 1; if (outlet_count >= ab[1]) { WriteLine(tap_count); return; } } } 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); } public static bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } //最大公約数 public static int Gcd(int a, int b) { if (a < b) { return Gcd(b, a); } while (b != 0) { var reminder = a % b; a = b; b = reminder; } return a; } //最小公倍数 public static int Lcm(int a, int b) { return a * b / Gcd(a, b); } //文字数を数える public static int CountChar(string s, char c) { return s.Length - s.Replace(c.ToString(), "").Length; } public static void debuglist(List<int> x) { foreach (var item in x) { WriteLine(item); } } public static void debuglist(List<string> x) { foreach (var item in x) { WriteLine(item); } } public static void debugarray(int[] x) { foreach (var item in x) { WriteLine(item); } } public static void debugarray(string[] x) { foreach (var item in x) { WriteLine(item); } } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var ab = ReadInts(); var tap_count = 0; var outlet_count = 1; while (outlet_count < ab[1]) { outlet_count--; outlet_count += ab[0]; tap_count++; } WriteLine(tap_count); } 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); } public static bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } //最大公約数 public static int Gcd(int a, int b) { if (a < b) { return Gcd(b, a); } while (b != 0) { var reminder = a % b; a = b; b = reminder; } return a; } //最小公倍数 public static int Lcm(int a, int b) { return a * b / Gcd(a, b); } //文字数を数える public static int CountChar(string s, char c) { return s.Length - s.Replace(c.ToString(), "").Length; } public static void debuglist(List<int> x) { foreach (var item in x) { WriteLine(item); } } public static void debuglist(List<string> x) { foreach (var item in x) { WriteLine(item); } } public static void debugarray(int[] x) { foreach (var item in x) { WriteLine(item); } } public static void debugarray(string[] x) { foreach (var item in x) { WriteLine(item); } } } }
[["-", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 8, 196, 0, 52, 15, 16, 12, 204, 205, 22], ["+", 0, 52, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 52, 15, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 68], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 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], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
8
586
31
namespace AtCoder.ABC.B139 { using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.IO; using AtCoder.ABC.IO; public class Quest { public object Solve(Parser parser) { int a = parser.Integer(); int b = parser.Integer(); // 4 + 3 + 3 = 10 // b >= a + (n - 1) * (a -1) int x = 0; int n = 0; while (b > x) { n++; x = a + (n - 1) * (a - 1); } return n; } } static class Program { static void Main(string[] args) { var i = new Parser(Console.OpenStandardInput()); var o = new Printer(Console.OpenStandardOutput()); var got = new Quest().Solve(i); o.WriteLine(got); o.Flush(); } } } namespace AtCoder.ABC.IO { #region IO using System; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; using System.Globalization; public class Parser { public Parser(Stream stream) { str = stream; } public readonly Stream str; private readonly byte[] buf = new byte[1024]; private int len, ptr; public bool isEof; public bool IsEndOfStream { get { return isEof; } } public IEnumerable<Parser> Take(int n) { return Enumerable.Range(1, n).Select(_ => this); } private byte read() { if (isEof) return 0; if (ptr < len) return buf[ptr++]; ptr = 0; if ((len = str.Read(buf, 0, 1024)) > 0) return buf[ptr++]; isEof = true; return 0; } public char Char() { byte b; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public string ScanLine() { var sb = new StringBuilder(); for (var b = Char(); b != '\n'; b = (char)read()) if (b == 0) break; else if (b != '\r') sb.Append(b); return sb.ToString(); } public long Long() { if (isEof) return long.MinValue; long ret = 0; byte b; var ng = false; do b = read(); while (b != 0 && b != '-' && (b < '0' || '9' < b)); if (b == 0) return long.MinValue; if (b == '-') { ng = true; b = read(); } for (;; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; ret = ret * 10 + b - '0'; } } public int Integer() { return (isEof) ? int.MinValue : (int)Long(); } public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; } static T[] enumerate<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(); return a; } public char[] Char(int n) { return enumerate(n, Char); } public string[] Scan(int n) { return enumerate(n, Scan); } public double[] Double(int n) { return enumerate(n, Double); } public int[] Integer(int n) { return enumerate(n, Integer); } public long[] Long(int n) { return enumerate(n, Long); } } public class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {} public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {} public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); } public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); } } #endregion }
namespace AtCoder.ABC.B139 { using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.IO; using AtCoder.ABC.IO; public class Quest { public object Solve(Parser parser) { int a = parser.Integer(); int b = parser.Integer(); // 4 + 3 + 3 = 10 // b >= a + (n - 1) * (a -1) int x = 1; int n = 0; while (b > x) { n++; x += (a - 1); } return n; } } static class Program { static void Main(string[] args) { var i = new Parser(Console.OpenStandardInput()); var o = new Printer(Console.OpenStandardOutput()); var got = new Quest().Solve(i); o.WriteLine(got); o.Flush(); } } } namespace AtCoder.ABC.IO { #region IO using System; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; using System.Globalization; public class Parser { public Parser(Stream stream) { str = stream; } public readonly Stream str; private readonly byte[] buf = new byte[1024]; private int len, ptr; public bool isEof; public bool IsEndOfStream { get { return isEof; } } public IEnumerable<Parser> Take(int n) { return Enumerable.Range(1, n).Select(_ => this); } private byte read() { if (isEof) return 0; if (ptr < len) return buf[ptr++]; ptr = 0; if ((len = str.Read(buf, 0, 1024)) > 0) return buf[ptr++]; isEof = true; return 0; } public char Char() { byte b; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public string ScanLine() { var sb = new StringBuilder(); for (var b = Char(); b != '\n'; b = (char)read()) if (b == 0) break; else if (b != '\r') sb.Append(b); return sb.ToString(); } public long Long() { if (isEof) return long.MinValue; long ret = 0; byte b; var ng = false; do b = read(); while (b != 0 && b != '-' && (b < '0' || '9' < b)); if (b == 0) return long.MinValue; if (b == '-') { ng = true; b = read(); } for (;; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; ret = ret * 10 + b - '0'; } } public int Integer() { return (isEof) ? int.MinValue : (int)Long(); } public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; } static T[] enumerate<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(); return a; } public char[] Char(int n) { return enumerate(n, Char); } public string[] Scan(int n) { return enumerate(n, Scan); } public double[] Double(int n) { return enumerate(n, Double); } public int[] Integer(int n) { return enumerate(n, Integer); } public long[] Long(int n) { return enumerate(n, Long); } } public class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {} public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {} public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); } public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); } } #endregion }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 11, 12, 16, 12, 16, 31, 23, 0, 24], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["-", 12, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 11, 12, 16, 12, 16, 31, 23, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 48], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107]]
8
1,020
12
using System; using System.Linq; using System.Collections.Generic; namespace B { class Program { static void Main(string[] args) { Console.WriteLine(Run(args)); } private static int Run(string[] args) { var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var A = input[0]; var B = input[1]; var ret = 1; ret += (B - A) / (A - 1); return ret; } } }
using System; using System.Linq; using System.Collections.Generic; namespace B { class Program { static void Main(string[] args) { Console.WriteLine(Run(args)); } private static int Run(string[] args) { var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var A = input[0]; var B = input[1]; var ret = 1; ret += (int)Math.Ceiling((float)(B - A) / (float)(A - 1)); return ret; } } }
[["+", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25], ["+", 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, 74, 51, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 0, 28, 0, 16, 31, 74, 51, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 25], ["+", 0, 28, 0, 16, 12, 74, 51, 23, 0, 25]]
8
121
14
using System; using System.Collections; using System.Collections.Generic; using System.Text; class Program { static void Main(string[] args) { var p = new Program(); var input = p.ConvertIntArray(p.ReadInput()); var count = 0; var A = input[0] - 1; var B = input[1] - 1; if (input[1] != 1) { while (input[1] > 0) { input[1] = input[1] - input[0]; count++; } } Console.WriteLine(count); } public string[] ReadInput() { return Console.ReadLine().Split(' '); } public int[] ConvertIntArray(string[] x) { var convertedArray = new int[x.Length]; for (var i = 0; i < x.Length; i++) { convertedArray[i] = int.Parse(x[i]); } return convertedArray; } }
using System; using System.Collections; using System.Collections.Generic; using System.Text; class Program { static void Main(string[] args) { var p = new Program(); var input = p.ConvertIntArray(p.ReadInput()); var count = 1; var A = input[0] - 1; var B = input[1] - 1; if (input[1] == 1) { count = 0; } else { while (B > A) { B -= A; count++; } } Console.WriteLine(count); } public string[] ReadInput() { return Console.ReadLine().Split(' '); } public int[] ConvertIntArray(string[] x) { var convertedArray = new int[x.Length]; for (var i = 0; i < x.Length; i++) { convertedArray[i] = int.Parse(x[i]); } return convertedArray; } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 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], ["-", 64, 196, 0, 52, 15, 16, 31, 204, 205, 22], ["-", 0, 52, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 52, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 57, 64, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 57, 75, 196, 0, 52, 15, 16, 12, 22], ["-", 8, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["-", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 11, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22]]
8
212
35
// ABC139 B - Power Socket // 20190902 using System; namespace B { class Program { static void Main(string[] args) { // Console.WriteLine("Hello World!"); //入力受け取り string str = Console.ReadLine(); string[] arr = str.Split(' '); int A = int.Parse(arr[0]); int B = int.Parse(arr[1]); //計算 int count = 1; int C = A; while (C < B) { C += A - 1; count++; } //出力 Console.WriteLine(count); } } }
// ABC139 B - Power Socket // 20190902 using System; namespace B { class Program { static void Main(string[] args) { // Console.WriteLine("Hello World!"); //入力受け取り string str = Console.ReadLine(); string[] arr = str.Split(' '); int A = int.Parse(arr[0]); int B = int.Parse(arr[1]); //計算 int count = 1; int C = A; while (C < B) { C += A - 1; count++; } if (B == 1) { count = 0; } //出力 Console.WriteLine(count); } } }
[["+", 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, 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
111
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { void Solve() { var N = ToInts(); var ret = 1; var a = N[0]; for (;;) { if (a >= N[1]) break; a += (N[0] - 1); ret += 1; } Console.WriteLine(ret); ; } static int[] ToInts() { var ss = Console.ReadLine().Split(); var ret = new /**/ int[ss.Length]; for (int i = 0; i < ss.Length; i++) { ret[i] = /**/ int.Parse(ss[i]); } return ret; } static void Main(string[] args) { new Program().Solve(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { void Solve() { var N = ToInts(); if (N[1] == 1) { Console.WriteLine(0); return; } var ret = 1; var max = N[0]; for (;;) { if (max >= N[1]) break; max += (N[0] - 1); ret += 1; } Console.WriteLine(ret); ; } static int[] ToInts() { var ss = Console.ReadLine().Split(); var ret = new /**/ int[ss.Length]; for (int i = 0; i < ss.Length; i++) { ret[i] = /**/ int.Parse(ss[i]); } return ret; } static void Main(string[] args) { new Program().Solve(); } }
[["+", 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], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 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, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22]]
8
189
26
using System; class Program { static void Main(string[] args) { string[] con = Console.ReadLine().Split(' '); int A = int.Parse(con[0]); int B = int.Parse(con[1]); int tap = A; int kosu = 1; while (B > tap) { kosu++; tap = tap + A - 1; } Console.WriteLine(kosu); Console.ReadLine(); } }
using System; class Program { static void Main(string[] args) { string[] con = Console.ReadLine().Split(' '); int A = int.Parse(con[0]); int B = int.Parse(con[1]); int tap = A; int kosu = 1; while (B > tap) { kosu++; tap = tap + A - 1; } if (B == 1) kosu = 0; Console.WriteLine(kosu); Console.ReadLine(); } }
[["+", 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], ["+", 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
104
10
using System; namespace PowerSocket_20190901 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int tap = int.Parse(input[0]); //電源タップの差込口の数 int outlet = int.Parse(input[1]); //目標の差込口の数 int calc_tap = 1; //最初の差込口の数 計算用 int answer = 0; //必要な電源タップの個数 for (int i = 0; i < int.MaxValue; i++) { calc_tap--; calc_tap += tap; answer++; if (calc_tap >= outlet) break; } Console.WriteLine(answer.ToString()); } } }
using System; namespace PowerSocket_20190901 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int tap = int.Parse(input[0]); //電源タップの差込口の数 int outlet = int.Parse(input[1]); //目標の差込口の数 int calc_tap = 1; //最初の差込口の数 計算用 int answer = 0; //必要な電源タップの個数 for (int i = 0; i < int.MaxValue; i++) { if (outlet == 1) //差込口が1個の場合はループしない break; calc_tap--; // 1個差込口を消費 calc_tap += tap; // tap個口の電源タップを差し込む answer++; //差し込んだ数をカウント if (calc_tap >= outlet) //目標と等しいあるいは目標以上の差込口の数になったら抜ける break; } Console.WriteLine(answer.ToString()); } } }
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 35]]
8
127
8
using System; namespace abc139_2 { class Program { static void Main(string[] args) { // input string[] str = Console.ReadLine().Split(' '); int a = int.Parse(str[0]); int b = int.Parse(str[1]); // output int ans = 0; bool flg = true; int tmp = b - a; if (tmp <= 0) { ans = 1; flg = false; } else { ans++; } while (flg) { tmp -= a - 1; if (tmp <= 0) { ans++; break; } ans++; } Console.WriteLine(ans.ToString()); } } }
using System; namespace abc139_2 { class Program { static void Main(string[] args) { // input string[] str = Console.ReadLine().Split(' '); int a = int.Parse(str[0]); int b = int.Parse(str[1]); // output int ans = 0; bool flg = true; int tmp = b - a; if (b == 1) { ans = 0; flg = false; } if (flg) { if (tmp <= 0) { ans = 1; flg = false; } else { ans++; } } while (flg) { tmp -= a - 1; if (tmp <= 0) { ans++; break; } ans++; } Console.WriteLine(ans.ToString()); } } }
[["+", 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, 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], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 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, 201, 0, 195, 8, 196, 0, 57, 15, 22], ["+", 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, 75, 196, 0, 46]]
8
146
22
using System; using System.Linq; using System.Threading.Tasks; using static System.Console; using static System.Math; class program { static void Main(string[] args) { program p = new program(); p.Run(); } void Run() { int[] tmp = Readint(); int a = tmp[0], b = tmp[1]; int hole = a, res = 1; while (true) { if (hole >= b) break; hole += a - 1; res++; } WriteLine(res.ToString()); } int[] Readint() { string[] s = ReadLine().Split(); int[] res = new int[s.Length]; Parallel.For(0, s.Length, i => { res[i] = int.Parse(s[i]); }); return res; } }
using System; using System.Linq; using System.Threading.Tasks; using static System.Console; using static System.Math; class program { static void Main(string[] args) { program p = new program(); p.Run(); } void Run() { int[] tmp = Readint(); int a = tmp[0], b = tmp[1]; int hole = a, res = 1; if (b < 2) { WriteLine("0"); return; } while (true) { if (hole >= b) break; hole += a - 1; res++; } WriteLine(res.ToString()); } int[] Readint() { string[] s = ReadLine().Split(); int[] res = new int[s.Length]; Parallel.For(0, s.Length, i => { res[i] = int.Parse(s[i]); }); return res; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 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
195
17
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc139 { class abc139b { static void Main(string[] args) { var buf = Console.ReadLine().Split(); var a = int.Parse(buf[0]); var b = int.Parse(buf[1]); var r = Solve(a, b); Console.WriteLine(r); } static int Solve(int a, int b) { var n = 0; var r = 1; do { ++n; r += a - 1; } while (r < b); return n; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc139 { class abc139b { static void Main(string[] args) { var buf = Console.ReadLine().Split(); var a = int.Parse(buf[0]); var b = int.Parse(buf[1]); var r = Solve(a, b); Console.WriteLine(r); } static int Solve(int a, int b) { var n = 0; var r = 1; while (r < b) { ++n; r += a - 1; } return n; } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 82, 0, 170], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 82, 0, 89], ["-", 8, 201, 0, 195, 8, 196, 0, 82, 0, 24], ["-", 0, 195, 8, 196, 0, 82, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 82, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 82, 15, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 82, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 82, 0, 35]]
8
146
14
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); if (ab[1] == 1) { Console.WriteLine(0); return; } var sum = 0; var count = 1; while (ab[1] > ab[0] + ab[0] * (count - 1)) { ++count; } Console.WriteLine(count); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); if (ab[1] == 1) { Console.WriteLine(0); return; } var count = 1; while (ab[1] > ab[0] + (ab[0] - 1) * (count - 1)) { ++count; } Console.WriteLine(count); } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 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], ["+", 15, 16, 12, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 15, 16, 12, 16, 12, 16, 31, 23, 0, 25]]
8
139
9
using System; namespace Abc138 { public class QuestionB { public static void Main(string[] args) { // 整数の入力 string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); int result = 1; while (true) { int count = a; count += (a - 1) * (result - 1); if (count >= b) { break; } result++; } Console.WriteLine(result); } } }
using System; namespace Abc138 { public class QuestionB { public static void Main(string[] args) { // 整数の入力 string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); if (b == 1) { Console.WriteLine(0); return; } int result = 1; while (true) { int count = a; count += (a - 1) * (result - 1); if (count >= b) { break; } result++; } Console.WriteLine(result); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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
119
17
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProblemB { class Program { static void Main(string[] args) { var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var A = read[0]; var B = read[1]; var ret = B <= A ? 1 : (B - A) % (A - 1) == 0 ? 1 + (B - A) / (A - 1) : 2 + (B - A) / (A - 1); Console.WriteLine(ret); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProblemB { class Program { static void Main(string[] args) { var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var A = read[0]; var B = read[1]; var ret = 0; if (B != 1) ret = B <= A ? 1 : (B - A) % (A - 1) == 0 ? 1 + (B - A) / (A - 1) : 2 + (B - A) / (A - 1); Console.WriteLine(ret); } } }
[["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32]]
8
152
10
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int count = 0; int temp = 0; if (B > A) { while (temp < B) { temp += A; if (count > 0) temp -= 1; count++; } } else { count = 1; } Console.WriteLine(count.ToString()); // Console.Read(); } } }
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int count = 0; int temp = 0; if (B > A) { while (temp < B) { temp += A; if (count > 0) temp -= 1; count++; } } else { if (B == 1) count = 0; else count = 1; } Console.WriteLine(count.ToString()); // Console.Read(); } } }
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 95], ["+", 75, 196, 0, 57, 75, 1, 0, 11, 31, 22]]
8
140
11
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC_Training { class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); Console.WriteLine(Ans(a, b)); } static int Ans(int x, int y) { if (x >= y) { return 1; } var amari = y - x; var count = 1; while (amari > 0) { amari -= x - 1; count++; } return count; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC_Training { class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); Console.WriteLine(Ans(a, b)); } static int Ans(int x, int y) { if (y == 1) { return 0; } if (x >= y) { return 1; } var amari = y - x; var count = 1; while (amari > 0) { amari -= x - 1; count++; } return count; } } }
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24]]
8
155
11
using System; namespace pro { class MainClass { public static void Main() { string[] str = Console.ReadLine().Split(' '); int a = int.Parse(str[0]); int b = int.Parse(str[1]); int kuti = a; int count = 1; if (a >= b) { Console.WriteLine(1); } else { while (kuti < b) { kuti += (a - 1); count++; } Console.WriteLine(count); } } } }
using System; namespace pro { class MainClass { public static void Main() { string[] str = Console.ReadLine().Split(' '); int a = int.Parse(str[0]); int b = int.Parse(str[1]); int kuti = a; int count = 1; if (b == 1) { Console.WriteLine(0); } else if (a >= b) { Console.WriteLine(1); } else { while (kuti < b) { kuti += (a - 1); count++; } Console.WriteLine(count); } } } }
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 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
117
16
using System; public class Test { public static void Main() { string[] input = Console.ReadLine().Trim().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int sum = 0; int count = 0; while (sum < B) { if (sum == 0) { sum += A; } else { sum += (A - 1); } count++; } Console.WriteLine(count); } }
using System; public class Test { public static void Main() { string[] input = Console.ReadLine().Trim().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int sum = 0; int count = 0; if (B == 1) { Console.WriteLine(0); return; } while (sum < B) { if (sum == 0) { sum += A; } else { sum += (A - 1); } count++; } Console.WriteLine(count); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 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
115
17
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { var array = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray(); var A = array[0]; var B = array[1]; var mod = (B - 1) / A; Console.WriteLine(mod + 1); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { var array = Console.ReadLine().Split().Select(_ => decimal.Parse(_)).ToArray(); var A = array[0]; var B = array[1]; var c = Math.Ceiling((B - 1) / (A - 1)); Console.WriteLine(c); } } }
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
99
17
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var a = cin.nextInt(); var b = cin.nextInt(); var ans = 0; var canuse = 0; while (true) { canuse += a; ans++; if (canuse >= b) { break; } canuse--; } Console.WriteLine(ans); } } #region library static class C { public static long LowerBound(long[] a, long key) { long l = 0; long r = a.Length; long mid; while (l < r) { mid = ((r - l) / 2) + l; if (a[mid] <= key) l = mid + 1; else r = mid; } return l; } public static long UpperBound(long[] a, long key) { long l = 0; long r = a.Length; long mid; while (l < r) { mid = ((r - l) / 2) + l; if (a[mid] < key) l = mid + 1; else r = mid; } return l; } } public static partial class MathEx { public static int GCD(int n, int m) { return (int)GCD((long)n, m); } public static long GCD(long n, long m) { n = Math.Abs(n); m = Math.Abs(m); while (n != 0) { m %= n; if (m == 0) return n; n %= m; } return m; } public static long LCM(long n, long m) { return (n / GCD(n, m)) * m; } public static bool[] Sieve(int max, List<int> primes = null) { var isPrime = new bool[max + 1]; for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true; for (int i = 2; i * i <= max; i++) if (!isPrime[i]) continue; else for (int j = i * i; j <= max; j += i) isPrime[j] = false; if (primes != null) for (int i = 0; i <= max; i++) if (isPrime[i]) primes.Add(i); return isPrime; } } static class Subsequence { /// <summary> /// 最長増加部分列 /// </summary> /// <param name="a">long[]</param> /// <returns></returns> public static long LIS(long[] a) { var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray(); for (int i = 0; i < a.Length; i++) { dp[C.LowerBound(dp, a[i])] = a[i]; } return C.LowerBound(dp, long.MaxValue - 1); } /// <summary> /// 重複を許さない最長増加部分列 /// </summary> /// <param name="a">long[]</param> /// <returns></returns> public static long UniqueLIS(long[] a) { var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray(); for (int i = 0; i < a.Length; i++) { dp[C.UpperBound(dp, a[i])] = a[i]; } return C.UpperBound(dp, long.MaxValue - 1); } } class PriorityQueue<T> { private readonly List<T> heap; private readonly Comparison<T> compare; private int size; public PriorityQueue() : this(Comparer<T>.Default) {} public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) {} public PriorityQueue(Comparison<T> comparison) : this(16, comparison) {} public PriorityQueue(int capacity, Comparison<T> comparison) { this.heap = new List<T>(capacity); this.compare = comparison; } public void Enqueue(T item) { this.heap.Add(item); var i = size++; while (i > 0) { var p = (i - 1) >> 1; if (compare(this.heap[p], item) <= 0) break; this.heap[i] = heap[p]; i = p; } this.heap[i] = item; } public T Dequeue() { var ret = this.heap[0]; var x = this.heap[--size]; var i = 0; while ((i << 1) + 1 < size) { var a = (i << 1) + 1; var b = (i << 1) + 2; if (b < size && compare(heap[b], heap[a]) < 0) a = b; if (compare(heap[a], x) >= 0) break; heap[i] = heap[a]; i = a; } heap[i] = x; heap.RemoveAt(size); return ret; } public T Peek() { return heap[0]; } public int Count { get { return size; } } public bool Any() { return size > 0; } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } public class ModInt { public static long Mod; public long num; public ModInt(long n, int mod = (int)1e9 + 7) { num = n; Mod = mod; } public override string ToString() { return num.ToString(); } public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; } public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; } public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); } public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); } public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); } public static ModInt Pow(long v, long k) { long ret = 1; for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod) if ((k & 1) == 1) ret = ret * v % Mod; return new ModInt(ret); } public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); } } #endregion class Program { static void Main(string[] s) => new Solver().Solve(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var a = cin.nextInt(); var b = cin.nextInt(); if (b == 1) { Console.WriteLine(0); return; } var ans = 0; var canuse = 0; while (true) { canuse += a; ans++; if (canuse >= b) { break; } canuse--; } Console.WriteLine(ans); } } #region library static class C { public static long LowerBound(long[] a, long key) { long l = 0; long r = a.Length; long mid; while (l < r) { mid = ((r - l) / 2) + l; if (a[mid] <= key) l = mid + 1; else r = mid; } return l; } public static long UpperBound(long[] a, long key) { long l = 0; long r = a.Length; long mid; while (l < r) { mid = ((r - l) / 2) + l; if (a[mid] < key) l = mid + 1; else r = mid; } return l; } } public static partial class MathEx { public static int GCD(int n, int m) { return (int)GCD((long)n, m); } public static long GCD(long n, long m) { n = Math.Abs(n); m = Math.Abs(m); while (n != 0) { m %= n; if (m == 0) return n; n %= m; } return m; } public static long LCM(long n, long m) { return (n / GCD(n, m)) * m; } public static bool[] Sieve(int max, List<int> primes = null) { var isPrime = new bool[max + 1]; for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true; for (int i = 2; i * i <= max; i++) if (!isPrime[i]) continue; else for (int j = i * i; j <= max; j += i) isPrime[j] = false; if (primes != null) for (int i = 0; i <= max; i++) if (isPrime[i]) primes.Add(i); return isPrime; } } static class Subsequence { /// <summary> /// 最長増加部分列 /// </summary> /// <param name="a">long[]</param> /// <returns></returns> public static long LIS(long[] a) { var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray(); for (int i = 0; i < a.Length; i++) { dp[C.LowerBound(dp, a[i])] = a[i]; } return C.LowerBound(dp, long.MaxValue - 1); } /// <summary> /// 重複を許さない最長増加部分列 /// </summary> /// <param name="a">long[]</param> /// <returns></returns> public static long UniqueLIS(long[] a) { var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray(); for (int i = 0; i < a.Length; i++) { dp[C.UpperBound(dp, a[i])] = a[i]; } return C.UpperBound(dp, long.MaxValue - 1); } } class PriorityQueue<T> { private readonly List<T> heap; private readonly Comparison<T> compare; private int size; public PriorityQueue() : this(Comparer<T>.Default) {} public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) {} public PriorityQueue(Comparison<T> comparison) : this(16, comparison) {} public PriorityQueue(int capacity, Comparison<T> comparison) { this.heap = new List<T>(capacity); this.compare = comparison; } public void Enqueue(T item) { this.heap.Add(item); var i = size++; while (i > 0) { var p = (i - 1) >> 1; if (compare(this.heap[p], item) <= 0) break; this.heap[i] = heap[p]; i = p; } this.heap[i] = item; } public T Dequeue() { var ret = this.heap[0]; var x = this.heap[--size]; var i = 0; while ((i << 1) + 1 < size) { var a = (i << 1) + 1; var b = (i << 1) + 2; if (b < size && compare(heap[b], heap[a]) < 0) a = b; if (compare(heap[a], x) >= 0) break; heap[i] = heap[a]; i = a; } heap[i] = x; heap.RemoveAt(size); return ret; } public T Peek() { return heap[0]; } public int Count { get { return size; } } public bool Any() { return size > 0; } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } public class ModInt { public static long Mod; public long num; public ModInt(long n, int mod = (int)1e9 + 7) { num = n; Mod = mod; } public override string ToString() { return num.ToString(); } public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; } public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; } public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); } public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); } public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); } public static ModInt Pow(long v, long k) { long ret = 1; for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod) if ((k & 1) == 1) ret = ret * v % Mod; return new ModInt(ret); } public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); } } #endregion class Program { static void Main(string[] s) => new Solver().Solve(); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 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,790
17
using System; using System.Linq; namespace ABC139_B { class Program { static void Main(string[] args) { var AB = Console.ReadLine().Split().Select(int.Parse).ToArray(); var A = AB[0]; var B = AB[1]; var ans = 1; var sum = A; while (true) { if (sum >= B) { break; } ans++; sum += A - 1; } Console.WriteLine(ans); } } }
using System; using System.Linq; namespace ABC139_B { class Program { static void Main(string[] args) { var AB = Console.ReadLine().Split().Select(int.Parse).ToArray(); var A = AB[0]; var B = AB[1]; if (B == 1) { Console.WriteLine(0); return; } var ans = 1; var sum = A; while (true) { if (sum >= B) { break; } ans++; sum += A - 1; } Console.WriteLine(ans); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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
109
17
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp5 { class Program { static void Main(string[] args) { String S = Console.ReadLine(); String[] line = S.Split(' '); int A = int.Parse(line[0]); int B = int.Parse(line[1]); int socket = 1; int ans = 0; while (true) { socket--; socket = socket + A; ans++; if (socket >= B) { break; } } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp5 { class Program { static void Main(string[] args) { String S = Console.ReadLine(); String[] line = S.Split(' '); int A = int.Parse(line[0]); int B = int.Parse(line[1]); int socket = 1; int ans = 0; while (true) { if (socket >= B) { break; } socket--; socket = socket + A; ans++; } Console.WriteLine(ans); } } }
[["+", 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, 20], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 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, 1, 0, 35], ["-", 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, 20], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 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], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
8
140
20
using System; using System.Linq; using System.Collections.Generic; namespace Algorithm { class Program { static void Main(string[] args) { var l = Console.ReadLine().Split().Select(int.Parse).ToArray(); int A = l[0], B = l[1]; var ans = A; var count = 1; B -= A; while (B > 0) { B -= A - 1; count++; } Console.WriteLine(count); } } }
using System; using System.Linq; using System.Collections.Generic; namespace Algorithm { class Program { static void Main(string[] args) { var l = Console.ReadLine().Split().Select(int.Parse).ToArray(); int A = l[0], B = l[1]; if (B == 1) { Console.WriteLine(0); return; } var ans = A; var count = 1; B -= A; while (B > 0) { B -= A - 1; count++; } Console.WriteLine(count); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 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
111
17
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace ABC189 { public class Program { #region templete private static void WL(string s) { WriteLine(s); } /// <summary> /// 最小公倍数 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> static long Gcd(long a, long b) { var v = new[] { a, b }; while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; } return v[0]; } /// <summary> /// 最小公約数 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> static long Lcm(long a, long b) { return a / Gcd(a, b) * b; } static void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; } static void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; } public static bool Inside(int x, int a, int b) { return (a <= x && x <= b) ? true : false; } public static bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = Math.Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } public static void Main(string[] args) { new Program().Solve(); ReadLine(); } #endregion public void Solve() { var cin = new Scanner(); var a = cin.nextInt(); var b = cin.nextInt(); int sum = a; if (sum >= b) { WL($"1"); return; } for (int cnt = 2; cnt < 100; cnt++) { sum += a - 1; if (sum >= b) { WL($"{cnt}"); return; } } } } } #region console in 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; } } #endregion
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace ABC189 { public class Program { #region templete private static void WL(string s) { WriteLine(s); } /// <summary> /// 最小公倍数 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> static long Gcd(long a, long b) { var v = new[] { a, b }; while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; } return v[0]; } /// <summary> /// 最小公約数 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> static long Lcm(long a, long b) { return a / Gcd(a, b) * b; } static void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; } static void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; } public static bool Inside(int x, int a, int b) { return (a <= x && x <= b) ? true : false; } public static bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = Math.Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } public static void Main(string[] args) { new Program().Solve(); ReadLine(); } #endregion public void Solve() { var cin = new Scanner(); var a = cin.nextInt(); var b = cin.nextInt(); int sum = a; if (b == 1) { WL($"0"); return; } if (sum >= b) { WL($"1"); return; } for (int cnt = 2; cnt < 100; cnt++) { sum += a - 1; if (sum >= b) { WL($"{cnt}"); return; } } } } } #region console in 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; } } #endregion
[["+", 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, 283, 0, 295], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 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
833
17
using System; using static System.Console; using System.Collections.Generic; using System.Linq; namespace Atcoder { class Program { static void Main(string[] args) { var input = InputNumList(); int a = input[0]; int b = input[1]; int tmp = a; int cnt = 1; while (true) { if (a >= b) break; a += tmp; a -= 1; cnt++; } WriteLine(cnt); } static int InputNum() { return int.Parse(ReadLine()); } static List<int> InputNumList() { return ReadLine().Split(' ').Select(int.Parse).ToList(); } } }
using System; using static System.Console; using System.Collections.Generic; using System.Linq; namespace Atcoder { class Program { static void Main(string[] args) { var input = InputNumList(); int a = input[0]; int b = input[1]; int tmp = a; int cnt = 1; while (true) { if (a >= b) break; a += tmp; a -= 1; cnt++; } if (b == 1) cnt = 0; WriteLine(cnt); } static int InputNum() { return int.Parse(ReadLine()); } static List<int> InputNumList() { return ReadLine().Split(' ').Select(int.Parse).ToList(); } } }
[["+", 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], ["+", 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
153
10
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using static System.Math; namespace NewCompetitionProgramming { public class Program { public static void Main(string[] args) { using (var sc = new SetConsole()) { Solve(); } } public static void Solve() { var ab = GetArray<int>(); var openCount = 1; var countTap = 0; while (ab[1] > openCount) { if (openCount == 1) { openCount = ab[0]; } else { openCount += ab[0]; } countTap++; } CWrite(countTap); } static void CWrite<T>(T str) => Console.WriteLine(str); static string GetString() => Console.ReadLine(); static T[] GetArray<T>() { var t = typeof(T); var str = Console.ReadLine(); if (t == typeof(string)) { return (T[])(object)str.Split(); } if (t == typeof(int)) { return (T[])(object)str.ToNumArray<T>(); } if (t == typeof(long)) { return (T[])(object)str.ToNumArray<T>(); } if (t == typeof(double)) { return (T[])(object)str.ToNumArray<T>(); } throw new NotSupportedException($"{t} is not supported."); } } class SetConsole : IDisposable { readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); public SetConsole() { sw.AutoFlush = false; Console.SetOut(sw); } public void Dispose() { Console.Out.Flush(); sw.AutoFlush = true; Console.SetOut(sw); } } static class ExtentionsLibrary { public static T[] CopyArray<T>(this T[] array) { var newArray = new T[array.Length]; Array.Copy(array, newArray, array.Length); return newArray; } public static T[,] CopyTwoDimensionalArray<T>(this T[,] dArray) { var firstDimentionLength = dArray.GetLength(0); var secondDimentionLength = dArray.GetLength(1); var newDArray = new T[firstDimentionLength, secondDimentionLength]; Array.Copy(dArray, newDArray, firstDimentionLength * secondDimentionLength); return newDArray; } public static T[] ToNumArray<T>(this string str) { var t = typeof(T); if (t == typeof(int)) { return (T[])(object)str.Split().Select(int.Parse).ToArray(); } if (t == typeof(long)) { return (T[])(object)str.Split().Select(long.Parse).ToArray(); } if (t == typeof(double)) { return (T[])(object)str.Split().Select(double.Parse).ToArray(); } throw new NotSupportedException(); } public static int ToInt(this string str) => int.Parse(str); public static int ToInt(this char chr) => int.Parse(chr.ToString()); public static long ToLong(this string str) => long.Parse(str); } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using static System.Math; namespace NewCompetitionProgramming { public class Program { public static void Main(string[] args) { using (var sc = new SetConsole()) { Solve(); } } public static void Solve() { var ab = GetArray<int>(); var openCount = 1; var countTap = 0; while (ab[1] > openCount) { openCount += ab[0] - 1; countTap++; } CWrite(countTap); } static void CWrite<T>(T str) => Console.WriteLine(str); static string GetString() => Console.ReadLine(); static T[] GetArray<T>() { var t = typeof(T); var str = Console.ReadLine(); if (t == typeof(string)) { return (T[])(object)str.Split(); } if (t == typeof(int)) { return (T[])(object)str.ToNumArray<T>(); } if (t == typeof(long)) { return (T[])(object)str.ToNumArray<T>(); } if (t == typeof(double)) { return (T[])(object)str.ToNumArray<T>(); } throw new NotSupportedException($"{t} is not supported."); } } class SetConsole : IDisposable { readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); public SetConsole() { sw.AutoFlush = false; Console.SetOut(sw); } public void Dispose() { Console.Out.Flush(); sw.AutoFlush = true; Console.SetOut(sw); } } static class ExtentionsLibrary { public static T[] CopyArray<T>(this T[] array) { var newArray = new T[array.Length]; Array.Copy(array, newArray, array.Length); return newArray; } public static T[,] CopyTwoDimensionalArray<T>(this T[,] dArray) { var firstDimentionLength = dArray.GetLength(0); var secondDimentionLength = dArray.GetLength(1); var newDArray = new T[firstDimentionLength, secondDimentionLength]; Array.Copy(dArray, newDArray, firstDimentionLength * secondDimentionLength); return newDArray; } public static T[] ToNumArray<T>(this string str) { var t = typeof(T); if (t == typeof(int)) { return (T[])(object)str.Split().Select(int.Parse).ToArray(); } if (t == typeof(long)) { return (T[])(object)str.Split().Select(long.Parse).ToArray(); } if (t == typeof(double)) { return (T[])(object)str.Split().Select(double.Parse).ToArray(); } throw new NotSupportedException(); } public static int ToInt(this string str) => int.Parse(str); public static int ToInt(this char chr) => int.Parse(chr.ToString()); public static long ToLong(this string str) => long.Parse(str); } }
[["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 95], ["-", 0, 52, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 57, 75, 196, 0, 46]]
8
709
20
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace AtCodeeeer { class AtCOOOOOOOOOOOder { static void Main(string[] args) { var s = ReadLine().Split(' ').Select(int.Parse).ToArray(); int a = s[0]; int b = s[1]; int now = a; int ans = 1; while (now < b) { now += a - 1; ans++; } WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace AtCodeeeer { class AtCOOOOOOOOOOOder { static void Main(string[] args) { var s = ReadLine().Split(' ').Select(int.Parse).ToArray(); int a = s[0]; int b = s[1]; int now = a; int ans = 1; while (now < b) { now -= 1; now += a; ans++; } WriteLine(b == 1 ? 0 : ans); } } }
[["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102]]
8
129
12
using System; using System.Linq; namespace ABC139 { class Program { static void Main() { var input = Console.ReadLine().Split(' ').Select(decimal.Parse); var A = input.First(); var B = input.Skip(1).First(); Console.WriteLine(Math.Ceiling(B / A)); } } }
using System; using System.Linq; namespace ABC139 { class Program { static void Main() { var input = Console.ReadLine().Split(' ').Select(decimal.Parse); var A = input.First(); var B = input.Skip(1).First(); Console.WriteLine(Math.Ceiling((B - 1) / (A - 1))); } } }
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
8
83
8
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using static Library.Comfort; using static Library.Math; using static Library.Algorithm; using static System.Math; using System.ComponentModel; using Microsoft.Win32; namespace AtCoderer { public class App { public static void Solve() { int a, b; Parse(out a, out b); a--; b--; cout = (b - 1) / a + 1; } public static void Main(string[] args) { #if DEBUG while (true) { Solve(); } #else Solve(); #endif } } } namespace Library { public static class Comfort { public const int mod = 1000000007; public class Point { public int a; public int b; public Point(int a, int b) { this.a = a; this.b = b; } } public static int[] OrderBy(this int[] IArr) { int[] arr = new int[IArr.Length]; Array.Copy(IArr, arr, IArr.Length); Array.Sort(arr); return arr; } public static int Max(params int[] p) => p.Max(); public static long Max(params long[] p) => p.Max(); public static int Min(params int[] p) => p.Min(); public static long Min(params long[] p) => p.Min(); public static int In() { return int.Parse(Console.ReadLine()); } public static int Inl() { return int.Parse(Console.ReadLine()); } public static int[] Parsed; public static int[] Parse() { Parsed = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); return Parsed; } public static long[] Parsel() { return Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); } public static void Parse(out int a, out int b) { var r = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); a = r[0]; b = r[1]; } public static void Parse(out int a, out int b, out int c) { var r = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; } public static void Parse(out int a, out int b, out int c, out int d) { var r = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; d = r[3]; } public static void Parse(out long a, out long b) { var r = Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); a = r[0]; b = r[1]; } public static void Parse(out long a, out long b, out long c) { var r = Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; } public static void Parse(out long a, out long b, out long c, out long d) { var r = Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; d = r[3]; } public static string ToString(this IEnumerable<char> v) { return string.Join("", v); } public static string Join<T>(this IEnumerable<T> v) { return string.Join(" ", v); } public static string Join<T>(this IEnumerable<T> v, char c) { return string.Join(c.ToString(), v); } public static string Join<T>(this IEnumerable<T> v, string s) { return string.Join(s, v); } public static object cout { set { Console.WriteLine(value); } } public static object dbg { set { #if DEBUG Console.WriteLine(value); #endif } } public static object dout { set { dbg = value; } } } public static class Math { public static bool IsNatural(this float v) => v - (int)v == 0; public static bool IsNatural(this double v) => v - (int)v == 0; public static long nCm(long n, long m) { if (m == 0) return 1; if (n == 0) return 0; return n * nCm(n - 1, m - 1) / m; } public static IEnumerable<int> Factor(int n) { int i = 2; int tmp = n; while (i * i <= n) { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } public static int Gcd(int a, int b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static int GcdRecursive(int x, int y) => y == 0 ? x : GcdRecursive(y, x % y); public static long Gcd(long a, long b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static long GcdRecursive(long x, long y) => y == 0 ? x : GcdRecursive(y, x % y); public static long Lcm(int a, int b) => ((long)a) * b / Gcd(a, b); } public static class Algorithm { public static IEnumerable<KeyValuePair<T, int>> UniteNext<T>(this IEnumerable<T> arr) where T : IEquatable<T> { int cont = 0; T prev = arr.First(); foreach (var v in arr) { if (v.Equals(prev)) { cont++; } else { yield return new KeyValuePair<T, int>(prev, cont); cont = 1; } prev = v; } yield return new KeyValuePair<T, int>(prev, cont); } public class EnumAll { bool Over = false; int UpperValue; int Dimension; public int[] Current { private set; get; } public EnumAll(int MaxValue, int Dimension) { this.Dimension = Dimension; UpperValue = MaxValue; Current = new int[Dimension]; Current[0] = -1; } public bool Next() { if (Over) return false; bool flag = false; for (int i = 0; i < Dimension; i++) { if (++Current[i] >= UpperValue) Current[i] = 0; else { flag = true; break; } } if (!flag) { Over = true; return false; } return true; } } public class Graph { public int Count = -1; private HashSet<int>[] Joined; public static Graph GenerateComplete(int size) { throw new NotImplementedException(); } public Graph(int size) { Joined = new HashSet<int>[size]; for (int i = 0; i < Joined.Length; i++) Joined[i] = new HashSet<int>(); Count = size; } public int[] GetConnected(int index) { return Joined[index].ToArray(); } public void AddEdge(int a, int b) { if (a == b) dbg = "ループを追加することはできません A:" + a + " B:" + b; else { if (!Joined[a].Add(b)) dbg = "多重辺を追加することはできません A:" + a + " B:" + b; else Joined[b].Add(a); } } public int[] ToTree(int Root) { var ar = new int[Count]; for (int i = 0; i < ar.Length; i++) ar[i] = -10000000; ar[Root] = -1; Queue<int> bfs = new Queue<int>(); bfs.Enqueue(Root); while (bfs.Count != 0) { var t = bfs.Dequeue(); foreach (var v in Joined[t]) { bfs.Enqueue(v); if (ar[v] == -10000000) ar[v] = t; } } return ar; } } public class UnionFind { private int[] Parent; private int GetRoot(int v) { if (Parent[v] < 0) return v; else return Parent[v] = GetRoot(Parent[v]); } public UnionFind(int size) { Parent = new int[size]; for (int i = 0; i < size; i++) Parent[i] = -1; } public bool AreGrouped(int a, int b) { return GetRoot(a) == GetRoot(b); } public void Connect(int a, int b) { a = GetRoot(a); b = GetRoot(b); if (a == b) return; if (Parent[b] < Parent[a]) { Parent[b] += Parent[a]; Parent[a] = b; } else { Parent[a] += Parent[b]; Parent[b] = a; } } public int GetGroupSize(int a) { return -Parent[GetRoot(a)]; } } public class PriorityQueue<T> where T : IComparable { List<T> buffer = new List<T>(); static void PushHeap(List<T> array, T elem) { int n = array.Count; array.Add(elem); while (n != 0) { int i = (n - 1) / 2; if (array[n].CompareTo(array[i]) < 0) { T tmp = array[n]; array[n] = array[i]; array[i] = tmp; } n = i; } } static void PopHeap(List<T> array) { int n = array.Count - 1; array[0] = array[n]; array.RemoveAt(array.Count - 1); for (int i = 0, j; (j = 2 * i + 1) < n;) { if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) > 0)) j++; if (array[i].CompareTo(array[j]) > 0) { T tmp = array[j]; array[j] = array[i]; array[i] = tmp; } i = j; } } public int Count { get { return buffer.Count; } } public void Push(T elem) { PushHeap(this.buffer, elem); } public T Peek() { return buffer[0]; } public T Pop() { T a = buffer[0]; PopHeap(this.buffer); return a; } } public class KMP { int[] Table; string a, b; int m = 0; int i = 0; public KMP(string a) { this.a = a; Table = new int[a.Length]; int subindex = 0; Table[0] = -1; Table[1] = 0; for (int i = 2; i < a.Length;) { if (a[i - 1] == a[subindex]) { subindex++; Table[i] = subindex; i++; } else if (subindex > 0) subindex = Table[subindex]; else { Table[i] = 0; i++; } } } public void SetSearchBase(string v) { b = v; m = 0; i = 0; } public int Search() { m++; i = 0; while (m + i < b.Length) { if (a[i] == b[m + i]) { i++; if (i == a.Length) return m; } else { m = m + i - Table[i]; if (i > 0) i = Table[i]; } } return -1; } } } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using static Library.Comfort; using static Library.Math; using static Library.Algorithm; using static System.Math; using System.ComponentModel; using Microsoft.Win32; namespace AtCoderer { public class App { public static void Solve() { float a, b; a = Parse()[0]; b = Parsed[1]; a--; b--; cout = Ceiling(b / a); } public static void Main(string[] args) { #if DEBUG while (true) { Solve(); } #else Solve(); #endif } } } namespace Library { public static class Comfort { public const int mod = 1000000007; public class Point { public int a; public int b; public Point(int a, int b) { this.a = a; this.b = b; } } public static int[] OrderBy(this int[] IArr) { int[] arr = new int[IArr.Length]; Array.Copy(IArr, arr, IArr.Length); Array.Sort(arr); return arr; } public static int Max(params int[] p) => p.Max(); public static long Max(params long[] p) => p.Max(); public static int Min(params int[] p) => p.Min(); public static long Min(params long[] p) => p.Min(); public static int In() { return int.Parse(Console.ReadLine()); } public static int Inl() { return int.Parse(Console.ReadLine()); } public static int[] Parsed; public static int[] Parse() { Parsed = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); return Parsed; } public static long[] Parsel() { return Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); } public static void Parse(out int a, out int b) { var r = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); a = r[0]; b = r[1]; } public static void Parse(out int a, out int b, out int c) { var r = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; } public static void Parse(out int a, out int b, out int c, out int d) { var r = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; d = r[3]; } public static void Parse(out long a, out long b) { var r = Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); a = r[0]; b = r[1]; } public static void Parse(out long a, out long b, out long c) { var r = Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; } public static void Parse(out long a, out long b, out long c, out long d) { var r = Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray(); a = r[0]; b = r[1]; c = r[2]; d = r[3]; } public static string ToString(this IEnumerable<char> v) { return string.Join("", v); } public static string Join<T>(this IEnumerable<T> v) { return string.Join(" ", v); } public static string Join<T>(this IEnumerable<T> v, char c) { return string.Join(c.ToString(), v); } public static string Join<T>(this IEnumerable<T> v, string s) { return string.Join(s, v); } public static object cout { set { Console.WriteLine(value); } } public static object dbg { set { #if DEBUG Console.WriteLine(value); #endif } } public static object dout { set { dbg = value; } } } public static class Math { public static bool IsNatural(this float v) => v - (int)v == 0; public static bool IsNatural(this double v) => v - (int)v == 0; public static long nCm(long n, long m) { if (m == 0) return 1; if (n == 0) return 0; return n * nCm(n - 1, m - 1) / m; } public static IEnumerable<int> Factor(int n) { int i = 2; int tmp = n; while (i * i <= n) { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } public static int Gcd(int a, int b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static int GcdRecursive(int x, int y) => y == 0 ? x : GcdRecursive(y, x % y); public static long Gcd(long a, long b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static long GcdRecursive(long x, long y) => y == 0 ? x : GcdRecursive(y, x % y); public static long Lcm(int a, int b) => ((long)a) * b / Gcd(a, b); } public static class Algorithm { public static IEnumerable<KeyValuePair<T, int>> UniteNext<T>(this IEnumerable<T> arr) where T : IEquatable<T> { int cont = 0; T prev = arr.First(); foreach (var v in arr) { if (v.Equals(prev)) { cont++; } else { yield return new KeyValuePair<T, int>(prev, cont); cont = 1; } prev = v; } yield return new KeyValuePair<T, int>(prev, cont); } public class EnumAll { bool Over = false; int UpperValue; int Dimension; public int[] Current { private set; get; } public EnumAll(int MaxValue, int Dimension) { this.Dimension = Dimension; UpperValue = MaxValue; Current = new int[Dimension]; Current[0] = -1; } public bool Next() { if (Over) return false; bool flag = false; for (int i = 0; i < Dimension; i++) { if (++Current[i] >= UpperValue) Current[i] = 0; else { flag = true; break; } } if (!flag) { Over = true; return false; } return true; } } public class Graph { public int Count = -1; private HashSet<int>[] Joined; public static Graph GenerateComplete(int size) { throw new NotImplementedException(); } public Graph(int size) { Joined = new HashSet<int>[size]; for (int i = 0; i < Joined.Length; i++) Joined[i] = new HashSet<int>(); Count = size; } public int[] GetConnected(int index) { return Joined[index].ToArray(); } public void AddEdge(int a, int b) { if (a == b) dbg = "ループを追加することはできません A:" + a + " B:" + b; else { if (!Joined[a].Add(b)) dbg = "多重辺を追加することはできません A:" + a + " B:" + b; else Joined[b].Add(a); } } public int[] ToTree(int Root) { var ar = new int[Count]; for (int i = 0; i < ar.Length; i++) ar[i] = -10000000; ar[Root] = -1; Queue<int> bfs = new Queue<int>(); bfs.Enqueue(Root); while (bfs.Count != 0) { var t = bfs.Dequeue(); foreach (var v in Joined[t]) { bfs.Enqueue(v); if (ar[v] == -10000000) ar[v] = t; } } return ar; } } public class UnionFind { private int[] Parent; private int GetRoot(int v) { if (Parent[v] < 0) return v; else return Parent[v] = GetRoot(Parent[v]); } public UnionFind(int size) { Parent = new int[size]; for (int i = 0; i < size; i++) Parent[i] = -1; } public bool AreGrouped(int a, int b) { return GetRoot(a) == GetRoot(b); } public void Connect(int a, int b) { a = GetRoot(a); b = GetRoot(b); if (a == b) return; if (Parent[b] < Parent[a]) { Parent[b] += Parent[a]; Parent[a] = b; } else { Parent[a] += Parent[b]; Parent[b] = a; } } public int GetGroupSize(int a) { return -Parent[GetRoot(a)]; } } public class PriorityQueue<T> where T : IComparable { List<T> buffer = new List<T>(); static void PushHeap(List<T> array, T elem) { int n = array.Count; array.Add(elem); while (n != 0) { int i = (n - 1) / 2; if (array[n].CompareTo(array[i]) < 0) { T tmp = array[n]; array[n] = array[i]; array[i] = tmp; } n = i; } } static void PopHeap(List<T> array) { int n = array.Count - 1; array[0] = array[n]; array.RemoveAt(array.Count - 1); for (int i = 0, j; (j = 2 * i + 1) < n;) { if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) > 0)) j++; if (array[i].CompareTo(array[j]) > 0) { T tmp = array[j]; array[j] = array[i]; array[i] = tmp; } i = j; } } public int Count { get { return buffer.Count; } } public void Push(T elem) { PushHeap(this.buffer, elem); } public T Peek() { return buffer[0]; } public T Pop() { T a = buffer[0]; PopHeap(this.buffer); return a; } } public class KMP { int[] Table; string a, b; int m = 0; int i = 0; public KMP(string a) { this.a = a; Table = new int[a.Length]; int subindex = 0; Table[0] = -1; Table[1] = 0; for (int i = 2; i < a.Length;) { if (a[i - 1] == a[subindex]) { subindex++; Table[i] = subindex; i++; } else if (subindex > 0) subindex = Table[subindex]; else { Table[i] = 0; i++; } } } public void SetSearchBase(string v) { b = v; m = 0; i = 0; } public int Search() { m++; i = 0; while (m + i < b.Length) { if (a[i] == b[m + i]) { i++; if (i == a.Length) return m; } else { m = m + i - Table[i]; if (i > 0) i = Table[i]; } } return -1; } } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 268], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 213, 63, 22], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
8
2,690
26
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); return; } public void Solve(ConsoleInput cin) { var A = cin.ReadInt; var B = cin.ReadInt; var ans = B / (A - 1) + 1; Console.WriteLine(ans); } } public static class Extensions { public static string Reverse(this string sourse) { char[] chrAry = sourse.ToCharArray(); Array.Reverse(chrAry); return new string(chrAry); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); return; } public void Solve(ConsoleInput cin) { var A = cin.ReadInt; var B = cin.ReadInt; var ans = 0; var count = 1; while (count < B) { count += A - 1; ans++; } Console.WriteLine(ans); } } public static class Extensions { public static string Reverse(this string sourse) { char[] chrAry = sourse.ToCharArray(); Array.Reverse(chrAry); return new string(chrAry); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
[["-", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 85], ["+", 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], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 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], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 212, 0, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
8
502
24
using System; using System.Linq; //リストの使用 using System.Collections.Generic; using System.Text; //テキストの高速出力に必要 class Program { static void Main() { string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); int answer = 1; int answerMemo = a; while (answerMemo < b) { answerMemo += a - 1; answer++; } Console.WriteLine(answer); } }
using System; using System.Linq; //リストの使用 using System.Collections.Generic; using System.Text; //テキストの高速出力に必要 class Program { static void Main() { string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); int answer = 1; int answerMemo = a; while (answerMemo < b) { answerMemo += a - 1; answer++; } if (b == 1) answer = 0; Console.WriteLine(answer); } }
[["+", 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], ["+", 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
111
10
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; using static MyIO; public class B { public static void Main() => (new Solver()).Solve(); } public class Solver { public void Solve() { int A = GetInt(); int B = GetInt(); Console.WriteLine((B - 1) / A + 1); } } public static class MyIO { private static string[] args = null; private static int num = -1; private static int used = -1; private static string getArg() { if (used == num) { args = Console.ReadLine().Split(' '); num = args.Length; used = 0; } return args[used++]; } public static int GetInt() => int.Parse(getArg()); public static long GetLong() => long.Parse(getArg()); public static double GetDouble() => double.Parse(getArg()); public static string GetString() => getArg(); public static char GetChar() => getArg()[0]; public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray(); public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray(); public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray(); public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray(); }
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; using static MyIO; public class B { public static void Main() => (new Solver()).Solve(); } public class Solver { public void Solve() { int A = GetInt(); int B = GetInt(); int res = 0; int num = 1; while (num < B) { num = num - 1 + A; res++; } Console.WriteLine(res); } } public static class MyIO { private static string[] args = null; private static int num = -1; private static int used = -1; private static string getArg() { if (used == num) { args = Console.ReadLine().Split(' '); num = args.Length; used = 0; } return args[used++]; } public static int GetInt() => int.Parse(getArg()); public static long GetLong() => long.Parse(getArg()); public static double GetDouble() => double.Parse(getArg()); public static string GetString() => getArg(); public static char GetChar() => getArg()[0]; public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray(); public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray(); public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray(); public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray(); }
[["-", 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, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["-", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 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
377
37
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var hs = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray(); var max = 0; var from = 0; for (var i = 1; i < n; i++) { if (hs[i] > hs[i - 1]) { from = i; if (i - from > max) max = i - from; } } if (n - 1 - from > max) max = n - 1 - from; Console.WriteLine(max); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var hs = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray(); var max = 0; var from = 0; for (var i = 1; i < n; i++) { if (hs[i] > hs[i - 1]) { if (i - from > max) max = i - from - 1; from = i; } } if (n - 1 - from > max) max = n - 1 - from; Console.WriteLine(max); } } }
[["-", 64, 196, 0, 1, 0, 11, 31, 22, 0, 314], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 16, 12, 22, 0, 314], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
8
170
10
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] H = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int[] ans = new int[N]; // for (int i = 1; i < N; i++) //{ // if(H[i] <= H[i - 1]) // ans[i] = ans[i - 1] + 1; // else // ans[i] = 0; //} for (int i = N - 1; i > 0; i++) { if (H[i] >= H[i + 1]) ans[i] = ans[i + 1] + 1; else ans[i] = 0; } Console.WriteLine(ans.Max()); Console.ReadKey(); } } // string s = Console.ReadLine(); // int[] intArray = Console.ReadLine().Split(' ').Select(i => // int.Parse(i)).ToArray(); int H = intArray[0]; int W = intArray[1]; int N = // int.Parse(Console.ReadLine()); List<int> A = new // List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray()); // Boolean ok = false; // Console.WriteLine(ans); // Console.WriteLine("Yes"); // Console.WriteLine("No"); // Console.ReadKey(); // Console.WriteLine(cnt); // string[] strArray = Console.ReadLine().Split(' ').ToArray(); // string S = strArray[0]; // string T = strArray[1];
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] H = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int[] ans = new int[N]; for (int i = 1; i < N; i++) { if (H[i] <= H[i - 1]) ans[i] = ans[i - 1] + 1; else ans[i] = 0; } Console.WriteLine(ans.Max()); Console.ReadKey(); } } // string s = Console.ReadLine(); // int[] intArray = Console.ReadLine().Split(' ').Select(i => // int.Parse(i)).ToArray(); int H = intArray[0]; int W = intArray[1]; int N = // int.Parse(Console.ReadLine()); List<int> A = new // List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray()); // Boolean ok = false; // Console.WriteLine(ans); // Console.WriteLine("Yes"); // Console.WriteLine("No"); // Console.ReadKey(); // Console.WriteLine(cnt); // string[] strArray = Console.ReadLine().Split(' ').ToArray(); // string S = strArray[0]; // string T = strArray[1];
[["-", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 47], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33]]
8
181
12
using System; namespace abc139_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = Convert.ToInt32(input[i]); } int move = 0; for (int i = 1; i < n; i++) { if (h[i - 1] >= h[i]) { move++; } else { move = 0; } } Console.WriteLine(move); Console.Read(); } } }
using System; namespace abc139_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = Convert.ToInt32(input[i]); } int move = 0; int ans = 0; for (int i = 1; i < n; i++) { if (h[i - 1] >= h[i]) { move++; } else { ans = Math.Max(ans, move); move = 0; } } ans = Math.Max(ans, move); Console.WriteLine(ans); Console.Read(); } } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
156
29
using System; using System.Linq; namespace C { class Program { static void Main(string[] args) { var n = (int)Console.ReadLine()[0]; var height = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var count = 0; var mid = height.Length / 2; for (int i = 0; i + 1 < height.Length; i++) { if (height[i] >= height[i + 1]) { count++; } else { if (count > mid) { break; } count = 0; } } Console.WriteLine(count); } } }
using System; using System.Linq; namespace C { class Program { static void Main(string[] args) { var n = (int)Console.ReadLine()[0]; var height = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var max = 0; var count = 0; var mid = height.Length / 2; for (int i = 0; i + 1 < height.Length; i++) { if (height[i] >= height[i + 1]) { count++; } else { if (count > max) { max = count; } if (max > mid) { break; } count = 0; } } Console.WriteLine(max > count ? max : count); } } }
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 47], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102]]
8
146
23
using System; namespace MyProgram { class AtCoder { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] H = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); int sum_1 = 0; int sum_2 = 0; for (var i = 0; i < N - 1; i++) { if (H[i] < H[i + 1]) { sum_1++; } else { sum_2 = sum_2 < sum_1 ? sum_1 : sum_2; sum_1 = 1; } } Console.WriteLine(sum_2); } } }
using System; namespace MyProgram { class AtCoder { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] H = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); int sum_1 = 0; int sum_2 = 0; for (var i = 0; i < N - 1; i++) { if (H[i] >= H[i + 1]) { sum_1++; } else { if (sum_1 > sum_2) sum_2 = sum_1; sum_1 = 0; } } if (sum_1 > sum_2) sum_2 = sum_1; Console.WriteLine(sum_2); } } }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 47], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["-", 0, 1, 0, 11, 12, 41, 15, 16, 17, 18], ["-", 0, 1, 0, 11, 12, 41, 15, 16, 12, 22], ["-", 75, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 75, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["-", 75, 196, 0, 1, 0, 11, 12, 41, 75, 22], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
134
26
using System; using System.Linq; namespace abc139_c { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList(); int r = 0; int rm = 0; for (int i = 0; i < N - 1; i++) if (H[i] < H[i + 1]) { if (rm < r) rm = r; r = 0; } else { r++; } Console.WriteLine(rm); } } }
using System; using System.Linq; namespace abc139_c { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList(); int r = 0; int rm = 0; for (int i = 0; i < N - 1; i++) if (H[i] < H[i + 1]) { r = 0; } else { r++; if (rm < r) rm = r; } Console.WriteLine(rm); } } }
[["-", 0, 7, 8, 57, 64, 196, 0, 57, 0, 121], ["-", 0, 7, 8, 57, 64, 196, 0, 57, 0, 24], ["-", 8, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["-", 8, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["-", 8, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 7, 8, 57, 64, 196, 0, 57, 0, 25], ["-", 64, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["-", 8, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 0, 7, 8, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 57, 75, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 57, 75, 196, 0, 57, 0, 24], ["+", 8, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 8, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 57, 75, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 57, 75, 196, 0, 57, 0, 25], ["+", 75, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 57, 64, 1, 0, 11, 12, 22]]
8
142
20
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Atcoder { /// <summary> /// ContestName : ABC139 /// Problem : B /// </summary> class Program { static void Main() { var sc = new Scanner(); new Program().Solve(sc, new AtMath()); } private void Solve(Scanner sc, AtMath math) { int n = sc.NextInt(); int[] h = sc.IntArray(); int max = 0; h = h.Reverse().ToArray(); int cnt = 0; for (int i = 1; i < n; i++) { if (h[i - 1] <= h[i]) { cnt++; } else { if (max < cnt) { max = cnt; } cnt = 0; } } Console.WriteLine(max); } } class AtMath { public const int MOD = 1000000007; public const int INF = 2147483647; public const long SINF = 9223372036854775807; /// <summary> /// 確率統計「nCr」を求める /// </summary> /// <param name="n"></param> /// <param name="r"></param> /// <returns></returns> public long Ncr(int n, int r) { int nn = n; int rr = 1; // nCr for (int i = 1; i < r; i++) { nn *= (n - i); rr *= (i + 1); } return nn / rr; } /// <summary> /// 最大公約数を求める /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public int Gcd(int a, int b) { if (a < b) { Swap(ref a, ref b); } if (a % b == 0) { return b; } else { return Gcd(b, a % b); } } /// <summary> /// 入れ替える /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="b"></param> public void Swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; } /// <summary> /// 素因数分解 /// </summary> /// <param name="n"></param> /// <returns></returns> public static Dictionary<long, int> Factorize(long n) { var ret = new Dictionary<long, int>(); for (long i = 2; i * i <= n; i++) { if (n % i != 0) { continue; } ret[i] = 0; while (n % i == 0) { n /= i; ret[i]++; } } if (n > 1) { if (ret.ContainsKey(n)) { ret[n]++; } else { ret[n] = 1; } } return ret; } } class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region スペース区切りで取得 public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region 型変換 private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region 配列取得 public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Atcoder { /// <summary> /// ContestName : ABC139 /// Problem : B /// </summary> class Program { static void Main() { var sc = new Scanner(); new Program().Solve(sc, new AtMath()); } private void Solve(Scanner sc, AtMath math) { int n = sc.NextInt(); int[] h = sc.IntArray(); int max = 0; h = h.Reverse().ToArray(); int cnt = 0; for (int i = 1; i < n; i++) { if (h[i - 1] <= h[i]) { cnt++; } else { if (max < cnt) { max = cnt; } cnt = 0; } } if (max < cnt) { max = cnt; } Console.WriteLine(max); } } class AtMath { public const int MOD = 1000000007; public const int INF = 2147483647; public const long SINF = 9223372036854775807; /// <summary> /// 確率統計「nCr」を求める /// </summary> /// <param name="n"></param> /// <param name="r"></param> /// <returns></returns> public long Ncr(int n, int r) { int nn = n; int rr = 1; // nCr for (int i = 1; i < r; i++) { nn *= (n - i); rr *= (i + 1); } return nn / rr; } /// <summary> /// 最大公約数を求める /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public int Gcd(int a, int b) { if (a < b) { Swap(ref a, ref b); } if (a % b == 0) { return b; } else { return Gcd(b, a % b); } } /// <summary> /// 入れ替える /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="b"></param> public void Swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; } /// <summary> /// 素因数分解 /// </summary> /// <param name="n"></param> /// <returns></returns> public static Dictionary<long, int> Factorize(long n) { var ret = new Dictionary<long, int>(); for (long i = 2; i * i <= n; i++) { if (n % i != 0) { continue; } ret[i] = 0; while (n % i == 0) { n /= i; ret[i]++; } } if (n > 1) { if (ret.ContainsKey(n)) { ret[n]++; } else { ret[n] = 1; } } return ret; } } class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region スペース区切りで取得 public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region 型変換 private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region 配列取得 public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
910
12
using System; using System.Collections.Generic; using System.Linq; namespace Contest { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); List<int> q = new List<int>(); for (int i = 0; i < n; i++) { q.Add(int.Parse(input[i])); } int result = 0; int res = 0; for (int i = 1; i < n; i++) { if (q[i - 1] >= q[i]) { res++; } else { if (result < res) { result = res; } res = 0; } } Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; namespace Contest { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); List<int> q = new List<int>(); for (int i = 0; i < n; i++) { q.Add(int.Parse(input[i])); } int result = 0; int res = 0; for (int i = 0; i < n - 1; i++) { if (q[i] >= q[i + 1]) { res++; } else { if (res > 0 && result < res) { result = res; } res = 0; } } if (res > 0 && result < res) { result = res; } Console.WriteLine(result); } } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
178
28
using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.IO; class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); int count = 0; int maxCount = 0; if (N == 1) { Console.WriteLine(0); return; } for (var i = 0; i < N - 1; i++) { if (H[i] >= H[i + 1]) { count++; } else { if (maxCount < count) { maxCount = count; } count = 0; } } Console.WriteLine(maxCount); } }
using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.IO; class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); int count = 0; int maxCount = 0; if (N == 1) { Console.WriteLine(0); return; } for (var i = 0; i < N - 1; i++) { if (H[i] >= H[i + 1]) { count++; if (i == N - 2) { if (maxCount < count) { maxCount = count; } } } else { if (maxCount < count) { maxCount = count; } count = 0; } } Console.WriteLine(maxCount); } }
[["+", 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, 60], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 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], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 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], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
176
22
using System; using System.Text.RegularExpressions; namespace ConsoleApp3 { class Program { static void Main(string[] args) { int len = Convert.ToInt32(Console.ReadLine()); double[] numlist = new double[len]; int tmp = 0; foreach (string x in Regex.Split(Console.ReadLine(), @"\s+")) { numlist[tmp] = Convert.ToDouble(x); tmp += 1; } double toplength = 0, tmplength = 0; for (int i = len - 2; i >= 0; --i) { if (numlist[i + 1] <= numlist[i]) tmplength += 1; else { if (toplength < tmplength) { toplength = tmplength; } tmplength = 0; if (toplength > i) break; } } Console.WriteLine(toplength); } } }
using System; using System.Text.RegularExpressions; namespace ConsoleApp3 { class Program { static void Main(string[] args) { int len = Convert.ToInt32(Console.ReadLine()); double[] numlist = new double[len]; int tmp = 0; foreach (string x in Regex.Split(Console.ReadLine(), @"\s+")) { numlist[tmp] = Convert.ToDouble(x); tmp += 1; } double toplength = 0, tmplength = 0; for (int i = len - 2; i >= 0; --i) { if (numlist[i + 1] <= numlist[i]) tmplength += 1; else { tmplength = 0; if (toplength > i + 1) break; } if (toplength < tmplength) toplength = tmplength; } Console.WriteLine(toplength); } } }
[["-", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["-", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35]]
8
174
24
using System; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int ans = 0; int count = 0; for (int i = 0; i < N - 1; i++) { if (H[i] < H[i + 1]) { if (ans < count) { ans = count; } count = 0; } else { count++; } } Console.WriteLine(ans); } }
using System; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int ans = 0; int count = 0; for (int i = 0; i < N - 1; i++) { if (H[i] < H[i + 1]) { if (ans < count) { ans = count; } count = 0; } else { count++; } } if (ans < count) ans = count; Console.WriteLine(ans); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
139
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); int a = int.Parse(str[0]); int b = int.Parse(str[1]); int moveCount = 0; int maxCount = 0; for (int i = 0; i < n - 1; i++) { if (int.Parse(str[i + 1]) <= int.Parse(str[i])) { moveCount++; } else { if (maxCount < moveCount) { maxCount = moveCount; } moveCount = 0; } } if (maxCount < moveCount) { maxCount = moveCount; } Console.WriteLine(maxCount); Console.ReadKey(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); int moveCount = 0; int maxCount = 0; for (int i = 0; i < n - 1; i++) { if (int.Parse(str[i + 1]) <= int.Parse(str[i])) { moveCount++; } else { if (maxCount < moveCount) { maxCount = moveCount; } moveCount = 0; } } if (maxCount < moveCount) { maxCount = moveCount; } Console.WriteLine(maxCount); } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 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
201
32
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A { class Program { /// <summary> /// The main entry point for the application /// </summary> [STAThread] public static void Main(string[] args) { string str_n = Console.ReadLine(); // 2つ以上のスペース区切り入力の取得 string[] str_h = Console.ReadLine().Split(' '); int count = int.Parse(str_n); int end = 0; int start = 0; int high = int.Parse(str_h[0]); int max = 0; for (int i = 0; i < count; i++) { if (high < int.Parse(str_h[i])) { end = i - 1; if (end - start > max) { max = end - start; } start = i; } high = int.Parse(str_h[i]); } Console.Write("{0}", max); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A { class Program { /// <summary> /// The main entry point for the application /// </summary> [STAThread] public static void Main(string[] args) { string str_n = Console.ReadLine(); // 2つ以上のスペース区切り入力の取得 string[] str_h = Console.ReadLine().Split(' '); int count = int.Parse(str_n); int end = 0; int start = 0; int high = int.Parse(str_h[0]); int max = 0; for (int i = 1; i < count; i++) { if (high < int.Parse(str_h[i])) { end = i - 1; if (end - start > max) { max = end - start; } start = i; } high = int.Parse(str_h[i]); } end = count - 1; if (end - start > max) { max = end - start; } Console.Write("{0}", max); } } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 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, 33], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 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, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
8
200
24
using System; using System.Collections.Generic; using System.Linq; class Program { public static void Main() { long N = long.Parse(Console.ReadLine()); var line = Console.ReadLine().Split(' ').Select(p => long.Parse(p)).ToArray(); long count = 0; List<long> countList = new List<long>(); for (long i = 0; i < line.Length; i++) { if (i == 0) { } else { if (line[i - 1] >= line[i]) { count = count + 1; if (i == line.Length - 1) { countList.Add(count); } } else { countList.Add(count); count = 0; } } } Console.WriteLine(countList.Max()); } }
using System; using System.Collections.Generic; using System.Linq; class Program { public static void Main() { long N = long.Parse(Console.ReadLine()); var line = Console.ReadLine().Split(' ').Select(p => long.Parse(p)).ToArray(); long count = 0; List<long> countList = new List<long>(); long ans = 0; for (long i = 0; i < line.Length; i++) { if (line.Length == 1) { goto END; } else if (i == 0) { } else { if (line[i - 1] >= line[i]) { count = count + 1; if (i == line.Length - 1) { countList.Add(count); } } else { countList.Add(count); count = 0; } } } ans = countList.Max(); END: Console.WriteLine(ans); } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 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, 126, 0, 127], ["+", 8, 196, 0, 57, 64, 196, 0, 126, 0, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 126, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["-", 8, 196, 0, 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, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 97, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 97, 0, 102], ["+", 0, 97, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 97, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 97, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 97, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
187
33
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] H = new long[N]; string[] input = Console.ReadLine().Split(' '); for (int i = 0; i < N; i++) { H[i] = long.Parse(input[i]); } int count = 0; int countMax = 0; long currentHeight = H[0]; for (int i = 1; i < N; i++) { if (H[i] <= currentHeight) { count++; currentHeight = H[i]; if (count > countMax) countMax = count; } else { if (count > countMax) countMax = count; currentHeight = H[i]; count = 0; } } Console.WriteLine(count.ToString()); // Console.Read(); } } }
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] H = new long[N]; string[] input = Console.ReadLine().Split(' '); for (int i = 0; i < N; i++) { H[i] = long.Parse(input[i]); } int count = 0; int countMax = 0; long currentHeight = H[0]; for (int i = 1; i < N; i++) { if (H[i] <= currentHeight) { count++; if (count > countMax) countMax = count; } else { if (count > countMax) countMax = count; count = 0; } currentHeight = H[i]; } Console.WriteLine(countMax.ToString()); // Console.Read(); } } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22]]
8
209
19
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { partial class Program { static int ReadInt() { return int.Parse(Console.ReadLine()); } static long ReadLong() { return long.Parse(Console.ReadLine()); } static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } 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; } } static void Main(string[] args) { //↓ var n = ReadInt(); var hs = ReadIntArray(); var max = 0; var count = 0; var prev = hs[0]; for (int i = 1; i < n; i++) { var current = hs[i]; if (prev >= current) { count++; } else { max = Math.Max(max, count); count = 0; } prev = current; } Console.WriteLine(max); //↑ } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { partial class Program { static int ReadInt() { return int.Parse(Console.ReadLine()); } static long ReadLong() { return long.Parse(Console.ReadLine()); } static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } 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; } } static void Main(string[] args) { //↓ var n = ReadInt(); var hs = ReadIntArray(); var max = 0; var count = 0; var prev = hs[0]; for (int i = 1; i < n; i++) { var current = hs[i]; if (prev >= current) { count++; } else { max = Math.Max(max, count); count = 0; } prev = current; } max = Math.Max(max, count); Console.WriteLine(max); //↑ } } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
790
11
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] s1 = Console.ReadLine().Split(' '); string[] s2 = Console.ReadLine().Split(' '); int[] a = new int[n], b = new int[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(s1[i]); b[i] = int.Parse(s2[i]); } long ans = 0; int p = 0; int lockAll = 0; while (lockAll < n) { if (b[p] < a[p]) { Console.WriteLine(-1); return; } else if (b[p] == a[p]) { } else { int sum = b[(p + 1) % n] + b[(p + n - 1) % n]; if (sum < b[p]) { ans += b[p] / sum; // int buf = b[p]; b[p] %= sum; // Console.Error.WriteLine(buf + " " + b[p]); lockAll = 0; } } lockAll++; p = (p + 1) % n; } for (int i = 0; i < n; i++) { if (b[i] != a[i]) { Console.WriteLine(-1); return; } } Console.WriteLine(ans); } } // mcs Main.cs // mono Main.exe
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] s1 = Console.ReadLine().Split(' '); string[] s2 = Console.ReadLine().Split(' '); int[] a = new int[n], b = new int[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(s1[i]); b[i] = int.Parse(s2[i]); } long ans = 0; int p = 0; int lockAll = 0; while (lockAll < n) { if (b[p] < a[p]) { Console.WriteLine(-1); return; } else if (b[p] == a[p]) { } else { int sum = b[(p + 1) % n] + b[(p + n - 1) % n]; if (b[p] - sum >= a[p]) { int buf = (b[p] - a[p]) / sum; ans += buf; b[p] -= buf * sum; lockAll = 0; } } lockAll++; p = (p + 1) % n; } for (int i = 0; i < n; i++) { if (b[i] != a[i]) { Console.WriteLine(-1); return; } } Console.WriteLine(ans); } } // mcs Main.cs // mono Main.exe
[["-", 75, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["-", 75, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 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, 33], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 75, 57, 75, 196, 0, 57, 15, 16, 17, 20], ["+", 75, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 12, 204, 205, 22], ["+", 31, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 75, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 48]]
8
327
29
using System; namespace _153232 { class Program { static void Main(string[] args) { string A = Console.ReadLine(); string B = Console.ReadLine(); int a = int.Parse(A); int b = int.Parse(B); int[] ss = new int[] { a + b, a - b, a * b }; int s; Array.Sort(ss); s = ss[2]; Console.WriteLine(s); } } }
using System; namespace _153232 { class Program { static void Main(string[] args) { string[] AB = Console.ReadLine().Split(); int a = int.Parse(AB[0]); int b = int.Parse(AB[1]); int[] ss = new int[] { a + b, a - b, a * b }; int s; Array.Sort(ss); s = ss[2]; Console.WriteLine(s); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
8
107
21
using System; namespace AtCorderBeginner137 { public class Answer { public static void Main(string[] args) { int a; int.TryParse(args[0], out a); int b; int.TryParse(args[1], out b); int sum = a + b; int sub = a - b; int multi = a * b; if (sum >= multi && sum >= sub) { Console.WriteLine(sum); } else if (sub >= multi && sub >= sum) { Console.WriteLine(sub); } else { Console.WriteLine(multi); } } } }
using System; namespace AtCorderBeginner137 { public class Answer { public static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int a; int.TryParse(input[0], out a); int b; int.TryParse(input[1], out b); int sum = a + b; int sub = a - b; int multi = a * b; if (sum >= multi && sum >= sub) { Console.WriteLine(sum); } else if (sub >= multi && sub >= sum) { Console.WriteLine(sub); } else { Console.WriteLine(multi); } } } }
[["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22]]
8
126
22
using System; class Program { static void Main(string[] args) { int[] ab = new int[2]; int[] results = new int[3]; int i, max = 0; string[] input = Console.ReadLine().Split(' '); for (i = 0; i < 2; i++) { ab[i] = int.Parse(input[i]); } results[0] = ab[0] + ab[1]; results[1] = ab[0] - ab[1]; results[2] = ab[0] * ab[1]; for (i = 0; i < 3; i++) { if (results[i] > max) { max = results[i]; } } Console.WriteLine(max); } }
using System; class Program { static void Main(string[] args) { int[] ab = new int[2]; int[] results = new int[3]; int max = -10000; int i; string[] input = Console.ReadLine().Split(' '); for (i = 0; i < 2; i++) { ab[i] = int.Parse(input[i]); } results[0] = ab[0] + ab[1]; results[1] = ab[0] - ab[1]; results[2] = ab[0] * ab[1]; for (i = 0; i < 3; i++) { if (results[i] > max) { max = results[i]; } } Console.WriteLine(max); } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22]]
8
180
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp7 { class Program { static void MainA(string[] args) { var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var n0 = arr[0] + arr[1]; var n1 = arr[0] - arr[1]; var n2 = arr[0] * arr[1]; Console.WriteLine(Math.Max(n0, Math.Max(n1, n2))); } static void Main(string[] args) { var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); List<int> nums = new List<int>(); for (int i = arr[0] - arr[1] / 2; i < arr[0] + arr[1] / 2; i++) { nums.Add(i); } Console.WriteLine(string.Join(" ", nums)); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp7 { class Program { static void MainA(string[] args) { var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var n0 = arr[0] + arr[1]; var n1 = arr[0] - arr[1]; var n2 = arr[0] * arr[1]; Console.WriteLine(Math.Max(n0, Math.Max(n1, n2))); } static void Main(string[] args) { var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); List<int> nums = new List<int>(); int start = arr[1] - arr[0] + 1; int end = arr[1] + arr[0]; for (int i = start; i < end; i++) { nums.Add(i); } Console.WriteLine(string.Join(" ", nums)); } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 16, 12, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 16, 12, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 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, 197, 0, 198, 39, 199], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 7, 15, 16, 12, 16, 12, 16, 17, 85], ["-", 0, 7, 15, 16, 12, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 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, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
8
254
34
using System; class Hello { static void Main(string[] args) { var AB = Console.ReadLine().Split(' '); byte a = byte.Parse(AB[0]); byte b = byte.Parse(AB[1]); for (var i = 0; i <= b - a; i++) { Console.Write((b - a + i + 1) + " "); } } }
using System; class Hello { static void Main(string[] args) { var AB = Console.ReadLine().Split(' '); byte a = byte.Parse(AB[0]); byte b = byte.Parse(AB[1]); for (var i = 0; i < a * 2 - 1; i++) { Console.Write((b - a + i + 1) + " "); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
97
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int postition = 0, range = 0; string[] mass = Console.ReadLine().Split(' '); int[] result = new int[3]; int[] listinput = new int[mass.Length]; for (int i = 0; i < mass.Length; i++) { listinput[i] = int.Parse(mass[i]); } range = int.Parse(mass[0]); postition = int.Parse(mass[1]); int nowposition = postition - (range - 1); for (int i = 0; i < (range - 1) * 2; i++) { Console.WriteLine(nowposition); Console.WriteLine(" "); nowposition++; } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int postition = 0, range = 0; string[] mass = Console.ReadLine().Split(' '); int[] result = new int[3]; int[] listinput = new int[mass.Length]; for (int i = 0; i < mass.Length; i++) { listinput[i] = int.Parse(mass[i]); } range = int.Parse(mass[0]); postition = int.Parse(mass[1]); int nowposition = postition - (range - 1); for (int i = 0; i <= (range - 1) * 2; i++) { Console.Write(nowposition); Console.Write(" "); nowposition++; } range = 0; } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
206
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); long[] KX = cin.ArrayLong(2, 0); long start = KX[1] - KX[0] + 1; long goal = KX[1] + KX[0] - 1; for (long i = start; i < goal; i++) { Console.Write(i + " "); } if (start != goal) Console.WriteLine(goal); else Console.WriteLine(); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public static 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]); } } // Answer.IntArrayAns(x); public static void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); long[] KX = cin.ArrayLong(2, 0); long start = KX[1] - KX[0] + 1; long goal = KX[1] + KX[0] - 1; for (long i = start; i < goal; i++) { Console.Write(i + " "); } Console.WriteLine(goal); } } 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 static 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]); } } // Answer.IntArrayAns(x); public static void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["-", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["-", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24]]
8
777
13
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(); } public static long C(long n, long k) { long bunbo = 1; long bunsi = 1; for (long i = n - k + 1; i <= n; i++) bunsi *= i; for (long i = 1; i <= k; i++) bunbo *= i; return bunsi / bunbo; } bool f = false; static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var n = Read(); char[][] s = new char [n][]; string[] str = new string[n]; for (int i = 0; i < n; i++) { s[i] = Console.ReadLine().ToCharArray(); Array.Sort(s[i]); str[i] = new string(s[i]); } Array.Sort(str); long ans = 0; long count = 0; for (int i = 0; i < n - 1; i++) { if (str[i] == str[i + 1]) count++; else { ans += C(count + 1, 2); count = 0; } } if (count != 0) ans += count; Console.WriteLine(ans); 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(); } public static long C(long n, long k) { long bunbo = 1; long bunsi = 1; for (long i = n - k + 1; i <= n; i++) bunsi *= i; for (long i = 1; i <= k; i++) bunbo *= i; return bunsi / bunbo; } bool f = false; static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var n = Read(); char[][] s = new char [n][]; string[] str = new string[n]; for (int i = 0; i < n; i++) { s[i] = Console.ReadLine().ToCharArray(); Array.Sort(s[i]); str[i] = new string(s[i]); } Array.Sort(str); long ans = 0; long count = 0; for (int i = 0; i < n - 1; i++) { if (str[i] == str[i + 1]) count++; else { ans += C(count + 1, 2); count = 0; } } if (count != 0) ans += C(count + 1, 2); Console.WriteLine(ans); Console.Out.Flush(); } } }
[["+", 0, 57, 64, 1, 0, 11, 12, 213, 63, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
8
372
7
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 n = Read().Int(); var d = new Dictionary<string, int>(); for (int i = 0; i < n; i++) { var r = Read(); var s = new string[10]; for (int j = 0; j < 10; j++) { s[j] = r[j].ToString(); } Array.Sort(s, StringComparer.OrdinalIgnoreCase); var str = string.Join(string.Empty, s); if (d.ContainsKey(str)) { d[str]++; } else { d.Add(str, 1); } } var ans = 0L; foreach (var item in d) { ans += item.Value * (item.Value - 1) / 2; } WriteRead(ans); } public static string Read() { return Console.ReadLine(); } public static string[] ReadSplit() { return Console.ReadLine().Split(' '); } public static void WriteRead(object str) { Console.WriteLine(str); Read(); } public static void Write(object str) { Console.WriteLine(str); } private static bool ChangeMin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; } private static bool ChangekMax<T>(ref T a, T b) where T : IComparable { if (b.CompareTo(a) > 0) { a = b; return true; } return false; } } } public static class Extentions { public static int Int(this object obj) { return int.Parse(obj.ToString()); } public static long Long(this object obj) { return long.Parse(obj.ToString()); } public static decimal Decimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double Double(this object obj) { return double.Parse(obj.ToString()); } public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct { T2 value; if (d.TryGetValue(key, out value)) { return value; } return new T2(); } }
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 n = Read().Int(); var d = new Dictionary<string, int>(); for (int i = 0; i < n; i++) { var r = Read(); var s = new string[10]; for (int j = 0; j < 10; j++) { s[j] = r[j].ToString(); } Array.Sort(s, StringComparer.OrdinalIgnoreCase); var str = string.Join(string.Empty, s); if (d.ContainsKey(str)) { d[str]++; } else { d.Add(str, 1); } } var ans = 0D; foreach (var item in d) { ans += (long)item.Value * (long)(item.Value - 1) / (long)2; } WriteRead(ans); } public static string Read() { return Console.ReadLine(); } public static string[] ReadSplit() { return Console.ReadLine().Split(' '); } public static void WriteRead(object str) { Console.WriteLine(str); Read(); } public static void Write(object str) { Console.WriteLine(str); } private static bool ChangeMin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b) > 0) { a = b; return true; } return false; } private static bool ChangekMax<T>(ref T a, T b) where T : IComparable { if (b.CompareTo(a) > 0) { a = b; return true; } return false; } } } public static class Extentions { public static int Int(this object obj) { return int.Parse(obj.ToString()); } public static long Long(this object obj) { return long.Parse(obj.ToString()); } public static decimal Decimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double Double(this object obj) { return double.Parse(obj.ToString()); } public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct { T2 value; if (d.TryGetValue(key, out value)) { return value; } return new T2(); } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 250], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 0, 25], ["+", 12, 16, 31, 16, 12, 74, 51, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25]]
8
544
11
using System; using System.Linq; class Program { static void Main(string[] args) { var scaner = new Scanner(); var n = scaner.ReadInt(); var s = scaner.ReadStrArray(n); for (int i = 0; i < s.Length; i++) { s[i] = new string(s[i].OrderBy(c => c).ToArray()); } var l = s.GroupBy(x => x); var ans = 0l; foreach (var g in l) { var count = g.Count(); if (count > 1) { ans += count * (count - 1) / 2; } } Console.WriteLine(ans); } } 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 long ReadLong() { return long.Parse(this.Next()); } 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 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; } }
using System; using System.Linq; class Program { static void Main(string[] args) { var scaner = new Scanner(); var n = scaner.ReadInt(); var s = scaner.ReadStrArray(n); for (int i = 0; i < s.Length; i++) { s[i] = new string(s[i].OrderBy(c => c).ToArray()); } var l = s.GroupBy(x => x); ulong ans = 0; foreach (var g in l) { var count = Convert.ToUInt64(g.Count()); ans += count * (count - 1) / 2; } Console.WriteLine(ans); } } 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 long ReadLong() { return long.Parse(this.Next()); } 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 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; } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 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, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 210, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 210, 8, 196, 0, 197, 0, 35], ["-", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46]]
8
569
17
using System; using System.Linq; using System.Collections.Generic; class c { static void Main() { int n = int.Parse(Console.ReadLine()); var list = new string[n]; for (int i = 0; i < n; i++) { list[i] = string.Join("", Console.ReadLine().OrderBy(f => f)); } list = list.OrderBy(f => f).ToArray(); long ans = 0; int cnt = 1; for (int i = 1; i < n; i++) { if (list[i] == list[i - 1]) cnt++; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } Console.WriteLine(ans + cnt * (cnt - 1) / 2); } }
using System; using System.Linq; using System.Collections.Generic; using System.Text; // for StringBuilder class c { static void Main() { int n = int.Parse(Console.ReadLine()); var list = new string[n]; for (int i = 0; i < n; i++) { list[i] = string.Join("", Console.ReadLine().OrderBy(f => f)); } Array.Sort(list, StringComparer.Ordinal); list = list.Reverse().ToArray(); long ans = 0; long cnt = 1; for (int i = 1; i < n; i++) { if (list[i] == list[i - 1]) cnt++; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } Console.WriteLine(ans + cnt * (cnt - 1) / 2); } }
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 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], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 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], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
185
23
using System; using System.Linq; class c { static void Main() { int n = int.Parse(Console.ReadLine()); var list = new string[n]; for (int i = 0; i < n; i++) { list[i] = string.Join("", Console.ReadLine().OrderBy(f => f)); } Array.Sort(list); long ans = 0; int cnt = 1; for (int i = 1; i < n; i++) { if (list[i] == list[i - 1]) cnt++; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } Console.WriteLine(ans + cnt * (cnt - 1) / 2); } }
using System; using System.Linq; using System.Collections.Generic; using System.Text; // for StringBuilder class c { static void Main() { int n = int.Parse(Console.ReadLine()); var list = new string[n]; for (int i = 0; i < n; i++) { list[i] = string.Join("", Console.ReadLine().OrderBy(f => f)); } Array.Sort(list, StringComparer.Ordinal); long ans = 0; long cnt = 1; for (int i = 1; i < n; i++) { if (list[i] == list[i - 1]) cnt++; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } Console.WriteLine(ans + cnt * (cnt - 1) / 2); } }
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 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], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
170
18
using System; using System.Collections.Generic; using static System.Math; using System.Linq; using System.Text; class DandA { static void Main(string[] args) { int n = ReadLineInt(); List<String> sList = new List<String>(); for (int i = 0; i < n; i++) { char[] wk = ReadLineStr().ToCharArray(); Array.Sort(wk); sList.Add(new String(wk)); } sList.Sort(); int rtn = 0; String wk_S = ""; for (int i = 0; i < n; i++) { if (wk_S == sList[i]) { rtn++; } wk_S = sList[i]; } 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 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()); } }
using System; using System.Collections.Generic; using static System.Math; using System.Linq; using System.Text; class DandA { static void Main(string[] args) { int n = ReadLineInt(); List<String> sList = new List<String>(); for (int i = 0; i < n; i++) { char[] wk = ReadLineStr().ToCharArray(); Array.Sort(wk); sList.Add(new String(wk)); } sList.Sort(); long rtn = 0; long cnt = 0; String wk_S = ""; for (int i = 0; i < n; i++) { if (wk_S == sList[i]) { cnt++; rtn += cnt; } else { wk_S = sList[i]; cnt = 0; } } 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 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()); } }
[["-", 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, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 8, 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, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 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, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
8
897
20
using System; using System.Linq; using System.Collections.Generic; namespace ConsoleApp2 { public class Program { static long D = (long)Math.Pow(10, 9) + 7; public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); Dictionary<string, int> stringMap = new Dictionary<string, int>(); for (int i = 0; i < N; i++) { string s = Console.ReadLine(); IEnumerable<char> cs = s.OrderBy(c => c); string sortedS = new string(cs.ToArray()); if (!stringMap.ContainsKey(sortedS)) stringMap.Add(sortedS, 1); else stringMap[sortedS]++; // Console.WriteLine(); } long ans = 0; foreach (var item in stringMap) { ans += item.Value * (item.Value - 1) / 2; } Console.WriteLine(ans); Console.ReadLine(); } } }
using System; using System.Linq; using System.Collections.Generic; namespace ConsoleApp2 { public class Program { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); Dictionary<string, int> stringMap = new Dictionary<string, int>(); for (int i = 0; i < N; i++) { string s = Console.ReadLine(); IEnumerable<char> cs = s.OrderBy(c => c); string sortedS = new string(cs.ToArray()); if (!stringMap.ContainsKey(sortedS)) stringMap.Add(sortedS, 1); else stringMap[sortedS]++; } long ans = 0; foreach (var item in stringMap) { ans += (long)item.Value * (long)(item.Value - 1) / 2; } Console.WriteLine(ans); Console.ReadLine(); } } }
[["-", 0, 235, 8, 201, 0, 124, 0, 251, 0, 115], ["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 8, 201, 0, 124, 0, 198, 0, 200, 141, 22], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["-", 0, 16, 31, 74, 51, 213, 63, 214, 205, 22], ["-", 0, 16, 31, 74, 51, 213, 63, 214, 0, 131], ["-", 0, 16, 31, 74, 51, 213, 63, 214, 141, 22], ["-", 0, 16, 31, 74, 51, 213, 3, 4, 0, 24], ["-", 31, 74, 51, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 16, 31, 74, 51, 213, 3, 4, 0, 21], ["-", 0, 16, 31, 74, 51, 213, 3, 4, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 201, 0, 235, 8, 201, 0, 124, 0, 35], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 0, 25]]
8
209
24
using System; class uneven { public static void Main() { String str = Console.ReadLine(); int count = 0; if (str.Length % 2 == 0) { for (int i = 1; i < str.Length; i += 2) { count += 9 * (int)Math.Pow(10, i - 1); } } else { for (int i = 1; i < str.Length - 1; i += 2) { count += 9 * (int)Math.Pow(10, i - 1); } count += int.Parse(str) - int.Parse(str[0].ToString()) * (int)Math.Pow(10, str.Length - 1); count++; } Console.WriteLine(count); } }
using System; class uneven { public static void Main() { String str = Console.ReadLine(); int count = 0; if (str.Length % 2 == 0) { for (int i = 1; i < str.Length; i += 2) { count += 9 * (int)Math.Pow(10, i - 1); } } else { for (int i = 1; i < str.Length - 1; i += 2) { count += 9 * (int)Math.Pow(10, i - 1); } count += int.Parse(str) + 1 - (int)Math.Pow(10, str.Length - 1); } Console.WriteLine(count); } }
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 203], ["-", 12, 16, 12, 16, 31, 213, 63, 214, 205, 199], ["-", 12, 16, 12, 16, 31, 213, 63, 214, 0, 131], ["-", 12, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 213, 63, 214, 205, 204, 205, 22], ["-", 0, 213, 63, 214, 205, 204, 206, 207, 0, 70], ["-", 63, 214, 205, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 213, 63, 214, 205, 204, 206, 207, 0, 73], ["-", 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], ["-", 12, 16, 12, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 48], ["-", 0, 11, 12, 16, 12, 16, 12, 74, 0, 24], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 29]]
8
169
19
using System; namespace Answer { class Program { public static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var digitNum = N.ToString().Length; var ans = 0; int init, last; var digit = 1; var lessThanN = true; while (lessThanN) { init = (int)Math.Pow(10, digit - 1); last = (int)Math.Pow(10, digit) - 1; if (last >= N) { lessThanN = false; last = N; } ans += (int)last - (int)init + 1; digit += 2; } Console.WriteLine(ans); } } }
using System; namespace Answer { class Program { public static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var digitNum = N.ToString().Length; var ans = 0; int init, last; var digit = 1; var lessThanN = true; while (lessThanN) { init = (int)Math.Pow(10, digit - 1); last = (int)Math.Pow(10, digit) - 1; if (init > N) break; if (last >= N) { lessThanN = false; last = N; } ans += (int)last - (int)init + 1; digit += 2; } Console.WriteLine(ans); } } }
[["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 35], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24]]
8
147
8
using System; class Program { static void Main(string[] args) { string s = Console.ReadLine(); int n = int.Parse(s); int len = s.Length; //桁数 int ret = 0; if (len == 1) { ret = 9; } else if (len == 2) { ret = 9; } else if (len == 3) { ret = n - 99 + 9; } else if (len == 4) { ret = 909; } else if (len == 5) { ret = n - 9000 - 90; } else if (len == 6) { ret = 90909; } Console.WriteLine(ret.ToString()); } }
using System; class Program { static void Main(string[] args) { string s = Console.ReadLine(); int n = int.Parse(s); int len = s.Length; //桁数 int ret = 0; if (len == 1) { ret = n; } else if (len == 2) { ret = 9; } else if (len == 3) { ret = n - 99 + 9; } else if (len == 4) { ret = 909; } else if (len == 5) { ret = n - 9000 - 90; } else { ret = 90909; } Console.WriteLine(ret.ToString()); } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 75, 57, 75, 57, 75, 57, 75, 57, 0, 121], ["-", 75, 57, 75, 57, 75, 57, 75, 57, 0, 24], ["-", 75, 57, 75, 57, 75, 57, 15, 16, 31, 22], ["-", 75, 57, 75, 57, 75, 57, 15, 16, 17, 60], ["-", 75, 57, 75, 57, 75, 57, 15, 16, 12, 203], ["-", 75, 57, 75, 57, 75, 57, 75, 57, 0, 25]]
8
146
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); int N = cin.nextInt(); int ans = 0; if (N < 10) ans = N; else if (N < 100) ans = 9; else if (N < 1000) ans = 9 + N - 99; else if (N < 10000) ans = 909; else if (N < 100000) ans = 909 + N - 9999; else ans = 90909; } } 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 static 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]); } } // Answer.IntArrayAns(x); public static void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); int N = cin.nextInt(); int ans = 0; if (N < 10) ans = N; else if (N < 100) ans = 9; else if (N < 1000) ans = 9 + N - 99; else if (N < 10000) ans = 909; else if (N < 100000) ans = 909 + N - 9999; else ans = 90909; 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 static 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]); } } // Answer.IntArrayAns(x); public static void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
[["+", 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
767
7
using System; using System.Linq; namespace CSharp { class Program { public static void Main() { var N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var result = true; for (int i = N - 1; i > 0; i--) { if (H[i] + 1 < H[i - 1]) { result = false; break; } else if (H[i] + 1 == H[i - 1]) { H[i - 1]--; } } Console.WriteLine(result); } } }
using System; using System.Linq; namespace CSharp { class Program { public static void Main() { var N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var result = true; for (int i = N - 1; i > 0; i--) { if (H[i] + 1 < H[i - 1]) { result = false; break; } else if (H[i] + 1 == H[i - 1]) { H[i - 1]--; } } Console.WriteLine(result ? "Yes" : "No"); } } }
[["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
8
146
8
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var n = cin.ReadInt; var inputArray = new int[n]; for (int i = 0; i < n; i++) { inputArray[i] = cin.ReadInt; } for (int i = n; i > 0; i--) { if (inputArray[i] - inputArray[i - 1] < 0) { inputArray[i] += 1; } if (inputArray[i] - inputArray[i - 1] < 0) { System.Console.WriteLine("No"); } } System.Console.WriteLine("Yes"); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var n = cin.ReadInt; var inputArray = new int[n]; for (int i = 0; i < n; i++) { inputArray[i] = cin.ReadInt; } if (n == 1) { System.Console.WriteLine("Yes"); return; } for (int i = n - 1; i > 0; i--) { if (inputArray[i] - inputArray[i - 1] < 0) { inputArray[i - 1] -= 1; } if (inputArray[i] - inputArray[i - 1] < 0) { System.Console.WriteLine("No"); return; } } System.Console.WriteLine("Yes"); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 141, 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], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110]]
8
546
29
using System; using System.Linq; using System.Collections.Generic; namespace atcoder { class Program { static void Main(string[] args) { if (ABC136.BuildStairs()) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } class ABC136 { public static bool BuildStairs() { int n = Input.getInt(); long[] h = Input.getLongArray(); if (n == 1) return true; for (int i = n - 1; i > 0; i--) { if (h[i] - h[i - 1] > 1) { h[i] = h[i] - 1; } if (h[i] - h[i - 1] > 1) { return false; } } return true; } } class Input { public static int getInt() { int i = int.Parse(Console.ReadLine()); return i; } public static string getString() { string s = Console.ReadLine(); return s; } public static int[] getIntArray() { string[] s = Console.ReadLine().Split(' '); int[] num = s.Select(x => int.Parse(x)).ToArray(); return num; } public static long[] getLongArray() { string[] s = Console.ReadLine().Split(' '); long[] num = s.Select(x => long.Parse(x)).ToArray(); return num; } } }
using System; using System.Linq; namespace atcoder { class Program { static void Main(string[] args) { if (ABC136.BuildStairs()) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } class ABC136 { public static bool BuildStairs() { int n = Input.getInt(); long[] h = Input.getLongArray(); if (n == 1) return true; for (int i = n - 1; i > 0; i--) { if (h[i - 1] - h[i] == 1) { h[i - 1] = h[i - 1] - 1; } if (h[i - 1] - h[i] > 0) { return false; } } return true; } } class Input { public static int getInt() { int i = int.Parse(Console.ReadLine()); return i; } public static string getString() { string s = Console.ReadLine(); return s; } public static int[] getIntArray() { string[] s = Console.ReadLine().Split(' '); int[] num = s.Select(x => int.Parse(x)).ToArray(); return num; } public static long[] getLongArray() { string[] s = Console.ReadLine().Split(' '); long[] num = s.Select(x => long.Parse(x)).ToArray(); return num; } } }
[["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
8
335
23
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace ConsoleApp1 { class Program { static void Main(string[] args) { A(); } static void A() { var N = ReadInt(); var a = ReadSplitInt(); for (int i = a.Count - 1; i > 0; i--) { if (a[i] < a[i - 1] && a[i - 1] - a[i] >= 2) { Println("No"); return; } } Println("Yes"); } static List<long> ReadLines(long n) { var l = new List<long>(); for (long i = 0; i < n; i++) { l.Add(ReadLong()); } return l; } static void YESOrNO(bool e) => Println(e ? "YES" : "NO"); static void YesOrNo(bool e) => Println(e ? "Yes" : "No"); static IEnumerable<int> Range(int start, int stop) { if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0)) return new List<int>(); return Enumerable.Range(start, stop - start); } static bool IsDigit(string str) { var i = 0; return int.TryParse(str, out i); } static int SumDigits(long num) { return num.ToString().Select(x => x.ToString()).Sum(int.Parse); } static int[] ToIntArray(string str) { return str.Select(x => x.ToString()).Select(int.Parse).ToArray(); } static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b); static long Lcm(long a, long b) => a / Gcd(a, b) * b; static bool IsPrime(int x) { if (x <= 1 || (x != 2 && x % 2 == 0)) return false; if (x == 2) return true; for (int i = 3; i < x; i += 2) if (x % i == 0) return false; return true; } static string Read() => Console.ReadLine(); static int ReadInt() => int.Parse(Read()); static long ReadLong() => long.Parse(Read()); static List<string> ReadSplit() => Read().Split().ToList(); static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList(); static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList(); static void Print(object value) => Console.Write(value.ToString()); static void Println(object value) => Console.WriteLine(value.ToString()); static string Join<T>(IEnumerable<T> list) => string.Join("", list); } public static class MyExtensions { public static string Slice(this string str, int start = 0, int stop = 0) { if (start > str.Length || stop > str.Length || start < 0 || stop < 0) return ""; if (stop == 0) stop = str.Length; return str.Substring(start, stop - start); } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace ConsoleApp1 { class Program { static void Main(string[] args) { A(); } static void A() { var N = ReadInt(); var a = ReadSplitLong(); for (int i = a.Count - 1; i > 0; i--) { if (a[i] < a[i - 1] && a[i - 1] - a[i] >= 2) { Println("No"); return; } else if (a[i] < a[i - 1]) { a[i - 1]--; } } Println("Yes"); } static List<long> ReadLines(long n) { var l = new List<long>(); for (long i = 0; i < n; i++) { l.Add(ReadLong()); } return l; } static void YESOrNO(bool e) => Println(e ? "YES" : "NO"); static void YesOrNo(bool e) => Println(e ? "Yes" : "No"); static IEnumerable<int> Range(int start, int stop) { if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0)) return new List<int>(); return Enumerable.Range(start, stop - start); } static bool IsDigit(string str) { var i = 0; return int.TryParse(str, out i); } static int SumDigits(long num) { return num.ToString().Select(x => x.ToString()).Sum(int.Parse); } static int[] ToIntArray(string str) { return str.Select(x => x.ToString()).Select(int.Parse).ToArray(); } static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b); static long Lcm(long a, long b) => a / Gcd(a, b) * b; static bool IsPrime(int x) { if (x <= 1 || (x != 2 && x % 2 == 0)) return false; if (x == 2) return true; for (int i = 3; i < x; i += 2) if (x % i == 0) return false; return true; } static string Read() => Console.ReadLine(); static int ReadInt() => int.Parse(Read()); static long ReadLong() => long.Parse(Read()); static List<string> ReadSplit() => Read().Split().ToList(); static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList(); static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList(); static void Print(object value) => Console.Write(value.ToString()); static void Println(object value) => Console.WriteLine(value.ToString()); static string Join<T>(IEnumerable<T> list) => string.Join("", list); } public static class MyExtensions { public static string Slice(this string str, int start = 0, int stop = 0) { if (start > str.Length || stop > str.Length || start < 0 || stop < 0) return ""; if (stop == 0) stop = str.Length; return str.Substring(start, stop - start); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 204, 205, 22], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 57, 15, 16, 12, 204, 205, 22], ["+", 75, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 75, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 223, 0, 204, 205, 22], ["+", 0, 1, 0, 223, 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], ["+", 0, 1, 0, 223, 0, 204, 206, 207, 0, 73], ["+", 75, 57, 64, 196, 0, 1, 0, 223, 0, 68]]
8
753
27
using System; using System.Linq; class Program { static void Main(string[] args) { //入力 int N = int.Parse(Console.ReadLine()); string s = Console.ReadLine(); // int[] H = new int[N]; // for (int i = 0; i < N; i++) { // H[i] = int.Parse(s.Split(' ')[i]); //} int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); ; //回答用フラグ bool flg = true; //検証 for (int i = 0; i < N; i++) { //先頭の数字は問答無用で1つ減らす if (i == 0) { H[i] -= 1; } else if (H[i] - H[i - 1] <= -1) { flg = false; //ループを抜ける break; } else if (H[i] - H[i - 1] == 0) { //何もしない } else if (H[i] - H[i - 1] >= 1) { H[i] = H[i] - 1; } } //出力 Console.WriteLine(flg ? "Yes" : "No"); } }
using System; using System.Linq; class Program { static void Main(string[] args) { //入力 int N = int.Parse(Console.ReadLine()); // string s = Console.ReadLine(); // int[] H = new int[N]; // for (int i = 0; i < N; i++) { // H[i] = int.Parse(s.Split(' ')[i]); //} int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); ; //回答用フラグ bool flg = true; //検証 for (int i = 0; i < N; i++) { //先頭の数字は問答無用で1つ減らす if (i == 0) { H[i] -= 1; } else if (H[i] - H[i - 1] <= -1) { flg = false; //ループを抜ける break; } else if (H[i] - H[i - 1] == 0) { //何もしない } else if (H[i] - H[i - 1] >= 1) { H[i] = H[i] - 1; } } //出力 Console.WriteLine(flg ? "Yes" : "No"); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35]]
8
219
9
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { // const int MOD = 1000000007; static void Main(string[] args) { new Program().Solve(); } void Solve() { Scanner cin = new Scanner(); int n = cin.NextInt(); long[] h = new long[n]; for (int i = 0; i < n; i++) { h[i] = cin.NextLong(); } long prev = h[0]; foreach (var candidate in h) { if (candidate - prev > 1) { Console.WriteLine("No"); return; } prev = candidate; } Console.WriteLine("Yes"); } } 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 char[] ArrayChar() { return Next().ToCharArray(); } 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.Text; using System.Threading.Tasks; class Program { // const int MOD = 1000000007; static void Main(string[] args) { new Program().Solve(); } void Solve() { Scanner cin = new Scanner(); int n = cin.NextInt(); long[] h = new long[n]; for (int i = 0; i < n; i++) { h[i] = cin.NextLong(); } long max = -1; long min = 10000000000; foreach (var candidate in h) { if (max < candidate) { max = candidate; } if (max - candidate > 1) { Console.WriteLine("No"); return; } } Console.WriteLine("Yes"); } } 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 char[] ArrayChar() { return Next().ToCharArray(); } 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, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 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, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 0, 210, 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, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 210, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 210, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35]]
8
537
31
using System; using System.Linq; namespace ABC136_C { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split().Select(long.Parse).ToArray(); H.Reverse(); var ans = true; for (int i = 0; i < N - 1; i++) { if (H[i] < H[i + 1]) { H[i + 1]--; if (H[i] < H[i + 1]) { ans = false; break; } } } Console.WriteLine(ans ? "Yes" : "No"); } } }
using System; using System.Linq; namespace ABC136_C { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split().Select(long.Parse).ToArray(); var ans = true; for (int i = N - 1; i >= 1; i--) { if (H[i] < H[i - 1]) { H[i - 1]--; if (H[i] < H[i - 1]) { ans = false; break; } } } Console.WriteLine(ans ? "Yes" : "No"); } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33]]
8
155
22
using System; class ProgramC { static void Main(string[] args) { string input = Console.ReadLine(); int n = int.Parse(input); string[] input_b = Console.ReadLine().Split(' '); long[] b = new long[n]; for (int i = 0; i < n; i++) b[i] = long.Parse(input_b[i]); int count = 0; int temp = 0; for (int i = 1; i < n; i++) { if (b[i] - b[i - 1] <= -2) { Console.WriteLine("No"); break; } else if (b[i] - b[i - 1] == -1) { if (temp == 1) { Console.WriteLine("No"); break; } temp = 1; } else if (b[i] - b[i - 1] >= 1) { temp = 0; } count++; if (count == n - 1) { Console.WriteLine("Yes"); break; } } } }
using System; class ProgramC { static void Main(string[] args) { string input = Console.ReadLine(); int n = int.Parse(input); string[] input_b = Console.ReadLine().Split(' '); long[] b = new long[n]; for (int i = 0; i < n; i++) b[i] = long.Parse(input_b[i]); int count = 0; int temp = 0; if (n == 1) { Console.WriteLine("Yes"); } else { for (int i = 1; i < n; i++) { if (b[i] - b[i - 1] <= -2) { Console.WriteLine("No"); break; } else if (b[i] - b[i - 1] == -1) { if (temp == 1) { Console.WriteLine("No"); break; } temp = 1; } else if (b[i] - b[i - 1] >= 1) { temp = 0; } count++; if (count == n - 1) { Console.WriteLine("Yes"); break; } } } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 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, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
241
20
using System; using System.Collections.Generic; using System.Linq; using System.Diagnostics; class Program { static void Main(string[] args) { var sc = new Scanner(); var n = sc.nextInt(); var h = new int[n]; var gap = new int[n]; bool flag = false; bool ans = true; int tmp = 0; for (int i = 0; i < n; i++) { h[i] = sc.nextInt(); if (i > 0) gap[i] = h[i] - h[i - 1]; if (gap[i] <= -1) { flag = true; } if (flag) tmp += gap[i]; if (tmp < -1) { ans = false; break; } else if (tmp >= 0) flag = false; } if (ans) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } // chokudai's Scanner 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.Generic; using System.Linq; using System.Diagnostics; class Program { static void Main(string[] args) { var sc = new Scanner(); var n = sc.nextInt(); var h = new int[n]; var gap = new long[n]; bool flag = false; bool ans = true; long tmp = 0; for (int i = 0; i < n; i++) { h[i] = sc.nextInt(); if (i > 0) gap[i] = h[i] - h[i - 1]; if (gap[i] <= -1) { flag = true; } if (flag) tmp += gap[i]; if (tmp < -1) { ans = false; break; } else if (tmp >= 0) { flag = false; tmp = 0; } } if (ans) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } // chokudai's Scanner class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } }
[["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 45], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46]]
8
562
10
using System; using System.Collections.Generic; using System.Linq; namespace ABC136C { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split().Select(int.Parse).ToArray(); bool ans = true; int min = H[0]; for (int i = 0; i < N - 1; i++) { if (H[i + 1] < min) { ans = false; break; } min = Math.Min(H[i], H[i + 1]); } if (ans) Console.WriteLine("Yes"); else Console.WriteLine("No"); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC136C { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split().Select(int.Parse).ToArray(); bool ans = true; int min = H[0]; for (int i = 0; i < N - 1; i++) { if (H[i + 1] < min) { ans = false; break; } min = Math.Max(min, H[i + 1] - 1); } if (ans) Console.WriteLine("Yes"); else Console.WriteLine("No"); Console.ReadKey(); } } }
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
170
9
using System; using System.Collections.Generic; using System.Linq; namespace test { class Program { static void Main(string[] args) { var N = ReadInt(); var H = ReadArrayInt(); var chk = H[0]; for (int i = 1; i < N; i++) { if (H[i] < chk) chk = H[i]; else if (H[i] - i > chk) { Console.WriteLine("No"); return; } } Console.WriteLine("Yes"); Console.ReadLine(); } 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 test { class Program { static void Main(string[] args) { var N = ReadInt(); var H = ReadArrayInt(); var chk = H[0]; for (int i = 1; i < N; i++) { if (H[i] > chk) chk = H[i] - 1; else if (H[i] < chk) { Console.WriteLine("No"); return; } } Console.WriteLine("Yes"); Console.ReadLine(); } 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, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 12, 203], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 33], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18]]
8
250
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClarss { public const long Giri = 1000000007; public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] s = Input(); long max = -10; for (int i = 0; i < n; i++) { long h = long.Parse(s[i]); if (h - 1 == max) { continue; } if (max <= h) { max = h; continue; } h -= 1; if (max > h) { Console.WriteLine("No"); return; } max = h; } Console.WriteLine("Yes"); } public static long GCD(long a, long b) { if (b == 1) return a; long p = b / a; return GCD(a, b - a * p); } public static string[] Input() { return Console.ReadLine().Split(' '); } public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClarss { public const long Giri = 1000000007; public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] s = Input(); long max = -10; for (int i = 0; i < n; i++) { long h = long.Parse(s[i]); if (h - 1 >= max) { max = h - 1; continue; } if (max <= h) { max = h; continue; } h -= 1; if (max > h) { Console.WriteLine("No"); return; } max = h; } Console.WriteLine("Yes"); } public static long GCD(long a, long b) { if (b == 1) return a; long p = b / a; return GCD(a, b - a * p); } public static string[] Input() { return Console.ReadLine().Split(' '); } public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); } }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
264
8
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 Pair : IComparable { public int x; public int y; public Pair(int X, int Y) { x = X; y = Y; } public int CompareTo(object obj) { Pair kore = (Pair)obj; return y.CompareTo(kore.y); } } class Program { public static Mlong[] combs; static void Main(string[] args) { StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput()); char[] s = scan.Scan().ToCharArray(); bool right = true; int zen = 0; // hidariの足すとこ用 int ren = 0; int[] ans = new int[s.Length]; for (int i = 0; i < s.Length; i++) { if (right) { if (s[i] == 'R') { ren++; } else { ans[i - 1] += (ren + 1) / 2; ans[i] += ren / 2; zen = i - 1; ren = 1; right = false; } } else { if (s[i] == 'L') { ren++; if (i == s.Length - 1) { ans[zen] += ren / 2; ans[zen + 1] += (ren + 1) / 2; } } else { ans[zen] += ren / 2; ans[zen + 1] += (ren + 1) / 2; ren = 1; right = true; } } } Console.WriteLine(String.Join(" ", ans)); } static int check(long moto, long tai) { if (tai % moto != 0) { return 0; } while (tai > 1) { if (tai % moto == 0) { tai /= moto; } else if (tai > moto) { tai %= moto; } else { tai -= moto; } } if (tai == 1) { return 1; } else { return 0; } } static int binary_search<T>(T key, T[] moto, Func<int, T, T[], bool> isok) { int ng = -1; int ok = moto.Length; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isok(mid, key, moto)) { ok = mid; } else { ng = mid; } } return ok; } static int binary_search(int key, int[] moto) { int ng = -1; int ok = moto.Length; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key, moto)) { ok = mid; } else { ng = mid; } } return ok; } static bool isOK(int index, int key, int[] moto) { return moto[index] >= key; } static long Syakutori( int[] a, long k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上 { long sum = 0; int right = 0; long ans = 0; for (int left = 0; left < a.Length; left++) { while (right < a.Length && sum < k) { sum += a[right]; right++; } if (k <= sum) { ans += a.Length - right + 1; } if (left == right) { right++; } else { sum -= a[left]; } } return ans; } static int[] zalgo(String s) { int n = s.Length; int[] ret = new int[n]; ret[0] = n; int i = 1, j = 0; while (i < n) { while (i + j < n && s[j] == s[i + j]) ++j; ret[i] = j; if (j == 0) { ++i; continue; } int k = 1; while (i + k < n && k + ret[k] < j) { ret[i + k] = ret[k]; ++k; } i += k; j -= k; } return ret; } static int gcd(int a, int b) { if (a % b == 0) { return b; } return gcd(b, a % b); } static long gcd(long a, long b) { if (a % b == 0) { return b; } return gcd(b, a % b); } 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 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 long DivideWith(long m, long n, List<long> primes) { while (m % n == 0) { primes.Add(n); m = m / n; } return m; } static long[] SoinsuBunkai(long num) { if (num == 1) return new long[] { 1 }; List<long> primes = new List<long>(); long n = DivideWith(num, 2, primes); n = DivideWith(n, 3, primes); n = DivideWith(n, 5, primes); long i = 0; while (n > 1) { int[] ps = { 7, 11, 13, 17, 19, 23, 29, 31 }; foreach (var p in ps) { // 30m+2, 30m+3, 30m+4, 30m+5, 30m+6、30m+8... は割る必要はない。 n = DivideWith(n, i + p, primes); if (n == 1) break; } i += 30; } return primes.ToArray(); } public static int h; public static int w; public static int BFS(int height, int width, char[,] map) { int[] dx = new int[] { -1, 0, 0, 1 }; int[] dy = new int[] { 0, 1, -1, 0 }; bool[,] visited = new bool[h, w]; int[,] len = new int[h, w]; var queue = new Queue<Tuple<int, int>>(); queue.Enqueue(new Tuple<int, int>(height, width)); int max = 0; visited[height, width] = true; while (queue.Count > 0) { var now = queue.Dequeue(); for (int i = 0; i < 4; i++) { int ny = now.Item1 + dy[i]; int nx = now.Item2 + dx[i]; if (ny >= h || ny < 0 || nx >= w || nx < 0) continue; if (visited[ny, nx] || map[ny, nx] == '#') continue; visited[ny, nx] = true; len[ny, nx] = len[now.Item1, now.Item2] + 1; max = Math.Max(max, len[ny, nx]); queue.Enqueue(new Tuple<int, int>(ny, nx)); } } return max; } } 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(long n) { long[] kore = new long[n]; for (int i = 0; i < n; i++) { kore[i] = Long(); } return kore; } public Mlong[] MLong(long n) { Mlong[] kore = new Mlong[n]; for (int i = 0; i < n; i++) { kore[i] = Long(); } return kore; } public long[,] Long(long h, long w) { long[,] kore = new long[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { kore[i, j] = Long(); } } return kore; } public int Integer() { return (int)Long(); } public Mint[] MInteger(long n) { Mint[] kore = new Mint[n]; for (int i = 0; i < n; i++) { kore[i] = Integer(); } return kore; } public int[] Integer(long n) { int[] kore = new int[n]; for (int i = 0; i < n; i++) { kore[i] = (int)Long(); } return kore; } public int[,] Integer(long h, long 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 : IComparable { 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); } static long GetInverse(long a) { long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1; while (true) { if (p == 1) return x2 + mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p; if (a == 1) return x1 + mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a; } } public Mlong modjyo(Mlong x) { return num * GetInverse(x.num) % mod; } public static implicit operator Mlong(long x) { return new Mlong(x); } public static Mlong operator %(Mlong x, Mlong y) { return new Mlong(x.num % y.num); } public static explicit operator long(Mlong x) { return x.num; } public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; } public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; } public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; } public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; } public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; } public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; } public Mlong Pow(Mlong n) { Mlong pow = this; Mlong res = 1; while (n > 0) { if (n % 2 == 1) { res *= pow; } pow *= pow; n.hutujyo(2); } /* if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mint buf = Pow(n.hutujyo(2)); return (buf * buf) % mod;*/ return res; } public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); } public static List<Mlong> factorialMemo = new List<Mlong>() { 1 }; static Mlong Factorial(int x) { for (int i = factorialMemo.Count; i <= x; i++) factorialMemo.Add(factorialMemo.Last() * i); return factorialMemo[x]; } public static Mlong Comb(Mlong n, Mlong a) { Mlong buf1 = 1; Mlong buf2 = 1; for (long i = 0; i < a.num; i++) { buf1 *= n - i; buf2 *= (i + 1); } return buf1.modjyo(buf2); } public static Mlong Comb(int n, int r) { return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r)); } public static void WriteLine(Mlong x) { Console.WriteLine(x.num); } public int CompareTo(object obj) { Mlong kore = (Mlong)obj; return num.CompareTo(kore.num); } } public class Mint : IComparable { 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); } static int GetInverse(long a) { long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1; while (true) { if (p == 1) return (int)(x2 + mod); div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p; if (a == 1) return (int)(x1 + mod); div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a; } } public Mint modjyo(Mint x) { return num * GetInverse(x.num) % mod; } /* public Mint modjyo(Mint x) { return num * x.Pow(mod - 2); }*/ public static implicit operator Mint(int x) { return new Mint(x); } public static Mint[] Toarray(int[] x) { Mint[] buf = new Mint[x.Length]; for (int i = 0; i < x.Length; i++) { buf[i] = x[i]; } return buf; } public static explicit operator int(Mint x) { return x.num; } public static Mint operator %(Mint x, Mint y) { return new Mint(x.num % y.num); } public static bool operator ==(Mint x, Mint y) { return x.num == y.num; } public static bool operator !=(Mint x, Mint y) { return x.num != y.num; } public static bool operator<(Mint x, Mint y) { return x.num < y.num; } public static bool operator>(Mint x, Mint y) { return x.num > y.num; } public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; } public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; } public Mint Pow(Mint n) { Mint pow = this; Mint res = 1; while (n > 0) { if (n % 2 == 1) { res *= pow; } pow *= pow; n.hutujyo(2); } /* if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mint buf = Pow(n.hutujyo(2)); return (buf * buf) % mod;*/ return res; } public static Mint Pow(Mint a, Mint n) { return a.Pow(n); } public static List<Mint> factorialMemo = new List<Mint>() { 1 }; static Mint Factorial(int x) { for (int i = factorialMemo.Count; i <= x; i++) factorialMemo.Add(factorialMemo.Last() * i); return factorialMemo[x]; } public static Mint Comb(int n, int r) { return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r)); } public static void WriteLine(Mint x) { Console.WriteLine(x.num); } public int CompareTo(object obj) { Mint kore = (Mint)obj; return num.CompareTo(kore.num); } } public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) {} public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) {} public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } public class Tree { public Node[] Nodes; public List<int[]> hen; public class Node { public int? parent = null; public List<int[]> children = new List<int[]>(); public int parentcolor = -1; } public Tree(int kosu) { Nodes = new Node[kosu]; for (int i = 0; i < Nodes.Length; i++) { Nodes[i] = new Node(); } hen = new List<int[]>(); } public void Connect(int oya, int ko, int id) { hen.Add(new int[] { oya, ko, 0 }); Nodes[oya].children.Add(new int[] { ko, id }); Nodes[ko].parent = oya; } } /// <summary> /// Self-Balancing Binary Search Tree /// (using Randamized BST) /// </summary> public class SB_BinarySearchTree<T> where T : IComparable { public class Node { public T Value; public Node LChild; public Node RChild; public int Count; // size of the sub tree public Node(T v) { Value = v; Count = 1; } } static Random _rnd = new Random(); public static int Count(Node t) { return t == null ? 0 : t.Count; } static Node Update(Node t) { t.Count = Count(t.LChild) + Count(t.RChild) + 1; return t; } public static Node Merge(Node l, Node r) { if (l == null || r == null) return l == null ? r : l; if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) { l.RChild = Merge(l.RChild, r); return Update(l); } else { r.LChild = Merge(l, r.LChild); return Update(r); } } /// <summary> /// split as [0, k), [k, n) /// </summary> public static Tuple<Node, Node> Split(Node t, int k) { if (t == null) return new Tuple<Node, Node>(null, null); if (k <= Count(t.LChild)) { var s = Split(t.LChild, k); t.LChild = s.Item2; return new Tuple<Node, Node>(s.Item1, Update(t)); } else { var s = Split(t.RChild, k - Count(t.LChild) - 1); t.RChild = s.Item1; return new Tuple<Node, Node>(Update(t), s.Item2); } } public static Node Remove(Node t, T v) { if (Find(t, v) == null) return t; return RemoveAt(t, LowerBound(t, v)); } public static Node RemoveAt(Node t, int k) { var s = Split(t, k); var s2 = Split(s.Item2, 1); return Merge(s.Item1, s2.Item2); } public static bool Contains(Node t, T v) { return Find(t, v) != null; } public static Node Find(Node t, T v) { while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp > 0) t = t.LChild; else if (cmp < 0) t = t.RChild; else break; } return t; } public static Node FindByIndex(Node t, int idx) { if (t == null) return null; var currentIdx = Count(t) - Count(t.RChild) - 1; while (t != null) { if (currentIdx == idx) return t; if (currentIdx > idx) { t = t.LChild; currentIdx -= (Count(t == null ? null : t.RChild) + 1); } else { t = t.RChild; currentIdx += (Count(t == null ? null : t.LChild) + 1); } } return null; } public static int UpperBound(Node t, T v) { var torg = t; if (t == null) return -1; var ret = Int32.MaxValue; var idx = Count(t) - Count(t.RChild) - 1; while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp > 0) { ret = Math.Min(ret, idx); t = t.LChild; idx -= (Count(t == null ? null : t.RChild) + 1); } else if (cmp <= 0) { t = t.RChild; idx += (Count(t == null ? null : t.LChild) + 1); } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static int LowerBound(Node t, T v) { var torg = t; if (t == null) return -1; var idx = Count(t) - Count(t.RChild) - 1; var ret = Int32.MaxValue; while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp >= 0) { if (cmp == 0) ret = Math.Min(ret, idx); t = t.LChild; if (t == null) ret = Math.Min(ret, idx); idx -= t == null ? 0 : (Count(t.RChild) + 1); } else if (cmp < 0) { t = t.RChild; idx += (Count(t == null ? null : t.LChild) + 1); if (t == null) return idx; } } // return ret; return ret == Int32.MaxValue ? Count(torg) : ret; } public static Node Insert(Node t, T v) { var ub = LowerBound(t, v); return InsertByIdx(t, ub, v); } static Node InsertByIdx(Node t, int k, T v) { var s = Split(t, k); return Merge(Merge(s.Item1, new Node(v)), s.Item2); } public static IEnumerable<T> Enumerate(Node t) { var ret = new List<T>(); Enumerate(t, ret); return ret; } static void Enumerate(Node t, List<T> ret) { if (t == null) return; Enumerate(t.LChild, ret); ret.Add(t.Value); Enumerate(t.RChild, ret); } } /// <summary> /// C-like set /// </summary> public class Set<T> where T : IComparable { protected SB_BinarySearchTree<T>.Node _root; public T this[int idx] { get { return ElementAt(idx); } } public int Count() { return SB_BinarySearchTree<T>.Count(_root); } public virtual void Insert(T v) { if (_root == null) _root = new SB_BinarySearchTree<T>.Node(v); else { if (SB_BinarySearchTree<T>.Find(_root, v) != null) return; _root = SB_BinarySearchTree<T>.Insert(_root, v); } } public void Clear() { _root = null; } public void Remove(T v) { _root = SB_BinarySearchTree<T>.Remove(_root, v); } public bool Contains(T v) { return SB_BinarySearchTree<T>.Contains(_root, v); } public T ElementAt(int k) { var node = SB_BinarySearchTree<T>.FindByIndex(_root, k); if (node == null) throw new IndexOutOfRangeException(); return node.Value; } public int Count(T v) { return SB_BinarySearchTree<T>.UpperBound(_root, v) - SB_BinarySearchTree<T>.LowerBound(_root, v); } public int LowerBound(T v) { return SB_BinarySearchTree<T>.LowerBound(_root, v); } public int UpperBound(T v) { return SB_BinarySearchTree<T>.UpperBound(_root, v); } public Tuple<int, int> EqualRange(T v) { if (!Contains(v)) return new Tuple<int, int>(-1, -1); return new Tuple<int, int>(SB_BinarySearchTree<T>.LowerBound(_root, v), SB_BinarySearchTree<T>.UpperBound(_root, v) - 1); } public List<T> ToList() { return new List<T>(SB_BinarySearchTree<T>.Enumerate(_root)); } } /// <summary> /// C-like multiset /// </summary> public class MultiSet<T> : Set<T> where T : IComparable { public override void Insert(T v) { if (_root == null) _root = new SB_BinarySearchTree<T>.Node(v); else _root = SB_BinarySearchTree<T>.Insert(_root, v); } } }
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 Pair : IComparable { public int x; public int y; public Pair(int X, int Y) { x = X; y = Y; } public int CompareTo(object obj) { Pair kore = (Pair)obj; return y.CompareTo(kore.y); } } class Program { public static Mlong[] combs; static void Main(string[] args) { StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput()); char[] s = scan.Scan().ToCharArray(); bool right = true; int zen = 0; // hidariの足すとこ用 int ren = 0; int[] ans = new int[s.Length]; for (int i = 0; i < s.Length; i++) { if (right) { if (s[i] == 'R') { ren++; } else { if (i == s.Length - 1) { ans[i]++; } ans[i - 1] += (ren + 1) / 2; ans[i] += ren / 2; zen = i - 1; ren = 1; right = false; } } else { if (s[i] == 'L') { ren++; if (i == s.Length - 1) { ans[zen] += ren / 2; ans[zen + 1] += (ren + 1) / 2; } } else { ans[zen] += ren / 2; ans[zen + 1] += (ren + 1) / 2; ren = 1; right = true; } } } Console.WriteLine(String.Join(" ", ans)); } static int check(long moto, long tai) { if (tai % moto != 0) { return 0; } while (tai > 1) { if (tai % moto == 0) { tai /= moto; } else if (tai > moto) { tai %= moto; } else { tai -= moto; } } if (tai == 1) { return 1; } else { return 0; } } static int binary_search<T>(T key, T[] moto, Func<int, T, T[], bool> isok) { int ng = -1; int ok = moto.Length; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isok(mid, key, moto)) { ok = mid; } else { ng = mid; } } return ok; } static int binary_search(int key, int[] moto) { int ng = -1; int ok = moto.Length; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key, moto)) { ok = mid; } else { ng = mid; } } return ok; } static bool isOK(int index, int key, int[] moto) { return moto[index] >= key; } static long Syakutori( int[] a, long k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上 { long sum = 0; int right = 0; long ans = 0; for (int left = 0; left < a.Length; left++) { while (right < a.Length && sum < k) { sum += a[right]; right++; } if (k <= sum) { ans += a.Length - right + 1; } if (left == right) { right++; } else { sum -= a[left]; } } return ans; } static int[] zalgo(String s) { int n = s.Length; int[] ret = new int[n]; ret[0] = n; int i = 1, j = 0; while (i < n) { while (i + j < n && s[j] == s[i + j]) ++j; ret[i] = j; if (j == 0) { ++i; continue; } int k = 1; while (i + k < n && k + ret[k] < j) { ret[i + k] = ret[k]; ++k; } i += k; j -= k; } return ret; } static int gcd(int a, int b) { if (a % b == 0) { return b; } return gcd(b, a % b); } static long gcd(long a, long b) { if (a % b == 0) { return b; } return gcd(b, a % b); } 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 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 long DivideWith(long m, long n, List<long> primes) { while (m % n == 0) { primes.Add(n); m = m / n; } return m; } static long[] SoinsuBunkai(long num) { if (num == 1) return new long[] { 1 }; List<long> primes = new List<long>(); long n = DivideWith(num, 2, primes); n = DivideWith(n, 3, primes); n = DivideWith(n, 5, primes); long i = 0; while (n > 1) { int[] ps = { 7, 11, 13, 17, 19, 23, 29, 31 }; foreach (var p in ps) { // 30m+2, 30m+3, 30m+4, 30m+5, 30m+6、30m+8... は割る必要はない。 n = DivideWith(n, i + p, primes); if (n == 1) break; } i += 30; } return primes.ToArray(); } public static int h; public static int w; public static int BFS(int height, int width, char[,] map) { int[] dx = new int[] { -1, 0, 0, 1 }; int[] dy = new int[] { 0, 1, -1, 0 }; bool[,] visited = new bool[h, w]; int[,] len = new int[h, w]; var queue = new Queue<Tuple<int, int>>(); queue.Enqueue(new Tuple<int, int>(height, width)); int max = 0; visited[height, width] = true; while (queue.Count > 0) { var now = queue.Dequeue(); for (int i = 0; i < 4; i++) { int ny = now.Item1 + dy[i]; int nx = now.Item2 + dx[i]; if (ny >= h || ny < 0 || nx >= w || nx < 0) continue; if (visited[ny, nx] || map[ny, nx] == '#') continue; visited[ny, nx] = true; len[ny, nx] = len[now.Item1, now.Item2] + 1; max = Math.Max(max, len[ny, nx]); queue.Enqueue(new Tuple<int, int>(ny, nx)); } } return max; } } 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(long n) { long[] kore = new long[n]; for (int i = 0; i < n; i++) { kore[i] = Long(); } return kore; } public Mlong[] MLong(long n) { Mlong[] kore = new Mlong[n]; for (int i = 0; i < n; i++) { kore[i] = Long(); } return kore; } public long[,] Long(long h, long w) { long[,] kore = new long[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { kore[i, j] = Long(); } } return kore; } public int Integer() { return (int)Long(); } public Mint[] MInteger(long n) { Mint[] kore = new Mint[n]; for (int i = 0; i < n; i++) { kore[i] = Integer(); } return kore; } public int[] Integer(long n) { int[] kore = new int[n]; for (int i = 0; i < n; i++) { kore[i] = (int)Long(); } return kore; } public int[,] Integer(long h, long 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 : IComparable { 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); } static long GetInverse(long a) { long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1; while (true) { if (p == 1) return x2 + mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p; if (a == 1) return x1 + mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a; } } public Mlong modjyo(Mlong x) { return num * GetInverse(x.num) % mod; } public static implicit operator Mlong(long x) { return new Mlong(x); } public static Mlong operator %(Mlong x, Mlong y) { return new Mlong(x.num % y.num); } public static explicit operator long(Mlong x) { return x.num; } public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; } public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; } public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; } public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; } public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; } public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; } public Mlong Pow(Mlong n) { Mlong pow = this; Mlong res = 1; while (n > 0) { if (n % 2 == 1) { res *= pow; } pow *= pow; n.hutujyo(2); } /* if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mint buf = Pow(n.hutujyo(2)); return (buf * buf) % mod;*/ return res; } public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); } public static List<Mlong> factorialMemo = new List<Mlong>() { 1 }; static Mlong Factorial(int x) { for (int i = factorialMemo.Count; i <= x; i++) factorialMemo.Add(factorialMemo.Last() * i); return factorialMemo[x]; } public static Mlong Comb(Mlong n, Mlong a) { Mlong buf1 = 1; Mlong buf2 = 1; for (long i = 0; i < a.num; i++) { buf1 *= n - i; buf2 *= (i + 1); } return buf1.modjyo(buf2); } public static Mlong Comb(int n, int r) { return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r)); } public static void WriteLine(Mlong x) { Console.WriteLine(x.num); } public int CompareTo(object obj) { Mlong kore = (Mlong)obj; return num.CompareTo(kore.num); } } public class Mint : IComparable { 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); } static int GetInverse(long a) { long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1; while (true) { if (p == 1) return (int)(x2 + mod); div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p; if (a == 1) return (int)(x1 + mod); div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a; } } public Mint modjyo(Mint x) { return num * GetInverse(x.num) % mod; } /* public Mint modjyo(Mint x) { return num * x.Pow(mod - 2); }*/ public static implicit operator Mint(int x) { return new Mint(x); } public static Mint[] Toarray(int[] x) { Mint[] buf = new Mint[x.Length]; for (int i = 0; i < x.Length; i++) { buf[i] = x[i]; } return buf; } public static explicit operator int(Mint x) { return x.num; } public static Mint operator %(Mint x, Mint y) { return new Mint(x.num % y.num); } public static bool operator ==(Mint x, Mint y) { return x.num == y.num; } public static bool operator !=(Mint x, Mint y) { return x.num != y.num; } public static bool operator<(Mint x, Mint y) { return x.num < y.num; } public static bool operator>(Mint x, Mint y) { return x.num > y.num; } public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; } public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; } public Mint Pow(Mint n) { Mint pow = this; Mint res = 1; while (n > 0) { if (n % 2 == 1) { res *= pow; } pow *= pow; n.hutujyo(2); } /* if (n == 1) { return this % mod; } if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; } Mint buf = Pow(n.hutujyo(2)); return (buf * buf) % mod;*/ return res; } public static Mint Pow(Mint a, Mint n) { return a.Pow(n); } public static List<Mint> factorialMemo = new List<Mint>() { 1 }; static Mint Factorial(int x) { for (int i = factorialMemo.Count; i <= x; i++) factorialMemo.Add(factorialMemo.Last() * i); return factorialMemo[x]; } public static Mint Comb(int n, int r) { return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r)); } public static void WriteLine(Mint x) { Console.WriteLine(x.num); } public int CompareTo(object obj) { Mint kore = (Mint)obj; return num.CompareTo(kore.num); } } public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) {} public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) {} public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } public class Tree { public Node[] Nodes; public List<int[]> hen; public class Node { public int? parent = null; public List<int[]> children = new List<int[]>(); public int parentcolor = -1; } public Tree(int kosu) { Nodes = new Node[kosu]; for (int i = 0; i < Nodes.Length; i++) { Nodes[i] = new Node(); } hen = new List<int[]>(); } public void Connect(int oya, int ko, int id) { hen.Add(new int[] { oya, ko, 0 }); Nodes[oya].children.Add(new int[] { ko, id }); Nodes[ko].parent = oya; } } /// <summary> /// Self-Balancing Binary Search Tree /// (using Randamized BST) /// </summary> public class SB_BinarySearchTree<T> where T : IComparable { public class Node { public T Value; public Node LChild; public Node RChild; public int Count; // size of the sub tree public Node(T v) { Value = v; Count = 1; } } static Random _rnd = new Random(); public static int Count(Node t) { return t == null ? 0 : t.Count; } static Node Update(Node t) { t.Count = Count(t.LChild) + Count(t.RChild) + 1; return t; } public static Node Merge(Node l, Node r) { if (l == null || r == null) return l == null ? r : l; if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) { l.RChild = Merge(l.RChild, r); return Update(l); } else { r.LChild = Merge(l, r.LChild); return Update(r); } } /// <summary> /// split as [0, k), [k, n) /// </summary> public static Tuple<Node, Node> Split(Node t, int k) { if (t == null) return new Tuple<Node, Node>(null, null); if (k <= Count(t.LChild)) { var s = Split(t.LChild, k); t.LChild = s.Item2; return new Tuple<Node, Node>(s.Item1, Update(t)); } else { var s = Split(t.RChild, k - Count(t.LChild) - 1); t.RChild = s.Item1; return new Tuple<Node, Node>(Update(t), s.Item2); } } public static Node Remove(Node t, T v) { if (Find(t, v) == null) return t; return RemoveAt(t, LowerBound(t, v)); } public static Node RemoveAt(Node t, int k) { var s = Split(t, k); var s2 = Split(s.Item2, 1); return Merge(s.Item1, s2.Item2); } public static bool Contains(Node t, T v) { return Find(t, v) != null; } public static Node Find(Node t, T v) { while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp > 0) t = t.LChild; else if (cmp < 0) t = t.RChild; else break; } return t; } public static Node FindByIndex(Node t, int idx) { if (t == null) return null; var currentIdx = Count(t) - Count(t.RChild) - 1; while (t != null) { if (currentIdx == idx) return t; if (currentIdx > idx) { t = t.LChild; currentIdx -= (Count(t == null ? null : t.RChild) + 1); } else { t = t.RChild; currentIdx += (Count(t == null ? null : t.LChild) + 1); } } return null; } public static int UpperBound(Node t, T v) { var torg = t; if (t == null) return -1; var ret = Int32.MaxValue; var idx = Count(t) - Count(t.RChild) - 1; while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp > 0) { ret = Math.Min(ret, idx); t = t.LChild; idx -= (Count(t == null ? null : t.RChild) + 1); } else if (cmp <= 0) { t = t.RChild; idx += (Count(t == null ? null : t.LChild) + 1); } } return ret == Int32.MaxValue ? Count(torg) : ret; } public static int LowerBound(Node t, T v) { var torg = t; if (t == null) return -1; var idx = Count(t) - Count(t.RChild) - 1; var ret = Int32.MaxValue; while (t != null) { var cmp = t.Value.CompareTo(v); if (cmp >= 0) { if (cmp == 0) ret = Math.Min(ret, idx); t = t.LChild; if (t == null) ret = Math.Min(ret, idx); idx -= t == null ? 0 : (Count(t.RChild) + 1); } else if (cmp < 0) { t = t.RChild; idx += (Count(t == null ? null : t.LChild) + 1); if (t == null) return idx; } } // return ret; return ret == Int32.MaxValue ? Count(torg) : ret; } public static Node Insert(Node t, T v) { var ub = LowerBound(t, v); return InsertByIdx(t, ub, v); } static Node InsertByIdx(Node t, int k, T v) { var s = Split(t, k); return Merge(Merge(s.Item1, new Node(v)), s.Item2); } public static IEnumerable<T> Enumerate(Node t) { var ret = new List<T>(); Enumerate(t, ret); return ret; } static void Enumerate(Node t, List<T> ret) { if (t == null) return; Enumerate(t.LChild, ret); ret.Add(t.Value); Enumerate(t.RChild, ret); } } /// <summary> /// C-like set /// </summary> public class Set<T> where T : IComparable { protected SB_BinarySearchTree<T>.Node _root; public T this[int idx] { get { return ElementAt(idx); } } public int Count() { return SB_BinarySearchTree<T>.Count(_root); } public virtual void Insert(T v) { if (_root == null) _root = new SB_BinarySearchTree<T>.Node(v); else { if (SB_BinarySearchTree<T>.Find(_root, v) != null) return; _root = SB_BinarySearchTree<T>.Insert(_root, v); } } public void Clear() { _root = null; } public void Remove(T v) { _root = SB_BinarySearchTree<T>.Remove(_root, v); } public bool Contains(T v) { return SB_BinarySearchTree<T>.Contains(_root, v); } public T ElementAt(int k) { var node = SB_BinarySearchTree<T>.FindByIndex(_root, k); if (node == null) throw new IndexOutOfRangeException(); return node.Value; } public int Count(T v) { return SB_BinarySearchTree<T>.UpperBound(_root, v) - SB_BinarySearchTree<T>.LowerBound(_root, v); } public int LowerBound(T v) { return SB_BinarySearchTree<T>.LowerBound(_root, v); } public int UpperBound(T v) { return SB_BinarySearchTree<T>.UpperBound(_root, v); } public Tuple<int, int> EqualRange(T v) { if (!Contains(v)) return new Tuple<int, int>(-1, -1); return new Tuple<int, int>(SB_BinarySearchTree<T>.LowerBound(_root, v), SB_BinarySearchTree<T>.UpperBound(_root, v) - 1); } public List<T> ToList() { return new List<T>(SB_BinarySearchTree<T>.Enumerate(_root)); } } /// <summary> /// C-like multiset /// </summary> public class MultiSet<T> : Set<T> where T : IComparable { public override void Insert(T v) { if (_root == null) _root = new SB_BinarySearchTree<T>.Node(v); else _root = SB_BinarySearchTree<T>.Insert(_root, v); } } }
[["+", 64, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 64, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 64, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 223, 0, 204, 205, 22], ["+", 0, 1, 0, 223, 0, 204, 206, 207, 0, 70], ["+", 0, 223, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 223, 0, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
8
6,790
18
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace ABC136D { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); return; } public void Solve(ConsoleInput cin) { var S = cin.ReadLine.ToCharArray(); var encoeded = new List<RunLength>(); char nowChar = 'a'; int nowNum = 0; for (int i = 0; i < S.Length; i++) { if (i == 0) { nowChar = S[0]; nowNum = 1; } else if (S[i] == nowChar) { nowNum++; } if (S[i] != nowChar) { encoeded.Add(new RunLength() { Character = nowChar, Num = nowNum }); nowChar = S[i]; nowNum = 1; } } encoeded.Add(new RunLength() { Character = nowChar, Num = nowNum }); var final = new List<int>(); for (int i = 0; i < encoeded.Count; i += 2) { decimal RCount = 0; decimal LCount = 0; RCount += Floor((decimal)encoeded[i].Num / 2); LCount += Ceiling((decimal)encoeded[i].Num / 2); RCount += Ceiling((decimal)encoeded[i + 1].Num / 2); LCount += Floor((decimal)encoeded[i + 1].Num / 2); for (int j = 0; j < encoeded[i].Num - 1; j++) { final.Add(0); } final.Add((int)RCount); final.Add((int)LCount); for (int j = 0; j < encoeded[i + 1].Num - 1; j++) { final.Add(0); } } Console.WriteLine(string.Join(" ", final.ToList())); } public class RunLength { public char Character; public int Num; } } public static class Extensions { public static string Reverse(this string sourse) { char[] chrAry = sourse.ToCharArray(); Array.Reverse(chrAry); return new string(chrAry); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace ABC136D { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); return; } public void Solve(ConsoleInput cin) { var S = cin.ReadLine.ToCharArray(); var encoeded = new List<RunLength>(); char nowChar = 'a'; int nowNum = 0; for (int i = 0; i < S.Length; i++) { if (i == 0) { nowChar = S[0]; nowNum = 1; } else if (S[i] == nowChar) { nowNum++; } if (S[i] != nowChar) { encoeded.Add(new RunLength() { Character = nowChar, Num = nowNum }); nowChar = S[i]; nowNum = 1; } } encoeded.Add(new RunLength() { Character = nowChar, Num = nowNum }); var final = new List<int>(); for (int i = 0; i < encoeded.Count; i += 2) { decimal RCount = 0; decimal LCount = 0; RCount += Floor((decimal)encoeded[i].Num / 2); LCount += Ceiling((decimal)encoeded[i].Num / 2); RCount += Ceiling((decimal)encoeded[i + 1].Num / 2); LCount += Floor((decimal)encoeded[i + 1].Num / 2); for (int j = 0; j < encoeded[i].Num - 1; j++) { final.Add(0); } final.Add((int)LCount); final.Add((int)RCount); for (int j = 0; j < encoeded[i + 1].Num - 1; j++) { final.Add(0); } } Console.WriteLine(string.Join(" ", final.ToList())); } public class RunLength { public char Character; public int Num; } } public static class Extensions { public static string Reverse(this string sourse) { char[] chrAry = sourse.ToCharArray(); Array.Reverse(chrAry); return new string(chrAry); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 74, 51, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 51, 22]]
8
841
4
using System; namespace question4 { class Program { static void Main(string[] args) { string LR = "LR"; string str = Console.ReadLine(); int N = str.Length; int[] idx = new int[N]; int[] res = new int[N]; int reg = 0; int count = 0; int pos = 0; string state = "leftwing"; for (int i = 0; i < N; i++) { if (state == "leftwing" && str[i].Equals(LR[1])) // 右送り { // state は左翼のまま count++; reg++; } else if (state == "leftwing" && str[i].Equals(LR[0])) // 切り替わり - 谷 { state = "rightwing"; // state は右翼になる count++; //この段階で reg は更新停止 idx[i - 1] = reg; //この場所を "pos" と記載。切り替わる直前の場所。 pos = i - 1; } else if (state == "rightwing" && str[i].Equals(LR[0])) //左送り { // state は右翼のまま count++; } else if (state == "rightwing" && str[i].Equals(LR[1])) //切り替わり - 山 { state = "leftwing"; // state は左翼になる //切り替わったのでカウントも停止 idx[i - 1] = count; // pos の場所と、pos+1 の場所だけ数字が記載される。 //偶数ならどっちも同じ数 if (count % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2; } //奇数なら else { //もし reg が偶数なら右のほうが大きいので if (reg % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2 + 1; } //そうじゃなければ左のほうが大きいはず else { res[pos] = count / 2 + 1; res[pos + 1] = count / 2; } } count = 1; //ここが左翼のスタートなのでカウント再開 reg = 1; //こっちも } if (i == (N - 1)) //終端 { state = "leftwing"; // state は左翼になる //切り替わったのでカウントも停止 idx[i] = count; // pos の場所と、pos+1 の場所だけ数字が記載される。 //偶数ならどっちも同じ数 if (count % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2; } //奇数なら else { //もし reg が偶数なら右のほうが大きいので if (reg % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2 + 1; } //そうじゃなければ左のほうが大きいはず else { res[pos] = count / 2 + 1; res[pos + 1] = count / 2; } } count = 0; reg = 0; } // res[i] = count; } System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < N; i++) { sb.Append(res[i]); } Console.WriteLine(sb.ToString()); // Console.ReadLine(); } } }
using System; namespace question4 { class Program { static void Main(string[] args) { string LR = "LR"; string str = Console.ReadLine(); int N = str.Length; int[] idx = new int[N]; int[] res = new int[N]; int reg = 0; int count = 0; int pos = 0; string state = "leftwing"; for (int i = 0; i < N; i++) { if (state == "leftwing" && str[i].Equals(LR[1])) // 右送り { // state は左翼のまま count++; reg++; } else if (state == "leftwing" && str[i].Equals(LR[0])) // 切り替わり - 谷 { state = "rightwing"; // state は右翼になる count++; //この段階で reg は更新停止 idx[i - 1] = reg; //この場所を "pos" と記載。切り替わる直前の場所。 pos = i - 1; } else if (state == "rightwing" && str[i].Equals(LR[0])) //左送り { // state は右翼のまま count++; } else if (state == "rightwing" && str[i].Equals(LR[1])) //切り替わり - 山 { state = "leftwing"; // state は左翼になる //切り替わったのでカウントも停止 idx[i - 1] = count; // pos の場所と、pos+1 の場所だけ数字が記載される。 //偶数ならどっちも同じ数 if (count % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2; } //奇数なら else { //もし reg が偶数なら右のほうが大きいので if (reg % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2 + 1; } //そうじゃなければ左のほうが大きいはず else { res[pos] = count / 2 + 1; res[pos + 1] = count / 2; } } count = 1; //ここが左翼のスタートなのでカウント再開 reg = 1; //こっちも } if (i == (N - 1)) //終端 { state = "leftwing"; // state は左翼になる //切り替わったのでカウントも停止 idx[i] = count; // pos の場所と、pos+1 の場所だけ数字が記載される。 //偶数ならどっちも同じ数 if (count % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2; } //奇数なら else { //もし reg が偶数なら右のほうが大きいので if (reg % 2 == 0) { res[pos] = count / 2; res[pos + 1] = count / 2 + 1; } //そうじゃなければ左のほうが大きいはず else { res[pos] = count / 2 + 1; res[pos + 1] = count / 2; } } count = 0; reg = 0; } // res[i] = count; } System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < N; i++) { sb.Append(res[i]); sb.Append(" "); } Console.WriteLine(sb.ToString()); // Console.ReadLine(); } } }
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
8
550
9
using System; using System.Linq; using System.Collections.Generic; namespace program { class Program { static void Main() { var s = Input.ScanStr() + "R"; int Lcount = 0, Rcount = 0, start = 0, point = 0; for (int i = 0; i < s.Length - 1; i++) { if (s[i] == 'L') Lcount++; else Rcount++; if (s[i] == 'R' && s[i + 1] == 'L') point = i - start; if (s[i] == 'L' && s[i + 1] == 'R') { Display(Lcount, Rcount, point); Lcount = Rcount = 0; start = i + 1; } } Console.WriteLine(); } static public void Out(object s) { Console.Write($"{s} "); } static public void Display(int L, int R, int point) { int Left, Right; Left = Right = (L + R) / 2; if ((L + R) % 2 == 1) { if (R > L) Right++; if (L > R) Left++; } for (int i = 0; i < Left + Right; i++) if (i == point) Out(Left); else if (i == point + 1) Out(Right); else Out(0); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } } static class MyMath { public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong GCD(ulong a, ulong b) { Func<ulong, ulong, ulong> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); } } }
using System; using System.Linq; using System.Collections.Generic; namespace program { class Program { static void Main() { var s = Input.ScanStr() + "R"; int Lcount = 0, Rcount = 0, start = 0, point = 0; for (int i = 0; i < s.Length - 1; i++) { if (s[i] == 'L') Lcount++; else Rcount++; if (s[i] == 'R' && s[i + 1] == 'L') point = i - start; if (s[i] == 'L' && s[i + 1] == 'R') { Display(Lcount, Rcount, point); Lcount = Rcount = 0; start = i + 1; } } Console.WriteLine(); } static public void Out(object s) { Console.Write($"{s} "); } static public void Display(int L, int R, int point) { int Left, Right; Left = Right = (L + R) / 2; if ((L + R) % 2 == 1) { if ((Math.Max(L, R) - 1) % 2 == 1) { if (L > R) Left++; else Right++; } else { if (L < R) Left++; else Right++; } } for (int i = 0; i < Left + Right; i++) if (i == point) Out(Left); else if (i == point + 1) Out(Right); else Out(0); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } } static class MyMath { public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong GCD(ulong a, ulong b) { Func<ulong, ulong, ulong> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); } } }
[["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 31, 23, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 31, 23, 0, 16, 31, 213, 3, 4, 0, 21], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 31, 23, 0, 16, 31, 213, 3, 4, 0, 25], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 64, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 64, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 75, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 57, 75, 196, 0, 57, 64, 1, 0, 35], ["+", 64, 196, 0, 57, 75, 196, 0, 57, 0, 95], ["+", 75, 196, 0, 57, 75, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
8
824
36
using System; class P { static void Main() { int n = int.Parse(Console.ReadLine()); double[] kachi = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); Array.Sort(kachi); Array.Reverse(kachi); double sum = 0; for (int i = 0; i < n - 1; i++) { sum += kachi[i] * Math.Pow(0.5, i + 1); Console.WriteLine(sum); } Console.WriteLine(sum + kachi[n - 1] * Math.Pow(0.5, n - 1)); } }
using System; class P { static void Main() { int n = int.Parse(Console.ReadLine()); double[] kachi = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); Array.Sort(kachi); Array.Reverse(kachi); double sum = 0; for (int i = 0; i < n - 1; i++) { sum += kachi[i] * Math.Pow(0.5, i + 1); } Console.WriteLine(sum + kachi[n - 1] * Math.Pow(0.5, n - 1)); } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
8
142
7
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { // 整数の入力 int N = int.Parse(Console.ReadLine()); // var s = Console.ReadLine (); // int[] numbers = new int[N]; float ans = 0; string[] input = Console.ReadLine().Split(' '); float[] numbers = input.Select(float.Parse).ToArray(); for (int i = 0; i < N - 1; i++) { var min1 = numbers.Min(); var min1Index = Array.IndexOf(numbers, min1); numbers[min1Index] = 100000; var min2 = numbers.Min(); var min2Index = Array.IndexOf(numbers, min2); var newValue = (min1 + min2) / 2; numbers[min1Index] = newValue; numbers[min2Index] = 100000; } Console.WriteLine(ans); // int cnt = 1; // int tmp1 = numbers[0]; //見始め // int tmp = numbers[1]; // for (int i = 1; i < N; i++) { // if (numbers[i] < tmp) { // cnt += 1; // if (numbers[i] <= tmp1) { // cnt += 1; // tmp1 = numbers[i]; // } // tmp = numbers[i]; // } else if (numbers[i] == tmp) { // cnt += 1; // } else { // } // } // Console.WriteLine (cnt); // // int D = int.Parse (Console.ReadLine ()); // string[] input = Console.ReadLine ().Split (' '); // int[] numbers = input // .Select (int.Parse) // .ToArray (); // int N = numbers[0]; // int D = num[1]; // int X = 2*D+1; // int cnt = 1; // while(true){ // if(cnt*X / N >= 1){ // break; // }else{ // cnt += 1; // } // } // スペース区切りの整数の入力 // string[] input = Console.ReadLine ().Split (' '); // int[] numbers = input // .Select (int.Parse) // .ToArray (); // int count = 0; // while (true) { // bool ck = cheCk (a, numbers); // if (check) { // numbers = Divide (a, numbers); // count += 1; // } else { // break; // } // } //出力 // Console.WriteLine (cnt); } // public static bool Check (int a, int[] numbers) { // bool check = true; // for (int i = 0; i < a; i++) { // if (numbers[i] % 2 != 0) { // check = false; // } // } // return check; // } // public static int[] Divide (int a, int[] num){ // for (int i = 0; i < a; i++) { // numbers[i] /= 2; // } // return numbers; // } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { // 整数の入力 int N = int.Parse(Console.ReadLine()); // var s = Console.ReadLine (); // int[] numbers = new int[N]; float ans = 0; string[] input = Console.ReadLine().Split(' '); float[] numbers = input.Select(float.Parse).ToArray(); for (int i = 0; i < N - 1; i++) { var min1 = numbers.Min(); var min1Index = Array.IndexOf(numbers, min1); numbers[min1Index] = 100000; var min2 = numbers.Min(); var min2Index = Array.IndexOf(numbers, min2); var newValue = (min1 + min2) / 2; numbers[min1Index] = newValue; numbers[min2Index] = 100000; } ans = numbers.Min(); Console.WriteLine(ans); // int cnt = 1; // int tmp1 = numbers[0]; //見始め // int tmp = numbers[1]; // for (int i = 1; i < N; i++) { // if (numbers[i] < tmp) { // cnt += 1; // if (numbers[i] <= tmp1) { // cnt += 1; // tmp1 = numbers[i]; // } // tmp = numbers[i]; // } else if (numbers[i] == tmp) { // cnt += 1; // } else { // } // } // Console.WriteLine (cnt); // // int D = int.Parse (Console.ReadLine ()); // string[] input = Console.ReadLine ().Split (' '); // int[] numbers = input // .Select (int.Parse) // .ToArray (); // int N = numbers[0]; // int D = num[1]; // int X = 2*D+1; // int cnt = 1; // while(true){ // if(cnt*X / N >= 1){ // break; // }else{ // cnt += 1; // } // } // スペース区切りの整数の入力 // string[] input = Console.ReadLine ().Split (' '); // int[] numbers = input // .Select (int.Parse) // .ToArray (); // int count = 0; // while (true) { // bool ck = cheCk (a, numbers); // if (check) { // numbers = Divide (a, numbers); // count += 1; // } else { // break; // } // } //出力 // Console.WriteLine (cnt); } // public static bool Check (int a, int[] numbers) { // bool check = true; // for (int i = 0; i < a; i++) { // if (numbers[i] % 2 != 0) { // check = false; // } // } // return check; // } // public static int[] Divide (int a, int[] num){ // for (int i = 0; i < a; i++) { // numbers[i] /= 2; // } // return numbers; // } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
252
8
using System; using System.Linq; class Program { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] V = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); double ans = V[0]; for (int i = N - 1; i < N; i++) { foreach (int Y in V) { ans = (ans + Y) / 2; } } Console.WriteLine(ans); Console.ReadLine(); } }
using System; using System.Linq; class Task6 { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] V = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); Array.Sort(V); double X = V[0]; for (int i = N - 1; i < N; i++) { foreach (int Y in V) { X = (X + Y) / 2; } } Console.WriteLine(X); } }
[["-", 36, 36, 36, 36, 0, 208, 0, 235, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 235, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 210, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 210, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
8
125
23
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { int N = cin.ReadInt; int[] intArray = new int[N]; for (int i = 0; i < N; i++) { intArray[i] = cin.ReadInt; } Array.Sort(intArray); int sum = 0; for (int j = 0; j < intArray.Length; j++) { if (j == 0) { sum += intArray[j]; } else { sum = (sum + intArray[j]) / 2; } } WriteLine(sum); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public decimal ReadDecimal { get { return decimal.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { int N = cin.ReadInt; int[] intArray = new int[N]; for (int i = 0; i < N; i++) { intArray[i] = cin.ReadInt; } Array.Sort(intArray); decimal sum = 0; for (int j = 0; j < intArray.Length; j++) { if (j == 0) { sum += intArray[j]; } else { sum = (sum + intArray[j]) / 2; } } WriteLine(Decimal.Round(sum, 5, MidpointRounding.AwayFromZero)); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public decimal ReadDecimal { get { return decimal.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 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, 25]]
8
549
13
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class AtCoderrr { static void Main(string[] args) { int n = int.Parse(ReadLine()); double[] s = ReadLine().Split(' ').Select(double.Parse).ToArray(); var ls = new List<double>(); double ans = 0; ls.AddRange(s); ls.Sort(); for (int i = 0; i < n - 1; i++) { ls.Add(Func(ls[0], ls[1])); ls.Remove(ls[0]); ls.Remove(ls[0]); } WriteLine(ls[0]); } static double Func(double x, double y) { return (x + y) / 2; } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class AtCoderrr { static void Main(string[] args) { int n = int.Parse(ReadLine()); double[] s = ReadLine().Split(' ').Select(double.Parse).ToArray(); var ls = new List<double>(); ls.AddRange(s); for (int i = 0; i < n - 1; i++) { ls.Sort(); ls.Add(Func(ls[0], ls[1])); ls.Remove(ls[0]); ls.Remove(ls[0]); } WriteLine(ls[0]); } static double Func(double x, double y) { return (x + y) / 2; } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
8
209
17
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC138D { class Program { static List<List<int>> ki; static int[] ans; static void Main(string[] args) { string[] NQ = Console.ReadLine().Split(' '); int N = int.Parse(NQ[0]); int Q = int.Parse(NQ[1]); int[] a = new int[N - 1]; int[] b = new int[N - 1]; int[] p = new int[Q]; int[] x = new int[Q]; ki = new List<List<int>>(); for (int i = 0; i < N; i++) { ki.Add(new List<int>()); } for (int i = 0; i < N - 1; i++) { string[] ab = Console.ReadLine().Split(' '); a[i] = int.Parse(ab[0]); b[i] = int.Parse(ab[1]); ki[a[i] - 1].Add(b[i]); ki[b[i] - 1].Add(a[i]); } int[] plus = new int[N]; for (int i = 0; i < Q; i++) { string[] px = Console.ReadLine().Split(' '); p[i] = int.Parse(px[0]); x[i] = int.Parse(px[1]); plus[p[i] - 1] += x[i]; } Console.WriteLine(string.Join(" ", ki[1])); ans = new int[N]; Queue<int> q = new Queue<int>(); q.Enqueue(1); q.Enqueue(0); q.Enqueue(0); tansaku(q, plus); Console.WriteLine(string.Join(" ", ans)); } static void tansaku(Queue<int> q, int[] plus) { if (q.Count == 0) { return; } else { int num = q.Dequeue(); int oya = q.Dequeue(); int count = q.Dequeue(); int l = ki[num - 1].Count; ans[num - 1] = count + plus[num - 1]; for (int i = 0; i < l; i++) { if (ki[num - 1][i] != oya) { q.Enqueue(ki[num - 1][i]); q.Enqueue(num); q.Enqueue(ans[num - 1]); } } tansaku(q, plus); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC138D { class Program { static List<List<int>> ki; static int[] ans; static void Main(string[] args) { string[] NQ = Console.ReadLine().Split(' '); int N = int.Parse(NQ[0]); int Q = int.Parse(NQ[1]); int[] a = new int[N - 1]; int[] b = new int[N - 1]; int[] p = new int[Q]; int[] x = new int[Q]; ki = new List<List<int>>(); for (int i = 0; i < N; i++) { ki.Add(new List<int>()); } for (int i = 0; i < N - 1; i++) { string[] ab = Console.ReadLine().Split(' '); a[i] = int.Parse(ab[0]); b[i] = int.Parse(ab[1]); ki[a[i] - 1].Add(b[i]); ki[b[i] - 1].Add(a[i]); } int[] plus = new int[N]; for (int i = 0; i < Q; i++) { string[] px = Console.ReadLine().Split(' '); p[i] = int.Parse(px[0]); x[i] = int.Parse(px[1]); plus[p[i] - 1] += x[i]; } // Console.WriteLine(string.Join(" ", ki[1])); ans = new int[N]; Queue<int> q = new Queue<int>(); q.Enqueue(1); q.Enqueue(0); q.Enqueue(0); tansaku(q, plus); Console.WriteLine(string.Join(" ", ans)); } static void tansaku(Queue<int> q, int[] plus) { if (q.Count == 0) { return; } else { int num = q.Dequeue(); int oya = q.Dequeue(); int count = q.Dequeue(); int l = ki[num - 1].Count; ans[num - 1] = count + plus[num - 1]; for (int i = 0; i < l; i++) { if (ki[num - 1][i] != oya) { q.Enqueue(ki[num - 1][i]); q.Enqueue(num); q.Enqueue(ans[num - 1]); } } tansaku(q, plus); } } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["-", 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, 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], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
633
19
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { //* var exStdIn = new System.IO.StreamReader("stdin.txt"); System.Console.SetIn(exStdIn); //*/ string[] input = Console.ReadLine().Split(' '); int n = int.Parse(input[0]); int q = int.Parse(input[1]); List<int>[] tree = new List<int>[n]; for (int i = 0; i < n; i++) tree[i] = new List<int>(); for (int i = 0; i < n - 1; i++) { input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); tree[a - 1].Add(b - 1); tree[b - 1].Add(a - 1); } int[] value = new int[n]; for (int i = 0; i < n; i++) value[i] = 0; //各頂点に格納 for (int i = 0; i < q; i++) { input = Console.ReadLine().Split(' '); int p = int.Parse(input[0]); int x = int.Parse(input[1]); value[p - 1] += x; } int[] counter = new int[n]; count(-1, 0, 0, counter, value, tree); Console.WriteLine(string.Join(" ", counter)); } public static void count(int parent, int me, int pval, int[] counter, int[] value, List<int>[] tree) { counter[me] = value[me] + pval; foreach (int child in tree[me]) { if (child != parent) { count(me, child, counter[me], counter, value, tree); } } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int n = int.Parse(input[0]); int q = int.Parse(input[1]); List<int>[] tree = new List<int>[n]; for (int i = 0; i < n; i++) tree[i] = new List<int>(); for (int i = 0; i < n - 1; i++) { input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); tree[a - 1].Add(b - 1); tree[b - 1].Add(a - 1); } int[] value = new int[n]; for (int i = 0; i < n; i++) value[i] = 0; //各頂点に格納 for (int i = 0; i < q; i++) { input = Console.ReadLine().Split(' '); int p = int.Parse(input[0]); int x = int.Parse(input[1]); value[p - 1] += x; } int[] counter = new int[n]; count(-1, 0, 0, counter, value, tree); Console.WriteLine(string.Join(" ", counter)); } public static void count(int parent, int me, int pval, int[] counter, int[] value, List<int>[] tree) { counter[me] = value[me] + pval; foreach (int child in tree[me]) { if (child != parent) { count(me, child, counter[me], counter, value, tree); } } } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["-", 0, 212, 0, 230, 39, 232, 234, 232, 234, 22], ["-", 0, 212, 0, 230, 39, 232, 234, 232, 0, 131], ["-", 0, 212, 0, 230, 39, 232, 234, 232, 141, 22], ["-", 0, 200, 0, 212, 0, 230, 39, 232, 0, 131], ["-", 0, 200, 0, 212, 0, 230, 39, 232, 141, 22], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 230, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 230, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 141, 22], ["-", 8, 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
478
24
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var nq = Console.ReadLine().Split(' '); var n = int.Parse(nq[0]); var q = int.Parse(nq[1]); var tree = new List<Tree>(); tree.Add(new Tree(-1, 0)); for (var i = 1; i < n; i++) { var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); tree.Add(new Tree(a - 1, 0)); } for (var j = 0; j < q; j++) { var px = Console.ReadLine().Split(' '); var p = int.Parse(px[0]); var x = int.Parse(px[1]); tree[p - 1].Value += x; } for (var k = 0; k < n; k++) { if (k != 0) { Console.Write(" "); tree[k].Value += tree[tree[k].Parent].Value; } Console.Write(tree[k].Value); } } public class Tree { public int Parent; public long Value; public Tree(int parent, int value) { this.Parent = parent; this.Value = value; } } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var nq = Console.ReadLine().Split(' '); var n = int.Parse(nq[0]); var q = int.Parse(nq[1]); var tree = new Dictionary<int, Tree>(); tree.Add(0, new Tree(-1, 0)); for (var i = 1; i < n; i++) { var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); tree.Add(b - 1, new Tree(a - 1, 0)); } for (var j = 0; j < q; j++) { var px = Console.ReadLine().Split(' '); var p = int.Parse(px[0]); var x = int.Parse(px[1]); tree[p - 1].Value += x; } for (var k = 0; k < n; k++) { if (k != 0) { Console.Write(" "); tree[k].Value += tree[tree[k].Parent].Value; } Console.Write(tree[k].Value); } } public class Tree { public int Parent; public long Value; public Tree(int parent, long value) { this.Parent = parent; this.Value = value; } } }
[["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 21], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199]]
8
339
12
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; class MainClass { static void Main() { string s = ReadLine(); string t = ReadLine(); string S = s + s; var next = new long [26][]; for (int i = 0; i < 26; i++) { next[i] = new long[s.Length]; int point = -1; for (int now = S.Length - 1; now >= 0; now--) { if (S[now] == 'a' + i) point = now; if (now < s.Length) { next[i][now] = point - now; } } } long ans = 0; long sindex = 0; for (int i = 0; i < t.Length; i++) { var v = next[t[i] - 'a'][sindex] + 1; if (v < 0) { WriteLine(-1); return; } ans += v; sindex = (sindex + v) % s.Length; } WriteLine(ans); } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; class MainClass { static void Main() { string s = ReadLine(); string t = ReadLine(); string S = s + s; var next = new long [26][]; for (int i = 0; i < 26; i++) { next[i] = new long[s.Length]; int point = -1; for (int now = S.Length - 1; now >= 0; now--) { if (S[now] == 'a' + i) point = now; if (now < s.Length) { next[i][now] = point - now; } } } long ans = 0; long sindex = 0; for (int i = 0; i < t.Length; i++) { var v = next[t[i] - 'a'][sindex]; if (v < 0) { WriteLine(-1); return; } else { ans += v + 1; sindex += v + 1; sindex %= s.Length; } } WriteLine(ans); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
8
249
19
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Library; using static Library.Input; namespace AtCoderTemplate { class ProgramE { static void Main() { var s = Line; var t = Line; var counts = Enumerable.Range(0, 26).Select(_ => new List<int>()).ToArray(); for (int i = 0; i < s.Length; i++) { counts[s[i] - 'a'].Add(i); } long result = 1; int value = 0; for (int i = 0; i < t.Length; i++) { var list = counts[t[i] - 'a']; if (!list.Any()) { System.Console.WriteLine(-1); return; } int left = -1, right = list.Count(); while (right - left > 1) { int mid = (left + right) / 2; if (list[mid] > value) right = mid; else left = mid; } if (right == list.Count()) { result += s.Length - (value - list[left]); value = list[left]; } else { result += list[right] - value; value = list[right]; } } System.Console.WriteLine(result); } } } namespace Library { class Input { static IEnumerator<string> enumerator = new string[] {}.AsEnumerable().GetEnumerator(); public static string Line => Console.ReadLine(); public static string[] StrArr => Line.Split(' '); public static int NextInt => int.Parse(NextWord()); public static long NextLong => long.Parse(NextWord()); public static List<int> IntList => StrArr.Select(int.Parse).ToList(); public static List<long> LongList => StrArr.Select(long.Parse).ToList(); public static IEnumerable<long[]> TakeLine(int N) { return Enumerable.Repeat(0, N).Select( _ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()); } public static string NextWord() { while (!enumerator.MoveNext()) { enumerator = StrArr.AsEnumerable().GetEnumerator(); } return enumerator.Current; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Library; using static Library.Input; namespace AtCoderTemplate { class ProgramE { static void Main() { var s = Line; var t = Line; var counts = Enumerable.Range(0, 26).Select(_ => new List<int>()).ToArray(); for (int i = 0; i < s.Length; i++) { counts[s[i] - 'a'].Add(i); } long result = 0; int value = -1; for (int i = 0; i < t.Length; i++) { var list = counts[t[i] - 'a']; if (!list.Any()) { System.Console.WriteLine(-1); return; } int left = -1, right = list.Count(); while (right - left > 1) { int mid = (left + right) / 2; if (list[mid] > value) right = mid; else left = mid; } if (right == list.Count()) { result += s.Length - (value - list.First()); value = list.First(); } else { result += list[right] - value; value = list[right]; } // System.Console.WriteLine($"left:{left}, right:{right}, value:{value}, // result:{result}"); } System.Console.WriteLine(result); } } } namespace Library { class Input { static IEnumerator<string> enumerator = new string[] {}.AsEnumerable().GetEnumerator(); public static string Line => Console.ReadLine(); public static string[] StrArr => Line.Split(' '); public static int NextInt => int.Parse(NextWord()); public static long NextLong => long.Parse(NextWord()); public static List<int> IntList => StrArr.Select(int.Parse).ToList(); public static List<long> LongList => StrArr.Select(long.Parse).ToList(); public static IEnumerable<long[]> TakeLine(int N) { return Enumerable.Repeat(0, N).Select( _ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()); } public static string NextWord() { while (!enumerator.MoveNext()) { enumerator = StrArr.AsEnumerable().GetEnumerator(); } return enumerator.Current; } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["-", 12, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 12, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 12, 23, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 12, 23, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
8
518
19
using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main() { var s = Console.ReadLine(); var t = Console.ReadLine(); var posList = Enumerable.Range(0, 'z' - 'a' + 1) .Select(x => new List<int>()) .ToList(); var text = s + s; for (var index = 0; index < text.Length; index++) { posList[text[index] - 'a'].Add(index); } long result = 0; foreach (var c in t) { var list = posList[c - 'a']; if (!list.Any()) { result = -1; break; } var current = (int)(result % s.Length); var next = list.FirstOrDefault(index => index >= current); if (next == 0) { result = -1; break; } result += next - current + 1; } Console.WriteLine(result); } }
using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main() { var s = Console.ReadLine(); var t = Console.ReadLine(); var posList = Enumerable.Range(0, 'z' - 'a' + 1) .Select(x => new List<int>()) .ToList(); var text = s + s; for (var index = 0; index < text.Length; index++) { posList[text[index] - 'a'].Add(index); } long result = 0; foreach (var c in t) { var list = posList[c - 'a']; if (!list.Any()) { result = -1; break; } var current = (int)(result % s.Length); var listIndex = list.BinarySearch(current); if (listIndex < 0) { listIndex = ~listIndex; } var next = list[listIndex]; result += next - current + 1; } Console.WriteLine(result); } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 17, 20], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 241, 0, 33], ["-", 64, 196, 0, 1, 0, 11, 12, 241, 0, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 64, 196, 0, 1, 0, 11, 12, 241, 0, 92], ["+", 64, 196, 0, 1, 0, 11, 12, 241, 0, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 210, 8, 196, 0, 197, 0, 35]]
8
227
28
using System; using System.Collections.Generic; using System.Text; using System.Numerics; using System.IO; namespace SolutionCS { class Program { static void Main(string[] args) { string s = Console.ReadLine(); string t = Console.ReadLine(); int[,] l = new int[s.Length, 26]; int[] count = new int[26]; for (int j = 0; j < 26; j++) { count[j] = -1; for (int i = 0; i < s.Length; i++) { l[i, j] = -1; } } string ss = s + s; for (int i = ss.Length - 1; i > 0; i--) { int charInd = ss[i] - 'a'; count[charInd] = 1; int arrInd = (i - 1) % s.Length; for (int j = 0; j < 26; j++) { if (l[arrInd, j] < 0) { l[arrInd, j] = count[j]; } if (count[j] > 0) { count[j]++; } } } int pos = 0; long ans = 0; if (t[0] != s[0]) { pos = l[0, t[0] - 'a']; ans = pos; } for (int i = 1; i < t.Length; i++) { int c = t[i] - 'a'; if (l[pos, c] < 0) { Console.WriteLine(-1); return; } int step = l[pos, c]; ans += step; pos += step; pos %= s.Length; } Console.WriteLine(ans + 1); } } }
using System; using System.Collections.Generic; using System.Text; using System.Numerics; using System.IO; namespace SolutionCS { class Program { static void Main(string[] args) { string s = Console.ReadLine(); string t = Console.ReadLine(); int[,] l = new int[s.Length, 26]; int[] count = new int[26]; for (int j = 0; j < 26; j++) { count[j] = -1; for (int i = 0; i < s.Length; i++) { l[i, j] = -1; } } string ss = s + s; for (int i = ss.Length - 1; i > 0; i--) { int charInd = ss[i] - 'a'; count[charInd] = 1; int arrInd = (i - 1) % s.Length; for (int j = 0; j < 26; j++) { if (l[arrInd, j] < 0) { l[arrInd, j] = count[j]; } if (count[j] > 0) { count[j]++; } } } int pos = 0; long ans = 0; if (t[0] != s[0]) { pos = l[0, t[0] - 'a']; if (pos < 0) { Console.WriteLine(-1); return; } ans = pos; } for (int i = 1; i < t.Length; i++) { int c = t[i] - 'a'; if (l[pos, c] < 0) { Console.WriteLine(-1); return; } int step = l[pos, c]; ans += step; pos += step; pos %= s.Length; } Console.WriteLine(ans + 1); } } }
[["+", 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, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 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, 241, 0, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 241, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
8
388
18
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { partial class Program { static void Main(string[] args) { //↓ var s = Console.ReadLine(); var t = Console.ReadLine(); var sset = new HashSet<char>(s); var tset = new HashSet<char>(t); if (!tset.All(tc => sset.Contains(tc))) { Console.WriteLine(-1); return; } var cd = new Dictionary<char, List<int>>(); for (int i = 0; i < s.Length; i++) { var c = s[i]; List<int> l; if (cd.TryGetValue(c, out l)) { l.Add(i); } else { l = new List<int>(); l.Add(i); cd[c] = l; } } var d = new Dictionary<char, int[]>(); foreach (var kv in cd) { d[kv.Key] = kv.Value.ToArray(); } long count = 0; int j = -1; for (int i = 0; i < t.Length; i++) { var c = t[i]; var l = d[c]; var ji = Array.BinarySearch(l, j); if (ji < 0) { ji = ~ji; if (ji < l.Length) { j = l[ji]; } else { count += s.Length; j = l[0]; continue; } } else { j = l[ji]; } if (j > -1) { continue; } else { count += s.Length; j = l[0]; } } count += j + 1; Console.WriteLine(count); //↑ } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { partial class Program { static void Main(string[] args) { //↓ var s = Console.ReadLine(); var t = Console.ReadLine(); var sset = new HashSet<char>(s); var tset = new HashSet<char>(t); if (!tset.All(tc => sset.Contains(tc))) { Console.WriteLine(-1); return; } var cd = new Dictionary<char, List<int>>(); for (int i = 0; i < s.Length; i++) { var c = s[i]; List<int> l; if (cd.TryGetValue(c, out l)) { l.Add(i); } else { l = new List<int>(); l.Add(i); cd[c] = l; } } var d = new Dictionary<char, int[]>(); foreach (var kv in cd) { d[kv.Key] = kv.Value.ToArray(); } long count = 0; int j = -1; for (int i = 0; i < t.Length; i++) { var c = t[i]; var l = d[c]; var ji = Array.BinarySearch(l, j); if (ji < 0) { ji = ~ji; if (ji < l.Length) { j = l[ji]; } else { count += s.Length; j = l[0]; continue; } } else { if (ji + 1 >= l.Length) { count += s.Length; j = l[0]; continue; } j = l[ji + 1]; } if (j > -1) { continue; } else { count += s.Length; j = l[0]; } } count += j + 1; Console.WriteLine(count); //↑ } } }
[["+", 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], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 20], ["+", 75, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["+", 75, 196, 0, 57, 15, 16, 12, 214, 141, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 75, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 75, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
398
29