buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; using System.Text.RegularExpressions; namespace Yuzuki { class Yukari { static int n; static long k; static int[] As; public static void Main(string[] args) { input(); int cur = 0, t = 1, s; int[] memo = new int[n]; memo[0] = 1; while (true) { cur = As[cur]; t++; if (memo[cur] > 0) { s = t - memo[cur]; break; } memo[cur] = t; } k = (k - t + 1) % s; while (k > 0) { cur = As[cur]; k--; } // Console.WriteLine(s); // Console.WriteLine(t); Console.WriteLine(cur + 1); } public static void input() { string[] buf = Console.ReadLine().Split(); n = int.Parse(buf[0]); k = long.Parse(buf[1]); As = new int[n]; buf = Console.ReadLine().Split(); for (int i = 0; i < n; i++) { As[i] = int.Parse(buf[i]) - 1; } } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; using System.Text.RegularExpressions; namespace Yuzuki { class Yukari { static int n; static long k; static int[] As; public static void Main(string[] args) { input(); int cur = 0, t = 1, s = 1; int[] memo = new int[n]; memo[0] = 1; while (true && k > 0) { cur = As[cur]; t++; k--; if (memo[cur] > 0) { s = t - memo[cur]; break; } memo[cur] = t; } k %= s; while (k > 0) { cur = As[cur]; k--; } // Console.WriteLine(s); // Console.WriteLine(t); Console.WriteLine(cur + 1); } public static void input() { string[] buf = Console.ReadLine().Split(); n = int.Parse(buf[0]); k = long.Parse(buf[1]); As = new int[n]; buf = Console.ReadLine().Split(); for (int i = 0; i < n; i++) { As[i] = int.Parse(buf[i]) - 1; } } } }
[["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 98], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 52, 15, 16, 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, 68], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 12, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["-", 12, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["-", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132]]
8
297
19
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; const double eps = 1e-11; static void Main() { Sc sc = new Sc(); var s = sc.La; var a = sc.Ia2; var h = Enumerable.Repeat(-1, (int)s[0] + 1).ToArray(); int d = 1, k = 0; while (h[d] == -1) { h[d] = k; d = a[d]; if (k == s[1]) { Console.WriteLine(d); return; } k++; } s[1] -= h[d]; s[1] %= k - h[d]; while (s[1] > 0) { d = a[d]; s[1]--; } Console.WriteLine(d); } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; const double eps = 1e-11; static void Main() { Sc sc = new Sc(); var s = sc.La; var a = sc.Ia2; var h = Enumerable.Repeat(-1, (int)s[0] + 1).ToArray(); int d = 1, k = 0; while (h[d] == -1) { h[d] = k; if (k == s[1]) { Console.WriteLine(d); return; } d = a[d]; k++; } s[1] -= h[d]; s[1] %= k - h[d]; while (s[1] > 0) { d = a[d]; s[1]--; } Console.WriteLine(d); } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
[["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 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, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
8
1,190
14
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var N = int.Parse(input[0]); var K = long.Parse(input[1]); var array = Console.ReadLine().Split(' '); var list = new List<int>(); var flag = new int[N]; foreach (var n in array) { list.Add(int.Parse(n)); } var cities = new List<int>(); var city = 1; var i = 0; var start = 0; var visitedCity = new List<int>(); visitedCity.Add(1); while (true) { city = list[city - 1]; if (flag[city - 1] == 0) { flag[city - 1] = i + 1; visitedCity.Add(city); } else { start = flag[city - 1]; break; } i++; } var newPath = new List<int>(); for (var j = start; j < visitedCity.Count; j++) { newPath.Add(visitedCity[j]); } long count = K; count -= start; count = count % newPath.Count; Console.WriteLine(newPath[(int)(count)]); Console.ReadLine(); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var N = int.Parse(input[0]); var K = long.Parse(input[1]); var array = Console.ReadLine().Split(' '); var list = new List<int>(); var flag = new int[N]; foreach (var n in array) { list.Add(int.Parse(n)); } var cities = new List<int>(); var city = 1; var i = 0; var start = 0; var visitedCity = new List<int>(); visitedCity.Add(1); while (true) { city = list[city - 1]; if (flag[city - 1] == 0) { flag[city - 1] = i + 1; visitedCity.Add(city); } else { start = flag[city - 1]; break; } i++; } var newPath = new List<int>(); for (var j = start; j < visitedCity.Count; j++) { newPath.Add(visitedCity[j]); } long count = K; if (count < start) { Console.WriteLine(visitedCity[(int)count]); } else { count -= start; count = count % newPath.Count; Console.WriteLine(newPath[(int)(count)]); } 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, 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], ["+", 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, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 204, 206, 207, 0, 28, 0, 74, 0, 24], ["+", 0, 204, 206, 207, 0, 28, 0, 74, 39, 199], ["+", 0, 204, 206, 207, 0, 28, 0, 74, 0, 25], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
313
24
using System; using System.Linq; using System.Collections.Generic; using E = System.Linq.Enumerable; public class Program { public static void Main() { var nk = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); var (n, k) = (nk[0], nk[1]); var seqA = Console.ReadLine() .Split() .Select(x => int.Parse(x)) .Prepend(1) .ToArray(); ++k; var (t, s) = (0, 1); var vs = new int[seqA.Length]; while (k-- > 0 && vs[s] < 1) { vs[s] = vs[t] + 1; (t, s) = (s, seqA[s]); } k %= vs[t] - vs[s] + 1; while (k-- > 0) { s = seqA[s]; } Console.WriteLine(s); } }
using System; using System.Linq; using System.Collections.Generic; using E = System.Linq.Enumerable; public class Program { public static void Main() { var nk = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); var (n, k) = (nk[0], nk[1]); var seqA = Console.ReadLine() .Split() .Select(x => int.Parse(x)) .Prepend(1) .ToArray(); ++k; var (t, s) = (0, 1); var vs = new int[seqA.Length]; while (k-- > 0 && vs[s] < 1) { vs[s] = vs[t] + 1; (t, s) = (s, seqA[s]); } if (k < 0) { s = t; } k %= vs[t] - vs[s] + 1; while (k-- > 0) { s = seqA[s]; } Console.WriteLine(s); } }
[["+", 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, 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
226
12
using System; using System.Collections.Generic; using System.Linq; using static System.Math; using static ABC166.abc166_f.Cin; using static ABC166.abc166_f.Util; using Pair = ABC166.abc166_f.VTuple<long, long>; /// <summary> /// ABC166 /// F - Three Variables Game /// https://atcoder.jp/contests/ABC166/tasks/abc166_f /// </summary> namespace ABC166.abc166_f { public class Program { public static void Main(string[] args) { int N = ri; int A = ri; int B = ri; int C = ri; string[] choice = new string[N]; for (int i = 0; i < N; i++) { choice[i] = rs; } DontAutoFlush(); char[] result = new char[N]; HashMap<ValueTuple<int, int, int, int>, bool> memo = new HashMap<ValueTuple<int, int, int, int>, bool>(); Action<int, int, int, int> rec = null; rec = (i, a, b, c) => { ValueTuple<int, int, int, int> key = (i, a, b, c); if (memo.ContainsKey(key) && memo[key] == false) { return; } if (a < 0 || b < 0 || c < 0) { memo[key] = false; return; } if (i == N) { for (int j = 0; j < N; j++) { Console.WriteLine(result[j]); } Flush(); Environment.Exit(0); } if (choice[i] == "AB") { result[i] = 'B'; rec(i + 1, a - 1, b + 1, c); result[i] = 'A'; rec(i + 1, a + 1, b - 1, c); } else if (choice[i] == "AC") { result[i] = 'C'; rec(i + 1, a - 1, b, c + 1); result[i] = 'A'; rec(i + 1, a + 1, b, c - 1); } else if (choice[i] == "BC") { result[i] = 'C'; rec(i + 1, a, b - 1, c + 1); result[i] = 'B'; rec(i + 1, a, b + 1, c - 1); } }; rec(0, A, B, C); } } /// <summary> /// 競プロライブラリ /// https://github.com/ha2ne2/ABC/tree/master/Lib /// </summary> public struct Mint : System.IComparable<Mint>, System.IEquatable<Mint> { public static readonly long MOD = (long)1e9 + 7; public long Value; public Mint(long val) { Value = val % MOD; if (Value < 0) Value += MOD; } private static Mint Ctor(long val) { return new Mint() { Value = val }; } public static Mint operator +(Mint a, Mint b) { long res = a.Value + b.Value; if (res > MOD) res -= MOD; return Ctor(res); } public static Mint operator -(Mint a, Mint b) { long res = a.Value - b.Value; if (res < 0) res += MOD; return Ctor(res); } public static Mint operator *(Mint a, Mint b) { long res = a.Value * b.Value; if (res > MOD) res %= MOD; return Ctor(res); } public static Mint operator /(Mint a, Mint b) { return a * Inv(b); } public override bool Equals(object obj) { return obj is Mint && Value == ((Mint)obj).Value; } public override int GetHashCode() { return Value.GetHashCode(); } public override string ToString() { return Value.ToString(); } public static implicit operator Mint(long a) { return new Mint(a); } public static explicit operator long(Mint a) { return a.Value; } public static Mint Pow(Mint a, long n) { if (n == 0) return new Mint(1); Mint b = Pow(a, n >> 1); b *= b; if ((n & 1) == 1) b *= a; return b; } public static Mint Inv(Mint n) { long a = n.Value; long b = MOD; long x = 1; long u = 0; while (b != 0) { long k = a / b; long _x = u; u = x - k * u; x = _x; long _a = a; a = b; b = _a - (k * b); } return new Mint(x); } public bool Equals(Mint other) { return Value == other.Value; } public int CompareTo(Mint other) { return Comparer<long>.Default.Compare(Value, other.Value); } } public class HashMap<K, V> : System.Collections.Generic.Dictionary<K, V> { private V DefaultValue; private static Func<V> CreateInstance = System.Linq.Expressions.Expression .Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V))) .Compile(); public HashMap() {} public HashMap(V defaultValue) { DefaultValue = defaultValue; } new public V this[K i] { get { V v; if (TryGetValue(i, out v)) { return v; } else { return base[i] = DefaultValue != null ? DefaultValue : CreateInstance(); } } set { base[i] = value; } } } public struct VTuple<T1, T2> : System.IComparable<VTuple<T1, T2>>, System.IEquatable<VTuple<T1, T2>> { public T1 Item1; public T2 Item2; public T1 First { get { return Item1; } } public T2 Second { get { return Item2; } } public VTuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; } public override bool Equals(object obj) { return obj is VTuple<T1, T2> && Equals((VTuple<T1, T2>)obj); } public override int GetHashCode() { int h1 = Item1 != null ? Item1.GetHashCode() : 0; int h2 = Item2 != null ? Item2.GetHashCode() : 0; return HashHelpers.CombineHashCodes(h1, h2); } public override string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ")"; } public bool Equals(VTuple<T1, T2> other) { return EqualityComparer<T1>.Default.Equals(Item1, other.Item1) && EqualityComparer<T2>.Default.Equals(Item2, other.Item2); } public int CompareTo(VTuple<T1, T2> other) { int c = Comparer<T1>.Default.Compare(Item1, other.Item1); if (c != 0) return c; return Comparer<T2>.Default.Compare(Item2, other.Item2); } } public struct VTuple3<T1, T2, T3> : System.IComparable<VTuple3<T1, T2, T3>>, System.IEquatable<VTuple3<T1, T2, T3>> { public T1 Item1; public T2 Item2; public T3 Item3; public VTuple3(T1 item1, T2 item2, T3 item3) { Item1 = item1; Item2 = item2; Item3 = item3; } public override bool Equals(object obj) { return obj is VTuple3<T1, T2, T3> && Equals((VTuple3<T1, T2, T3>)obj); } public override int GetHashCode() { int h1 = Item1 != null ? Item1.GetHashCode() : 0; int h2 = Item2 != null ? Item2.GetHashCode() : 0; int h3 = Item3 != null ? Item3.GetHashCode() : 0; return HashHelpers.CombineHashCodes(h1, h2, h3); } public override string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ")"; } public bool Equals(VTuple3<T1, T2, T3> other) { return EqualityComparer<T1>.Default.Equals(Item1, other.Item1) && EqualityComparer<T2>.Default.Equals(Item2, other.Item2) && EqualityComparer<T3>.Default.Equals(Item3, other.Item3); } public int CompareTo(VTuple3<T1, T2, T3> other) { int c = Comparer<T1>.Default.Compare(Item1, other.Item1); if (c != 0) return c; c = Comparer<T2>.Default.Compare(Item2, other.Item2); if (c != 0) return c; return Comparer<T3>.Default.Compare(Item3, other.Item3); } } public struct VTuple4<T1, T2, T3, T4> : System.IComparable<VTuple4<T1, T2, T3, T4>>, System.IEquatable<VTuple4<T1, T2, T3, T4>> { public T1 Item1; public T2 Item2; public T3 Item3; public T4 Item4; public VTuple4(T1 item1, T2 item2, T3 item3, T4 item4) { Item1 = item1; Item2 = item2; Item3 = item3; Item4 = item4; } public override bool Equals(object obj) { return obj is VTuple4<T1, T2, T3, T4> && Equals((VTuple4<T1, T2, T3, T4>)obj); } public override int GetHashCode() { int h1 = Item1 != null ? Item1.GetHashCode() : 0; int h2 = Item2 != null ? Item2.GetHashCode() : 0; int h3 = Item3 != null ? Item3.GetHashCode() : 0; int h4 = Item3 != null ? Item4.GetHashCode() : 0; return HashHelpers.CombineHashCodes(h1, h2, h3, h4); } public override string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ")"; } public bool Equals(VTuple4<T1, T2, T3, T4> other) { return EqualityComparer<T1>.Default.Equals(Item1, other.Item1) && EqualityComparer<T2>.Default.Equals(Item2, other.Item2) && EqualityComparer<T3>.Default.Equals(Item3, other.Item3) && EqualityComparer<T4>.Default.Equals(Item4, other.Item4); } public int CompareTo(VTuple4<T1, T2, T3, T4> other) { int c = Comparer<T1>.Default.Compare(Item1, other.Item1); if (c != 0) return c; c = Comparer<T2>.Default.Compare(Item2, other.Item2); if (c != 0) return c; c = Comparer<T3>.Default.Compare(Item3, other.Item3); if (c != 0) return c; return Comparer<T4>.Default.Compare(Item4, other.Item4); } } public static class HashHelpers { public static readonly int RandomSeed = new System.Random().Next(int.MinValue, int.MaxValue); public static int Combine(int h1, int h2) { uint rol5 = ((uint)h1 << 5) | ((uint)h1 >> 27); return ((int)rol5 + h1) ^ h2; } public static int CombineHashCodes(int h1, int h2) { return Combine(Combine(RandomSeed, h1), h2); } public static int CombineHashCodes(int h1, int h2, int h3) { return Combine(CombineHashCodes(h1, h2), h3); } public static int CombineHashCodes(int h1, int h2, int h3, int h4) { return Combine(CombineHashCodes(h1, h2, h3), h4); } } public static class Cin { public static int ri { get { return ReadInt(); } } public static int[] ria { get { return ReadIntArray(); } } public static long rl { get { return ReadLong(); } } public static long[] rla { get { return ReadLongArray(); } } public static double rd { get { return ReadDouble(); } } public static double[] rda { get { return ReadDoubleArray(); } } public static string rs { get { return ReadString(); } } public static string[] rsa { get { return ReadStringArray(); } } public static int ReadInt() { return int.Parse(Next()); } public static long ReadLong() { return long.Parse(Next()); } public static double ReadDouble() { return double.Parse(Next()); } public static string ReadString() { return Next(); } public static int[] ReadIntArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } public static long[] ReadLongArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } public static double[] ReadDoubleArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); } public static string[] ReadStringArray() { Tokens = null; return Console.ReadLine().Split(' '); } public static void ReadCol(out long[] a, long N) { a = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); } } public static void ReadCols(out long[] a, out long[] b, long N) { a = new long[N]; b = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); } } public static void ReadCols(out long[] a, out long[] b, out long[] c, long N) { a = new long[N]; b = new long[N]; c = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); c[i] = ReadLong(); } } public static int[,] ReadIntTable(int h, int w) { Tokens = null; int[,] ret = new int[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ret[i, j] = ReadInt(); } } return ret; } public static long[,] ReadLongTable(long h, long w) { Tokens = null; long[,] ret = new long[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ret[i, j] = ReadLong(); } } return ret; } public static char[,] ReadCharTable(int h, int w) { Tokens = null; char[,] res = new char[h, w]; for (int i = 0; i < h; i++) { string s = ReadString(); for (int j = 0; j < w; j++) { res[i, j] = s[j]; } } return res; } private static string[] Tokens; private static int Pointer; private static string Next() { if (Tokens == null || Tokens.Length <= Pointer) { Tokens = Console.ReadLine().Split(' '); Pointer = 0; } return Tokens[Pointer++]; } } public static class Util { public static readonly long INF = (long)1e17; public readonly static long MOD = (long)1e9 + 7; public readonly static int[] DXY4 = { 0, 1, 0, -1, 0 }; public readonly static int[] DXY8 = { 1, 1, 0, 1, -1, 0, -1, -1, 1 }; public static void DontAutoFlush() { if (Console.IsOutputRedirected) return; var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } public static void Flush() { Console.Out.Flush(); } public static T[] Sort<T>(T[] array) { Array.Sort<T>(array); return array; } public static T[] SortDecend<T>(T[] array) { Array.Sort<T>(array); Array.Reverse(array); return array; } public static void Swap<T>(ref T a, ref T b) { T _a = a; a = b; b = _a; } public static long GCD(long a, long b) { while (b != 0) { long _a = a; a = b; b = _a % b; } return a; } public static long LCM(long a, long b) { if (a == 0 || b == 0) return 0; return a * b / GCD(a, b); } public static void ChMax(ref long a, long b) { if (a < b) a = b; } public static void ChMin(ref long a, long b) { if (a > b) a = b; } public static void ChMax(ref int a, int b) { if (a < b) a = b; } public static void ChMin(ref int a, int b) { if (a > b) a = b; } public static void FillArray<T>(T[] array, T value) { int max = array.Length; for (int i = 0; i < max; i++) { array[i] = value; } } public static void FillArray<T>(T[,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { array[i, j] = value; } } } public static void FillArray<T>(T[,,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); int max2 = array.GetLength(2); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { for (int k = 0; k < max2; k++) { array[i, j, k] = value; } } } } public static long[] Accumulate(long[] array) { long[] acc = new long[array.Length + 1]; for (int i = 0; i < array.Length; i++) { acc[i + 1] = acc[i] + array[i]; } return acc; } public static double[] Accumulate(double[] array) { double[] acc = new double[array.Length + 1]; for (int i = 0; i < array.Length; i++) { acc[i + 1] = acc[i] + array[i]; } return acc; } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; using static ABC166.abc166_f.Cin; using static ABC166.abc166_f.Util; using Pair = ABC166.abc166_f.VTuple<long, long>; /// <summary> /// ABC166 /// F - Three Variables Game /// https://atcoder.jp/contests/ABC166/tasks/abc166_f /// </summary> namespace ABC166.abc166_f { public class Program { public static void Main(string[] args) { int N = ri; int A = ri; int B = ri; int C = ri; string[] choice = new string[N]; for (int i = 0; i < N; i++) { choice[i] = rs; } DontAutoFlush(); char[] result = new char[N]; HashMap<ValueTuple<int, int, int, int>, bool> memo = new HashMap<ValueTuple<int, int, int, int>, bool>(); Action<int, int, int, int> rec = null; rec = (i, a, b, c) => { ValueTuple<int, int, int, int> key = (i, a, b, c); if (memo.ContainsKey(key) && memo[key] == false) { return; } if (a < 0 || b < 0 || c < 0) { memo[key] = false; return; } if (i == N) { Console.WriteLine("Yes"); for (int j = 0; j < N; j++) { Console.WriteLine(result[j]); } Flush(); Environment.Exit(0); } if (choice[i] == "AB") { result[i] = 'B'; rec(i + 1, a - 1, b + 1, c); result[i] = 'A'; rec(i + 1, a + 1, b - 1, c); } else if (choice[i] == "AC") { result[i] = 'C'; rec(i + 1, a - 1, b, c + 1); result[i] = 'A'; rec(i + 1, a + 1, b, c - 1); } else if (choice[i] == "BC") { result[i] = 'C'; rec(i + 1, a, b - 1, c + 1); result[i] = 'B'; rec(i + 1, a, b + 1, c - 1); } }; rec(0, A, B, C); Console.WriteLine("No"); } } /// <summary> /// 競プロライブラリ /// https://github.com/ha2ne2/ABC/tree/master/Lib /// </summary> public struct Mint : System.IComparable<Mint>, System.IEquatable<Mint> { public static readonly long MOD = (long)1e9 + 7; public long Value; public Mint(long val) { Value = val % MOD; if (Value < 0) Value += MOD; } private static Mint Ctor(long val) { return new Mint() { Value = val }; } public static Mint operator +(Mint a, Mint b) { long res = a.Value + b.Value; if (res > MOD) res -= MOD; return Ctor(res); } public static Mint operator -(Mint a, Mint b) { long res = a.Value - b.Value; if (res < 0) res += MOD; return Ctor(res); } public static Mint operator *(Mint a, Mint b) { long res = a.Value * b.Value; if (res > MOD) res %= MOD; return Ctor(res); } public static Mint operator /(Mint a, Mint b) { return a * Inv(b); } public override bool Equals(object obj) { return obj is Mint && Value == ((Mint)obj).Value; } public override int GetHashCode() { return Value.GetHashCode(); } public override string ToString() { return Value.ToString(); } public static implicit operator Mint(long a) { return new Mint(a); } public static explicit operator long(Mint a) { return a.Value; } public static Mint Pow(Mint a, long n) { if (n == 0) return new Mint(1); Mint b = Pow(a, n >> 1); b *= b; if ((n & 1) == 1) b *= a; return b; } public static Mint Inv(Mint n) { long a = n.Value; long b = MOD; long x = 1; long u = 0; while (b != 0) { long k = a / b; long _x = u; u = x - k * u; x = _x; long _a = a; a = b; b = _a - (k * b); } return new Mint(x); } public bool Equals(Mint other) { return Value == other.Value; } public int CompareTo(Mint other) { return Comparer<long>.Default.Compare(Value, other.Value); } } public class HashMap<K, V> : System.Collections.Generic.Dictionary<K, V> { private V DefaultValue; private static Func<V> CreateInstance = System.Linq.Expressions.Expression .Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V))) .Compile(); public HashMap() {} public HashMap(V defaultValue) { DefaultValue = defaultValue; } new public V this[K i] { get { V v; if (TryGetValue(i, out v)) { return v; } else { return base[i] = DefaultValue != null ? DefaultValue : CreateInstance(); } } set { base[i] = value; } } } public struct VTuple<T1, T2> : System.IComparable<VTuple<T1, T2>>, System.IEquatable<VTuple<T1, T2>> { public T1 Item1; public T2 Item2; public T1 First { get { return Item1; } } public T2 Second { get { return Item2; } } public VTuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; } public override bool Equals(object obj) { return obj is VTuple<T1, T2> && Equals((VTuple<T1, T2>)obj); } public override int GetHashCode() { int h1 = Item1 != null ? Item1.GetHashCode() : 0; int h2 = Item2 != null ? Item2.GetHashCode() : 0; return HashHelpers.CombineHashCodes(h1, h2); } public override string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ")"; } public bool Equals(VTuple<T1, T2> other) { return EqualityComparer<T1>.Default.Equals(Item1, other.Item1) && EqualityComparer<T2>.Default.Equals(Item2, other.Item2); } public int CompareTo(VTuple<T1, T2> other) { int c = Comparer<T1>.Default.Compare(Item1, other.Item1); if (c != 0) return c; return Comparer<T2>.Default.Compare(Item2, other.Item2); } } public struct VTuple3<T1, T2, T3> : System.IComparable<VTuple3<T1, T2, T3>>, System.IEquatable<VTuple3<T1, T2, T3>> { public T1 Item1; public T2 Item2; public T3 Item3; public VTuple3(T1 item1, T2 item2, T3 item3) { Item1 = item1; Item2 = item2; Item3 = item3; } public override bool Equals(object obj) { return obj is VTuple3<T1, T2, T3> && Equals((VTuple3<T1, T2, T3>)obj); } public override int GetHashCode() { int h1 = Item1 != null ? Item1.GetHashCode() : 0; int h2 = Item2 != null ? Item2.GetHashCode() : 0; int h3 = Item3 != null ? Item3.GetHashCode() : 0; return HashHelpers.CombineHashCodes(h1, h2, h3); } public override string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ")"; } public bool Equals(VTuple3<T1, T2, T3> other) { return EqualityComparer<T1>.Default.Equals(Item1, other.Item1) && EqualityComparer<T2>.Default.Equals(Item2, other.Item2) && EqualityComparer<T3>.Default.Equals(Item3, other.Item3); } public int CompareTo(VTuple3<T1, T2, T3> other) { int c = Comparer<T1>.Default.Compare(Item1, other.Item1); if (c != 0) return c; c = Comparer<T2>.Default.Compare(Item2, other.Item2); if (c != 0) return c; return Comparer<T3>.Default.Compare(Item3, other.Item3); } } public struct VTuple4<T1, T2, T3, T4> : System.IComparable<VTuple4<T1, T2, T3, T4>>, System.IEquatable<VTuple4<T1, T2, T3, T4>> { public T1 Item1; public T2 Item2; public T3 Item3; public T4 Item4; public VTuple4(T1 item1, T2 item2, T3 item3, T4 item4) { Item1 = item1; Item2 = item2; Item3 = item3; Item4 = item4; } public override bool Equals(object obj) { return obj is VTuple4<T1, T2, T3, T4> && Equals((VTuple4<T1, T2, T3, T4>)obj); } public override int GetHashCode() { int h1 = Item1 != null ? Item1.GetHashCode() : 0; int h2 = Item2 != null ? Item2.GetHashCode() : 0; int h3 = Item3 != null ? Item3.GetHashCode() : 0; int h4 = Item3 != null ? Item4.GetHashCode() : 0; return HashHelpers.CombineHashCodes(h1, h2, h3, h4); } public override string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ")"; } public bool Equals(VTuple4<T1, T2, T3, T4> other) { return EqualityComparer<T1>.Default.Equals(Item1, other.Item1) && EqualityComparer<T2>.Default.Equals(Item2, other.Item2) && EqualityComparer<T3>.Default.Equals(Item3, other.Item3) && EqualityComparer<T4>.Default.Equals(Item4, other.Item4); } public int CompareTo(VTuple4<T1, T2, T3, T4> other) { int c = Comparer<T1>.Default.Compare(Item1, other.Item1); if (c != 0) return c; c = Comparer<T2>.Default.Compare(Item2, other.Item2); if (c != 0) return c; c = Comparer<T3>.Default.Compare(Item3, other.Item3); if (c != 0) return c; return Comparer<T4>.Default.Compare(Item4, other.Item4); } } public static class HashHelpers { public static readonly int RandomSeed = new System.Random().Next(int.MinValue, int.MaxValue); public static int Combine(int h1, int h2) { uint rol5 = ((uint)h1 << 5) | ((uint)h1 >> 27); return ((int)rol5 + h1) ^ h2; } public static int CombineHashCodes(int h1, int h2) { return Combine(Combine(RandomSeed, h1), h2); } public static int CombineHashCodes(int h1, int h2, int h3) { return Combine(CombineHashCodes(h1, h2), h3); } public static int CombineHashCodes(int h1, int h2, int h3, int h4) { return Combine(CombineHashCodes(h1, h2, h3), h4); } } public static class Cin { public static int ri { get { return ReadInt(); } } public static int[] ria { get { return ReadIntArray(); } } public static long rl { get { return ReadLong(); } } public static long[] rla { get { return ReadLongArray(); } } public static double rd { get { return ReadDouble(); } } public static double[] rda { get { return ReadDoubleArray(); } } public static string rs { get { return ReadString(); } } public static string[] rsa { get { return ReadStringArray(); } } public static int ReadInt() { return int.Parse(Next()); } public static long ReadLong() { return long.Parse(Next()); } public static double ReadDouble() { return double.Parse(Next()); } public static string ReadString() { return Next(); } public static int[] ReadIntArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } public static long[] ReadLongArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } public static double[] ReadDoubleArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); } public static string[] ReadStringArray() { Tokens = null; return Console.ReadLine().Split(' '); } public static void ReadCol(out long[] a, long N) { a = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); } } public static void ReadCols(out long[] a, out long[] b, long N) { a = new long[N]; b = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); } } public static void ReadCols(out long[] a, out long[] b, out long[] c, long N) { a = new long[N]; b = new long[N]; c = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); c[i] = ReadLong(); } } public static int[,] ReadIntTable(int h, int w) { Tokens = null; int[,] ret = new int[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ret[i, j] = ReadInt(); } } return ret; } public static long[,] ReadLongTable(long h, long w) { Tokens = null; long[,] ret = new long[h, w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ret[i, j] = ReadLong(); } } return ret; } public static char[,] ReadCharTable(int h, int w) { Tokens = null; char[,] res = new char[h, w]; for (int i = 0; i < h; i++) { string s = ReadString(); for (int j = 0; j < w; j++) { res[i, j] = s[j]; } } return res; } private static string[] Tokens; private static int Pointer; private static string Next() { if (Tokens == null || Tokens.Length <= Pointer) { Tokens = Console.ReadLine().Split(' '); Pointer = 0; } return Tokens[Pointer++]; } } public static class Util { public static readonly long INF = (long)1e17; public readonly static long MOD = (long)1e9 + 7; public readonly static int[] DXY4 = { 0, 1, 0, -1, 0 }; public readonly static int[] DXY8 = { 1, 1, 0, 1, -1, 0, -1, -1, 1 }; public static void DontAutoFlush() { if (Console.IsOutputRedirected) return; var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } public static void Flush() { Console.Out.Flush(); } public static T[] Sort<T>(T[] array) { Array.Sort<T>(array); return array; } public static T[] SortDecend<T>(T[] array) { Array.Sort<T>(array); Array.Reverse(array); return array; } public static void Swap<T>(ref T a, ref T b) { T _a = a; a = b; b = _a; } public static long GCD(long a, long b) { while (b != 0) { long _a = a; a = b; b = _a % b; } return a; } public static long LCM(long a, long b) { if (a == 0 || b == 0) return 0; return a * b / GCD(a, b); } public static void ChMax(ref long a, long b) { if (a < b) a = b; } public static void ChMin(ref long a, long b) { if (a > b) a = b; } public static void ChMax(ref int a, int b) { if (a < b) a = b; } public static void ChMin(ref int a, int b) { if (a > b) a = b; } public static void FillArray<T>(T[] array, T value) { int max = array.Length; for (int i = 0; i < max; i++) { array[i] = value; } } public static void FillArray<T>(T[,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { array[i, j] = value; } } } public static void FillArray<T>(T[,,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); int max2 = array.GetLength(2); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { for (int k = 0; k < max2; k++) { array[i, j, k] = value; } } } } public static long[] Accumulate(long[] array) { long[] acc = new long[array.Length + 1]; for (int i = 0; i < array.Length; i++) { acc[i + 1] = acc[i] + array[i]; } return acc; } public static double[] Accumulate(double[] array) { double[] acc = new double[array.Length + 1]; for (int i = 0; i < array.Length; i++) { acc[i + 1] = acc[i] + array[i]; } return acc; } } }
[["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 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
4,159
18
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class A_165_We_Love_Golf { // https://atcoder.jp/contests/abc165/tasks/abc165_a public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 long k = long.Parse(Console.ReadLine()); // 整数配列の入力 var Array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int a = Array[0]; int b = Array[1]; for (int i = a; i < b + 1; i++) { if (i % k == 0) { Console.WriteLine("OK"); break; } else if (i % k != 0 && i == b + 1) { Console.WriteLine("NG"); } } Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class A_165_We_Love_Golf { // https://atcoder.jp/contests/abc165/tasks/abc165_a public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 long k = long.Parse(Console.ReadLine()); // 整数配列の入力 var Array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int a = Array[0]; int b = Array[1]; for (int i = a; i < b + 1; i++) { if (i % k == 0) { Console.WriteLine("OK"); break; } else if (i == b) { Console.WriteLine("NG"); } } Console.Out.Flush(); } } }
[["-", 75, 57, 15, 16, 31, 16, 31, 16, 17, 109], ["-", 75, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 79], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["-", 75, 57, 15, 16, 12, 16, 12, 16, 17, 72], ["-", 75, 57, 15, 16, 12, 16, 12, 16, 12, 203]]
8
216
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // 問題: class A_165_We_Love_Golf { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 int n = int.Parse(Console.ReadLine()); // 整数配列の入力 var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int a = inputintArray[0]; int b = inputintArray[1]; for (int i = 0; i < b - a + 1; i++) { if ((a + i) % n == 0) { Console.WriteLine("OK"); return; } else if (i == b - a) { Console.WriteLine("NG"); } } Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // 問題: class A_165_We_Love_Golf { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 int k = int.Parse(Console.ReadLine()); // 整数配列の入力 var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int a = inputintArray[0]; int b = inputintArray[1]; for (int i = a; i < b + 1; i++) { if (i % k == 0) { Console.WriteLine("OK"); break; } else if (i == b) { Console.WriteLine("NG"); } } // for (int i = 1; i < b + 1; i++) //{ // int keisan = k * i; // if (keisan >= a && keisan <= b) // { // Console.WriteLine("OK"); // break; // } // else if (i == b) // { // Console.WriteLine("NG"); // } //} Console.Out.Flush(); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 33], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 17, 33], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 12, 22]]
8
216
31
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // 問題: class A_165_We_Love_Golf { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 int n = int.Parse(Console.ReadLine()); // 整数配列の入力 var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int a = inputintArray[0]; int b = inputintArray[1]; for (int i = 0; i < b - a + 1; i++) { if ((a + i) % n == 0) { Console.WriteLine("OK"); return; } else if (i == b - a) { Console.WriteLine("NG"); } } Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // 問題: class A_165_We_Love_Golf { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 int k = int.Parse(Console.ReadLine()); // 整数配列の入力 var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int a = inputintArray[0]; int b = inputintArray[1]; // for (int i = a; i < b + 1; i++) //{ // if (i % k == 0) // { // Console.WriteLine("OK"); // break; // } // else if (i == b) // { // Console.WriteLine("NG"); // } //} for (int i = 1; i < b + 1; i++) { int keisan = k * i; if (keisan >= a && keisan <= b) { Console.WriteLine("OK"); break; } else if (i == b) { Console.WriteLine("NG"); } } Console.Out.Flush(); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 33], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 20], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 17, 33], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 12, 22]]
8
216
31
using System; using System.Collections.Generic; using System.Linq; namespace AtcoderSubmit { class Program { static void Main(string[] args) { var k = int.Parse(Console.ReadLine()); var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var a = line[0]; var b = line[1]; var m = a % k; var result = (b - a + a % k) >= k ? "OK" : "NG"; Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtcoderSubmit { class Program { static void Main(string[] args) { var k = int.Parse(Console.ReadLine()); var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var a = line[0]; var b = line[1]; var result = default(string); if (a % k == 0) { result = "OK"; } else { result = (b - a + a % k >= k) ? "OK" : "NG"; } Console.WriteLine(result); } } }
[["-", 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, 304, 0, 162], ["+", 0, 198, 0, 200, 0, 212, 0, 304, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 304, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 304, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 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], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 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, 212, 0, 41, 15, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 41, 15, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
128
25
using System; using System.Linq; namespace atcorder { class Program { static void Main() { var k = int.Parse(Console.ReadLine()); var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); int sho = a / k; if (k * (sho + 1) >= a && k * (sho + 1) <= b) { Console.WriteLine("OK"); } else { Console.WriteLine("NG"); } } } }
using System; using System.Linq; namespace atcorder { class Program { static void Main() { var k = int.Parse(Console.ReadLine()); var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); int sho = a / k; if (a % k != 0) { sho += 1; } if (k * sho >= a && k * sho <= b) { Console.WriteLine("OK"); } else { Console.WriteLine("NG"); } } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["-", 15, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 31, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 15, 16, 31, 16, 31, 16, 12, 23, 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, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["-", 15, 16, 12, 16, 31, 16, 12, 23, 0, 24], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["-", 15, 16, 12, 16, 31, 16, 12, 23, 0, 25]]
8
131
22
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; using System.Linq; using E = System.Linq.Enumerable; internal partial class Solver { public void Run() { var k = ni(); var a = ni(); var b = ni(); a %= k; b %= k; if (b < a) a -= k; cout.WriteLine(a <= 0 ? "OK" : "NG"); } } // PREWRITEN CODE BEGINS FROM HERE internal partial class Solver : Scanner { public static void Main() { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver(Console.In, Console.Out).Run(); Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } internal static class LinqPadExtension { [Conditional("DEBUG")] public static void Dump<T>(this T obj) { #if DEBUG LINQPad.Extensions.Dump(obj); #endif } } public class Scanner { private readonly TextReader Reader; private readonly CultureInfo ci = CultureInfo.InvariantCulture; private readonly char[] buffer = new char[2 * 1024]; private int cursor = 0, length = 0; private string Token; private readonly StringBuilder sb = new StringBuilder(1024); public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return checked((int)NextLong()); } public long NextLong() { var s = Next(); long r = 0; int i = 0; bool negative = false; if (s[i] == '-') { negative = true; i++; } for (; i < s.Length; i++) { r = r * 10 + (s[i] - '0'); #if DEBUG if (!char.IsDigit(s[i])) throw new FormatException(); #endif } return negative ? -r : r; } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (Token == null) { if (!StockToken()) { throw new Exception(); } } var token = Token; Token = null; return token; } public bool HasNext() { if (Token != null) { return true; } return StockToken(); } private bool StockToken() { while (true) { sb.Clear(); while (true) { if (cursor >= length) { cursor = 0; if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) { break; } } var c = buffer[cursor++]; if (33 <= c && c <= 126) { sb.Append(c); } else { if (sb.Length > 0) break; } } if (sb.Length > 0) { Token = sb.ToString(); return true; } return false; } } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; using System.Linq; using E = System.Linq.Enumerable; internal partial class Solver { public void Run() { var k = ni(); var a = ni(); var b = ni(); bool ans = false; for (int i = a; i <= b; i++) { if (i % k == 0) { ans = true; } } cout.WriteLine(ans ? "OK" : "NG"); } } // PREWRITEN CODE BEGINS FROM HERE internal partial class Solver : Scanner { public static void Main() { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver(Console.In, Console.Out).Run(); Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } internal static class LinqPadExtension { [Conditional("DEBUG")] public static void Dump<T>(this T obj) { #if DEBUG LINQPad.Extensions.Dump(obj); #endif } } public class Scanner { private readonly TextReader Reader; private readonly CultureInfo ci = CultureInfo.InvariantCulture; private readonly char[] buffer = new char[2 * 1024]; private int cursor = 0, length = 0; private string Token; private readonly StringBuilder sb = new StringBuilder(1024); public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return checked((int)NextLong()); } public long NextLong() { var s = Next(); long r = 0; int i = 0; bool negative = false; if (s[i] == '-') { negative = true; i++; } for (; i < s.Length; i++) { r = r * 10 + (s[i] - '0'); #if DEBUG if (!char.IsDigit(s[i])) throw new FormatException(); #endif } return negative ? -r : r; } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (Token == null) { if (!StockToken()) { throw new Exception(); } } var token = Token; Token = null; return token; } public bool HasNext() { if (Token != null) { return true; } return StockToken(); } private bool StockToken() { while (true) { sb.Clear(); while (true) { if (cursor >= length) { cursor = 0; if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) { break; } } var c = buffer[cursor++]; if (33 <= c && c <= 126) { sb.Append(c); } else { if (sb.Length > 0) break; } } if (sb.Length > 0) { Token = sb.ToString(); return true; } return false; } } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 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], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 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, 110], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 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], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 15, 22]]
8
1,124
41
using System; namespace ConsoleApp2 { class Program { static void Main() { int a, b, i, j, k; string ab; k = int.Parse(Console.ReadLine()); ab = Console.ReadLine(); i = ab.IndexOf(" "); if (i >= 0) { a = int.Parse(ab.Substring(0, i)); b = int.Parse(ab.Substring(i + 1)); for (j = a; j <= b; j++) { if ((j % k) == 0) { Console.WriteLine("OK"); break; } else { Console.WriteLine("NG"); } } } else { Console.WriteLine("NG"); } } } }
using System; namespace ConsoleApp2 { class Program { static void Main() { int a, b, i, j, k; string ab; bool gflag = false; k = int.Parse(Console.ReadLine()); ab = Console.ReadLine(); i = ab.IndexOf(" "); if (i >= 0) { a = int.Parse(ab.Substring(0, i)); b = int.Parse(ab.Substring(i + 1)); for (j = a; j <= b; j++) { if ((j % k) == 0) { gflag = true; break; } } } if (gflag) { Console.WriteLine("OK"); } else { Console.WriteLine("NG"); } } } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 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], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["-", 64, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 7, 8, 196, 0, 46], ["+", 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, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 0, 57, 64, 196, 0, 7, 8, 196, 0, 46]]
8
166
27
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Main { public static class Program { static void Main(string[] args) { int k = int.Parse(Console.ReadLine()); int[] ab = GetIntList(Console.ReadLine()); var a = ab[0]; var b = ab[1]; var answer = "NG"; if (k == 1) { answer = "OK"; } else { if (b - a >= k) { answer = "OK"; } } Console.WriteLine(answer); } #region libraries private static int[] GetIntList(string line) { return line.Split(' ').Select(x => int.Parse(x)).ToArray(); } private static double[] GetDoubleList(string line) { return line.Split(' ').Select(x => double.Parse(x)).ToArray(); } private static ulong[] GetUlongList(string line) { return line.Split(' ').Select(x => ulong.Parse(x)).ToArray(); } private static long[] GetLongList(string line) { return line.Split(' ').Select(x => long.Parse(x)).ToArray(); } private static int SearchNearest(this IEnumerable<int> list, int target) { var min = list.Min(c => Math.Abs(c - target)); return list.First(c => Math.Abs(c - target) == min); } public static bool IsOdd(int i) { return i % 2 == 1 ? true : false; } public static int Gcd(int a, int b) { if (a < b) { Gcd(b, a); } while (b != 0) { var rm = a % b; a = b; b = rm; } return a; } #endregion libraries } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Main { public static class Program { static void Main(string[] args) { int k = int.Parse(Console.ReadLine()); int[] ab = GetIntList(Console.ReadLine()); var a = ab[0]; var b = ab[1]; var answer = "NG"; for (int i = 0; i < b; i++) { var p = k * (i + 1); if (a <= p && p <= b) { answer = "OK"; break; } } Console.WriteLine(answer); } #region libraries private static int[] GetIntList(string line) { return line.Split(' ').Select(x => int.Parse(x)).ToArray(); } private static double[] GetDoubleList(string line) { return line.Split(' ').Select(x => double.Parse(x)).ToArray(); } private static ulong[] GetUlongList(string line) { return line.Split(' ').Select(x => ulong.Parse(x)).ToArray(); } private static long[] GetLongList(string line) { return line.Split(' ').Select(x => long.Parse(x)).ToArray(); } private static int SearchNearest(this IEnumerable<int> list, int target) { var min = list.Min(c => Math.Abs(c - target)); return list.First(c => Math.Abs(c - target) == min); } public static bool IsOdd(int i) { return i % 2 == 1 ? true : false; } public static int Gcd(int a, int b) { if (a < b) { Gcd(b, a); } while (b != 0) { var rm = a % b; a = b; b = rm; } return a; } #endregion libraries } }
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 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], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 62], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 75, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 75, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
8
432
44
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; using System.Text; using static System.Math; class MainClass { public static void Main(string[] args) { var K = LnInt(); var _ = LnInts(); var A = _[0]; var B = _[1]; if (B - A + 1 >= K) { print("OK"); } else { print("NG"); } } public static void print(object obj) { Console.WriteLine(obj); } public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } } public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } } public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; } public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); } public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; } public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); } public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; } public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; } }
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; using System.Text; using static System.Math; class MainClass { public static void Main(string[] args) { var K = LnInt(); var _ = LnInts(); var A = _[0]; var B = _[1]; for (int i = A; i <= B; i++) { if (i % K == 0) { print("OK"); return; } } print("NG"); } public static void print(object obj) { Console.WriteLine(obj); } public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } } public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } } public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; } public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); } public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; } public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); } public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; } public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; } }
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 33], ["+", 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], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
563
31
using System; class Program { static void Main(string[] args) { int k = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(" "); int a = int.Parse(s[0]); int b = int.Parse(s[1]); if (a > b) { int temp = a; a = b; b = temp; } bool ok = false; for (int i = k; i <= b; i = i + i) { if (i >= a & i <= b) { ok = true; break; } } if (ok) { Console.WriteLine("OK"); } else { Console.WriteLine("NG"); } } }
using System; class Program { static void Main(string[] args) { int k = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(" "); int a = int.Parse(s[0]); int b = int.Parse(s[1]); if (a > b) { int temp = a; a = b; b = temp; } bool ok = false; for (int i = 1; (i * k) <= b; i++) { if ((i * k) >= a & (i * k) <= b) { ok = true; break; } } if (ok) { Console.WriteLine("OK"); } else { Console.WriteLine("NG"); } } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 15, 16, 31, 23, 0, 24], ["+", 0, 7, 15, 16, 31, 23, 0, 16, 17, 48], ["+", 0, 7, 15, 16, 31, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 31, 23, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 26, 11, 31, 22], ["-", 8, 196, 0, 7, 26, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 7, 26, 11, 12, 16, 17, 72], ["-", 8, 196, 0, 7, 26, 11, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 57, 15, 16, 12, 16, 31, 23, 0, 24], ["+", 15, 16, 12, 16, 31, 23, 0, 16, 17, 48], ["+", 15, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 23, 0, 25]]
8
166
19
// C# program to build the smallest number // by removing n digits from a given number using System; using System.Collections.Generic; using System.Linq; class GFG { public static void Main(String[] args) { var n = int.Parse(Console.ReadLine()); var input = Console.ReadLine().Split(' '); var l = int.Parse(input[0]); var u = int.Parse(input[1]); Golf(n, l, u); } public static void Golf(int k, int l, int u) { for (int i = l; i <= u; i++) { var tmp = i % k; if (tmp == 0) { Console.Write("OK"); break; } } Console.Write("NG"); } }
// C# program to build the smallest number // by removing n digits from a given number using System; using System.Collections.Generic; using System.Linq; class GFG { public static void Main(String[] args) { var n = int.Parse(Console.ReadLine()); var input = Console.ReadLine().Split(' '); var l = int.Parse(input[0]); var u = int.Parse(input[1]); Golf(n, l, u); } public static void Golf(int k, int l, int u) { for (int i = l; i <= u; i++) { var tmp = i % k; if (tmp == 0) { Console.Write("OK"); Console.WriteLine(); return; } } Console.Write("NG"); Console.WriteLine(); } }
[["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 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
165
14
using System; public class Hello { public static void Main() { // Your code here! string Ns = System.Console.ReadLine(); string[] S = System.Console.ReadLine().Split(' '); // System.Console.WriteLine("Hello C#"); int A = int.Parse(S[0]); int B = int.Parse(S[1]); int N = int.Parse(Ns); for (int i = A; i <= B; i++) { if (i % N == 0) { System.Console.WriteLine("OK"); break; } } System.Console.WriteLine("NG"); } }
using System; public class Hello { public static void Main() { // Your code here! string Ns = System.Console.ReadLine(); string[] S = System.Console.ReadLine().Split(' '); // System.Console.WriteLine("Hello C#"); int A = int.Parse(S[0]); int B = int.Parse(S[1]); int N = int.Parse(Ns); bool fl = false; for (int i = A; i <= B; i++) { if (i % N == 0) { System.Console.WriteLine("OK"); fl = true; break; } } if (fl == false) { System.Console.WriteLine("NG"); } } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 8, 196, 0, 57, 64, 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], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
135
17
using System; class A { static void Main() { int K = int.Parse(Console.ReadLine()); int[] P = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int A = P[0]; int B = P[1]; int C = B % K; if (C < B) Console.WriteLine("NG"); else Console.WriteLine("OK"); } }
using System; class A { static void Main() { int K = int.Parse(Console.ReadLine()); int[] P = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int A = P[0]; int B = P[1]; int C = B / K; if (C * K <= B && C * K >= A) Console.WriteLine("OK"); else Console.WriteLine("NG"); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
103
16
using System; using System.Linq; using System.Collections.Generic; using System.IO; namespace AtCoder { class Program { public static void Main() { #if TextInput using (var reader = new StreamReader(Debug.SampleTextPath)) { Console.SetIn(reader); #endif var scale = IO.ReadInt(); var intArray = IO.ReadIntArray(); var checkNumber = (intArray[1] / scale) * scale; IO.Write(intArray[0] <= checkNumber); #if TextInput } #endif } } public static class IO { public static string Read() { return Console.ReadLine(); } public static string[] ReadArray(char iSplitter = ' ') { return Read().Split(iSplitter); } public static int ReadInt() { return int.Parse(Read()); } public static int[] ReadIntArray(char iSplitter = ' ') { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); } public static long ReadLong() { return long.Parse(Read()); } public static long[] ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); } public static double ReadDouble() { return double.Parse(Read()); } public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); } public static char[] ReadCharArray() { return Read().ToCharArray(); } public static void Write(string iValue) { Console.WriteLine(iValue); } public static void Write(int iValue) { Console.WriteLine(iValue); } public static void Write(long iValue) { Console.WriteLine(iValue); } public static void Write(double iValue) { Console.WriteLine(iValue); } public static void Write(decimal iValue) { Console.WriteLine(iValue); } public static void Write(bool iValue) { Console.WriteLine(iValue ? "Yes" : "No"); } public static void Write<Type>(IEnumerable<Type> iValue, string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord, iValue)); } } public static class Util { public static long Gcd(long i0, long i1) { return (i0 > i1) ? _Gcd(i0, i1) : _Gcd(i1, i0); } public static long Lcm(long i0, long i1) { return (i0 * i1) / Gcd(i0, i1); } public static long ModPow(long iBaseNumber, long iPow, long iModNumber) { var num = 1L; while (iPow != 0) { if ((iPow & 0x1) != 0) { num = (num * iBaseNumber) % iModNumber; } iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber; iPow >>= 1; } return num; } public static long CombinationNum(int iLeftNumber, int iRightNumber) { if (iRightNumber == 0) { return 1; } if (iLeftNumber == 0) { return 0; } return iLeftNumber * CombinationNum(iLeftNumber - 1, iRightNumber - 1) / iRightNumber; } public static long Factorial(long iNumber) { if (iNumber == 0) { return 1L; } return iNumber * Factorial(iNumber - 1); } private static long _Gcd(long i0, long i1) { return (i1 == 0) ? i0 : _Gcd(i1, i0 % i1); } } public class UnionFind { public int[] Parents; public int[] RootNums; public UnionFind(int iRootNum) { Parents = Enumerable.Range(0, iRootNum).ToArray(); RootNums = new int[iRootNum]; } public void Normalize() { for (var iIndex = 0; iIndex < Parents.Length; ++iIndex) { var rootIndex = _GetRoot(iIndex); ++RootNums[rootIndex]; Parents[iIndex] = rootIndex; } } public void Union(int iNumber0, int iNumber1) { var rootNumber0 = _GetRoot(iNumber0); var rootNumber1 = _GetRoot(iNumber1); if (rootNumber0 < rootNumber1) { Parents[rootNumber1] = rootNumber0; } else { Parents[rootNumber0] = rootNumber1; } } public int _GetRoot(int iNumber) { return (Parents[iNumber] == iNumber) ? iNumber : _GetRoot(Parents[iNumber]); } } public class CumulativeSum { public static CumulativeSum Create(IEnumerable<long> iNumbers) { var numbers = iNumbers.ToArray(); var cumulativeSum = new CumulativeSum { Numbers = numbers, SumNumbers = new long[numbers.Length + 1] }; var sumNumber = 0L; for (var iIndex = 0; iIndex < numbers.Length; ++iIndex) { sumNumber += numbers[iIndex]; cumulativeSum.SumNumbers[iIndex + 1] = sumNumber; } return cumulativeSum; } public long[] Numbers { get; private set; } public long[] SumNumbers { get; private set; } public int GetMaxTotalIndex(int iAreaNum) { var maxIndex = -1; var maxNumber = 0L; var num = Numbers.Length - iAreaNum + 1; for (var iIndex = 0; iIndex < num; ++iIndex) { var checkNumber = SumNumbers[iAreaNum + iIndex] - SumNumbers[iIndex]; if (maxNumber < checkNumber) { maxIndex = iIndex; maxNumber = checkNumber; } } return maxIndex; } } }
using System; using System.Linq; using System.Collections.Generic; using System.IO; namespace AtCoder { class Program { public static void Main() { #if TextInput using (var reader = new StreamReader(Debug.SampleTextPath)) { Console.SetIn(reader); #endif var scale = IO.ReadInt(); var intArray = IO.ReadIntArray(); var checkNumber = (intArray[1] / scale) * scale; IO.Write(intArray[0] <= checkNumber ? "OK" : "NG"); #if TextInput } #endif } } public static class IO { public static string Read() { return Console.ReadLine(); } public static string[] ReadArray(char iSplitter = ' ') { return Read().Split(iSplitter); } public static int ReadInt() { return int.Parse(Read()); } public static int[] ReadIntArray(char iSplitter = ' ') { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); } public static long ReadLong() { return long.Parse(Read()); } public static long[] ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); } public static double ReadDouble() { return double.Parse(Read()); } public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); } public static char[] ReadCharArray() { return Read().ToCharArray(); } public static void Write(string iValue) { Console.WriteLine(iValue); } public static void Write(int iValue) { Console.WriteLine(iValue); } public static void Write(long iValue) { Console.WriteLine(iValue); } public static void Write(double iValue) { Console.WriteLine(iValue); } public static void Write(decimal iValue) { Console.WriteLine(iValue); } public static void Write(bool iValue) { Console.WriteLine(iValue ? "Yes" : "No"); } public static void Write<Type>(IEnumerable<Type> iValue, string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord, iValue)); } } public static class Util { public static long Gcd(long i0, long i1) { return (i0 > i1) ? _Gcd(i0, i1) : _Gcd(i1, i0); } public static long Lcm(long i0, long i1) { return (i0 * i1) / Gcd(i0, i1); } public static long ModPow(long iBaseNumber, long iPow, long iModNumber) { var num = 1L; while (iPow != 0) { if ((iPow & 0x1) != 0) { num = (num * iBaseNumber) % iModNumber; } iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber; iPow >>= 1; } return num; } public static long CombinationNum(int iLeftNumber, int iRightNumber) { if (iRightNumber == 0) { return 1; } if (iLeftNumber == 0) { return 0; } return iLeftNumber * CombinationNum(iLeftNumber - 1, iRightNumber - 1) / iRightNumber; } public static long Factorial(long iNumber) { if (iNumber == 0) { return 1L; } return iNumber * Factorial(iNumber - 1); } private static long _Gcd(long i0, long i1) { return (i1 == 0) ? i0 : _Gcd(i1, i0 % i1); } } public class UnionFind { public int[] Parents; public int[] RootNums; public UnionFind(int iRootNum) { Parents = Enumerable.Range(0, iRootNum).ToArray(); RootNums = new int[iRootNum]; } public void Normalize() { for (var iIndex = 0; iIndex < Parents.Length; ++iIndex) { var rootIndex = _GetRoot(iIndex); ++RootNums[rootIndex]; Parents[iIndex] = rootIndex; } } public void Union(int iNumber0, int iNumber1) { var rootNumber0 = _GetRoot(iNumber0); var rootNumber1 = _GetRoot(iNumber1); if (rootNumber0 < rootNumber1) { Parents[rootNumber1] = rootNumber0; } else { Parents[rootNumber0] = rootNumber1; } } public int _GetRoot(int iNumber) { return (Parents[iNumber] == iNumber) ? iNumber : _GetRoot(Parents[iNumber]); } } public class CumulativeSum { public static CumulativeSum Create(IEnumerable<long> iNumbers) { var numbers = iNumbers.ToArray(); var cumulativeSum = new CumulativeSum { Numbers = numbers, SumNumbers = new long[numbers.Length + 1] }; var sumNumber = 0L; for (var iIndex = 0; iIndex < numbers.Length; ++iIndex) { sumNumber += numbers[iIndex]; cumulativeSum.SumNumbers[iIndex + 1] = sumNumber; } return cumulativeSum; } public long[] Numbers { get; private set; } public long[] SumNumbers { get; private set; } public int GetMaxTotalIndex(int iAreaNum) { var maxIndex = -1; var maxNumber = 0L; var num = Numbers.Length - iAreaNum + 1; for (var iIndex = 0; iIndex < num; ++iIndex) { var checkNumber = SumNumbers[iAreaNum + iIndex] - SumNumbers[iIndex]; if (maxNumber < checkNumber) { maxIndex = iIndex; maxNumber = checkNumber; } } return maxIndex; } } }
[["+", 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
1,113
8
using System; using System.Linq; using System.Collections.Generic; namespace ABC { class ProgramB { static void Main(string[] args) { var x = long.Parse(Console.ReadLine()); var result = 0L; var a = 100L; while (a < x) { a = (long)(a + a * 0.01f); result++; } Console.WriteLine(result); } } }
using System; using System.Linq; using System.Collections.Generic; namespace ABC { class ProgramB { static void Main(string[] args) { var x = long.Parse(Console.ReadLine()); var result = 0L; var a = 100L; while (a < x) { a = a + (a / 100L); result++; } Console.WriteLine(result); } } }
[["-", 8, 196, 0, 1, 0, 11, 12, 74, 0, 24], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25], ["-", 0, 1, 0, 11, 12, 74, 51, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 12, 74, 51, 23, 0, 16, 12, 16, 17, 48], ["-", 12, 74, 51, 23, 0, 16, 12, 16, 12, 250], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 85], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 203]]
8
89
9
using System; class Program { static void Main(string[] args) { var x = long.Parse(Console.ReadLine()); decimal money = 100; decimal rate = 1.01m; for (var i = 1; true; i++) { money = money * rate; if (money >= x) { Console.WriteLine(i); break; } } } }
using System; class Program { static void Main(string[] args) { var x = long.Parse(Console.ReadLine()); decimal money = 100; for (var i = 1; true; i++) { money = Math.Floor(money * 1.01m); if (money >= x) { Console.WriteLine(i); break; } } } }
[["-", 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, 250], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 250], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
8
79
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionD { /// <summary> /// B - 1% /// https://atcoder.jp/contests/abc165/tasks/abc165_b /// </summary> public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 long num_X = long.Parse(Console.ReadLine()); long num_Sum = 100; //残高 int num_N = 0; do { num_Sum += num_Sum / 100; num_N++; } while (num_Sum <= num_X); Console.WriteLine(num_N); Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionD { /// <summary> /// B - 1% /// https://atcoder.jp/contests/abc165/tasks/abc165_b /// </summary> public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数の入力 long num_X = long.Parse(Console.ReadLine()); long num_Sum = 100; //残高 int num_N = 0; while (num_Sum < num_X) { num_Sum += num_Sum / 100; num_N++; } Console.WriteLine(num_N); Console.Out.Flush(); } } }
[["-", 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, 19], ["-", 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
142
14
using System; using System.Linq; namespace ConsoleApp1 { public class Class1 { static void Main(string[] args) { long start = 100; long goal = long.Parse(Console.ReadLine()); int ans = 0; while (start < goal) { start += (long)Math.Floor(start * 0.01f); ans++; } Console.Write(ans); } } }
using System; using System.Linq; namespace ConsoleApp1 { public class Class1 { static void Main(string[] args) { long start = 100; long goal = long.Parse(Console.ReadLine()); int ans = 0; while (start < goal) { start += start / 100; ans++; } Console.Write(ans); } } }
[["-", 8, 196, 0, 1, 0, 11, 12, 74, 0, 24], ["-", 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], ["-", 51, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 51, 213, 3, 4, 0, 28, 0, 16, 12, 250], ["-", 0, 11, 12, 74, 51, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
8
84
12
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { long X = long.Parse(Console.ReadLine()); double saving = 100; int ans = 0; while (saving < X) { saving += (saving * 0.01); Math.Floor(saving); ans++; } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { long X = long.Parse(Console.ReadLine()); long saving = 100; int ans = 0; while (saving < X) { saving += (saving / 100); ans++; } Console.WriteLine(ans); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 1, 0, 11, 12, 23, 0, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 23, 0, 16, 12, 250], ["-", 8, 196, 0, 1, 0, 11, 12, 23, 0, 25], ["-", 8, 196, 0, 52, 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], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 12, 203]]
8
91
13
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Main { public static class Program { static void Main(string[] args) { Double x = Double.Parse(Console.ReadLine()); var answer = 0.0; answer = (Math.Log10(x) - 2) / (Math.Log10(101) - 2); Console.WriteLine(Math.Ceiling(answer)); } #region libraries private static int[] GetIntList(string line) { return line.Split(' ').Select(x => int.Parse(x)).ToArray(); } private static double[] GetDoubleList(string line) { return line.Split(' ').Select(x => double.Parse(x)).ToArray(); } private static ulong[] GetUlongList(string line) { return line.Split(' ').Select(x => ulong.Parse(x)).ToArray(); } private static long[] GetLongList(string line) { return line.Split(' ').Select(x => long.Parse(x)).ToArray(); } private static int SearchNearest(this IEnumerable<int> list, int target) { var min = list.Min(c => Math.Abs(c - target)); return list.First(c => Math.Abs(c - target) == min); } public static bool IsOdd(int i) { return i % 2 == 1 ? true : false; } public static int Gcd(int a, int b) { if (a < b) { Gcd(b, a); } while (b != 0) { var rm = a % b; a = b; b = rm; } return a; } #endregion libraries } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Main { public static class Program { static void Main(string[] args) { Double x = Double.Parse(Console.ReadLine()); var answer = 0.0; answer = (Math.Log10(x) - 2.0) / (Math.Log10(101) - 2.0); double k = 100; int i = 0; while (k < x) { k = Math.Floor(k * 1.01); i++; } Console.WriteLine(i); } #region libraries private static int[] GetIntList(string line) { return line.Split(' ').Select(x => int.Parse(x)).ToArray(); } private static double[] GetDoubleList(string line) { return line.Split(' ').Select(x => double.Parse(x)).ToArray(); } private static ulong[] GetUlongList(string line) { return line.Split(' ').Select(x => ulong.Parse(x)).ToArray(); } private static long[] GetLongList(string line) { return line.Split(' ').Select(x => long.Parse(x)).ToArray(); } private static int SearchNearest(this IEnumerable<int> list, int target) { var min = list.Min(c => Math.Abs(c - target)); return list.First(c => Math.Abs(c - target) == min); } public static bool IsOdd(int i) { return i % 2 == 1 ? true : false; } public static int Gcd(int a, int b) { if (a < b) { Gcd(b, a); } while (b != 0) { var rm = a % b; a = b; b = rm; } return a; } #endregion libraries } }
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 250], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 250], ["-", 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], ["+", 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], ["+", 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, 32], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 250], ["+", 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
396
41
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var x = long.Parse(Console.ReadLine()); long m = 100; long ans = 0; while (true) { m = m + (long)((float)m * 0.01f); ans++; if (m >= x) break; } Console.WriteLine(ans); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { long x = long.Parse(Console.ReadLine()); long m = 100; long ans = 0; while (true) { long tmp = (long)(m * 0.01d); m = m + tmp; ans++; if (m >= x) break; } Console.WriteLine(ans); } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 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, 74, 51, 23, 0, 24], ["-", 12, 74, 51, 23, 0, 16, 31, 74, 39, 199], ["-", 12, 74, 51, 23, 0, 16, 31, 74, 0, 25], ["-", 12, 16, 12, 74, 51, 23, 0, 16, 12, 250], ["+", 0, 212, 0, 74, 51, 23, 0, 16, 12, 250], ["+", 8, 196, 0, 52, 8, 196, 0, 197, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
8
94
18
using System; using System.Collections.Generic; class Program { static void Main() { string[] Sh = Console.ReadLine().Split(' '); int Th = int.Parse(Sh[0]); int Ta = int.Parse(Sh[1]); int Ah = int.Parse(Sh[2]); int Aa = int.Parse(Sh[3]); while (Th <= 0 || Ah <= 0) { Ah -= Ta; Th -= Aa; } if (Ah <= 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } }
using System; using System.Collections.Generic; class Program { static void Main() { string[] Sh = Console.ReadLine().Split(' '); int Th = int.Parse(Sh[0]); int Ta = int.Parse(Sh[1]); int Ah = int.Parse(Sh[2]); int Aa = int.Parse(Sh[3]); while (true) { Ah -= Ta; Th -= Aa; if (Ah <= 0 || Th <= 0) { break; } } if (Ah <= 0) { Console.WriteLine("Yes"); } else if (Th <= 0) { Console.WriteLine("No"); } } }
[["-", 8, 196, 0, 52, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 17, 19], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 106], ["-", 8, 196, 0, 52, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 52, 15, 16, 12, 16, 17, 19], ["-", 8, 196, 0, 52, 15, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["+", 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], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 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, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 31, 22], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25]]
8
140
28
using System; using System.Linq; public class ABC164B { private static void Main(string[] args) { var input = ReadIntsAsArray(); var a = input[0]; var b = input[1]; var c = input[2]; var d = input[3]; var answer = (c / b) >= (a / d) ? "Yes" : "No"; Console.WriteLine(answer); } private static int[] ReadIntsAsArray() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray(); }
using System; using System.Linq; public class ABC164B { private static void Main(string[] args) { var input = ReadDoublesAsArray(); var a = input[0]; var b = input[1]; var c = input[2]; var d = input[3]; var answer = (Math.Ceiling(c / b) <= Math.Ceiling(a / d)) ? "Yes" : "No"; Console.WriteLine(answer); } private static double[] ReadDoublesAsArray() => Console.ReadLine().Trim().Split().Select(x => double.Parse(x)).ToArray(); }
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 15, 23, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 15, 23, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 23, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 23, 0, 16, 31, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 17, 20], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 17, 19], ["+", 15, 23, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 23, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 23, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 23, 0, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 235, 8, 201, 0, 195, 39, 224, 39, 199], ["+", 0, 235, 8, 201, 0, 195, 39, 224, 39, 199], ["-", 0, 208, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 141, 22], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
8
133
18
using System; namespace Atcoder { class Program { static void Main(string[] args) { int thit, tak, ahit, atak; bool count = false; string[] str = Console.ReadLine().Split(' '); thit = int.Parse(str[0]); tak = int.Parse(str[1]); ahit = int.Parse(str[2]); atak = int.Parse(str[3]); while (thit > 0 || ahit > 0) { ahit = ahit - tak; if (ahit <= 0) { count = true; break; } thit = thit - atak; } if (count) { Console.WriteLine("Yes"); } else Console.WriteLine("No"); } } }
using System; namespace Atcoder { class Program { static void Main(string[] args) { int thit, tak, ahit, atak; bool count = false; string[] str = Console.ReadLine().Split(' '); thit = int.Parse(str[0]); tak = int.Parse(str[1]); ahit = int.Parse(str[2]); atak = int.Parse(str[3]); while (thit > 0 || ahit > 0) { ahit = ahit - tak; if (ahit <= 0) { count = true; break; } thit = thit - atak; if (thit <= 0) { break; } } if (count) { Console.WriteLine("Yes"); } else Console.WriteLine("No"); } } }
[["+", 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, 19], ["+", 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], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
8
165
10
using System; class MainClass { public static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int C = int.Parse(input[2]); int D = int.Parse(input[3]); if (C / B <= A / D) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } }
using System; class MainClass { public static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int A = int.Parse(input[0]); int B = int.Parse(input[1]); int C = int.Parse(input[2]); int D = int.Parse(input[3]); if ((C - 1) / B <= (A - 1) / D) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } }
[["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 57, 15, 16, 12, 16, 31, 23, 0, 24], ["+", 15, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 16, 31, 23, 0, 25]]
8
122
8
using System; using System.Collections.Generic; using System.Linq; namespace Atcoder { class Program { static void Main(string[] args) { //テンプレート //// 整数の入力 // int a = int.Parse(Console.ReadLine()); //// スペース区切りの整数の入力 // string[] input = Console.ReadLine().Split(' '); // int b = int.Parse(input[0]); // int c = int.Parse(input[1]); //// 文字列の入力 // string s = Console.ReadLine(); ////出力 // Console.WriteLine(a + b + c + " " + s); // A // string[] input = Console.ReadLine().Split(' '); // int s = int.Parse(input[0]); // int w = int.Parse(input[1]); // if (s <= w) //{ // Console.WriteLine("unsafe"); //} // else //{ // Console.WriteLine("safe"); //} // Console.ReadLine(); // B string[] input = Console.ReadLine().Split(' '); var a = Double.Parse(input[0]); var b = Double.Parse(input[1]); var c = Double.Parse(input[2]); var d = Double.Parse(input[3]); double p1 = c / b; double p2 = a / d; if (p1 <= p2) Console.WriteLine("Yes"); else Console.WriteLine("No"); Console.ReadLine(); } } }
using System; using System.Collections.Generic; using System.Linq; namespace Atcoder { class Program { static void Main(string[] args) { //テンプレート //// 整数の入力 // int a = int.Parse(Console.ReadLine()); //// スペース区切りの整数の入力 // string[] input = Console.ReadLine().Split(' '); // int b = int.Parse(input[0]); // int c = int.Parse(input[1]); //// 文字列の入力 // string s = Console.ReadLine(); ////出力 // Console.WriteLine(a + b + c + " " + s); // A // string[] input = Console.ReadLine().Split(' '); // int s = int.Parse(input[0]); // int w = int.Parse(input[1]); // if (s <= w) //{ // Console.WriteLine("unsafe"); //} // else //{ // Console.WriteLine("safe"); //} // Console.ReadLine(); // B string[] input = Console.ReadLine().Split(' '); var a = Double.Parse(input[0]); var b = Double.Parse(input[1]); var c = Double.Parse(input[2]); var d = Double.Parse(input[3]); double p1 = Math.Ceiling(c / b); double p2 = Math.Ceiling(a / d); if (p1 <= p2) Console.WriteLine("Yes"); else Console.WriteLine("No"); Console.ReadLine(); } } }
[["+", 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
174
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; public static long mod = 1000000007; void calc() { cin = new Scanner(); cin2 = new Func(); int a = cin.nextInt(); int b = cin.nextInt(); int c = cin.nextInt(); int d = cin.nextInt(); string ans = "Yes"; double x = (double)c / (double)b; double y = (double)a / (double)d; if (y < x) ans = "No"; Console.WriteLine(ans); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public static long mod = 1000000007; public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } public long mod_pow(long x, long n) { long ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = ans * x; ans %= mod; } x = x * x % mod; n >>= 1; } return ans; } public long factorial(long x) { long n = 1; if (x <= 1) return x; else { n *= (x * factorial(x - 1)); n %= mod; return n; } } public long combination(long n, long r) { if (r * 2 > n) r = n - r; long dividend = 1; long divisor = 1; for (long i = 1; i <= r; ++i) { dividend *= (n - i + 1); dividend %= mod; divisor *= i; divisor %= mod; } return (dividend * mod_pow(divisor, mod - 2)) % mod; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; public static long mod = 1000000007; void calc() { cin = new Scanner(); cin2 = new Func(); int a = cin.nextInt(); int b = cin.nextInt(); int c = cin.nextInt(); int d = cin.nextInt(); string ans = "Yes"; int x = c / b; int y = a / d; if (c % b != 0) x++; if (a % d != 0) y++; if (y < x) ans = "No"; Console.WriteLine(ans); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public static long mod = 1000000007; public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } public long mod_pow(long x, long n) { long ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = ans * x; ans %= mod; } x = x * x % mod; n >>= 1; } return ans; } public long factorial(long x) { long n = 1; if (x <= 1) return x; else { n *= (x * factorial(x - 1)); n %= mod; return n; } } public long combination(long n, long r) { if (r * 2 > n) r = n - r; long dividend = 1; long divisor = 1; for (long i = 1; i <= r; ++i) { dividend *= (n - i + 1); dividend %= mod; divisor *= i; divisor %= mod; } return (dividend * mod_pow(divisor, mod - 2)) % mod; } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 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, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["-", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["-", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
8
983
34
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long mod = 1000000007; static void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; } static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static void Solve() { int A; int B; int C; int D; Multi(out A, out B, out C, out D); var ans = (C - B) / B + 1 <= (D - A) / A + 1 ? "Yes" : "No"; Console.WriteLine(ans); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long mod = 1000000007; static void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; } static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static void Solve() { int A; int B; int C; int D; Multi(out A, out B, out C, out D); var ans = (C - 1) / B + 1 > (A - 1) / D + 1 ? "No" : "Yes"; Console.WriteLine(ans); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } }
[["-", 31, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 17, 19], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 47], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 41, 15, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 41, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 41, 64, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 41, 64, 5, 0, 222], ["-", 0, 200, 0, 212, 0, 41, 75, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 41, 75, 5, 0, 222]]
8
1,550
14
using System; using System.Linq; namespace B { class Program { static void Main(string[] args) { var input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray(); int A = input[0]; int B = input[1]; int C = input[2]; int D = input[3]; bool winTakahashi = false; while (true) { A -= D; if (A <= 0) { break; } C -= B; if (C <= 0) { winTakahashi = true; break; } } if (winTakahashi) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; using System.Linq; namespace B { class Program { static void Main(string[] args) { var input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray(); int A = input[0]; int B = input[1]; int C = input[2]; int D = input[3]; while (true) { C -= B; if (C <= 0) { break; } A -= D; if (A <= 0) { break; } } if (A > 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("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, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 15, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
8
158
25
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace C_gacha { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] Thg = new string[N]; for (int i = 0; i <= N; i++) { Thg[i] = Console.ReadLine(); } Console.WriteLine(Thg.Distinct().ToArray().Length); Console.Read(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace C_gacha { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] Thg = new string[N]; for (int i = 0; i < N; i++) { Thg[i] = Console.ReadLine(); } string[] A = Thg.Distinct().ToArray(); Console.WriteLine(A.Length); Console.Read(); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 197, 0, 198, 39, 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], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 22]]
8
121
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace C { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var S = new List<string>(); for (int i = 0; i < N; i++) { S.Add(Console.ReadLine()); } var list = S.Distinct(); var ans = list; Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace C { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var S = new List<string>(); for (int i = 0; i < N; i++) { S.Add(Console.ReadLine()); } IEnumerable<string> list = S.Distinct(); int ans = list.Count(); Console.WriteLine(ans); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 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, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
8
119
11
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var inp = Console.ReadLine().Split(' '); int n = int.Parse(inp[0]); List<string> keihin = new List<string>(); for (int i = 0; i < n; i++) { var inps = Console.ReadLine(); if (keihin.Contains(inps)) break; keihin.Add(inps); } Console.WriteLine(keihin.Count); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var inp = Console.ReadLine().Split(' '); int n = int.Parse(inp[0]); List<string> keihin = new List<string>(); for (int i = 0; i < n; i++) { var inps = Console.ReadLine(); keihin.Add(inps); } keihin = keihin.Distinct().ToList(); Console.WriteLine(keihin.Count); } }
[["+", 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, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 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, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 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, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
8
120
22
using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main() { int num = int.Parse(Console.ReadLine()); // Console.WriteLine(num); List<string> list = new List<string>(); string ip = Console.ReadLine(); list.Add(ip); for (int i = 0; i < num; i++) { ip = Console.ReadLine(); list.Add(ip); } list.Distinct(); Console.WriteLine(list.Count); } }
using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main() { int num = int.Parse(Console.ReadLine()); // Console.WriteLine(num); List<string> list = new List<string>(); string ip = Console.ReadLine(); list.Add(ip); for (int i = 1; i < num; i++) { ip = Console.ReadLine(); list.Add(ip); } Console.WriteLine(list.Distinct().Count()); } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 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], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
119
14
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace B { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var nm = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); Console.WriteLine(nm[0] - ai.Sum()); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace B { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var nm = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); var result = nm[0] - ai.Sum(); Console.WriteLine(result >= 0 ? result : -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], ["+", 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, 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], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 20], ["+", 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, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 241, 0, 33], ["+", 3, 4, 0, 28, 0, 41, 75, 241, 0, 203]]
8
168
20
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; using System.Text.RegularExpressions; namespace Yuzuki { class Yukari { public static void Main(string[] args) { string[] buf = Console.ReadLine().Split(); int n = int.Parse(buf[0]); buf = Console.ReadLine().Split(); var ans = new Dictionary<int, int>(); for (int i = 0; i < n - 1; i++) { ans[int.Parse(buf[i]) - 1]++; } for (int i = 0; i < n; i++) { Console.WriteLine(ans[i]); } } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; using System.Text.RegularExpressions; namespace Yuzuki { class Yukari { public static void Main(string[] args) { string[] buf = Console.ReadLine().Split(); int n = int.Parse(buf[0]); buf = Console.ReadLine().Split(); var ans = new Dictionary<int, int>(); for (int i = 0; i < n; i++) { ans[i] = 0; } for (int i = 0; i < n - 1; i++) { ans[int.Parse(buf[i]) - 1]++; } for (int i = 0; i < n; i++) { Console.WriteLine(ans[i]); } } } }
[["+", 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, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 8, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22]]
8
177
23
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoderTest { class ABC163C { public static int readLineAsInt() { var line = Console.ReadLine(); return int.Parse(line); } public static List<int> readLineAsListOfInt() { var line = Console.ReadLine(); return line.Split(' ').Select(x => int.Parse(x)).ToList(); } public static List<List<int>> readLinesAsTableOfInt(int N) { var ret = new List<List<int>>(); for (int i = 0; i < N; ++i) ret.Add(readLineAsListOfInt()); return ret; } public static List<int> readLinesAsListOfIntFromColumn(int N) { var ret = new List<int>(); for (int i = 0; i < N; ++i) ret.Add(readLineAsListOfInt()[0]); return ret; } static void Main(string[] args) { var N = readLineAsInt(); var As = readLineAsListOfInt(); var res = core(N, As); for (int i = 0; i < N; ++i) Console.WriteLine(res[i].ToString()); } static List<int> core(int N, List<int> As) { var ret = new List<int>(); for (int i = 0; i < N; ++i) { int id = i + 1; int num_buka = 0; for (int j = i + 1; j < N; ++j) if (As[j] == id) num_buka++; ret.Add(num_buka); } return ret; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoderTest { class ABC163C { public static int readLineAsInt() { var line = Console.ReadLine(); return int.Parse(line); } public static List<int> readLineAsListOfInt() { var line = Console.ReadLine(); return line.Split(' ').Select(x => int.Parse(x)).ToList(); } public static List<List<int>> readLinesAsTableOfInt(int N) { var ret = new List<List<int>>(); for (int i = 0; i < N; ++i) ret.Add(readLineAsListOfInt()); return ret; } public static List<int> readLinesAsListOfIntFromColumn(int N) { var ret = new List<int>(); for (int i = 0; i < N; ++i) ret.Add(readLineAsListOfInt()[0]); return ret; } static void Main(string[] args) { var N = readLineAsInt(); var As = readLineAsListOfInt(); var res = core(N, As); for (int i = 0; i < N; ++i) Console.WriteLine(res[i].ToString()); } static List<int> core(int N, List<int> As) { var table = new int[N]; for (int i = 0; i < N; ++i) table[i] = 0; for (int i = 1; i < N; ++i) table[As[i - 1] - 1]++; return table.ToList(); } } }
[["-", 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, 230, 39, 236, 141, 22], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 8, 1, 0, 11, 31, 204, 205, 22], ["+", 8, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 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, 197, 0, 35], ["+", 8, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 241, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 8, 57, 0, 121], ["-", 0, 7, 8, 196, 0, 7, 8, 57, 0, 24], ["+", 0, 7, 8, 1, 0, 223, 0, 204, 205, 22], ["+", 8, 1, 0, 223, 0, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 57, 15, 16, 17, 60], ["-", 8, 196, 0, 7, 8, 57, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 8, 57, 0, 25], ["-", 0, 7, 8, 57, 64, 1, 0, 223, 0, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 8, 1, 0, 223, 0, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 37, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 37, 0, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 22]]
8
373
55
using System; using System.Collections.Generic; using System.Linq; namespace abc161 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToList(); var temp = new int[n]; for (int i = 0; i < n - 1; i++) { var x = a[i]; temp[x - 1]++; } for (int l = 0; l < a.Count; l++) { Console.WriteLine(temp[a[l]]); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace abc161 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToList(); var temp = new int[n]; for (int i = 0; i < n - 1; i++) { var x = a[i]; temp[x - 1]++; } foreach (var item in temp) { Console.WriteLine(item); } } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["-", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
151
27
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { long M = 1000000007; var nk = IO.ReadSplitLong; long ans = 0; for (long i = nk[1]; i <= nk[0] + 1; i++) { ans = (ans + i * nk[0] % M) % M; ans = (ans - i * i % M) % M; ans = (ans + i) % M; ans = (ans + 1) % M; } WriteLine(ans); } public class IO { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); #endregion } public class Mod { #region // 割る数の定義 private readonly static long M = 1000000007; // 足し算 public static long Add(long a, long b) => (a * b) % M; // 引き算 public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; // 掛け算 public static long Multi(long a, long b) => (a * b) % M; #endregion } public class Scanner { #region public string Str => Console.ReadLine().Trim(); public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray(); public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray(); // public char[][] Grid(int n) => Create(n, () => Str.ToCharArray()); // public int[] ArrInt1D(int n) => Create(n, () => Int); // public long[] ArrLong1D(int n) => Create(n, () => Long); // public int[][] ArrInt2D(int n) => Create(n, () => ArrInt); // public long[][] ArrLong2D(int n) => Create(n, () => ArrLong); private Queue<string> q = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] // インライン化を推奨する public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); } public void Make<T1>(out T1 v1) => v1 = Next<T1>(); public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); } public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); } public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); } public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); } public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); } #endregion } public static long GCD(long x, long y) { #region if (x < y) { var tmp = x; x = y; y = tmp; } while (true) { if (x % y == 0) { return y; } else { var tmp = x; x = y; y = tmp % y; } } #endregion } public static long Choice2(long n) { #region if (n <= 1) return 0; if (n == 2) return 1; else return n * (n - 1) / 2; #endregion } } }
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { long M = 1000000007; var nk = IO.ReadSplitLong; long ans = 0; for (long i = nk[1]; i <= nk[0] + 1; i++) { ans = (ans + i * nk[0]); ans = (ans - i * i); ans = (ans + i); ans = (ans + 1); } WriteLine(ans % M); } public class IO { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); #endregion } public class Mod { #region // 割る数の定義 private readonly static long M = 1000000007; // 足し算 public static long Add(long a, long b) => (a * b) % M; // 引き算 public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; // 掛け算 public static long Multi(long a, long b) => (a * b) % M; #endregion } public class Scanner { #region public string Str => Console.ReadLine().Trim(); public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray(); public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray(); // public char[][] Grid(int n) => Create(n, () => Str.ToCharArray()); // public int[] ArrInt1D(int n) => Create(n, () => Int); // public long[] ArrLong1D(int n) => Create(n, () => Long); // public int[][] ArrInt2D(int n) => Create(n, () => ArrInt); // public long[][] ArrLong2D(int n) => Create(n, () => ArrLong); private Queue<string> q = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] // インライン化を推奨する public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); } public void Make<T1>(out T1 v1) => v1 = Next<T1>(); public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); } public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); } public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); } public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); } public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); } #endregion } public static long GCD(long x, long y) { #region if (x < y) { var tmp = x; x = y; y = tmp; } while (true) { if (x % y == 0) { return y; } else { var tmp = x; x = y; y = tmp % y; } } #endregion } public static long Choice2(long n) { #region if (n <= 1) return 0; if (n == 2) return 1; else return n * (n - 1) / 2; #endregion } } }
[["-", 12, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["-", 12, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
8
1,126
7
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace cysharp_test { class Program { static void Main(string[] args) { new Program().solve(); } void solve() { long[] NK = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); long N = NK[0]; long K = NK[1]; long count = 0; for (long i = K; i <= N + 1; i++) { long max = (N - i + 1 + N) * i / 2; long min = (0 + i - 1) + i / 2; count += max - min + 1; // count += i * N - 2 * sum(i - 1) + 1; } Console.WriteLine(count); Console.ReadLine(); } static long sum(long n) { long sum = 0; for (int i = 1; i <= n; i++) { sum += i; } return sum; } } class Vector2 { public Vector2(long x, long y) { this.x = x; this.y = y; } long x, y; public static Vector2 operator +(Vector2 a, Vector2 b) { return new Vector2(a.x + b.x, a.y + b.y); } public static Vector2 operator -(Vector2 a, Vector2 b) { return new Vector2(a.x - b.x, a.y - b.y); } public static Vector2 operator *(Vector2 a, long scala) { return new Vector2(a.x * scala, a.y + scala); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace cysharp_test { class Program { static void Main(string[] args) { new Program().solve(); } void solve() { ulong[] NK = Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray(); ulong N = NK[0]; ulong K = NK[1]; ulong count = 0; for (ulong i = K; i <= N + 1; i++) { ulong max = (N - i + 1 + N) * i / 2; ulong min = (0 + i - 1) * i / 2; count += max - min + 1; // Console.WriteLine(max + " " + min); // count += i * N - 2 * sum(i - 1) + 1; } Console.WriteLine(count % 1000000007); Console.ReadLine(); } static long sum(long n) { long sum = 0; for (int i = 1; i <= n; i++) { sum += i; } return sum; } } class Vector2 { public Vector2(long x, long y) { this.x = x; this.y = y; } long x, y; public static Vector2 operator +(Vector2 a, Vector2 b) { return new Vector2(a.x + b.x, a.y + b.y); } public static Vector2 operator -(Vector2 a, Vector2 b) { return new Vector2(a.x - b.x, a.y - b.y); } public static Vector2 operator *(Vector2 a, long scala) { return new Vector2(a.x * scala, a.y + scala); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 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, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
346
20
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO.Pipes; using System.Runtime; namespace Csharponly { class Program { static public void Main() { int[] NK = Arrayint(); string ans = Team(NK[0] + 1, NK[1]); long a = long.Parse(ans); long b = a % 1000000007; Console.WriteLine(b); } static string Team(int a, int b) { string ans = "1"; for (int i = b; i < a; i++) { ans = Tasu(ans, Kakeru((a - i).ToString(), i.ToString())); } return ans; } // b*(b+1)*(b*2)* *a static int Warunum(int aa, int bb) { int cc = 1; for (int i = bb; i < aa; i++) { cc = cc * i; } return cc; } static string Kakeru(string a1, string b1) { int anum = a1.Length; int bnum = b1.Length; int[] a = Array(a1); int[] b = Array(b1); int[] kakeruans = new int[anum + bnum]; for (int i = 0; i < anum; i++) { for (int j = 0; j < bnum; j++) { kakeruans[i + j] += a[i] * b[j]; } } for (int i = 0; i < kakeruans.Length; i++) { if (kakeruans[i] >= 10) { kakeruans[i + 1] += kakeruans[i] / 10; kakeruans[i] = kakeruans[i] % 10; } } string kakerustring = ""; for (int i = 0; i < kakeruans.Length - 1; i++) { kakerustring = kakeruans[i].ToString() + kakerustring; } if (kakeruans[kakeruans.Length - 1] != 0) { kakerustring = kakeruans[kakeruans.Length - 1].ToString() + kakerustring; } return kakerustring; } static string Tasu(string a1, string b1) { int anum = a1.Length; int bnum = b1.Length; int[] a = Array(a1); int[] b = Array(b1); string tasustring = ""; if (anum < bnum) { int[] tasuans = new int[bnum + 1]; for (int i = 0; i < anum; i++) { tasuans[i] = a[i] + b[i]; } for (int i = anum; i < bnum; i++) { tasuans[i] = b[i]; } for (int i = 0; i < tasuans.Length; i++) { if (tasuans[i] >= 10) { tasuans[i] -= 10; tasuans[i + 1]++; } } for (int i = 0; i < tasuans.Length - 1; i++) { tasustring = tasuans[i].ToString() + tasustring; } if (tasuans[tasuans.Length - 1] != 0) { tasustring = tasuans[tasuans.Length - 1].ToString() + tasustring; } } else { int[] tasuans = new int[anum + 1]; for (int i = 0; i < bnum; i++) { tasuans[i] = a[i] + b[i]; } for (int i = bnum; i < anum; i++) { tasuans[i] = a[i]; } for (int i = 0; i < tasuans.Length; i++) { if (tasuans[i] >= 10) { tasuans[i] -= 10; tasuans[i + 1]++; } } for (int i = 0; i < tasuans.Length - 1; i++) { tasustring = tasuans[i].ToString() + tasustring; } if (tasuans[tasuans.Length - 1] != 0) { tasustring = tasuans[tasuans.Length - 1].ToString() + tasustring; } } return tasustring; } static int[] Array(string A) { int[] a = new int[A.Length]; string num; for (int i = 0; i < A.Length; i++) { num = A.Substring(i, 1); a[A.Length - i - 1] = int.Parse(num); } return a; } //一つの文字列を受け渡す static string Onestring() { return Console.ReadLine(); } //複数の文字列を配列で受け渡す //文字列と文字列の間は" "で区切る static string[] Arraystring() { return Console.ReadLine().Split(' '); } //一つの数字を受け渡す static int Oneint() { return int.Parse(Console.ReadLine()); } //複数の数字を配列で受け渡す //数字と数字の間は" "で区切る static int[] Arrayint() { String[] input_line = Console.ReadLine().Split(' '); int[] input_num = new int[input_line.Length]; for (int i = 0; i < input_line.Length; i++) { input_num[i] = int.Parse(input_line[i]); } return input_num; } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO.Pipes; using System.Runtime; namespace Csharponly { class Program { static public void Main() { int[] NK = Arrayint(); string ans = Team(NK[0] + 1, NK[1]); long a = long.Parse(ans); long b = a % 1000000007; Console.WriteLine(b); } static string Team(int a, int b) { string ans = "1"; for (int i = b; i < a; i++) { ans = Tasu(Tasu(ans, Kakeru((a - i).ToString(), i.ToString())), "1"); // Console.WriteLine(ans); } return ans; } // b*(b+1)*(b*2)* *a static int Warunum(int aa, int bb) { int cc = 1; for (int i = bb; i < aa; i++) { cc = cc * i; } return cc; } static string Kakeru(string a1, string b1) { int anum = a1.Length; int bnum = b1.Length; int[] a = Array(a1); int[] b = Array(b1); int[] kakeruans = new int[anum + bnum]; for (int i = 0; i < anum; i++) { for (int j = 0; j < bnum; j++) { kakeruans[i + j] += a[i] * b[j]; } } for (int i = 0; i < kakeruans.Length; i++) { if (kakeruans[i] >= 10) { kakeruans[i + 1] += kakeruans[i] / 10; kakeruans[i] = kakeruans[i] % 10; } } string kakerustring = ""; for (int i = 0; i < kakeruans.Length - 1; i++) { kakerustring = kakeruans[i].ToString() + kakerustring; } if (kakeruans[kakeruans.Length - 1] != 0) { kakerustring = kakeruans[kakeruans.Length - 1].ToString() + kakerustring; } return kakerustring; } static string Tasu(string a1, string b1) { int anum = a1.Length; int bnum = b1.Length; int[] a = Array(a1); int[] b = Array(b1); string tasustring = ""; if (anum < bnum) { int[] tasuans = new int[bnum + 1]; for (int i = 0; i < anum; i++) { tasuans[i] = a[i] + b[i]; } for (int i = anum; i < bnum; i++) { tasuans[i] = b[i]; } for (int i = 0; i < tasuans.Length; i++) { if (tasuans[i] >= 10) { tasuans[i] -= 10; tasuans[i + 1]++; } } for (int i = 0; i < tasuans.Length - 1; i++) { tasustring = tasuans[i].ToString() + tasustring; } if (tasuans[tasuans.Length - 1] != 0) { tasustring = tasuans[tasuans.Length - 1].ToString() + tasustring; } } else { int[] tasuans = new int[anum + 1]; for (int i = 0; i < bnum; i++) { tasuans[i] = a[i] + b[i]; } for (int i = bnum; i < anum; i++) { tasuans[i] = a[i]; } for (int i = 0; i < tasuans.Length; i++) { if (tasuans[i] >= 10) { tasuans[i] -= 10; tasuans[i + 1]++; } } for (int i = 0; i < tasuans.Length - 1; i++) { tasustring = tasuans[i].ToString() + tasustring; } if (tasuans[tasuans.Length - 1] != 0) { tasustring = tasuans[tasuans.Length - 1].ToString() + tasustring; } } return tasustring; } static int[] Array(string A) { int[] a = new int[A.Length]; string num; for (int i = 0; i < A.Length; i++) { num = A.Substring(i, 1); a[A.Length - i - 1] = int.Parse(num); } return a; } //一つの文字列を受け渡す static string Onestring() { return Console.ReadLine(); } //複数の文字列を配列で受け渡す //文字列と文字列の間は" "で区切る static string[] Arraystring() { return Console.ReadLine().Split(' '); } //一つの数字を受け渡す static int Oneint() { return int.Parse(Console.ReadLine()); } //複数の数字を配列で受け渡す //数字と数字の間は" "で区切る static int[] Arrayint() { String[] input_line = Console.ReadLine().Split(' '); int[] input_num = new int[input_line.Length]; for (int i = 0; i < input_line.Length; i++) { input_num[i] = int.Parse(input_line[i]); } return input_num; } } }
[["+", 12, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 12, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 12, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
1,082
7
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; public static class P { public static void Main() { var nk = Console.ReadLine().Split().Select(int.Parse).ToArray(); var n = nk[0]; var k = nk[1]; ModInt res = 0; // k個選んだ時に取りうる値の範囲、k+1個の時に… for (long i = k; i <= n; i++) { var min = i * (i + 1) / 2; var max = i * (i + 1) / 2 + i * (k - i); res += max - min + 1; } Console.WriteLine(res); } } struct ModInt { public const int Mod = 1000000007; const long POSITIVIZER = ((long)Mod) << 31; long Data; public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; } public static implicit operator long(ModInt modInt) => modInt.Data; public static implicit operator ModInt(long val) => new ModInt(val); public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod }; public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b); public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; } public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod }; public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b); public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; } public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b); public static ModInt operator *(ModInt a, long b) => a * new ModInt(b); public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod }; public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod }; public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data; public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data; public override string ToString() => Data.ToString(); public override bool Equals(object obj) => (ModInt)obj == this; public override int GetHashCode() => (int)Data; 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; } } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; public static class P { public static void Main() { var nk = Console.ReadLine().Split().Select(int.Parse).ToArray(); var n = nk[0]; var k = nk[1]; ModInt res = 0; // k個選んだ時に取りうる値の範囲、k+1個の時に… for (long i = k; i <= (n + 1); i++) { var min = i * (i - 1) / 2; var max = min + i * (n - i + 1); res += max - min + 1; } Console.WriteLine(res); } } struct ModInt { public const int Mod = 1000000007; const long POSITIVIZER = ((long)Mod) << 31; long Data; public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; } public static implicit operator long(ModInt modInt) => modInt.Data; public static implicit operator ModInt(long val) => new ModInt(val); public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod }; public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b); public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; } public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod }; public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b); public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; } public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b); public static ModInt operator *(ModInt a, long b) => a * new ModInt(b); public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod }; public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod }; public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data; public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data; public override string ToString() => Data.ToString(); public override bool Equals(object obj) => (ModInt)obj == this; public override int GetHashCode() => (int)Data; 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; } } }
[["+", 8, 196, 0, 7, 15, 16, 12, 23, 0, 24], ["+", 0, 7, 15, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 7, 15, 16, 12, 23, 0, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 23, 0, 25], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["-", 0, 212, 0, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 212, 0, 16, 31, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["-", 31, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["-", 31, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["-", 31, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["-", 0, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 12, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 203]]
8
760
20
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { try { SetOut(sw); Solve.Answer(); Out.Flush(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void dfs(List<int> A, int n, int m, int q) { if (A.Count == n + 1) { // calc score int now = 0; for (int i = 0; i < q; i++) { if (A[b[i]] - A[a[i]] == c[i]) now += d[i]; } ans = Max(ans, now); return; } A.Add(A[A.Count - 1]); while (A[A.Count - 1] <= m) { dfs(A, n, m, q); A[A.Count - 1]++; } } static int ans = 0; static List<int> a = new List<int>(); static List<int> b = new List<int>(); static List<int> c = new List<int>(); static List<int> d = new List<int>(); public static void Answer() { var nmq = IO.RSInt; var n = nmq[0]; var m = nmq[1]; var q = nmq[2]; for (int i = 0; i < q; i++) { var work = IO.RSInt; a.Add(work[0]); b.Add(work[1]); c.Add(work[2]); d.Add(work[3]); } var tmp = new List<int>(); tmp.Add(1); dfs(tmp, n, m, q); WriteLine(ans); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { try { SetOut(sw); Solve.Answer(); Out.Flush(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void dfs(List<int> A, int n, int m, int q) { if (A.Count == n + 1) { int now = 0; for (int i = 0; i < q; i++) { if (A[b[i]] - A[a[i]] == c[i]) now += d[i]; } ans = Max(ans, now); return; } A.Add(A[A.Count - 1]); while (A[A.Count - 1] <= m) { dfs(A, n, m, q); A[A.Count - 1]++; } A.RemoveAt(A.Count - 1); } static int ans = 0; static List<int> a = new List<int>(); static List<int> b = new List<int>(); static List<int> c = new List<int>(); static List<int> d = new List<int>(); public static void Answer() { var nmq = IO.RSInt; var n = nmq[0]; var m = nmq[1]; var q = nmq[2]; for (int i = 0; i < q; i++) { var work = IO.RSInt; a.Add(work[0]); b.Add(work[1]); c.Add(work[2]); d.Add(work[3]); } var tmp = new List<int>(); tmp.Add(1); dfs(tmp, n, m, q); WriteLine(ans); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
[["+", 8, 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, 16, 31, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
805
11
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var A = cin.ReadLong; var B = cin.ReadLong; var N = cin.ReadLong; WriteLine(N >= B ? A : (long)((double)(N * A) / (double)B)); } } 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; } } struct ModInt { const int M = 1000000007; public long V; public ModInt(long v) { V = (v %= M) < 0 ? v + M : v; } public static implicit operator ModInt(long v) => new ModInt(v); public static ModInt operator +(ModInt x) => x; public static ModInt operator -(ModInt x) => -x.V; public static ModInt operator +(ModInt x, ModInt y) => x.V + y.V; public static ModInt operator -(ModInt x, ModInt y) => x.V - y.V; public static ModInt operator *(ModInt x, ModInt y) => x.V * y.V; public static ModInt operator /(ModInt x, ModInt y) => x.V * y.Inv(); public ModInt Pow(int i) => MPow(V, i); public ModInt Inv() => MPow(V, M - 2); public override string ToString() => $"{V}"; static long MPow(long b, int i) { for (var r = 1L;; b = b * b % M) { if (i % 2 > 0) r = r * b % M; if ((i /= 2) < 1) return r; } } public static long MFactorial(int n) { for (long x = 1, i = 1;; x = x * ++i % M) if (i >= n) return x; } public static long MNpr(int n, int r) { if (n < r) return 0; for (long x = 1, i = n - r;; x = x * ++i % M) if (i >= n) return x; } public static ModInt MNcr(int n, int r) => n < r ? 0 : n - r < r ? MNcr(n, n - r) : (ModInt)MNpr(n, r) / MFactorial(r); } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var A = cin.ReadLong; var B = cin.ReadLong; var N = cin.ReadLong; WriteLine(N < B ? (long)((double)(N * A) / (double)B) : (long)((double)((B - 1) * A) / (double)B)); } } 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; } } struct ModInt { const int M = 1000000007; public long V; public ModInt(long v) { V = (v %= M) < 0 ? v + M : v; } public static implicit operator ModInt(long v) => new ModInt(v); public static ModInt operator +(ModInt x) => x; public static ModInt operator -(ModInt x) => -x.V; public static ModInt operator +(ModInt x, ModInt y) => x.V + y.V; public static ModInt operator -(ModInt x, ModInt y) => x.V - y.V; public static ModInt operator *(ModInt x, ModInt y) => x.V * y.V; public static ModInt operator /(ModInt x, ModInt y) => x.V * y.Inv(); public ModInt Pow(int i) => MPow(V, i); public ModInt Inv() => MPow(V, M - 2); public override string ToString() => $"{V}"; static long MPow(long b, int i) { for (var r = 1L;; b = b * b % M) { if (i % 2 > 0) r = r * b % M; if ((i /= 2) < 1) return r; } } public static long MFactorial(int n) { for (long x = 1, i = 1;; x = x * ++i % M) if (i >= n) return x; } public static long MNpr(int n, int r) { if (n < r) return 0; for (long x = 1, i = n - r;; x = x * ++i % M) if (i >= n) return x; } public static ModInt MNcr(int n, int r) => n < r ? 0 : n - r < r ? MNcr(n, n - r) : (ModInt)MNpr(n, r) / MFactorial(r); } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 20], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 18], ["+", 3, 4, 0, 28, 0, 41, 64, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 41, 64, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 41, 64, 74, 0, 25], ["+", 0, 28, 0, 41, 64, 74, 51, 23, 0, 24], ["+", 64, 74, 51, 23, 0, 16, 31, 74, 0, 24], ["+", 64, 74, 51, 23, 0, 16, 31, 74, 39, 199], ["+", 64, 74, 51, 23, 0, 16, 31, 74, 0, 25], ["+", 51, 23, 0, 16, 31, 74, 51, 23, 0, 24], ["+", 0, 16, 31, 74, 51, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 74, 51, 23, 0, 16, 17, 48], ["+", 51, 23, 0, 16, 31, 74, 51, 23, 0, 25], ["+", 0, 41, 64, 74, 51, 23, 0, 16, 17, 85], ["+", 64, 74, 51, 23, 0, 16, 12, 74, 0, 24], ["+", 64, 74, 51, 23, 0, 16, 12, 74, 39, 199], ["+", 64, 74, 51, 23, 0, 16, 12, 74, 0, 25], ["+", 64, 74, 51, 23, 0, 16, 12, 74, 51, 22], ["+", 0, 28, 0, 41, 64, 74, 51, 23, 0, 25], ["-", 0, 16, 31, 74, 51, 23, 0, 16, 31, 22], ["+", 51, 23, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 51, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 51, 23, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 31, 74, 51, 23, 0, 16, 31, 23, 0, 25]]
8
884
25
using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main(string[] args) { var ABN = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); var (A, B, N) = (ABN[0], ABN[1], ABN[2]); var ans = Math.Min(B - 1, (A * N / B) - A * (N / B)); WriteLine(ans); } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main(string[] args) { var ABN = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); var (A, B, N) = (ABN[0], ABN[1], ABN[2]); var x = (N < B - 1) ? N : B - 1; var ans = (A * x / B) - A * (x / B); WriteLine(ans); } }
[["-", 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], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 31, 22], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 17, 18], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 200, 0, 212, 0, 41, 15, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 17, 33], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 28, 0, 16, 12, 16, 12, 23, 0, 25]]
8
125
24
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; const double eps = 1e-11; static void Main() { Sc sc = new Sc(); var n = sc.I; var a = sc.Ia; var h = a.Select((x, idx) => new long[] { idx, x }) .OrderByDescending(x => x[1]) .ToArray(); var dp = new long[n + 1]; for (int i = 0; i < h.Length; i++) { for (int j = i + 1; j > 0; j--) { if (dp[j] == 0) { dp[j] += Abs((j - 1) - h[i][0]) * h[i][1]; } else { dp[j] = Max(Abs((j - 1) - h[i][0]) * h[i][1] + dp[j - 1], Abs((n - 1 - (i - j)) - h[i][0]) * h[i][1] + dp[j]); } } dp[0] += Abs((n - 1 - i) - h[i][0]) * h[i][1]; } Console.WriteLine("{0}", dp.Max()); } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; const double eps = 1e-11; static void Main() { Sc sc = new Sc(); var n = sc.I; var a = sc.Ia; var h = a.Select((x, idx) => new long[] { idx, x }) .OrderByDescending(x => x[1]) .ToArray(); var dp = new long[n + 1]; for (int i = 0; i < h.Length; i++) { for (int j = i + 1; j > 0; j--) { if (dp[j] == 0) { dp[j] = Abs((j - 1) - h[i][0]) * h[i][1] + dp[j - 1]; } else { dp[j] = Max(Abs((j - 1) - h[i][0]) * h[i][1] + dp[j - 1], Abs((n - 1 - (i - j)) - h[i][0]) * h[i][1] + dp[j]); } } dp[0] += Abs((n - 1 - i) - h[i][0]) * h[i][1]; } Console.WriteLine("{0}", dp.Max()); } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
[["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33]]
8
1,306
9
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class ABC163F { static bool SAIKI = false; static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var N = NN; var cList = NNList(N); var abList = Repeat(0, N - 1).Select(_ => new { a = NN - 1, b = NN - 1 }).ToArray(); var tree = new LIB_Tree(N); foreach (var item in abList) { tree.AddPath(item.a, item.b); } var dic = new Dictionary<long, long>[N]; var cnt = new long[N]; var list = Repeat(0, N + 1).Select(_ => new List<long>()).ToArray(); foreach (var item in tree.BFSFromLeaf(0)) { foreach (var item2 in tree.GetSurround(item.node) .Where(e => e != item.parent) .OrderByDescending(e => dic[e].Count)) { cnt[item.node] += cnt[item2]; if (dic[item.node] == null) { dic[item.node] = dic[item2]; if (dic[item.node].ContainsKey(cList[item.node])) { list[cList[item.node]].Add(cnt[item2] - dic[item2][cList[item.node]]); } else { list[cList[item.node]].Add(cnt[item2]); } } else { foreach (var item3 in dic[item2]) { if (dic[item.node].ContainsKey(item3.Key)) { dic[item.node][item3.Key] += item3.Value; } else { dic[item.node][item3.Key] = item3.Value; } } if (dic[item.node].ContainsKey(cList[item.node])) { list[cList[item.node]].Add(cnt[item2] - dic[item2][cList[item.node]]); } else { list[cList[item.node]].Add(cnt[item2]); } } } if (dic[item.node] == null) { dic[item.node] = new Dictionary<long, long>(); } cnt[item.node]++; dic[item.node][cList[item.node]] = cnt[item.node]; } for (var i = 1; i <= N; i++) { var v = 0L; if (dic[0].ContainsKey(i)) v = dic[0][i]; list[i].Add(cnt[0] - v); } var basenum = N * (N + 1) / 2; for (var i = 1; i <= N; i++) { var ans = 0L; foreach (var item in list[i]) { ans += item * (item + 1) / 2; } Console.WriteLine(basenum - ans); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static LIB_FastIO fastio = new LIB_FastIODebug(); static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); } static long NN => fastio.Long(); static double ND => fastio.Double(); static string NS => fastio.Scan(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector); static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library { partial class LIB_Tree { int N; List<int>[] path; public struct EulerRes { public long node; public long parent; public long direction; } public struct BFSRes { public long node; public long parent; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_Tree(long n) { N = (int)n; path = Enumerable.Repeat(0, N).Select(_ => new List<int>()).ToArray(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddPath(long u, long v) { if (u >= N || v >= N) throw new Exception(); path[u].Add((int)v); path[v].Add((int)u); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int[] GetSurround(long u) => path[u].ToArray(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public List<BFSRes> BFSFromRoot(long root) { var bfsList = new List<BFSRes>(); var q = new Queue<int>(); var done = new bool[N]; bfsList.Add(new BFSRes { node = root, parent = -1 }); done[root] = true; q.Enqueue((int)root); while (q.Count > 0) { var w = q.Dequeue(); foreach (var i in path[w]) { if (done[i]) continue; done[i] = true; q.Enqueue(i); bfsList.Add(new BFSRes { node = i, parent = w }); } } return bfsList; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public List<BFSRes> BFSFromLeaf(long root) => BFSFromRoot(root).ToArray().Reverse().ToList(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public List<EulerRes> EulerTour(long root) { var eulerList = new List<EulerRes>(); var s = new Stack<Tuple<int, int>>(); var done = new bool[N]; done[root] = true; s.Push(Tuple.Create((int)root, -1)); while (s.Count > 0) { var w = s.Peek(); var ad = true; foreach (var i in path[w.Item1]) { if (done[i]) continue; done[i] = true; ad = false; s.Push(Tuple.Create(i, w.Item1)); } if (!ad || path[w.Item1].Count == 1) eulerList.Add( new EulerRes { node = w.Item1, parent = w.Item2, direction = 1 }); if (ad) { s.Pop(); eulerList.Add( new EulerRes { node = w.Item1, parent = w.Item2, direction = -1 }); } } return eulerList; } } class LIB_FastIO { public LIB_FastIO() { str = Console.OpenStandardInput(); } readonly Stream str; readonly byte[] buf = new byte[1024]; int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } 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++]; } char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } virtual public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } virtual 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'; } } virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } class LIB_FastIODebug : LIB_FastIO { Queue<string> param = new Queue<string>(); string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } public LIB_FastIODebug() {} public override string Scan() => NextString(); public override long Long() => long.Parse(NextString()); public override double Double() => double.Parse(NextString()); } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class ABC163F { static bool SAIKI = false; static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var N = NN; var cList = NNList(N).Select(e => e - 1).ToArray(); var abList = Repeat(0, N - 1).Select(_ => new { a = NN - 1, b = NN - 1 }).ToArray(); var tree = new LIB_Tree(N); foreach (var item in abList) { tree.AddPath(item.a, item.b); } var dic = new Dictionary<long, long>[N]; var cnt = new long[N]; var list = Repeat(0, N).Select(_ => new List<long>()).ToArray(); foreach (var item in tree.BFSFromLeaf(0)) { foreach (var item2 in tree.GetSurround(item.node) .Where(e => e != item.parent) .OrderByDescending(e => dic[e].Count)) { cnt[item.node] += cnt[item2]; if (dic[item.node] == null) { dic[item.node] = dic[item2]; if (dic[item2].ContainsKey(cList[item.node])) { list[cList[item.node]].Add(cnt[item2] - dic[item2][cList[item.node]]); } else { list[cList[item.node]].Add(cnt[item2]); } } else { foreach (var item3 in dic[item2]) { if (dic[item.node].ContainsKey(item3.Key)) { dic[item.node][item3.Key] += item3.Value; } else { dic[item.node][item3.Key] = item3.Value; } } if (dic[item2].ContainsKey(cList[item.node])) { list[cList[item.node]].Add(cnt[item2] - dic[item2][cList[item.node]]); } else { list[cList[item.node]].Add(cnt[item2]); } } } if (dic[item.node] == null) { dic[item.node] = new Dictionary<long, long>(); } cnt[item.node]++; dic[item.node][cList[item.node]] = cnt[item.node]; } for (var i = 0; i < N; i++) { var v = 0L; if (dic[0].ContainsKey(i)) v = dic[0][i]; list[i].Add(cnt[0] - v); } var basenum = N * (N + 1) / 2; for (var i = 0; i < N; i++) { var ans = 0L; foreach (var item in list[i]) { ans += item * (item + 1) / 2; } Console.WriteLine(basenum - ans); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static LIB_FastIO fastio = new LIB_FastIODebug(); static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); } static long NN => fastio.Long(); static double ND => fastio.Double(); static string NS => fastio.Scan(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector); static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library { partial class LIB_Tree { int N; List<int>[] path; public struct EulerRes { public long node; public long parent; public long direction; } public struct BFSRes { public long node; public long parent; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_Tree(long n) { N = (int)n; path = Enumerable.Repeat(0, N).Select(_ => new List<int>()).ToArray(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddPath(long u, long v) { if (u >= N || v >= N) throw new Exception(); path[u].Add((int)v); path[v].Add((int)u); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int[] GetSurround(long u) => path[u].ToArray(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public List<BFSRes> BFSFromRoot(long root) { var bfsList = new List<BFSRes>(); var q = new Queue<int>(); var done = new bool[N]; bfsList.Add(new BFSRes { node = root, parent = -1 }); done[root] = true; q.Enqueue((int)root); while (q.Count > 0) { var w = q.Dequeue(); foreach (var i in path[w]) { if (done[i]) continue; done[i] = true; q.Enqueue(i); bfsList.Add(new BFSRes { node = i, parent = w }); } } return bfsList; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public List<BFSRes> BFSFromLeaf(long root) => BFSFromRoot(root).ToArray().Reverse().ToList(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public List<EulerRes> EulerTour(long root) { var eulerList = new List<EulerRes>(); var s = new Stack<Tuple<int, int>>(); var done = new bool[N]; done[root] = true; s.Push(Tuple.Create((int)root, -1)); while (s.Count > 0) { var w = s.Peek(); var ad = true; foreach (var i in path[w.Item1]) { if (done[i]) continue; done[i] = true; ad = false; s.Push(Tuple.Create(i, w.Item1)); } if (!ad || path[w.Item1].Count == 1) eulerList.Add( new EulerRes { node = w.Item1, parent = w.Item2, direction = 1 }); if (ad) { s.Pop(); eulerList.Add( new EulerRes { node = w.Item1, parent = w.Item2, direction = -1 }); } } return eulerList; } } class LIB_FastIO { public LIB_FastIO() { str = Console.OpenStandardInput(); } readonly Stream str; readonly byte[] buf = new byte[1024]; int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } 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++]; } char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } virtual public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } virtual 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'; } } virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } class LIB_FastIODebug : LIB_FastIO { Queue<string> param = new Queue<string>(); string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } public LIB_FastIODebug() {} public override string Scan() => NextString(); public override long Long() => long.Parse(NextString()); public override double Double() => double.Parse(NextString()); } }
[["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 12, 203], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 205, 204, 206, 207, 0, 28, 0, 214, 205, 22], ["-", 205, 204, 206, 207, 0, 28, 0, 214, 0, 131], ["-", 205, 204, 206, 207, 0, 28, 0, 214, 141, 22], ["+", 63, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18]]
8
2,643
31
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC162_A { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); bool ans = (N % 10) == 7; if (ans) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC162_A { class Program { static void Main(string[] args) { var N = Console.ReadLine(); bool ans = (N.Contains("7")); if (ans) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 17, 109], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 60], ["+", 0, 212, 0, 23, 0, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 23, 0, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 23, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 212, 0, 23, 0, 213, 3, 4, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 23, 0, 25]]
8
98
16
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; using static System.Math; class MainClass { public static void Main(string[] args) { var N = LnInt(); var hun = N / 100; var ten = N % 100 / 10; var one = N % 10; Console.WriteLine(one == 7 || hun == 7 || ten == 7); } public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; } public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); } public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; } public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; } }
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; using static System.Math; class MainClass { public static void Main(string[] args) { var N = LnInt(); var hun = N / 100; var ten = N % 100 / 10; var one = N % 10; Console.WriteLine((one == 7 || hun == 7 || ten == 7) ? "Yes" : "No"); } public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; } public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); } public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; } public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; } }
[["+", 3, 4, 0, 28, 0, 41, 15, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 41, 15, 23, 0, 25], ["+", 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
268
10
namespace Test { using System; using System.Collections.Generic; using System.Linq; using System.Text; public class Test { public static void Main(string[] args) { var t = new Test(); var input = t.ReadInputOneLine(); if (input % 10 == 7 || input / 10 == 7 || input / 100 == 7) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } public int ReadInputOneLine() { return int.Parse(Console.ReadLine()); } public string[] ReadInput() { return Console.ReadLine().Split(' '); } public List<int> ParseIntList(string[] x) { var convertedList = new List<int>(x.Length); for (var i = 0; i < x.Length; i++) { convertedList.Add(int.Parse(x[i])); } return convertedList; } public List<double> ParseDoubleList(string[] x) { var convertedList = new List<double>(x.Length); for (var i = 0; i < x.Length; i++) { convertedList.Add(double.Parse(x[i])); } return convertedList; } public List<long> ParseLongList(string[] x) { var convertedList = new List<long>(x.Length); for (var i = 0; i < x.Length; i++) { convertedList.Add(long.Parse(x[i])); } return convertedList; } public int CountContainWords(string source, string word) { var count = 0; var loopCount = source.Length - (word.Length - 1); for (var i = 0; i < loopCount; i++) { if (source.Substring(i, word.Length) == word) { count++; } } return count; } } }
namespace Test { using System; using System.Collections.Generic; using System.Linq; using System.Text; public class Test { public static void Main(string[] args) { var t = new Test(); var input = t.ReadInputOneLine(); var middle = (input / 10) % 10; if (input % 10 == 7 || middle == 7 || input / 100 == 7) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } public int ReadInputOneLine() { return int.Parse(Console.ReadLine()); } public string[] ReadInput() { return Console.ReadLine().Split(' '); } public List<int> ParseIntList(string[] x) { var convertedList = new List<int>(x.Length); for (var i = 0; i < x.Length; i++) { convertedList.Add(int.Parse(x[i])); } return convertedList; } public List<double> ParseDoubleList(string[] x) { var convertedList = new List<double>(x.Length); for (var i = 0; i < x.Length; i++) { convertedList.Add(double.Parse(x[i])); } return convertedList; } public List<long> ParseLongList(string[] x) { var convertedList = new List<long>(x.Length); for (var i = 0; i < x.Length; i++) { convertedList.Add(long.Parse(x[i])); } return convertedList; } public int CountContainWords(string source, string word) { var count = 0; var loopCount = source.Length - (word.Length - 1); for (var i = 0; i < loopCount; i++) { if (source.Substring(i, word.Length) == word) { count++; } } return count; } } }
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 15, 16, 31, 16, 12, 16, 31, 16, 31, 22], ["-", 15, 16, 31, 16, 12, 16, 31, 16, 17, 85], ["-", 15, 16, 31, 16, 12, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22]]
8
406
15
using System; public class SevenSpotter { public static void Main(string[] args) { var number = int.Parse(Console.ReadLine()); var result = IsThereA7(number); Console.WriteLine(result); } public static bool IsThereA7(int number) { for (int i = 0; i < 3; i++) { var divisor = Math.Pow(10, i); var divided = number / divisor; var roundedColumn = Math.Floor(divided); if (roundedColumn % 10 == 7) { return true; } } return false; } }
using System; public class SevenSpotter { public static void Main(string[] args) { var number = int.Parse(Console.ReadLine()); var result = IsThereA7(number); Console.WriteLine(result); } public static string IsThereA7(int number) { for (int i = 0; i < 3; i++) { var divisor = Math.Pow(10, i); var divided = number / divisor; var roundedColumn = Math.Floor(divided); if (roundedColumn % 10 == 7) { return "Yes"; } } return "No"; } }
[["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 0, 57, 64, 196, 0, 37, 0, 211, 0, 146], ["+", 0, 57, 64, 196, 0, 37, 0, 5, 0, 62], ["+", 0, 57, 64, 196, 0, 37, 0, 5, 0, 222], ["-", 0, 195, 8, 196, 0, 37, 0, 211, 0, 147], ["+", 0, 195, 8, 196, 0, 37, 0, 5, 0, 62], ["+", 0, 195, 8, 196, 0, 37, 0, 5, 0, 222]]
8
120
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; class Program { static void Main(string[] args) { // 入力 string[] sS = System.Console.ReadLine().Trim().Split(' '); long iN = long.Parse(sS[0]); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // 解析 long iSum = 0; for (long i = 1; i <= iN; i++) { if (i % 3 == 0 || i % 5 == 0) { } else { iSum += i; } } sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("続行するには何かキーを押してください..."); Console.ReadKey(); #endif } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; class Program { static void Main(string[] args) { // 入力 string[] sS = System.Console.ReadLine().Trim().Split(' '); long iN = long.Parse(sS[0]); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // 解析 long iSum = 0; for (long i = 1; i <= iN; i++) { if (i % 3 == 0 || i % 5 == 0) { } else { iSum += i; } } // 出力 System.Console.WriteLine("{0}", iSum.ToString().Trim()); sw.Stop(); #if DEBUG Console.WriteLine(); Console.WriteLine("{0}", sw.Elapsed.ToString()); Console.WriteLine("続行するには何かキーを押してください..."); Console.ReadKey(); #endif } }
[["+", 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, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 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], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
194
21
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace D { class Program { static void Main(string[] args) { string line = Console.ReadLine(); string[] strs = line.Split(' '); long A = long.Parse(strs[0]); long B = long.Parse(strs[1]); long N = long.Parse(strs[2]); if (N >= B) N = B - 1; long x1 = (long)(A / B); long x2 = (long)(A * N / B); Console.WriteLine(x1 > x2 ? x1 : x2); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace D { class Program { static void Main(string[] args) { string line = Console.ReadLine(); string[] strs = line.Split(' '); long A = long.Parse(strs[0]); long B = long.Parse(strs[1]); long N = long.Parse(strs[2]); if (N >= B) N = B - 1; long x = (long)(A * N / (double)B); Console.WriteLine(x); } } }
[["-", 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, 74, 0, 24], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 200, 0, 212, 0, 74, 51, 23, 0, 24], ["-", 0, 212, 0, 74, 51, 23, 0, 16, 31, 22], ["-", 0, 212, 0, 74, 51, 23, 0, 16, 17, 85], ["-", 0, 212, 0, 74, 51, 23, 0, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 74, 51, 23, 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, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 74, 51, 23, 0, 16, 12, 74, 0, 24], ["+", 0, 74, 51, 23, 0, 16, 12, 74, 39, 199], ["+", 0, 74, 51, 23, 0, 16, 12, 74, 0, 25], ["-", 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], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
159
25
using System; namespace ForATCODER { public class Program { public static void Main(string[] args) { int N = s2i(Console.ReadLine()); int sum = 0; for (int i = 1; i < N; i++) { if (i % 3 != 0 && i % 5 != 0) sum += i; } RESULT(sum); } static int s2i(String s) { return Convert.ToInt32(s); } static void RESULT(int res) { Console.WriteLine(res); } static void RESULT(String res) { Console.WriteLine(res); } static String[] ReadLineAll(int count) { String[] res = new String[count]; for (int i = 0; i < count; i++) { res[i] = Console.ReadLine(); } return res; } static int[] S2Iarray(String[] src) { int len = src.Length; int[] res = new int[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt32(src[i]); } return res; } } }
using System; namespace ForATCODER { public class Program { public static void Main(string[] args) { ulong N = (ulong)s2i(Console.ReadLine()); ulong sum = 0; for (ulong i = 1; i <= N; i++) { if (i % 3 != 0 && i % 5 != 0) sum += i; } Console.WriteLine(sum); } static int s2i(String s) { return Convert.ToInt32(s); } static void RESULT(int res) { Console.WriteLine(res); } static void RESULT(String res) { Console.WriteLine(res); } static String[] ReadLineAll(int count) { String[] res = new String[count]; for (int i = 0; i < count; i++) { res[i] = Console.ReadLine(); } return res; } static int[] S2Iarray(String[] src) { int len = src.Length; int[] res = new int[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt32(src[i]); } return res; } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 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
246
15
using System; using System.Collections; using System.Collections.Generic; using System.IO.Pipes; using System.Linq; using System.Numerics; using System.Security.Cryptography; using System.Text; using System.Threading; namespace ForATCODER { public class Program { public static void Main(string[] args) { // int N =s2i(Console.ReadLine()); long[] input = s2larray(Console.ReadLine().Split(' ')); long ret = input[1] - 1; if (input[2] < ret) ret = input[2]; RESULT(ret); } public static bool checka(int[] a, int m) { int back = 1; for (int i = 0; i < a.Length; i++) { if (a[i] >= 1 && a[i] <= m) { if (a[i] >= back) { back = a[i]; } else { return false; } } else { return false; } } return true; } public static ulong pow(int a, int b) { ulong res = 1; for (int i = 0; i < b; i++) { res *= (ulong)a; } return res; } static int s2i(String s) { return Convert.ToInt32(s); } static long s2l(String s) { return Convert.ToInt64(s); } static void RESULT(double res) { Console.WriteLine(res); } static void RESULT(long res) { Console.WriteLine(res); } static void RESULT(ulong res) { Console.WriteLine(res); } static void RESULT(int res) { Console.WriteLine(res); } static void RESULT(String res) { Console.WriteLine(res); } static String[] ReadLineAll(int count) { String[] res = new String[count]; for (int i = 0; i < count; i++) { res[i] = Console.ReadLine(); } return res; } static int[] s2iarray(String[] src) { int len = src.Length; int[] res = new int[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt32(src[i]); } return res; } static long[] s2larray(String[] src) { int len = src.Length; long[] res = new long[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt64(src[i]); } return res; } static ulong[] s2larray2(String[] src) { int len = src.Length; ulong[] res = new ulong[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToUInt64(src[i]); } return res; } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO.Pipes; using System.Linq; using System.Numerics; using System.Security.Cryptography; using System.Text; using System.Threading; namespace ForATCODER { public class Program { public static void Main(string[] args) { // int N =s2i(Console.ReadLine()); long[] input = s2larray(Console.ReadLine().Split(' ')); long ret = input[1] - 1; if (input[2] < ret) ret = input[2]; RESULT(((input[0] * ret) / input[1]) - input[0] * (ret / input[1])); } public static bool checka(int[] a, int m) { int back = 1; for (int i = 0; i < a.Length; i++) { if (a[i] >= 1 && a[i] <= m) { if (a[i] >= back) { back = a[i]; } else { return false; } } else { return false; } } return true; } public static ulong pow(int a, int b) { ulong res = 1; for (int i = 0; i < b; i++) { res *= (ulong)a; } return res; } static int s2i(String s) { return Convert.ToInt32(s); } static long s2l(String s) { return Convert.ToInt64(s); } static void RESULT(double res) { Console.WriteLine(res); } static void RESULT(long res) { Console.WriteLine(res); } static void RESULT(ulong res) { Console.WriteLine(res); } static void RESULT(int res) { Console.WriteLine(res); } static void RESULT(String res) { Console.WriteLine(res); } static String[] ReadLineAll(int count) { String[] res = new String[count]; for (int i = 0; i < count; i++) { res[i] = Console.ReadLine(); } return res; } static int[] s2iarray(String[] src) { int len = src.Length; int[] res = new int[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt32(src[i]); } return res; } static long[] s2larray(String[] src) { int len = src.Length; long[] res = new long[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt64(src[i]); } return res; } static ulong[] s2larray2(String[] src) { int len = src.Length; ulong[] res = new ulong[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToUInt64(src[i]); } return res; } } }
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 48], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 85], ["+", 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, 203], ["+", 31, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 16, 31, 204, 205, 22], ["+", 0, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 48], ["+", 0, 28, 0, 16, 12, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 85], ["+", 12, 16, 12, 23, 0, 16, 12, 204, 205, 22], ["+", 12, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 28, 0, 16, 12, 16, 12, 23, 0, 25]]
8
617
28
using System; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public static void Main(string[] args) { new B().test(); } } public class B { public void test() { // 普通の文字列取得 // 英語小文字のみ var input = CommonRead.ReadLong(); var notFizzBuzz = new List<long>(); for (long i = 1; i <= input; i++) { if (i % 3 == 0 | i % 5 == 0 | i % 15 == 0) notFizzBuzz.Add(i); } //出力 Console.WriteLine(notFizzBuzz.Sum()); } } static class CommonRead { public static string ReadStr() { return Console.ReadLine(); } public static string[] ReadStrA() { return ReadStr().Split(' '); } public static List<string> ReadStrL() { return ReadStrA().ToList(); } public static int ReadInt() { return Convert.ToInt32(ReadStr()); } public static int[] ReadIntA() { return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray(); } public static List<int> ReadIntL() { return ReadStrA().Select(s => Convert.ToInt32(s)).ToList(); } public static long ReadLong() { return Convert.ToInt64(ReadStr()); } public static long[] ReadLongA() { return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray(); } public static List<long> ReadLongL() { return ReadStrA().Select(s => Convert.ToInt64(s)).ToList(); } public static decimal ReadDecimal() { return Convert.ToDecimal(ReadStr()); } public static decimal[] ReadDecimalA() { return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray(); } public static List<decimal> ReadDecimalL() { return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList(); } public static double ReadDouble() { return Convert.ToDouble(ReadStr()); } public static double[] ReadDoubleA() { return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray(); } public static List<double> ReadDoubleL() { return ReadStrA().Select(s => Convert.ToDouble(s)).ToList(); } }
using System; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public static void Main(string[] args) { new B().test(); } } public class B { public void test() { // 普通の文字列取得 // 英語小文字のみ var input = CommonRead.ReadLong(); var notFizzBuzz = new List<long>(); for (long i = 0; i <= input; i++) { if (i % 3 == 0 | i % 5 == 0) continue; notFizzBuzz.Add(i); } //出力 Console.WriteLine(notFizzBuzz.Sum()); } } static class CommonRead { public static string ReadStr() { return Console.ReadLine(); } public static string[] ReadStrA() { return ReadStr().Split(' '); } public static List<string> ReadStrL() { return ReadStrA().ToList(); } public static int ReadInt() { return Convert.ToInt32(ReadStr()); } public static int[] ReadIntA() { return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray(); } public static List<int> ReadIntL() { return ReadStrA().Select(s => Convert.ToInt32(s)).ToList(); } public static long ReadLong() { return Convert.ToInt64(ReadStr()); } public static long[] ReadLongA() { return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray(); } public static List<long> ReadLongL() { return ReadStrA().Select(s => Convert.ToInt64(s)).ToList(); } public static decimal ReadDecimal() { return Convert.ToDecimal(ReadStr()); } public static decimal[] ReadDecimalA() { return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray(); } public static List<decimal> ReadDecimalL() { return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList(); } public static double ReadDouble() { return Convert.ToDouble(ReadStr()); } public static double[] ReadDoubleA() { return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray(); } public static List<double> ReadDoubleL() { return ReadStrA().Select(s => Convert.ToDouble(s)).ToList(); } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 60], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 139], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35]]
8
521
10
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 = (double)cin.nextLong(); var b = (double)cin.nextLong(); var n = cin.nextLong(); Console.WriteLine(Math.Floor((a * n) / b) - (a * Math.Floor(n / b))); } } class NBinarySearch { long ok; long ng; Func<long, bool> isOK; /// <param name="ok">必ず条件を満たすN</param> /// <param name="ng">必ず条件を満たさないN</param> /// <param name="isOK">midの判定</param> public NBinarySearch(long ok, long ng, Func<long, bool> isOK) { this.ok = ok; this.ng = ng; this.isOK = isOK; } public long OK() { long ok = this.ok; long ng = this.ng; while (Math.Abs(ok - ng) > 1) { long mid = (ok + ng) / 2; if (isOK(mid)) ok = mid; else ng = mid; } return ok; } public long NG() { long ok = this.ok; long ng = this.ng; while (Math.Abs(ok - ng) > 1) { long mid = (ok + ng) / 2; if (isOK(mid)) ok = mid; else ng = mid; } return ng; } } 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 int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } 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 long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] 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 = (double)cin.nextLong(); var b = (double)cin.nextLong(); var n = cin.nextLong(); var x = Math.Min(n, b - 1); Console.WriteLine(Math.Floor((a * x) / b) - (a * Math.Floor(x / b))); } } class NBinarySearch { long ok; long ng; Func<long, bool> isOK; /// <param name="ok">必ず条件を満たすN</param> /// <param name="ng">必ず条件を満たさないN</param> /// <param name="isOK">midの判定</param> public NBinarySearch(long ok, long ng, Func<long, bool> isOK) { this.ok = ok; this.ng = ng; this.isOK = isOK; } public long OK() { long ok = this.ok; long ng = this.ng; while (Math.Abs(ok - ng) > 1) { long mid = (ok + ng) / 2; if (isOK(mid)) ok = mid; else ng = mid; } return ok; } public long NG() { long ok = this.ok; long ng = this.ng; while (Math.Abs(ok - ng) > 1) { long mid = (ok + ng) / 2; if (isOK(mid)) ok = mid; else ng = mid; } return ng; } } 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 int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } 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 long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] s) => new Solver().Solve(); } }
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 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], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22]]
8
793
18
using System; using static System.Console; using static System.Math; using System.Linq; using System.Collections.Generic; namespace Main { class Program { static void Main(string[] args) { ulong N = ulong.Parse(ReadLine()); ulong sum = 0; for (ulong i = 0; i < N; i++) { if (i % 3 != 0 && i % 5 != .0) { sum += i; } } WriteLine(sum); } } }
using System; using static System.Console; using static System.Math; using System.Linq; using System.Collections.Generic; namespace Main { class Program { static void Main(string[] args) { ulong N = ulong.Parse(ReadLine()); ulong sum = 0; for (ulong i = 0; i < N; i++) { if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0) { sum += i + 1; } } WriteLine(sum); } } }
[["+", 15, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 15, 16, 31, 16, 31, 16, 31, 23, 0, 25], ["+", 15, 16, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 15, 16, 12, 16, 31, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 250], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
8
104
12
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); long sum = 0; for (int i = 0; i < n; i++) { sum += i % 3 == 0 ? 0 : i % 5 == 0 ? 0 : i; } Console.WriteLine(sum); } } }
using System; namespace AtCoder { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); long sum = 0; for (int i = 1; i <= n; i++) { sum += i % 3 == 0 ? 0 : i % 5 == 0 ? 0 : i; } Console.WriteLine(sum); } } }
[["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
92
16
using System; namespace _165d { class Program { static void Main(string[] args) { float[] ABN = Array.ConvertAll(Console.ReadLine().Split(), float.Parse); // int[] NMQ = Array.ConvertAll(Console.ReadLine().Split(),int.Parse); // long K = long.Parse(Console.ReadLine()); // int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse); // string S = Console.ReadLine(); // int A = int.Parse(Console.ReadLine()); // int b = int.Parse(Console.ReadLine()); // string A = Console.ReadLine(); // string B = Console.ReadLine(); // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), // Console.ReadLine() }).Select(int.Parse); int[] abc = // Array.ConvertAll(Console.ReadLine().Split(),int.Parse); var X = // Console.ReadLine(); int[,] abcd = new int[NMQ[2],4]; int[] A = new // int[NMQ[0]]; int[] A_num = new int[NMQ[0]]; for(int i = 0; // i<A_num.Length;i++){ // A_num[i] = 0; // } // for(int i = 0; i<NMQ[2];i++){ // var read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse); // for(int j = 0; j< 4;j++){ // abcd[i,j] = read[j]; // } // } // NがBより大の時、かつABN[1]-1が0ではない時 // float x = (ABN[2]>ABN[1])?ABN[1]-1:ABN[2]; float x = ABN[2]; // Nをいれる if (ABN[2] >= ABN[1] - 1) { x = ABN[1] - 1; } int res = (int)((int)(ABN[0] * x / ABN[1]) - ABN[0] * (int)(x / ABN[1])); Console.WriteLine(res); } } }
using System; namespace _165d { class Program { static void Main(string[] args) { long[] ABN = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); // int[] NMQ = Array.ConvertAll(Console.ReadLine().Split(),int.Parse); // long K = long.Parse(Console.ReadLine()); // int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse); // string S = Console.ReadLine(); // int A = int.Parse(Console.ReadLine()); // int b = int.Parse(Console.ReadLine()); // string A = Console.ReadLine(); // string B = Console.ReadLine(); // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), // Console.ReadLine() }).Select(int.Parse); int[] abc = // Array.ConvertAll(Console.ReadLine().Split(),int.Parse); var X = // Console.ReadLine(); int[,] abcd = new int[NMQ[2],4]; int[] A = new // int[NMQ[0]]; int[] A_num = new int[NMQ[0]]; for(int i = 0; // i<A_num.Length;i++){ // A_num[i] = 0; // } // for(int i = 0; i<NMQ[2];i++){ // var read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse); // for(int j = 0; j< 4;j++){ // abcd[i,j] = read[j]; // } // } // NがBより大の時、かつABN[1]-1が0ではない時 // float x = (ABN[2]>ABN[1])?ABN[1]-1:ABN[2]; long x = ABN[2]; // Nをいれる if (ABN[2] >= ABN[1] - 1) { x = ABN[1] - 1; } long res = ABN[0] * x / ABN[1] - ABN[0] * (x / ABN[1]); Console.WriteLine(res); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 200, 0, 212, 0, 74, 51, 23, 0, 24], ["-", 0, 74, 51, 23, 0, 16, 31, 74, 0, 24], ["-", 0, 74, 51, 23, 0, 16, 31, 74, 39, 199], ["-", 0, 74, 51, 23, 0, 16, 31, 74, 0, 25], ["-", 51, 23, 0, 16, 31, 74, 51, 23, 0, 24], ["-", 51, 23, 0, 16, 31, 74, 51, 23, 0, 25], ["-", 51, 23, 0, 16, 12, 16, 12, 74, 0, 24], ["-", 51, 23, 0, 16, 12, 16, 12, 74, 39, 199], ["-", 51, 23, 0, 16, 12, 16, 12, 74, 0, 25], ["-", 0, 16, 12, 16, 12, 74, 51, 23, 0, 25]]
8
153
21
using System; using System.Collections.Generic; using System.Windows; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { public class Program { static void Main(string[] args) { var r = ReadSplit(); var a = r[0].Double(); var b = r[1].Double(); var n = r[2].Double(); double ans = 0; if (b != 1) { ans = Math.Floor(a * n / b); } WriteRead(ans); } public class Permutation { public IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items) { return _GetPermutations<T>(new List<T>(), items.ToList()); } private IEnumerable<T[]> _GetPermutations<T>(IEnumerable<T> perm, IEnumerable<T> items) { if (items.Count() == 0) { yield return perm.ToArray(); } else { foreach (var item in items) { var result = _GetPermutations<T>(perm.Concat(new T[] { item }), items.Where(x => x.Equals(item) == false)); foreach (var xs in result) yield return xs.ToArray(); } } } } 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 r = ReadSplit(); var a = r[0].Double(); var b = r[1].Double(); var n = r[2].Double(); var ans = 0D; if (b - 1 > n) { ans = Math.Floor(a * n / b); } else { ans = Math.Floor(a * (b - 1) / b); } WriteRead(ans); } public class Permutation { public IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items) { return _GetPermutations<T>(new List<T>(), items.ToList()); } private IEnumerable<T[]> _GetPermutations<T>(IEnumerable<T> perm, IEnumerable<T> items) { if (items.Count() == 0) { yield return perm.ToArray(); } else { foreach (var item in items) { var result = _GetPermutations<T>(perm.Concat(new T[] { item }), items.Where(x => x.Equals(item) == false)); foreach (var xs in result) yield return xs.ToArray(); } } } } 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, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 250], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 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], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["+", 0, 28, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 16, 12, 23, 0, 25]]
8
600
28
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; class Program { public static void Main() { var a = Read.Long(); var b = Read.Long(); var n = Read.Long(); long x = Min(b - 1, n); long result = (long)((a * x) / (double)b) - a * (long)(x / (double)b); WriteLine($"{result}"); } } static class Read { static Queue<string> queue = new Queue<string>(); static void Enqueue() { ReadLine().Split(' ').ToList().Select(a => { queue.Enqueue(a); return true; }); } public static int Int() { if (queue.Count == 0) Enqueue(); return int.Parse(queue.Dequeue()); } public static long Long() { if (queue.Count == 0) Enqueue(); return long.Parse(queue.Dequeue()); } public static double Double() { if (queue.Count == 0) Enqueue(); return double.Parse(queue.Dequeue()); } public static string String() { if (queue.Count == 0) Enqueue(); return queue.Dequeue(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; class Program { public static void Main() { var a = Read.Long(); var b = Read.Long(); var n = Read.Long(); long x = Min(b - 1, n); long result = (long)((a * x) / (double)b) - a * (long)(x / (double)b); WriteLine($"{result}"); } } static class Read { static Queue<string> queue = new Queue<string>(); static void Enqueue() { ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a)); } public static int Int() { if (queue.Count == 0) Enqueue(); return int.Parse(queue.Dequeue()); } public static long Long() { if (queue.Count == 0) Enqueue(); return long.Parse(queue.Dequeue()); } public static double Double() { if (queue.Count == 0) Enqueue(); return double.Parse(queue.Dequeue()); } public static string String() { if (queue.Count == 0) Enqueue(); return queue.Dequeue(); } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 196, 0, 45], ["-", 0, 28, 0, 218, 8, 196, 0, 1, 0, 35], ["-", 0, 28, 0, 218, 8, 196, 0, 37, 0, 38], ["-", 0, 218, 8, 196, 0, 37, 0, 211, 0, 146], ["-", 0, 28, 0, 218, 8, 196, 0, 37, 0, 35], ["-", 3, 4, 0, 28, 0, 218, 8, 196, 0, 46]]
8
308
8
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; namespace AtCoder { class Program { static void Main() { var raw = ReadLine().Split().Select(long.Parse).ToArray(); var A = raw[0]; var B = raw[1]; var N = raw[2]; Func<long, long> func = x => (long)(A * x / B) - A * (long)(x / B); WriteLine(Math.Max(func(0), func(N))); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; namespace AtCoder { class Program { static void Main() { var raw = ReadLine().Split().Select(long.Parse).ToArray(); var A = raw[0]; var B = raw[1]; var N = raw[2]; Func<long, long> func = x => (long)(A * x / B) - A * (long)(x / B); WriteLine(func(Math.Min(B - 1, N))); } } }
[["+", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 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, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
142
13
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace D { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var abn = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); Func<long, long> f = x => (long)(Math.Floor((abn[0] * x) / (double)abn[1]) - abn[0] * Math.Floor(x / (double)abn[1])); Console.WriteLine(f(abn[1] < abn[2] ? abn[1] - 1 : abn[2])); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace D { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var abn = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); Func<long, long> f = x => (long)(Math.Floor((abn[0] * x) / (double)abn[1]) - abn[0] * Math.Floor(x / (double)abn[1])); Console.WriteLine(f(Math.Min(abn[1] - 1, abn[2]))); } } }
[["-", 0, 28, 0, 41, 15, 16, 31, 204, 205, 22], ["-", 0, 41, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 41, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 18], ["-", 0, 28, 0, 41, 15, 16, 12, 204, 205, 22], ["-", 0, 41, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 41, 15, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
208
17
using System; using System.Collections.Generic; using System.Text; using System.Linq; namespace Practice { class Program { static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } private const int MOD = 1000000007; private const int MAX = 1000001; static long[] fac = new long[MAX]; static long[] finv = new long[MAX]; static long[] inv = new long[MAX]; private struct P { public int a; public int b; public int c; public int d; } private static int[] A; private static List<P> p; private static long score; static void Solve() { var a = Input.NextLong(); var b = Input.NextLong(); var n = Input.NextLong(); long x = n / b * b; if (x == 0) { x = n; } long ans = a * x / b - a * (x / b); Console.WriteLine(ans); } #region よく使う便利関数 private static Dictionary<long, int> Factorize(long n) { var dic = new Dictionary<long, int>(); for (long i = 2; i * i <= n; ++i) { while (n % i == 0) { if (!dic.ContainsKey(i)) { dic.Add(i, 0); } dic[i]++; n /= i; } } if (n != 1) { dic.Add(n, 1); } return dic; } static void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 static long COM(long n, long k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } static class Input { static char[] separator = { ' ' }; public static bool IsEof { get; set; } static Queue<string> q { get; set; } static Input() { IsEof = false; q = new Queue<string>(); } /// <summary> /// 入力予約 /// </summary> /// <param name="items"></param> public static void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } /// <summary> /// 入力予約 /// </summary> /// <param name="s"></param> /// <returns></returns> public static bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } return true; } /// <summary> /// 内部queueに入力からの値をsplitして格納する /// </summary> /// <returns></returns> static bool read() { var s = Console.ReadLine(); if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } if (!q.Any()) return read(); return true; } /// <summary> /// 次のstringを一つ読み込む /// </summary> /// <returns></returns> public static string Next() { if (!q.Any()) { if (!read()) { IsEof = true; return ""; } } return q.Dequeue(); } public static int NextInt() => int.Parse(Next()); public static long NextLong() => long.Parse(Next()); public static double NextDouble() => double.Parse(Next()); public static List<string> Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList(); public static List<int> NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList(); public static List<long> NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList(); public static List<double> NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList(); public static List<string> NextLine() => Console.ReadLine() .Trim() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .ToList(); public static List<int> NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList(); public static List<long> NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList(); public static List<double> NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList(); } private static bool isPrime(long x) { if (x == 2) { return true; } if (x < 2 || x % 2 == 0) { return false; } long i = 3; while (i * i <= x) { if (x % i == 0) { return false; } i = i + 2; } return true; } private static long lcm(long x, long y) { return x / gcd(x, y) * y; } private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; } private static long pow(long x, long n) { if (n == 0) { return 1; } long res = pow(x * x % MOD, n / 2); if (n % 2 == 1) { res = res * x % MOD; } return res; } private static void Swap<T>(ref T x, ref T y) { T t = x; x = y; y = t; } /// <summary> /// 指定した値以上の先頭のインデクスを返す /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値以上の先頭のインデクス</returns> public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) < 0) low = mid + 1; else high = mid; } return low; } //引数省略のオーバーロード public static int LowerBound<T>(IReadOnlyList<T> arr, T value) where T : IComparable { return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default); } /// <summary> /// 指定した値より大きい先頭のインデクスを返す /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値より大きい先頭のインデクス</returns> public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) <= 0) low = mid + 1; else high = mid; } return low; } //引数省略のオーバーロード public static int UpperBound<T>(IReadOnlyList<T> arr, T value) { return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default); } #endregion } public class DisjointSet { private int[] rank; private int[] p; private int[] size; public DisjointSet(int n) { rank = new int[n]; p = new int[n]; size = new int[n]; for (int i = 0; i < n; ++i) { MakeSet(i); } } public void MakeSet(int x) { p[x] = x; rank[x] = 0; size[x] = 1; } public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); } public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); } public void Link(int x, int y) { if (rank[x] > rank[y]) { p[y] = x; size[x] += size[y]; size[y] = 0; } else { p[x] = y; size[y] += size[x]; size[x] = 0; if (rank[x] == rank[y]) { rank[y]++; } } } public int FindSet(int x) { if (x != p[x]) { p[x] = FindSet(p[x]); } return p[x]; } public int Size(int x) { int root = FindSet(x); return size[root]; } } public class PriorityQueue<T> where T : IComparable { private IComparer<T> _comparer = null; private int _type = 0; private T[] _heap; private int _sz = 0; private int _count = 0; /// <summary> /// Priority Queue with custom comparer /// </summary> public PriorityQueue(int maxSize, IComparer<T> comparer) { _heap = new T[maxSize]; _comparer = comparer; } /// <summary> /// Priority queue /// </summary> /// <param name="maxSize">max size</param> /// <param name="type">0: asc, 1:desc</param> public PriorityQueue(int maxSize, int type = 0) { _heap = new T[maxSize]; _type = type; } private int Compare(T x, T y) { if (_comparer != null) return _comparer.Compare(x, y); return _type == 0 ? x.CompareTo(y) : y.CompareTo(x); } public void Push(T x) { _count++; // node number var i = _sz++; while (i > 0) { // parent node number var p = (i - 1) / 2; if (Compare(_heap[p], x) <= 0) break; _heap[i] = _heap[p]; i = p; } _heap[i] = x; } public T Pop() { _count--; T ret = _heap[0]; T x = _heap[--_sz]; int i = 0; while (i * 2 + 1 < _sz) { // children int a = i * 2 + 1; int b = i * 2 + 2; if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b; if (Compare(_heap[a], x) >= 0) break; _heap[i] = _heap[a]; i = a; } _heap[i] = x; return ret; } public int Count() { return _count; } public T Peek() { return _heap[0]; } public bool Contains(T x) { for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true; return false; } public void Clear() { while (this.Count() > 0) this.Pop(); } public IEnumerator<T> GetEnumerator() { var ret = new List<T>(); while (this.Count() > 0) { ret.Add(this.Pop()); } foreach (var r in ret) { this.Push(r); yield return r; } } public T[] ToArray() { T[] array = new T[_sz]; int i = 0; foreach (var r in this) { array[i++] = r; } return array; } } }
using System; using System.Collections.Generic; using System.Text; using System.Linq; namespace Practice { class Program { static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } private const int MOD = 1000000007; private const int MAX = 1000001; static long[] fac = new long[MAX]; static long[] finv = new long[MAX]; static long[] inv = new long[MAX]; private struct P { public int a; public int b; public int c; public int d; } private static int[] A; private static List<P> p; private static long score; static void Solve() { var a = Input.NextLong(); var b = Input.NextLong(); var n = Input.NextLong(); long x = b - 1; if (x > n) { x = n; } long ans = a * x / b - a * (x / b); Console.WriteLine(ans); } #region よく使う便利関数 private static Dictionary<long, int> Factorize(long n) { var dic = new Dictionary<long, int>(); for (long i = 2; i * i <= n; ++i) { while (n % i == 0) { if (!dic.ContainsKey(i)) { dic.Add(i, 0); } dic[i]++; n /= i; } } if (n != 1) { dic.Add(n, 1); } return dic; } static void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 static long COM(long n, long k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } static class Input { static char[] separator = { ' ' }; public static bool IsEof { get; set; } static Queue<string> q { get; set; } static Input() { IsEof = false; q = new Queue<string>(); } /// <summary> /// 入力予約 /// </summary> /// <param name="items"></param> public static void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } /// <summary> /// 入力予約 /// </summary> /// <param name="s"></param> /// <returns></returns> public static bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } return true; } /// <summary> /// 内部queueに入力からの値をsplitして格納する /// </summary> /// <returns></returns> static bool read() { var s = Console.ReadLine(); if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } if (!q.Any()) return read(); return true; } /// <summary> /// 次のstringを一つ読み込む /// </summary> /// <returns></returns> public static string Next() { if (!q.Any()) { if (!read()) { IsEof = true; return ""; } } return q.Dequeue(); } public static int NextInt() => int.Parse(Next()); public static long NextLong() => long.Parse(Next()); public static double NextDouble() => double.Parse(Next()); public static List<string> Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList(); public static List<int> NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList(); public static List<long> NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList(); public static List<double> NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList(); public static List<string> NextLine() => Console.ReadLine() .Trim() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .ToList(); public static List<int> NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList(); public static List<long> NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList(); public static List<double> NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList(); } private static bool isPrime(long x) { if (x == 2) { return true; } if (x < 2 || x % 2 == 0) { return false; } long i = 3; while (i * i <= x) { if (x % i == 0) { return false; } i = i + 2; } return true; } private static long lcm(long x, long y) { return x / gcd(x, y) * y; } private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; } private static long pow(long x, long n) { if (n == 0) { return 1; } long res = pow(x * x % MOD, n / 2); if (n % 2 == 1) { res = res * x % MOD; } return res; } private static void Swap<T>(ref T x, ref T y) { T t = x; x = y; y = t; } /// <summary> /// 指定した値以上の先頭のインデクスを返す /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値以上の先頭のインデクス</returns> public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) < 0) low = mid + 1; else high = mid; } return low; } //引数省略のオーバーロード public static int LowerBound<T>(IReadOnlyList<T> arr, T value) where T : IComparable { return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default); } /// <summary> /// 指定した値より大きい先頭のインデクスを返す /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値より大きい先頭のインデクス</returns> public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) <= 0) low = mid + 1; else high = mid; } return low; } //引数省略のオーバーロード public static int UpperBound<T>(IReadOnlyList<T> arr, T value) { return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default); } #endregion } public class DisjointSet { private int[] rank; private int[] p; private int[] size; public DisjointSet(int n) { rank = new int[n]; p = new int[n]; size = new int[n]; for (int i = 0; i < n; ++i) { MakeSet(i); } } public void MakeSet(int x) { p[x] = x; rank[x] = 0; size[x] = 1; } public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); } public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); } public void Link(int x, int y) { if (rank[x] > rank[y]) { p[y] = x; size[x] += size[y]; size[y] = 0; } else { p[x] = y; size[y] += size[x]; size[x] = 0; if (rank[x] == rank[y]) { rank[y]++; } } } public int FindSet(int x) { if (x != p[x]) { p[x] = FindSet(p[x]); } return p[x]; } public int Size(int x) { int root = FindSet(x); return size[root]; } } public class PriorityQueue<T> where T : IComparable { private IComparer<T> _comparer = null; private int _type = 0; private T[] _heap; private int _sz = 0; private int _count = 0; /// <summary> /// Priority Queue with custom comparer /// </summary> public PriorityQueue(int maxSize, IComparer<T> comparer) { _heap = new T[maxSize]; _comparer = comparer; } /// <summary> /// Priority queue /// </summary> /// <param name="maxSize">max size</param> /// <param name="type">0: asc, 1:desc</param> public PriorityQueue(int maxSize, int type = 0) { _heap = new T[maxSize]; _type = type; } private int Compare(T x, T y) { if (_comparer != null) return _comparer.Compare(x, y); return _type == 0 ? x.CompareTo(y) : y.CompareTo(x); } public void Push(T x) { _count++; // node number var i = _sz++; while (i > 0) { // parent node number var p = (i - 1) / 2; if (Compare(_heap[p], x) <= 0) break; _heap[i] = _heap[p]; i = p; } _heap[i] = x; } public T Pop() { _count--; T ret = _heap[0]; T x = _heap[--_sz]; int i = 0; while (i * 2 + 1 < _sz) { // children int a = i * 2 + 1; int b = i * 2 + 2; if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b; if (Compare(_heap[a], x) >= 0) break; _heap[i] = _heap[a]; i = a; } _heap[i] = x; return ret; } public int Count() { return _count; } public T Peek() { return _heap[0]; } public bool Contains(T x) { for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true; return false; } public void Clear() { while (this.Count() > 0) this.Pop(); } public IEnumerator<T> GetEnumerator() { var ret = new List<T>(); while (this.Count() > 0) { ret.Add(this.Pop()); } foreach (var r in ret) { this.Push(r); yield return r; } } public T[] ToArray() { T[] array = new T[_sz]; int i = 0; foreach (var r in this) { array[i++] = r; } return array; } } }
[["-", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
8
2,487
10
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; namespace AtCoder { public class Program { static void Main() { var cin = new Scanner(); long a = cin.Long(); long b = cin.Long(); long n = cin.Long(); var bp = GetPrimeFactors(b); var ap = GetPrimeFactors(a); foreach (var akey in ap.Keys) { if (bp.ContainsKey(akey)) { bp[akey] = Math.Max(bp[akey] - ap[akey], 0); } } long m = 1; foreach (var key in bp.Keys) { if (bp[key] > 0) { for (int j = 0; j < bp[key]; j++) { m *= key; } } } if (m <= n) { if (m % b == 0) { if (m > 1) { m--; } } } else { m = n; if (m % b == 0) { if (m > 1) { m--; } } } long ans = (a * m / b) - a * (m / b); Console.WriteLine(ans); } public static Dictionary<long, long> GetPrimeFactors(long value) { var factors = new Dictionary<long, long>(); for (long i = 2; i * i <= value; ++i) { while (value % i == 0) { if (factors.ContainsKey(i) == false) { factors[i] = 1; } else { factors[i] += 1; } value /= i; } } if (value != 1) { factors[value] = 1; } return factors; } } public class HashMap<TKey, TValue> : Dictionary<TKey, TValue> { private readonly Func<TKey, TValue> initialzier_; public HashMap(Func<TKey, TValue> initialzier) : base() { initialzier_ = initialzier; } public HashMap(Func<TKey, TValue> initialzier, int capacity) : base(capacity) { initialzier_ = initialzier; } new public TValue this[TKey key] { get { if (ContainsKey(key) == false) { base[key] = initialzier_(key); } return base[key]; } set { base[key] = value; } } } public static class Helper { public static void UpdateMin<T>(ref T target, T value) where T : IComparable<T> => target = target.CompareTo(value) > 0 ? value : target; public static void UpdateMin<T>(ref T target, T value, Action<T> onUpdated) where T : IComparable<T> { if (target.CompareTo(value) > 0) { target = value; onUpdated(value); } } public static void UpdateMax<T>(ref T target, T value) where T : IComparable<T> => target = target.CompareTo(value) < 0 ? value : target; public static void UpdateMax<T>(ref T target, T value, Action<T> onUpdated) where T : IComparable<T> { if (target.CompareTo(value) < 0) { target = value; onUpdated(value); } } public static T[] Array<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToArray(); public static List<T> List<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToList(); public static T[,] Array2<T>(int n, int m, T init) { var array = new T[n, m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { array[i, j] = init; } } return array; } public static T[,] Array2<T>(int n, int m, Func<int, int, T> initializer) { var array = new T[n, m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { array[i, j] = initializer(i, j); } } return array; } public static T[,,] Array3<T>(int n1, int n2, int n3, T init) { var array = new T[n1, n2, n3]; for (int i1 = 0; i1 < n1; i1++) { for (int i2 = 0; i2 < n2; i2++) { for (int i3 = 0; i3 < n3; i3++) { array[i1, i2, i3] = init; } } } return array; } private static readonly int[] delta4_ = { 1, 0, -1, 0, 1 }; public static void DoAt4(int i, int j, int imax, int jmax, Action<int, int> action) { for (int n = 0; n < 4; n++) { int ii = i + delta4_[n]; int jj = j + delta4_[n + 1]; if ((uint)ii < (uint)imax && (uint)jj < (uint)jmax) { action(ii, jj); } } } } public class Scanner { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; public Scanner(string file = "") { if (string.IsNullOrWhiteSpace(file)) { reader_ = Console.ReadLine; } else { filePath_ = file; var fs = new StreamReader(file); reader_ = fs.ReadLine; } buf_ = new string[0]; index_ = 0; } public string Next() { if (index_ < buf_.Length) { return buf_[index_++]; } string st = reader_(); while (st == "") { st = reader_(); } buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries); if (buf_.Length == 0) { return Next(); } index_ = 0; return buf_[index_++]; } public int Int() => int.Parse(Next()); public long Long() => long.Parse(Next()); public double Double() => double.Parse(Next()); public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = Int() + add; } return Array; } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = Long() + add; } return Array; } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = Double() + add; } return Array; } public void Save(string text) { if (string.IsNullOrWhiteSpace(filePath_)) { return; } File.WriteAllText(filePath_ + "_output.txt", text); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; namespace AtCoder { public class Program { static void Main() { var cin = new Scanner(); long a = cin.Long(); long b = cin.Long(); long n = cin.Long(); var bp = GetPrimeFactors(b); var ap = GetPrimeFactors(a); foreach (var akey in ap.Keys) { if (bp.ContainsKey(akey)) { bp[akey] = Math.Max(bp[akey] - ap[akey], 0); } } long m = 1; foreach (var key in bp.Keys) { if (bp[key] > 0) { for (int j = 0; j < bp[key]; j++) { m *= key; } } } if (m <= n) { if (m % b == 0) { if (m > 1) { m--; } } } else { m = n; if (m % b == 0) { if (m > 1) { m--; } } } long ans = (a * m / b) - a * (m / b); m = Math.Min(n, b - 1); ans = Math.Max( ans, (a * m / b) - a * (m / b)); Console.WriteLine(ans); } public static Dictionary<long, long> GetPrimeFactors(long value) { var factors = new Dictionary<long, long>(); for (long i = 2; i * i <= value; ++i) { while (value % i == 0) { if (factors.ContainsKey(i) == false) { factors[i] = 1; } else { factors[i] += 1; } value /= i; } } if (value != 1) { factors[value] = 1; } return factors; } } public class HashMap<TKey, TValue> : Dictionary<TKey, TValue> { private readonly Func<TKey, TValue> initialzier_; public HashMap(Func<TKey, TValue> initialzier) : base() { initialzier_ = initialzier; } public HashMap(Func<TKey, TValue> initialzier, int capacity) : base(capacity) { initialzier_ = initialzier; } new public TValue this[TKey key] { get { if (ContainsKey(key) == false) { base[key] = initialzier_(key); } return base[key]; } set { base[key] = value; } } } public static class Helper { public static void UpdateMin<T>(ref T target, T value) where T : IComparable<T> => target = target.CompareTo(value) > 0 ? value : target; public static void UpdateMin<T>(ref T target, T value, Action<T> onUpdated) where T : IComparable<T> { if (target.CompareTo(value) > 0) { target = value; onUpdated(value); } } public static void UpdateMax<T>(ref T target, T value) where T : IComparable<T> => target = target.CompareTo(value) < 0 ? value : target; public static void UpdateMax<T>(ref T target, T value, Action<T> onUpdated) where T : IComparable<T> { if (target.CompareTo(value) < 0) { target = value; onUpdated(value); } } public static T[] Array<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToArray(); public static List<T> List<T>(int n, Func<int, T> init) => Enumerable.Range(0, n).Select(x => init(x)).ToList(); public static T[,] Array2<T>(int n, int m, T init) { var array = new T[n, m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { array[i, j] = init; } } return array; } public static T[,] Array2<T>(int n, int m, Func<int, int, T> initializer) { var array = new T[n, m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { array[i, j] = initializer(i, j); } } return array; } public static T[,,] Array3<T>(int n1, int n2, int n3, T init) { var array = new T[n1, n2, n3]; for (int i1 = 0; i1 < n1; i1++) { for (int i2 = 0; i2 < n2; i2++) { for (int i3 = 0; i3 < n3; i3++) { array[i1, i2, i3] = init; } } } return array; } private static readonly int[] delta4_ = { 1, 0, -1, 0, 1 }; public static void DoAt4(int i, int j, int imax, int jmax, Action<int, int> action) { for (int n = 0; n < 4; n++) { int ii = i + delta4_[n]; int jj = j + delta4_[n + 1]; if ((uint)ii < (uint)imax && (uint)jj < (uint)jmax) { action(ii, jj); } } } } public class Scanner { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private readonly Func<string> reader_; private string[] buf_; private int index_; public Scanner(string file = "") { if (string.IsNullOrWhiteSpace(file)) { reader_ = Console.ReadLine; } else { filePath_ = file; var fs = new StreamReader(file); reader_ = fs.ReadLine; } buf_ = new string[0]; index_ = 0; } public string Next() { if (index_ < buf_.Length) { return buf_[index_++]; } string st = reader_(); while (st == "") { st = reader_(); } buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries); if (buf_.Length == 0) { return Next(); } index_ = 0; return buf_[index_++]; } public int Int() => int.Parse(Next()); public long Long() => long.Parse(Next()); public double Double() => double.Parse(Next()); public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = Int() + add; } return Array; } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = Long() + add; } return Array; } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = Double() + add; } return Array; } public void Save(string text) { if (string.IsNullOrWhiteSpace(filePath_)) { return; } File.WriteAllText(filePath_ + "_output.txt", text); } } }
[["+", 0, 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], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 48], ["+", 0, 28, 0, 16, 12, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 85], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 16, 12, 23, 0, 25]]
8
1,616
38
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; public static class P { public static void Main() { var abn = Console.ReadLine().Split().Select(long.Parse).ToArray(); var a = abn[0]; var b = abn[1]; var n = abn[2]; Console.WriteLine(a * n / b - a * (n / b)); } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; public static class P { public static void Main() { var abn = Console.ReadLine().Split().Select(long.Parse).ToArray(); var a = abn[0]; var b = abn[1]; var n = abn[2]; var x = Min(b - 1, n); // for (int x = 0; x <= n; x++) { Console.WriteLine(a * x / b - a * (x / b)); } } }
[["+", 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, 213, 63, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 196, 0, 45], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 196, 0, 46]]
8
141
18
using System; using System.Collections.Generic; using static Assistant.Input; using static Assistant.Debug; using System.Linq; using Assistant; using System.Text; namespace ABC165F { class Program { static long[] a; static List<int>[] edge; static int N; static void Main(string[] args) { N = RInt; a = RLongs; edge = new List<int> [N].Select(x => new List<int>()).ToArray(); for (int i = 0; i < N - 1; i++) { var u = RInt - 1; var v = RInt - 1; edge[u].Add(v); edge[v].Add(u); } ans = new int [N].Select(x => -1).ToArray(); ans[0] = 0; dp = new long [N].Select(x => long.MaxValue).ToArray(); dp[0] = a[0]; DFS(0); StringBuilder sb = new StringBuilder(); foreach (var a in ans) { sb.AppendLine((a + 1).ToString()); } Console.WriteLine(sb); } static int[] ans; static long[] dp; public static void DFS(int now) { foreach (var to in edge[now]) { if (ans[to] != -1) continue; int index = LowerBound(dp, a[to]); var temp = dp[index]; dp[index] = a[to]; ans[to] = index; DFS(to); dp[index] = temp; } } /// <summary> /// 二分探索 key以上の最低 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="v"></param> /// <returns></returns> public static int LowerBound<T>(T[] a, T v) { return LowerBound(a, v, Comparer<T>.Default); } public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp) { var l = 0; var r = a.Length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = cmp.Compare(a[mid], v); if (res == -1) l = mid + 1; else r = mid - 1; } return l; } } } namespace Assistant { static class Input { static List<string> line = new List<string>(); static int index = 0; static String RNext() { if (line.Count <= index) line.AddRange(Console.ReadLine().Split()); return line[index++]; } public static int RInt => int.Parse(RNext()); public static long RLong => long.Parse(RNext()); public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray(); public static string RString => RNext(); //以下未テスト public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray(); public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray(); public static char[][] RMap(int h) => Enumerable.Repeat(0, h) .Select(x => Console.ReadLine().ToCharArray()) .ToArray(); } static class Debug { static public void Draw2D(int[,] map, int mode = 1) { #if DEBUG int W = map.GetLength(0); int H = map.GetLength(1); int[,] map2 = new int[W + 1, H + 1]; for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (i == 0 && j == 0) map2[i, j] = 0; else if (i == 0) map2[i, j] = j - 1; else if (j == 0) map2[i, j] = i - 1; else map2[i, j] = map[i - 1, j - 1]; } } for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (mode == 0) Console.Write(map2[i, j] % 10); if (mode == 1) Console.Write(map2[i, j] + " "); } Console.WriteLine(); } Console.WriteLine(); #endif } public static void Draw1D(int[] array, int mode = 0) { #if DEBUG Console.WriteLine(string.Join(" ", array)); #endif } } }
using System; using System.Collections.Generic; using static Assistant.Input; using static Assistant.Debug; using System.Linq; using Assistant; using System.Text; namespace ABC165F { class Program { static int[] a; static List<int>[] edge; static int N; static void Main(string[] args) { N = RInt; a = RInts; edge = new List<int> [N].Select(x => new List<int>()).ToArray(); for (int i = 0; i < N - 1; i++) { var u = RInt - 1; var v = RInt - 1; edge[u].Add(v); edge[v].Add(u); } ans = new int [N].Select(x => -1).ToArray(); ans[0] = 1; dp = new int [N].Select(x => INF).ToArray(); dp[0] = a[0]; DFS(0); StringBuilder sb = new StringBuilder(); foreach (var a in ans) { sb.AppendLine(a.ToString()); } Console.WriteLine(sb); } static int INF = int.MaxValue; static int[] ans; static int[] dp; public static void DFS(int now) { foreach (var to in edge[now]) { if (ans[to] != -1) continue; int index = LowerBound(dp, a[to]); var temp = dp[index]; dp[index] = a[to]; ans[to] = LowerBound(dp, INF); DFS(to); dp[index] = temp; } } /// <summary> /// 二分探索 key以上の最低 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="v"></param> /// <returns></returns> public static int LowerBound<T>(T[] a, T v) { return LowerBound(a, v, Comparer<T>.Default); } public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp) { var l = 0; var r = a.Length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = cmp.Compare(a[mid], v); if (res == -1) l = mid + 1; else r = mid - 1; } return l; } } } namespace Assistant { static class Input { static List<string> line = new List<string>(); static int index = 0; static String RNext() { if (line.Count <= index) line.AddRange(Console.ReadLine().Split()); return line[index++]; } public static int RInt => int.Parse(RNext()); public static long RLong => long.Parse(RNext()); public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray(); public static string RString => RNext(); //以下未テスト public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray(); public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray(); public static char[][] RMap(int h) => Enumerable.Repeat(0, h) .Select(x => Console.ReadLine().ToCharArray()) .ToArray(); } static class Debug { static public void Draw2D(int[,] map, int mode = 1) { #if DEBUG int W = map.GetLength(0); int H = map.GetLength(1); int[,] map2 = new int[W + 1, H + 1]; for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (i == 0 && j == 0) map2[i, j] = 0; else if (i == 0) map2[i, j] = j - 1; else if (j == 0) map2[i, j] = i - 1; else map2[i, j] = map[i - 1, j - 1]; } } for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (mode == 0) Console.Write(map2[i, j] % 10); if (mode == 1) Console.Write(map2[i, j] + " "); } Console.WriteLine(); } Console.WriteLine(); #endif } public static void Draw1D(int[] array, int mode = 0) { #if DEBUG Console.WriteLine(string.Join(" ", array)); #endif } } }
[["-", 8, 201, 0, 124, 0, 198, 39, 224, 39, 199], ["+", 8, 201, 0, 124, 0, 198, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["-", 205, 213, 63, 214, 205, 227, 39, 224, 39, 199], ["+", 205, 213, 63, 214, 205, 227, 39, 224, 39, 199], ["-", 3, 4, 0, 28, 0, 218, 8, 214, 205, 199], ["-", 3, 4, 0, 28, 0, 218, 8, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["-", 0, 28, 0, 213, 63, 214, 205, 23, 0, 24], ["-", 0, 213, 63, 214, 205, 23, 0, 16, 17, 72], ["-", 0, 213, 63, 214, 205, 23, 0, 16, 12, 203], ["-", 0, 28, 0, 213, 63, 214, 205, 23, 0, 25], ["+", 8, 201, 0, 124, 0, 198, 0, 200, 141, 22], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 8, 201, 0, 235, 8, 201, 0, 124, 0, 35], ["+", 0, 235, 8, 201, 0, 124, 0, 251, 0, 115], ["-", 0, 210, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 213, 63, 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
1,078
33
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using nint = System.Int64; static class Program { const int mod = (int)1e9 + 7; const long inf = (long)1e18; static List<int>[] li; static bool[] b; static int[] h, ans; static Avl avl = new Avl(true, true); static void Main() { Sc sc = new Sc(); var s = sc.Ia; int n = s[0], m = n - 1; li = new List<int>[n + 1]; b = new bool[n + 1]; h = sc.Ia2; ans = new int[n]; for (int i = 1; i <= n; i++) { li[i] = new List<int>(); } for (int i = 0; i < m; i++) { var e = sc.Ia; li[e[0]].Add(e[1]); li[e[1]].Add(e[0]); } Fu(1, 0); Console.WriteLine("{0}", String.Join("\n", ans)); } static void Fu(int a, int g) { b[a] = true; long d = (long)h[a] * 1000000 + a; var e = avl.Rd(0, (long)(h[a]) * 1000000); var p = e == null ? 1 : (e.d + 1); g = Max((int)p, g); ans[a - 1] = g; avl.Ud(d, p); for (int i = 0; i < li[a].Count; i++) { if (!b[li[a][i]]) { Fu(li[a][i], g); } } avl.Dl(d); } } public class Avl { public class Nd { public int h = 1, c = 1; public readonly nint n; public long d; public Nd l, r, nx; public Nd(nint n, long d, Nd du) { this.n = n; this.d = d; nx = this; l = du; r = du; } public override string ToString() => "n:" + n.ToString() + " d:" + d.ToString(); } private static Func<long, long, bool> compare; private static Action<Nd> compare2; public Nd root, du; public int cnt = 0; public bool bb; public Avl(bool bo, bool bb) { if (bo) { du = new Nd(nint.MinValue, long.MinValue, du); compare = CoMax; compare2 = CoMax; } else { du = new Nd(nint.MinValue, long.MaxValue, du); compare = CoMin; compare2 = CoMin; } this.bb = bb; du.h = 0; du.c = 0; root = du; } private bool CoMax(long a, long b) { return a >= b; } private bool CoMin(long a, long b) { return a <= b; } private void CoMax(Nd t) { t.nx = t; if (t.nx.d < t.l.nx.d) { t.nx = t.l.nx; } if (t.nx.d < t.r.nx.d) { t.nx = t.r.nx; } } private void CoMin(Nd t) { t.nx = t; if (t.nx.d > t.l.nx.d) { t.nx = t.l.nx; } if (t.nx.d > t.r.nx.d) { t.nx = t.r.nx; } } public void Ud(nint n, long d) { if (root == du) { root = new Nd(n, d, du); cnt++; } else if (root.n == n) { if (bb) { root.d += d; } else { root.d = d; } compare2(root); } else if (Fu(root, n, d)) { if (Abs(root.l.h - root.r.h) > 1) { root = Rotate(root); } cnt++; } } private bool Fu(Nd t, nint n, long d) { bool bo = false; if (t.n > n) { if (t.l != du) { if (t.l.n == n) { if (bb) { t.l.d += d; } else { t.l.d = d; } compare2(t.l); } else if (bo = Fu(t.l, n, d)) { t.c++; if (Abs(t.l.l.h - t.l.r.h) > 1) { t.l = Rotate(t.l); } t.h = Max(t.l.h, t.r.h) + 1; } compare2(t); } else { t.l = new Nd(n, d, du); bo = true; t.c++; t.h = Max(t.l.h, t.r.h) + 1; t.nx = compare(t.nx.d, t.l.d) ? t.nx : t.l; } } else { if (t.r != du) { if (t.r.n == n) { if (bb) { t.r.d += d; } else { t.r.d = d; } compare2(t.r); } else if (bo = Fu(t.r, n, d)) { t.c++; if (Abs(t.r.l.h - t.r.r.h) > 1) { t.r = Rotate(t.r); } t.h = Max(t.l.h, t.r.h) + 1; } compare2(t); } else { t.r = new Nd(n, d, du); bo = true; t.c++; t.h = Max(t.l.h, t.r.h) + 1; t.nx = compare(t.nx.d, t.r.d) ? t.nx : t.r; } } return bo; } private Nd Rotate(Nd t) { Nd nd = du; if (t.l.h > t.r.h) { if (t.l.l.h > t.l.r.h) { nd = t.l; t.l = t.l.r; nd.r = t; Ft(t); } else { nd = t.l.r; t.l.r = nd.l; nd.l = t.l; Ft(t.l); t.l = nd.r; nd.r = t; Ft(t); } } else { if (t.r.l.h > t.r.r.h) { nd = t.r.l; t.r.l = nd.r; nd.r = t.r; Ft(t.r); t.r = nd.l; nd.l = t; Ft(t); } else { nd = t.r; t.r = t.r.l; nd.l = t; Ft(t); } } Ft(nd); return nd; } private void Ft(Nd t) { t.h = Max(t.l.h, t.r.h) + 1; t.c = t.l.c + t.r.c + 1; compare2(t); } public bool Dl(nint n) { if (cnt == 0) { return false; } Nd t = root; if (t.n == n) { root = Fd2(root); if (cnt == 0) { return true; } else if (Abs(root.l.h - root.r.h) > 1) { root = Rotate(root); } else { Ft(root); } return true; } bool bo = Fd1(root, n); if (Abs(root.l.h - root.r.h) > 1) { root = Rotate(root); } else { Ft(root); } return bo; } private bool Fd1(Nd t, nint n) { if (t.n > n) { if (t.l == du) { return false; } else if (t.l.n != n) { bool bo = Fd1(t.l, n); if (Abs(t.l.l.h - t.l.r.h) > 1) { t.l = Rotate(t.l); } else { Ft(t.l); } return bo; } else { t.l = Fd2(t.l); Ft(t); return true; } } else { if (t.r == du) { return false; } else if (t.r.n != n) { bool bo = Fd1(t.r, n); if (Abs(t.r.l.h - t.r.r.h) > 1) { t.r = Rotate(t.r); } else { Ft(t.r); } return bo; } else { t.r = Fd2(t.r); Ft(t); return true; } } } private Nd Fd2(Nd dn) { cnt--; if (dn.l == du) { return dn.r; } if (dn.r == du) { return dn.l; } Nd u = dn.l; if (u.r == du) { u.r = dn.r; Ft(u); return u; } u = Fd3(u, dn); if (Abs(dn.l.l.h - dn.l.r.h) > 1) { u.l = Rotate(dn.l); } else { Ft(dn.l); } Ft(u); return u; } private Nd Fd3(Nd u, Nd dn) { if (u.r.r != du) { Nd v = Fd3(u.r, dn); if (Abs(u.r.l.h - u.r.r.h) > 1) { u.r = Rotate(u.r); } else { Ft(u.r); } return v; } else { Nd v = u.r; u.r = u.r.l; v.l = dn.l; v.r = dn.r; return v; } } public Nd Hs(nint n) { Nd t = root; if (cnt == 0) { return null; } if (t.n == n) { return t; } Nd a = null; while (true) { if (t.n > n) { if (t.l == du) { break; } else if (t.l.n != n) { t = t.l; } else { a = t.l; break; } } else { if (t.r == du) { break; } else if (t.r.n != n) { t = t.r; } else { a = t.r; break; } } } return a; } public Nd Ra(int n) { return cnt >= n ? Fr(root, n) : null; } private Nd Fr(Nd t, int n) { if (t.l.c > n - 1) { return Fr(t.l, n); } if (t.l.c < n - 1) { return Fr(t.r, n - t.l.c - 1); } return t; } public Nd Lb(nint n) { return cnt != 0 ? Flb(root, n) : null; } private Nd Flb(Nd t, nint n) { if (t.n < n) { if (t.r == du) { return null; } return Flb(t.r, n); } if (t.n > n) { if (t.l == du) { return t; } Nd u = Flb(t.l, n); return u == null ? t : u; } return t; } public Nd Ub(nint n) { return cnt != 0 ? Fub(root, n) : null; } private Nd Fub(Nd t, nint n) { if (t.n > n) { if (t.l == du) { return null; } return Fub(t.l, n); } if (t.n < n) { if (t.r == du) { return t; } Nd u = Fub(t.r, n); return u == null ? t : u; } return t; } public int Rg(nint a, nint b) { return cnt != 0 ? Frg(root, a, b, false, false) : 0; } private int Frg(Nd t, nint a, nint b, bool l, bool r) { if (t.h == 0) { return 0; } if (l && r) { return t.c; } if (t.n < a) { return Frg(t.r, a, b, t.n >= a, r); } if (t.n > b) { return Frg(t.l, a, b, l, t.n <= b); } return Frg(t.l, a, b, l, t.n <= b) + Frg(t.r, a, b, t.n >= a, r) + 1; } public Nd Rd(nint a, nint b) { return cnt != 0 ? Frd(root, a, b, false, false) : null; } private Nd Frd(Nd t, nint a, nint b, bool l, bool r) { if (t.h == 0) { return du; } if (l && r) { return t.nx; } if (t.n < a) { return Frd(t.r, a, b, t.n >= a, r); } if (t.n > b) { return Frd(t.l, a, b, l, t.n <= b); } var e1 = Frd(t.l, a, b, l, t.n <= b); var e2 = Frd(t.r, a, b, t.n >= a, r); e1 = compare(e1.d, e2.d) ? e1 : e2; return compare(t.d, e1.d) ? t : e1; } public Nd Gl(nint a, nint b, long d) { return cnt == 0 ? null : Fgl(root, a, b, d); } private Nd Fgl(Nd t, nint a, nint b, long d) { Nd p = null; if (a <= t.n && t.n <= b && compare(t.d, d)) { p = t; } if (a <= t.n && compare(t.l.nx.d, d)) { var z = Fgl(t.l, a, b, d); if (z != null) { p = z; } } if (p == null && t.n <= b && compare(t.r.nx.d, d)) { p = Fgl(t.r, a, b, d); } return p; } public Nd Gr(nint a, nint b, long d) { return cnt == 0 ? null : Fgr(root, a, b, d); } private Nd Fgr(Nd t, nint a, nint b, long d) { Nd p = null; if (a <= t.n && t.n <= b && compare(t.d, d)) { p = t; } if (t.n <= b && compare(t.r.nx.d, d)) { var z = Fgr(t.r, a, b, d); if (z != null) { p = z; } } if (p == null && a <= t.n && compare(t.l.nx.d, d)) { p = Fgr(t.r, a, b, d); } return p; } public void En(Action<Nd> f) { if (cnt > 0) { Fen(root, f); } } private void Fen(Nd t, Action<Nd> f) { f(t); if (t.l != du) { Fen(t.l, f); } if (t.r != du) { Fen(t.r, f); } } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using nint = System.Int64; static class Program { const int mod = (int)1e9 + 7; const long inf = (long)1e18; static List<int>[] li; static bool[] b; static int[] h, ans; static Avl avl = new Avl(true, true); static void Main() { Sc sc = new Sc(); var s = sc.Ia; int n = s[0], m = n - 1; li = new List<int>[n + 1]; b = new bool[n + 1]; h = sc.Ia2; ans = new int[n]; for (int i = 1; i <= n; i++) { li[i] = new List<int>(); } for (int i = 0; i < m; i++) { var e = sc.Ia; li[e[0]].Add(e[1]); li[e[1]].Add(e[0]); } Fu(1, 1); Console.WriteLine("{0}", String.Join("\n", ans)); } static void Fu(int a, int g) { b[a] = true; long d = (long)h[a] * 1000000 + a; var e = avl.Rd(0, (long)(h[a]) * 1000000); var p = (e == null || e.d < 0) ? 1 : (e.d + 1); g = Max((int)p, g); ans[a - 1] = g; avl.Ud(d, p); for (int i = 0; i < li[a].Count; i++) { if (!b[li[a][i]]) { Fu(li[a][i], g); } } avl.Dl(d); } } public class Avl { public class Nd { public int h = 1, c = 1; public readonly nint n; public long d; public Nd l, r, nx; public Nd(nint n, long d, Nd du) { this.n = n; this.d = d; nx = this; l = du; r = du; } public override string ToString() => "n:" + n.ToString() + " d:" + d.ToString(); } private static Func<long, long, bool> compare; private static Action<Nd> compare2; public Nd root, du; public int cnt = 0; public bool bb; public Avl(bool bo, bool bb) { if (bo) { du = new Nd(nint.MinValue, long.MinValue, du); compare = CoMax; compare2 = CoMax; } else { du = new Nd(nint.MinValue, long.MaxValue, du); compare = CoMin; compare2 = CoMin; } this.bb = bb; du.h = 0; du.c = 0; root = du; } private bool CoMax(long a, long b) { return a >= b; } private bool CoMin(long a, long b) { return a <= b; } private void CoMax(Nd t) { t.nx = t; if (t.nx.d < t.l.nx.d) { t.nx = t.l.nx; } if (t.nx.d < t.r.nx.d) { t.nx = t.r.nx; } } private void CoMin(Nd t) { t.nx = t; if (t.nx.d > t.l.nx.d) { t.nx = t.l.nx; } if (t.nx.d > t.r.nx.d) { t.nx = t.r.nx; } } public void Ud(nint n, long d) { if (root == du) { root = new Nd(n, d, du); cnt++; } else if (root.n == n) { if (bb) { root.d += d; } else { root.d = d; } compare2(root); } else if (Fu(root, n, d)) { if (Abs(root.l.h - root.r.h) > 1) { root = Rotate(root); } cnt++; } } private bool Fu(Nd t, nint n, long d) { bool bo = false; if (t.n > n) { if (t.l != du) { if (t.l.n == n) { if (bb) { t.l.d += d; } else { t.l.d = d; } compare2(t.l); } else if (bo = Fu(t.l, n, d)) { t.c++; if (Abs(t.l.l.h - t.l.r.h) > 1) { t.l = Rotate(t.l); } t.h = Max(t.l.h, t.r.h) + 1; } compare2(t); } else { t.l = new Nd(n, d, du); bo = true; t.c++; t.h = Max(t.l.h, t.r.h) + 1; t.nx = compare(t.nx.d, t.l.d) ? t.nx : t.l; } } else { if (t.r != du) { if (t.r.n == n) { if (bb) { t.r.d += d; } else { t.r.d = d; } compare2(t.r); } else if (bo = Fu(t.r, n, d)) { t.c++; if (Abs(t.r.l.h - t.r.r.h) > 1) { t.r = Rotate(t.r); } t.h = Max(t.l.h, t.r.h) + 1; } compare2(t); } else { t.r = new Nd(n, d, du); bo = true; t.c++; t.h = Max(t.l.h, t.r.h) + 1; t.nx = compare(t.nx.d, t.r.d) ? t.nx : t.r; } } return bo; } private Nd Rotate(Nd t) { Nd nd = du; if (t.l.h > t.r.h) { if (t.l.l.h > t.l.r.h) { nd = t.l; t.l = t.l.r; nd.r = t; Ft(t); } else { nd = t.l.r; t.l.r = nd.l; nd.l = t.l; Ft(t.l); t.l = nd.r; nd.r = t; Ft(t); } } else { if (t.r.l.h > t.r.r.h) { nd = t.r.l; t.r.l = nd.r; nd.r = t.r; Ft(t.r); t.r = nd.l; nd.l = t; Ft(t); } else { nd = t.r; t.r = t.r.l; nd.l = t; Ft(t); } } Ft(nd); return nd; } private void Ft(Nd t) { t.h = Max(t.l.h, t.r.h) + 1; t.c = t.l.c + t.r.c + 1; compare2(t); } public bool Dl(nint n) { if (cnt == 0) { return false; } Nd t = root; if (t.n == n) { root = Fd2(root); if (cnt == 0) { return true; } else if (Abs(root.l.h - root.r.h) > 1) { root = Rotate(root); } else { Ft(root); } return true; } bool bo = Fd1(root, n); if (Abs(root.l.h - root.r.h) > 1) { root = Rotate(root); } else { Ft(root); } return bo; } private bool Fd1(Nd t, nint n) { if (t.n > n) { if (t.l == du) { return false; } else if (t.l.n != n) { bool bo = Fd1(t.l, n); if (Abs(t.l.l.h - t.l.r.h) > 1) { t.l = Rotate(t.l); } else { Ft(t.l); } return bo; } else { t.l = Fd2(t.l); Ft(t); return true; } } else { if (t.r == du) { return false; } else if (t.r.n != n) { bool bo = Fd1(t.r, n); if (Abs(t.r.l.h - t.r.r.h) > 1) { t.r = Rotate(t.r); } else { Ft(t.r); } return bo; } else { t.r = Fd2(t.r); Ft(t); return true; } } } private Nd Fd2(Nd dn) { cnt--; if (dn.l == du) { return dn.r; } if (dn.r == du) { return dn.l; } Nd u = dn.l; if (u.r == du) { u.r = dn.r; Ft(u); return u; } u = Fd3(u, dn); if (Abs(dn.l.l.h - dn.l.r.h) > 1) { u.l = Rotate(dn.l); } else { Ft(dn.l); } Ft(u); return u; } private Nd Fd3(Nd u, Nd dn) { if (u.r.r != du) { Nd v = Fd3(u.r, dn); if (Abs(u.r.l.h - u.r.r.h) > 1) { u.r = Rotate(u.r); } else { Ft(u.r); } return v; } else { Nd v = u.r; u.r = u.r.l; v.l = dn.l; v.r = dn.r; return v; } } public Nd Hs(nint n) { Nd t = root; if (cnt == 0) { return null; } if (t.n == n) { return t; } Nd a = null; while (true) { if (t.n > n) { if (t.l == du) { break; } else if (t.l.n != n) { t = t.l; } else { a = t.l; break; } } else { if (t.r == du) { break; } else if (t.r.n != n) { t = t.r; } else { a = t.r; break; } } } return a; } public Nd Ra(int n) { return cnt >= n ? Fr(root, n) : null; } private Nd Fr(Nd t, int n) { if (t.l.c > n - 1) { return Fr(t.l, n); } if (t.l.c < n - 1) { return Fr(t.r, n - t.l.c - 1); } return t; } public Nd Lb(nint n) { return cnt != 0 ? Flb(root, n) : null; } private Nd Flb(Nd t, nint n) { if (t.n < n) { if (t.r == du) { return null; } return Flb(t.r, n); } if (t.n > n) { if (t.l == du) { return t; } Nd u = Flb(t.l, n); return u == null ? t : u; } return t; } public Nd Ub(nint n) { return cnt != 0 ? Fub(root, n) : null; } private Nd Fub(Nd t, nint n) { if (t.n > n) { if (t.l == du) { return null; } return Fub(t.l, n); } if (t.n < n) { if (t.r == du) { return t; } Nd u = Fub(t.r, n); return u == null ? t : u; } return t; } public int Rg(nint a, nint b) { return cnt != 0 ? Frg(root, a, b, false, false) : 0; } private int Frg(Nd t, nint a, nint b, bool l, bool r) { if (t.h == 0) { return 0; } if (l && r) { return t.c; } if (t.n < a) { return Frg(t.r, a, b, t.n >= a, r); } if (t.n > b) { return Frg(t.l, a, b, l, t.n <= b); } return Frg(t.l, a, b, l, t.n <= b) + Frg(t.r, a, b, t.n >= a, r) + 1; } public Nd Rd(nint a, nint b) { return cnt != 0 ? Frd(root, a, b, false, false) : null; } private Nd Frd(Nd t, nint a, nint b, bool l, bool r) { if (t.h == 0) { return du; } if (l && r) { return t.nx; } if (t.n < a) { return Frd(t.r, a, b, t.n >= a, r); } if (t.n > b) { return Frd(t.l, a, b, l, t.n <= b); } var e1 = Frd(t.l, a, b, l, t.n <= b); var e2 = Frd(t.r, a, b, t.n >= a, r); e1 = compare(e1.d, e2.d) ? e1 : e2; return compare(t.d, e1.d) ? t : e1; } public Nd Gl(nint a, nint b, long d) { return cnt == 0 ? null : Fgl(root, a, b, d); } private Nd Fgl(Nd t, nint a, nint b, long d) { Nd p = null; if (a <= t.n && t.n <= b && compare(t.d, d)) { p = t; } if (a <= t.n && compare(t.l.nx.d, d)) { var z = Fgl(t.l, a, b, d); if (z != null) { p = z; } } if (p == null && t.n <= b && compare(t.r.nx.d, d)) { p = Fgl(t.r, a, b, d); } return p; } public Nd Gr(nint a, nint b, long d) { return cnt == 0 ? null : Fgr(root, a, b, d); } private Nd Fgr(Nd t, nint a, nint b, long d) { Nd p = null; if (a <= t.n && t.n <= b && compare(t.d, d)) { p = t; } if (t.n <= b && compare(t.r.nx.d, d)) { var z = Fgr(t.r, a, b, d); if (z != null) { p = z; } } if (p == null && a <= t.n && compare(t.l.nx.d, d)) { p = Fgr(t.r, a, b, d); } return p; } public void En(Action<Nd> f) { if (cnt > 0) { Fen(root, f); } } private void Fen(Nd t, Action<Nd> f) { f(t); if (t.l != du) { Fen(t.l, f); } if (t.r != du) { Fen(t.r, f); } } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public double[] Da2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), double.Parse); } } public double[] Da3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), double.Parse); } public double[] Da3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), double.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 41, 15, 23, 0, 24], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 17, 106], ["+", 15, 23, 0, 16, 12, 16, 31, 214, 205, 22], ["+", 15, 23, 0, 16, 12, 16, 31, 214, 0, 131], ["+", 15, 23, 0, 16, 12, 16, 31, 214, 141, 22], ["+", 0, 41, 15, 23, 0, 16, 12, 16, 17, 18], ["+", 0, 41, 15, 23, 0, 16, 12, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 41, 15, 23, 0, 25]]
8
4,659
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC162D { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string input = Console.ReadLine(); string[] S = new string[N]; for (int i = 0; i < N; i++) { S[i] = input.Substring(i, 1); } int count = 0; for (int i = 1; 2 * i < N; i++) { for (int j = 0; j + i + i < N; j++) { if (S[j] != S[j + i] & S[j] != S[j + i + i]) { if (S[j + i] != S[j + i + i]) { count += 1; } } } } Array.Sort(S); Queue<int> Q = new Queue<int>(); for (int i = 0; i < N - 1; i++) { if (S[i] != S[i + 1]) { Q.Enqueue(i + 1); } } if (Q.Count == 2) { int b = Q.Dequeue(); int g = Q.Dequeue() - b; int r = N - g - b; // Console.WriteLine(r); // Console.WriteLine(g); // Console.WriteLine(b); Console.WriteLine(r * g * b - count); } else { Console.WriteLine(0); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC162D { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string input = Console.ReadLine(); string[] S = new string[N]; for (int i = 0; i < N; i++) { S[i] = input.Substring(i, 1); } long count = 0; for (int i = 1; 2 * i < N; i++) { for (int j = 0; j + i + i < N; j++) { if (S[j] != S[j + i] & S[j] != S[j + i + i]) { if (S[j + i] != S[j + i + i]) { count += 1; } } } } Array.Sort(S); Queue<long> Q = new Queue<long>(); for (int i = 0; i < N - 1; i++) { if (S[i] != S[i + 1]) { Q.Enqueue(i + 1); } } if (Q.Count == 2) { long b = Q.Dequeue(); long g = Q.Dequeue() - b; long r = N - g - b; // Console.WriteLine(r); // Console.WriteLine(g); // Console.WriteLine(b); long ans = r * g * b - count; Console.WriteLine(ans); } else { Console.WriteLine(0); } } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
336
25
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { public static long count; static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string s = Console.ReadLine(); char[] sArr = s.ToArray(); int[] arrAns = new int[1]; checkAns(0, sArr, n, 'R', arrAns); long allCount = 1; foreach (var g in sArr.GroupBy(x => x)) { allCount *= g.Count(); } Console.WriteLine(allCount - count); } static void checkAns(int ind, char[] sArr, int n, char target, int[] arrAns) { for (int i = 0; i < n; i++) { if (sArr[i] == target) { if (ind == 0) { arrAns[0] = i; checkAns(1, sArr, n, 'G', arrAns); } else if (ind == 1) { int max = Math.Max(arrAns[0], i); int min = Math.Min(arrAns[0], i); if (max + max - min < n) { if (sArr[max + max - min] == 'B') count++; } if (min - (max - min) >= 0) { if (sArr[min - (max - min)] == 'B') count++; } if ((max - min) % 2 == 0) { if (sArr[min + (max - min) / 2] == 'B') count++; } } } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { public static long count; static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string s = Console.ReadLine(); char[] sArr = s.ToArray(); int[] arrAns = new int[1]; checkAns(0, sArr, n, 'R', arrAns); long allCount = 1; var ele = sArr.GroupBy(x => x); if (ele.Count() != 3) { Console.WriteLine(0); return; } foreach (var g in ele) { allCount *= g.Count(); } Console.WriteLine(allCount - count); } static void checkAns(int ind, char[] sArr, int n, char target, int[] arrAns) { for (int i = 0; i < n; i++) { if (sArr[i] == target) { if (ind == 0) { arrAns[0] = i; checkAns(1, sArr, n, 'G', arrAns); } else if (ind == 1) { int max = Math.Max(arrAns[0], i); int min = Math.Min(arrAns[0], i); if (max + max - min < n) { if (sArr[max + max - min] == 'B') count++; } if (min - (max - min) >= 0) { if (sArr[min - (max - min)] == 'B') count++; } if ((max - min) % 2 == 0) { if (sArr[min + (max - min) / 2] == 'B') count++; } } } } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 24], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["+", 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, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 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, 210, 0, 266], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 24], ["+", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22]]
8
359
34
using System; using System.Collections.Generic; using System.Linq; namespace ABC162D { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var s = Console.ReadLine(); int[] dR = new int[N]; int[] dG = new int[N]; int[] dB = new int[N]; for (int i = s.Length - 2; i >= 0; i--) { dR[i] = dR[i + 1]; dG[i] = dG[i + 1]; dB[i] = dB[i + 1]; if (s[i + 1] == 'R') dR[i]++; if (s[i + 1] == 'G') dG[i]++; if (s[i + 1] == 'B') dB[i]++; } int ans = 0; for (int i = 0; i < N - 2; i++) { if (s[i] == 'R') ans += dG[i] * dB[i]; else if (s[i] == 'G') ans += dB[i] * dR[i]; else if (s[i] == 'B') ans += dR[i] * dG[i]; } for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { int final = 2 * j - i; if (final >= N) break; if (s[i] == 'R' && s[j] == 'G' && s[final] == 'B') ans--; if (s[i] == 'R' && s[j] == 'B' && s[final] == 'G') ans--; if (s[i] == 'G' && s[j] == 'B' && s[final] == 'R') ans--; if (s[i] == 'G' && s[j] == 'R' && s[final] == 'B') ans--; if (s[i] == 'B' && s[j] == 'G' && s[final] == 'R') ans--; if (s[i] == 'B' && s[j] == 'R' && s[final] == 'G') ans--; } } Console.WriteLine(ans); Console.ReadKey(); } static int[] ReadInt() { int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray(); return ret; } static long[] ReadLong() { long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray(); return ret; } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC162D { class Program { static void Main(string[] args) { long N = long.Parse(Console.ReadLine()); var s = Console.ReadLine(); long[] dR = new long[N]; long[] dG = new long[N]; long[] dB = new long[N]; for (int i = s.Length - 2; i >= 0; i--) { dR[i] = dR[i + 1]; dG[i] = dG[i + 1]; dB[i] = dB[i + 1]; if (s[i + 1] == 'R') dR[i]++; if (s[i + 1] == 'G') dG[i]++; if (s[i + 1] == 'B') dB[i]++; } long ans = 0; for (int i = 0; i < N - 2; i++) { if (s[i] == 'R') ans += dG[i] * dB[i]; else if (s[i] == 'G') ans += dB[i] * dR[i]; else if (s[i] == 'B') ans += dR[i] * dG[i]; } for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { int final = 2 * j - i; if (final >= N) break; if (s[i] == 'R' && s[j] == 'G' && s[final] == 'B') ans--; if (s[i] == 'R' && s[j] == 'B' && s[final] == 'G') ans--; if (s[i] == 'G' && s[j] == 'B' && s[final] == 'R') ans--; if (s[i] == 'G' && s[j] == 'R' && s[final] == 'B') ans--; if (s[i] == 'B' && s[j] == 'G' && s[final] == 'R') ans--; if (s[i] == 'B' && s[j] == 'R' && s[final] == 'G') ans--; } } Console.WriteLine(ans); Console.ReadKey(); } static int[] ReadInt() { int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray(); return ret; } static long[] ReadLong() { long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray(); return ret; } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199]]
8
633
18
using System; using System.Collections; using System.Collections.Generic; using System.IO.Pipes; using System.Linq; using System.Numerics; using System.Security.Cryptography; using System.Text; using System.Threading; namespace ForATCODER { public class Program { public static void Main(string[] args) { int N = s2i(Console.ReadLine()); String S = Console.ReadLine(); long max = S.Count(x => x == 'R') * S.Count(x => x == 'G') * S.Count(x => x == 'B'); long c = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (S[i] == S[j]) continue; int k = 2 * j - i; if (k >= N) continue; // k=2j-i if (S[i] != S[k] && S[j] != S[k]) { c++; } } } RESULT(max - c); } public static ulong pow(int a, int b) { ulong res = 1; for (int i = 0; i < b; i++) { res *= (ulong)a; } return res; } static int s2i(String s) { return Convert.ToInt32(s); } static long s2l(String s) { return Convert.ToInt64(s); } static void RESULT(double res) { Console.WriteLine(res); } static void RESULT(long res) { Console.WriteLine(res); } static void RESULT(ulong res) { Console.WriteLine(res); } static void RESULT(int res) { Console.WriteLine(res); } static void RESULT(String res) { Console.WriteLine(res); } static String[] ReadLineAll(int count) { String[] res = new String[count]; for (int i = 0; i < count; i++) { res[i] = Console.ReadLine(); } return res; } static int[] s2iarray(String[] src) { int len = src.Length; int[] res = new int[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt32(src[i]); } return res; } static ulong[] s2larray(String[] src) { int len = src.Length; ulong[] res = new ulong[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToUInt64(src[i]); } return res; } static ulong[] s2larray2(String[] src) { int len = src.Length; ulong[] res = new ulong[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToUInt64(src[i]); } return res; } } public struct Polynomial { // 多項式中の変数 public static readonly Polynomial X = new Polynomial(new Dictionary<int, double> { { 1, 1 } }); // 度数 public int Degree { get { return Coefficients.Count == 0 ? 0 : Coefficients.Max(c => c.Key); } } // 変数に値を代入した値を取得します。 public double this[double value] { get { return Coefficients.Sum(c => c.Value * Math.Pow(value, c.Key)); } } private static readonly IDictionary<int, double> _coefficients_empty = new Dictionary<int, double>(); private IDictionary<int, double> _coefficients; private IDictionary<int, double> Coefficients { get { return _coefficients == null ? _coefficients_empty : _coefficients; } } private Polynomial(IDictionary<int, double> coefficients) { _coefficients = coefficients; } public static implicit operator Polynomial(double value) { return value == 0 ? default(Polynomial) : new Polynomial(new Dictionary<int, double> { { 0, value } }); } public static Polynomial operator +(Polynomial p1, Polynomial p2) { var coefficients = new Dictionary<int, double>(p1.Coefficients); foreach (var item2 in p2.Coefficients) { AddMonomial(coefficients, item2.Key, item2.Value); } return new Polynomial(coefficients); } public static Polynomial operator -(Polynomial p1, Polynomial p2) { var coefficients = new Dictionary<int, double>(p1.Coefficients); foreach (var item2 in p2.Coefficients) { AddMonomial(coefficients, item2.Key, -item2.Value); } return new Polynomial(coefficients); } public static Polynomial operator *(Polynomial p1, Polynomial p2) { var coefficients = new Dictionary<int, double>(); foreach (var item1 in p1.Coefficients) { foreach (var item2 in p2.Coefficients) { AddMonomial(coefficients, item1.Key + item2.Key, item1.Value * item2.Value); } } return new Polynomial(coefficients); } public static Polynomial operator /(Polynomial p, double value) { var coefficients = new Dictionary<int, double>(); foreach (var item in p.Coefficients) { AddMonomial(coefficients, item.Key, item.Value / value); } return new Polynomial(coefficients); } public static Polynomial operator ^(Polynomial p, int power) { if (power < 0) { throw new ArgumentOutOfRangeException("power", "The value must be non-negative."); } Polynomial result = 1; for (var i = 0; i < power; i++) { result *= p; } return result; } public static Polynomial operator +(Polynomial p) { return p; } public static Polynomial operator -(Polynomial p) { return -1 * p; } public static bool operator ==(Polynomial p1, Polynomial p2) { return p1.Equals(p2); } public static bool operator !=(Polynomial p1, Polynomial p2) { return !p1.Equals(p2); } private static void AddMonomial(Dictionary<int, double> coefficients, int index, double coefficient) { var totalCoefficient = coefficients.ContainsKey(index) ? coefficient + coefficients[index] : coefficient; if (totalCoefficient != 0) { coefficients[index] = totalCoefficient; } else { coefficients.Remove(index); } } private double GetCoefficient(int index) { return Coefficients.ContainsKey(index) ? Coefficients[index] : 0; } // 左辺、右辺を指定して方程式を作り、解を求めます。 public static double[] SolveEquation(Polynomial left, Polynomial right) { var equation = left - right; switch (equation.Degree) { case 0: if (equation != 0) { return new double[0]; } else { throw new OverflowException( "an arbitrary real number is a solution of this equation."); } case 1: { var a = equation.GetCoefficient(1); var b = equation.GetCoefficient(0); return new[] { -b / a }; } case 2: { var a = equation.GetCoefficient(2); var b = equation.GetCoefficient(1); var c = equation.GetCoefficient(0); var d = b * b - 4 * a * c; return d > 0 ? new[] { (-b - Math.Sqrt(d)) / (2 * a), (-b + Math.Sqrt(d)) / (2 * a) } : d == 0 ? new[] { -b / (2 * a) } : new double[0]; } default: throw new NotImplementedException("disable to be solved."); } } // 右辺を指定して方程式を作り、解を求めます。 public double[] SolveEquation(Polynomial right) { return Polynomial.SolveEquation(this, right); } // この多項式を表す文字列に変換します。 public override string ToString() { return ToString("X"); } // 変数となる文字列を指定して、この多項式を表す文字列に変換します。 public string ToString(string variable) { if (this == 0) return "0"; var builder = new StringBuilder(); foreach (var c in Coefficients.OrderByDescending(x => x.Key)) { var abs = Math.Abs(c.Value); builder.Append(c.Value > 0 ? '+' : '-').Append(' '); if (c.Key == 0 || abs != 1) builder.Append(abs); if (c.Key != 0) builder.Append(variable); if (c.Key > 1) builder.Append('^').Append(c.Key); builder.Append(' '); } builder.Remove(builder.Length - 1, 1); return builder[0] == '+' ? builder.ToString(2, builder.Length - 2) : builder.ToString(); } // override object.Equals public override bool Equals(object obj) { Polynomial p; try { p = Polynomial.Cast(obj); } catch { return false; } if (Coefficients.Count != p.Coefficients.Count) return false; foreach (var c in Coefficients) { double value; if (!p.Coefficients.TryGetValue(c.Key, out value) || value != c.Value) return false; } return true; } private static Polynomial Cast(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } else if (obj is Polynomial) { return (Polynomial)obj; } else { return Convert.ToDouble(obj); } } // override object.GetHashCode public override int GetHashCode() { return Degree ^ Coefficients.Count; } // 多項式を1変数関数と見なして微分します。 public Polynomial Differentiate() { var coefficients = new Dictionary<int, double>(); foreach (var item in Coefficients) { AddMonomial(coefficients, item.Key - 1, item.Key * item.Value); } return new Polynomial(coefficients); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO.Pipes; using System.Linq; using System.Numerics; using System.Security.Cryptography; using System.Text; using System.Threading; namespace ForATCODER { public class Program { public static void Main(string[] args) { int N = s2i(Console.ReadLine()); String S = Console.ReadLine(); long max = (long)S.Count(x => x == 'R') * (long)S.Count(x => x == 'G') * (long)S.Count(x => x == 'B'); long c = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (S[i] == S[j]) continue; int k = 2 * j - i; if (k >= N) continue; // k=2j-i if (S[i] != S[k] && S[j] != S[k]) { c++; } } } RESULT(max - c); } public static ulong pow(int a, int b) { ulong res = 1; for (int i = 0; i < b; i++) { res *= (ulong)a; } return res; } static int s2i(String s) { return Convert.ToInt32(s); } static long s2l(String s) { return Convert.ToInt64(s); } static void RESULT(double res) { Console.WriteLine(res); } static void RESULT(long res) { Console.WriteLine(res); } static void RESULT(ulong res) { Console.WriteLine(res); } static void RESULT(int res) { Console.WriteLine(res); } static void RESULT(String res) { Console.WriteLine(res); } static String[] ReadLineAll(int count) { String[] res = new String[count]; for (int i = 0; i < count; i++) { res[i] = Console.ReadLine(); } return res; } static int[] s2iarray(String[] src) { int len = src.Length; int[] res = new int[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToInt32(src[i]); } return res; } static ulong[] s2larray(String[] src) { int len = src.Length; ulong[] res = new ulong[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToUInt64(src[i]); } return res; } static ulong[] s2larray2(String[] src) { int len = src.Length; ulong[] res = new ulong[len]; for (int i = 0; i < len; i++) { res[i] = Convert.ToUInt64(src[i]); } return res; } } public struct Polynomial { // 多項式中の変数 public static readonly Polynomial X = new Polynomial(new Dictionary<int, double> { { 1, 1 } }); // 度数 public int Degree { get { return Coefficients.Count == 0 ? 0 : Coefficients.Max(c => c.Key); } } // 変数に値を代入した値を取得します。 public double this[double value] { get { return Coefficients.Sum(c => c.Value * Math.Pow(value, c.Key)); } } private static readonly IDictionary<int, double> _coefficients_empty = new Dictionary<int, double>(); private IDictionary<int, double> _coefficients; private IDictionary<int, double> Coefficients { get { return _coefficients == null ? _coefficients_empty : _coefficients; } } private Polynomial(IDictionary<int, double> coefficients) { _coefficients = coefficients; } public static implicit operator Polynomial(double value) { return value == 0 ? default(Polynomial) : new Polynomial(new Dictionary<int, double> { { 0, value } }); } public static Polynomial operator +(Polynomial p1, Polynomial p2) { var coefficients = new Dictionary<int, double>(p1.Coefficients); foreach (var item2 in p2.Coefficients) { AddMonomial(coefficients, item2.Key, item2.Value); } return new Polynomial(coefficients); } public static Polynomial operator -(Polynomial p1, Polynomial p2) { var coefficients = new Dictionary<int, double>(p1.Coefficients); foreach (var item2 in p2.Coefficients) { AddMonomial(coefficients, item2.Key, -item2.Value); } return new Polynomial(coefficients); } public static Polynomial operator *(Polynomial p1, Polynomial p2) { var coefficients = new Dictionary<int, double>(); foreach (var item1 in p1.Coefficients) { foreach (var item2 in p2.Coefficients) { AddMonomial(coefficients, item1.Key + item2.Key, item1.Value * item2.Value); } } return new Polynomial(coefficients); } public static Polynomial operator /(Polynomial p, double value) { var coefficients = new Dictionary<int, double>(); foreach (var item in p.Coefficients) { AddMonomial(coefficients, item.Key, item.Value / value); } return new Polynomial(coefficients); } public static Polynomial operator ^(Polynomial p, int power) { if (power < 0) { throw new ArgumentOutOfRangeException("power", "The value must be non-negative."); } Polynomial result = 1; for (var i = 0; i < power; i++) { result *= p; } return result; } public static Polynomial operator +(Polynomial p) { return p; } public static Polynomial operator -(Polynomial p) { return -1 * p; } public static bool operator ==(Polynomial p1, Polynomial p2) { return p1.Equals(p2); } public static bool operator !=(Polynomial p1, Polynomial p2) { return !p1.Equals(p2); } private static void AddMonomial(Dictionary<int, double> coefficients, int index, double coefficient) { var totalCoefficient = coefficients.ContainsKey(index) ? coefficient + coefficients[index] : coefficient; if (totalCoefficient != 0) { coefficients[index] = totalCoefficient; } else { coefficients.Remove(index); } } private double GetCoefficient(int index) { return Coefficients.ContainsKey(index) ? Coefficients[index] : 0; } // 左辺、右辺を指定して方程式を作り、解を求めます。 public static double[] SolveEquation(Polynomial left, Polynomial right) { var equation = left - right; switch (equation.Degree) { case 0: if (equation != 0) { return new double[0]; } else { throw new OverflowException( "an arbitrary real number is a solution of this equation."); } case 1: { var a = equation.GetCoefficient(1); var b = equation.GetCoefficient(0); return new[] { -b / a }; } case 2: { var a = equation.GetCoefficient(2); var b = equation.GetCoefficient(1); var c = equation.GetCoefficient(0); var d = b * b - 4 * a * c; return d > 0 ? new[] { (-b - Math.Sqrt(d)) / (2 * a), (-b + Math.Sqrt(d)) / (2 * a) } : d == 0 ? new[] { -b / (2 * a) } : new double[0]; } default: throw new NotImplementedException("disable to be solved."); } } // 右辺を指定して方程式を作り、解を求めます。 public double[] SolveEquation(Polynomial right) { return Polynomial.SolveEquation(this, right); } // この多項式を表す文字列に変換します。 public override string ToString() { return ToString("X"); } // 変数となる文字列を指定して、この多項式を表す文字列に変換します。 public string ToString(string variable) { if (this == 0) return "0"; var builder = new StringBuilder(); foreach (var c in Coefficients.OrderByDescending(x => x.Key)) { var abs = Math.Abs(c.Value); builder.Append(c.Value > 0 ? '+' : '-').Append(' '); if (c.Key == 0 || abs != 1) builder.Append(abs); if (c.Key != 0) builder.Append(variable); if (c.Key > 1) builder.Append('^').Append(c.Key); builder.Append(' '); } builder.Remove(builder.Length - 1, 1); return builder[0] == '+' ? builder.ToString(2, builder.Length - 2) : builder.ToString(); } // override object.Equals public override bool Equals(object obj) { Polynomial p; try { p = Polynomial.Cast(obj); } catch { return false; } if (Coefficients.Count != p.Coefficients.Count) return false; foreach (var c in Coefficients) { double value; if (!p.Coefficients.TryGetValue(c.Key, out value) || value != c.Value) return false; } return true; } private static Polynomial Cast(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } else if (obj is Polynomial) { return (Polynomial)obj; } else { return Convert.ToDouble(obj); } } // override object.GetHashCode public override int GetHashCode() { return Degree ^ Coefficients.Count; } // 多項式を1変数関数と見なして微分します。 public Polynomial Differentiate() { var coefficients = new Dictionary<int, double>(); foreach (var item in Coefficients) { AddMonomial(coefficients, item.Key - 1, item.Key * item.Value); } return new Polynomial(coefficients); } } }
[["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 212, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 212, 0, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 212, 0, 16, 31, 16, 12, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25]]
8
2,008
9
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 d = DateTime.Now; var n = Read().ToInt(); var s = Read(); var r = new List<int>(); var g = new List<int>(); var b = new List<int>(); for (int i = 0; i < n; i++) { var aa = s[i].ToString(); if (aa == "R") r.Add(i); if (aa == "G") g.Add(i); if (aa == "B") b.Add(i); } decimal ans = r.Count * g.Count * b.Count; if (ans == 0) { WriteRead(0); return; } decimal sub = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i + (2 * j) >= n) continue; if (s[i] != s[i + j] && s[i] != s[i + (2 * j)] && s[i + j] != s[i + (2 * j)]) { sub++; } } } WriteRead(ans - sub); } 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); } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double ToDouble(this object obj) { return double.Parse(obj.ToString()); } 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 d = DateTime.Now; var n = Read().ToInt(); var s = Read(); var r = new List<int>(); var g = new List<int>(); var b = new List<int>(); for (int i = 0; i < n; i++) { var aa = s[i].ToString(); if (aa == "R") r.Add(i); if (aa == "G") g.Add(i); if (aa == "B") b.Add(i); } decimal ans = r.Count.ToDecimal() * g.Count.ToDecimal() * b.Count.ToDecimal(); if (ans == 0) { WriteRead(0); return; } decimal sub = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i + (2 * j) >= n) continue; if (s[i] != s[i + j] && s[i] != s[i + (2 * j)] && s[i + j] != s[i + (2 * j)]) { sub++; } } } WriteRead(ans - sub); } 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); } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double ToDouble(this object obj) { return double.Parse(obj.ToString()); } 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, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 212, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 212, 0, 16, 12, 213, 3, 4, 0, 25]]
8
530
12
using System; using System.Collections.Generic; using System.Linq; class Progaram { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine().ToCharArray(); var r = 0; var g = 0; var b = 0; for (var i = 0; n > i; i++) { if (s[i] == 'R') r++; if (s[i] == 'G') g++; if (s[i] == 'B') b++; } long res = r * g * b; for (var i = 0; n > i; i++) { for (var j = i + 1; n > j; j++) { var k = 2 * (j + 1) - (i + 1); if (k - 1 < n && s[i] != s[j] && s[i] != s[k - 1] && s[j] != s[k - 1]) res--; } } Console.WriteLine(res); } }
using System; using System.Collections.Generic; using System.Linq; class Progaram { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine().ToCharArray(); var r = 0L; var g = 0L; var b = 0L; for (var i = 0; n > i; i++) { if (s[i] == 'R') r++; else if (s[i] == 'G') g++; else b++; } long res = r * g * b; for (var i = 0; n > i; i++) { for (var j = i + 1; n > j; j++) { var k = 2 * (j + 1) - (i + 1); if (k - 1 < n && s[i] != s[j] && s[i] != s[k - 1] && s[j] != s[k - 1]) res--; } } Console.WriteLine(res); } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104], ["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 95]]
8
242
19
using System; using System.Collections.Generic; namespace B { class Program { static void Main(string[] args) { string line = Console.ReadLine(); int N = int.Parse(line); line = Console.ReadLine(); int sum = 0; var listR = new List<int>(); var listG = new List<int>(); var listB = new List<int>(); // R[n]の後ろにあるBは何個 var listRB = new Dictionary<int, int>(); var listRG = new Dictionary<int, int>(); var listBG = new Dictionary<int, int>(); var listBR = new Dictionary<int, int>(); var listGR = new Dictionary<int, int>(); var listGB = new Dictionary<int, int>(); for (int i = 0; i < N; i++) { if (line[i] == 'R') listR.Add(i); else if (line[i] == 'G') listG.Add(i); else listB.Add(i); } int beforeA = 0; int beforeB = 0; for (int i = 0; i < listR.Count; i++) { for (int j = beforeA; j < listB.Count; j++) { if (listR[i] < listB[j]) { beforeA = j; listRB.Add(i, listB.Count - j); break; } } for (int j = beforeB; j < listG.Count; j++) { if (listR[i] < listG[j]) { beforeB = j; listRG.Add(i, listG.Count - j); break; } } } beforeA = 0; beforeB = 0; for (int i = 0; i < listG.Count; i++) { for (int j = beforeA; j < listB.Count; j++) { if (listG[i] < listB[j]) { beforeA = j; listGB.Add(i, listB.Count - j); break; } } for (int j = beforeB; j < listR.Count; j++) { if (listG[i] < listR[j]) { beforeB = j; listGR.Add(i, listR.Count - j); break; } } } beforeA = 0; beforeB = 0; for (int i = 0; i < listB.Count; i++) { for (int j = beforeA; j < listR.Count; j++) { if (listB[i] < listR[j]) { beforeA = j; listBR.Add(i, listR.Count - j); break; } } for (int j = beforeB; j < listG.Count; j++) { if (listB[i] < listG[j]) { beforeB = j; listBG.Add(i, listG.Count - j); break; } } } for (int i = 0; i < N; i++) { if (line[i] == 'R') { for (int j = listB.Count - 1; j >= 0; j--) { if (listB[j] < i) break; if (listBG.ContainsKey(j)) sum += listBG[j]; } for (int j = listG.Count - 1; j >= 0; j--) { if (listG[j] < i) break; if (listGB.ContainsKey(j)) sum += listGB[j]; } } else if (line[i] == 'G') { for (int j = listB.Count - 1; j >= 0; j--) { if (listB[j] < i) break; if (listBR.ContainsKey(j)) sum += listBR[j]; } for (int j = listR.Count - 1; j >= 0; j--) { if (listR[j] < i) break; if (listRB.ContainsKey(j)) sum += listRB[j]; } } else if (line[i] == 'B') { for (int j = listG.Count - 1; j >= 0; j--) { if (listG[j] < i) break; if (listGR.ContainsKey(j)) sum += listGR[j]; } for (int j = listR.Count - 1; j >= 0; j--) { if (listR[j] < i) break; if (listRG.ContainsKey(j)) sum += listRG[j]; } } } //拾ってはいけないパターンだけ削る int minus = 0; for (int i = 1; i <= N / 2; i++) { for (int j = 0; j < N - i * 2; j++) { if (line[j] != line[j + i] && line[j + i] != line[j + i + i] && line[j] != line[j + i + i]) minus++; } } Console.WriteLine(listR.Count * listG.Count * listB.Count - minus); // Console.WriteLine(sum-minus); } } }
using System; using System.Collections.Generic; namespace B { class Program { static void Main(string[] args) { string line = Console.ReadLine(); int N = int.Parse(line); line = Console.ReadLine(); int sum = 0; var listR = new List<int>(); var listG = new List<int>(); var listB = new List<int>(); // R[n]の後ろにあるBは何個 var listRB = new Dictionary<int, int>(); var listRG = new Dictionary<int, int>(); var listBG = new Dictionary<int, int>(); var listBR = new Dictionary<int, int>(); var listGR = new Dictionary<int, int>(); var listGB = new Dictionary<int, int>(); for (int i = 0; i < N; i++) { if (line[i] == 'R') listR.Add(i); else if (line[i] == 'G') listG.Add(i); else listB.Add(i); } int beforeA = 0; int beforeB = 0; for (int i = 0; i < listR.Count; i++) { for (int j = beforeA; j < listB.Count; j++) { if (listR[i] < listB[j]) { beforeA = j; listRB.Add(i, listB.Count - j); break; } } for (int j = beforeB; j < listG.Count; j++) { if (listR[i] < listG[j]) { beforeB = j; listRG.Add(i, listG.Count - j); break; } } } beforeA = 0; beforeB = 0; for (int i = 0; i < listG.Count; i++) { for (int j = beforeA; j < listB.Count; j++) { if (listG[i] < listB[j]) { beforeA = j; listGB.Add(i, listB.Count - j); break; } } for (int j = beforeB; j < listR.Count; j++) { if (listG[i] < listR[j]) { beforeB = j; listGR.Add(i, listR.Count - j); break; } } } beforeA = 0; beforeB = 0; for (int i = 0; i < listB.Count; i++) { for (int j = beforeA; j < listR.Count; j++) { if (listB[i] < listR[j]) { beforeA = j; listBR.Add(i, listR.Count - j); break; } } for (int j = beforeB; j < listG.Count; j++) { if (listB[i] < listG[j]) { beforeB = j; listBG.Add(i, listG.Count - j); break; } } } for (int i = 0; i < N; i++) { if (line[i] == 'R') { for (int j = listB.Count - 1; j >= 0; j--) { if (listB[j] < i) break; if (listBG.ContainsKey(j)) sum += listBG[j]; } for (int j = listG.Count - 1; j >= 0; j--) { if (listG[j] < i) break; if (listGB.ContainsKey(j)) sum += listGB[j]; } } else if (line[i] == 'G') { for (int j = listB.Count - 1; j >= 0; j--) { if (listB[j] < i) break; if (listBR.ContainsKey(j)) sum += listBR[j]; } for (int j = listR.Count - 1; j >= 0; j--) { if (listR[j] < i) break; if (listRB.ContainsKey(j)) sum += listRB[j]; } } else if (line[i] == 'B') { for (int j = listG.Count - 1; j >= 0; j--) { if (listG[j] < i) break; if (listGR.ContainsKey(j)) sum += listGR[j]; } for (int j = listR.Count - 1; j >= 0; j--) { if (listR[j] < i) break; if (listRG.ContainsKey(j)) sum += listRG[j]; } } } //拾ってはいけないパターンだけ削る long minus = 0; for (int i = 1; i <= N / 2; i++) { for (int j = 0; j < N - i * 2; j++) { if (line[j] != line[j + i] && line[j + i] != line[j + i + i] && line[j] != line[j + i + i]) minus++; } } Console.WriteLine( (long)listR.Count * (long)listG.Count * (long)listB.Count - minus); // Console.WriteLine(sum-minus); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 16, 31, 16, 31, 16, 12, 74, 0, 25], ["+", 0, 28, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 28, 0, 16, 31, 16, 12, 74, 0, 25]]
8
1,070
11
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace competitive_programming { class Program { static void Main(string[] args) { var main = new Program(); main.solve(); } void solve() { int N = int.Parse(Console.ReadLine()); var S = Console.ReadLine(); long count = S.Count(s => s == 'R') * S.Count(s => s == 'G') * S.Count(s => s == 'B'); for (int i = 0; i < N; i++) { for (int j = 1; j < N; j++) { if (i - j < 0 || i + j >= N || i - j >= N || i + j < 0) continue; if (S[i - j] != S[i] && S[i] != S[i + j] && S[i - j] != S[i + j]) count--; } } if (count < 0) count = 0; Console.WriteLine(count); } public static long Gcd(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } } struct Vector2 { public Vector2(long x, long y) { this.x = x; this.y = y; } public long x; public long y; } struct Vector3 { public int x; public int y; public int z; } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace competitive_programming { class Program { static void Main(string[] args) { var main = new Program(); main.solve(); } void solve() { int N = int.Parse(Console.ReadLine()); var S = Console.ReadLine(); long r = S.Count(c => c == 'R'); long g = S.Count(c => c == 'G'); long b = S.Count(c => c == 'B'); long count = r * g * b; for (int i = 0; i < N; i++) { for (int j = 1; j < N; j++) { if (i - j < 0 || i + j >= N || i - j >= N || i + j < 0) continue; if (S[i - j] != S[i] && S[i] != S[i + j] && S[i - j] != S[i + j]) count--; } } if (count < 0) count = 0; Console.WriteLine(count); } public static long Gcd(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } } struct Vector2 { public Vector2(long x, long y) { this.x = x; this.y = y; } public long x; public long y; } struct Vector3 { public int x; public int y; public int z; } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["+", 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, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
8
362
33
using System; using System.Collections; using System.Collections.Generic; namespace 練習問題 { class Program { static void Main(string[] args) { // var sw =z new System.Diagnostics.Stopwatch(); // sw.Start(); List<int> pattern = new List<int>(); int n = 0; string s = ""; int result = 0; // Si != Sj && Si != Sk && Sj != Sk // j - i != k - j debug Debug = new debug(); if (args.Length == 0) { Debug.FlagFalse(); /* string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); */ n = int.Parse(Console.ReadLine()); s = Console.ReadLine(); // string d = Console.ReadLine(); // string[] input = Console.ReadLine().Split(' '); } else { Debug.FlagTrue(); if (args[0] == "1") { pattern.Add(4); pattern.Add(3); n = pattern[0]; s = "RRGB"; } else if (args[0] == "2") { pattern.Add(39); pattern.Add(4); n = pattern[0]; s = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"; } else if (args[0] == "3") { n = 702; s = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"; } else { n = 3; s = "RGBR"; } } List<int> r = new List<int>(); List<int> g = new List<int>(); List<int> b = new List<int>(); for (int i = 0; i < n; i++) { if (s.Substring(i, 1) == "R") { r.Add(i); } else if (s.Substring(i, 1) == "G") { g.Add(i); } else if (s.Substring(i, 1) == "B") { b.Add(i); } } result = r.Count * g.Count * b.Count; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { var k = j + (j - i); if (k >= n) { continue; } else if (s.Substring(i, 1) != s.Substring(j, 1) && s.Substring(i, 1) != s.Substring(k, 1) && s.Substring(j, 1) != s.Substring(k, 1)) { result--; } } } // var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = // false}; Console.SetOut(sw); /*何らかの出力処理*/ Console.WriteLine(result); // Console.Out.Flush(); // sw.Stop(); // Console.WriteLine("■処理Aにかかった時間"); // TimeSpan ts = sw.Elapsed; // Console.WriteLine($" {ts}"); } static int intPow(int target, int kaisu) { int startTarget = target; for (int i = 1; i < kaisu; i++) { target *= startTarget; } return target; } static void bubble_sort(List<List<int>> a) { int count = 0; for (int i = 0; i < a.Count; i++) { for (int j = 0; j < a.Count - i - 1; j++) { // if (a[j] == a[a.Count - 1]){ // continue; // } count++; if (a[j][1] > a[j + 1][1]) { int localsave = 0; localsave = a[j + 1][1]; a[j + 1][1] = a[j][1]; a[j][1] = localsave; localsave = a[j][0]; a[j][0] = a[j + 1][0]; a[j + 1][0] = localsave; } } // debug(a,"途中" + i); } // debug(a,"result"); // Console.WriteLine("回数"+count); for (int i = 0; i < a.Count; i++) { Console.WriteLine(a[i][0] + " " + a[i][1]); } } /* 標準入力と標準出力が使えるかのチェック static void echo() { string echotest = Console.ReadLine(); Console.WriteLine(echotest); } static void HelloWorld(){ Console.WriteLine("Hello World!"); } */ } public class debug { //宣言時は、「 debug Debug = new debug(); 」推奨 bool debug_flag = true; public void Log(string str) { if (debug_flag == true) { Console.WriteLine(str); } } public void Log(int str) { if (debug_flag == true) { Console.WriteLine(str); } } public void Log(float str) { if (debug_flag == true) { Console.WriteLine(str); } } public void Log(object obj) { if (debug_flag == true) { Console.WriteLine(obj); } } public void Log(int[] arr) { if (debug_flag == true) { Console.WriteLine(string.Join(",", arr)); } } public void Log(string[] arr) { if (debug_flag == true) { Console.WriteLine(string.Join(",", arr)); } } public void Log(List<int> arr) { if (debug_flag == true) { string shuturyoku = ""; for (int i = 0; i < arr.Count; i++) { shuturyoku += arr[i] + ","; } Console.WriteLine(shuturyoku.TrimEnd(',')); } } public void Log(List<string> arr) { if (debug_flag == true) { string shuturyoku = ""; for (int i = 0; i < arr.Count; i++) { shuturyoku += arr[i] + ","; } Console.WriteLine(shuturyoku.TrimEnd(',')); } } public void Log(List<float> arr) { if (debug_flag == true) { string shuturyoku = ""; for (int i = 0; i < arr.Count; i++) { shuturyoku += arr[i] + ","; } Console.WriteLine(shuturyoku.TrimEnd(',')); } } public void Log() { if (debug_flag == true) { Console.WriteLine("アタイイレナサイ"); } } public void FlagFalse() { debug_flag = false; } public void FlagTrue() { debug_flag = true; } } }
using System; using System.Collections; using System.Collections.Generic; namespace 練習問題 { class Program { static void Main(string[] args) { // var sw =z new System.Diagnostics.Stopwatch(); // sw.Start(); List<int> pattern = new List<int>(); int n = 0; string s = ""; long result = 0; // Si != Sj && Si != Sk && Sj != Sk // j - i != k - j debug Debug = new debug(); if (args.Length == 0) { Debug.FlagFalse(); /* string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); */ n = int.Parse(Console.ReadLine()); s = Console.ReadLine(); // string d = Console.ReadLine(); // string[] input = Console.ReadLine().Split(' '); } else { Debug.FlagTrue(); if (args[0] == "1") { pattern.Add(4); pattern.Add(3); n = pattern[0]; s = "RRGB"; } else if (args[0] == "2") { pattern.Add(39); pattern.Add(4); n = pattern[0]; s = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"; } else if (args[0] == "3") { n = 702; s = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBBRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"; } else { n = 3; s = "RGBR"; } } List<int> r = new List<int>(); List<int> g = new List<int>(); List<int> b = new List<int>(); for (int i = 0; i < n; i++) { if (s.Substring(i, 1) == "R") { r.Add(i); } else if (s.Substring(i, 1) == "G") { g.Add(i); } else { b.Add(i); } } result = (long)r.Count * (long)g.Count * (long)b.Count; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { var k = j + (j - i); if (k >= n) { continue; } else if (s.Substring(i, 1) != s.Substring(j, 1) && s.Substring(i, 1) != s.Substring(k, 1) && s.Substring(j, 1) != s.Substring(k, 1)) { result--; } } } // var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = // false}; Console.SetOut(sw); /*何らかの出力処理*/ Console.WriteLine(result); // Console.Out.Flush(); // sw.Stop(); // Console.WriteLine("■処理Aにかかった時間"); // TimeSpan ts = sw.Elapsed; // Console.WriteLine($" {ts}"); } static int intPow(int target, int kaisu) { int startTarget = target; for (int i = 1; i < kaisu; i++) { target *= startTarget; } return target; } static void bubble_sort(List<List<int>> a) { int count = 0; for (int i = 0; i < a.Count; i++) { for (int j = 0; j < a.Count - i - 1; j++) { // if (a[j] == a[a.Count - 1]){ // continue; // } count++; if (a[j][1] > a[j + 1][1]) { int localsave = 0; localsave = a[j + 1][1]; a[j + 1][1] = a[j][1]; a[j][1] = localsave; localsave = a[j][0]; a[j][0] = a[j + 1][0]; a[j + 1][0] = localsave; } } // debug(a,"途中" + i); } // debug(a,"result"); // Console.WriteLine("回数"+count); for (int i = 0; i < a.Count; i++) { Console.WriteLine(a[i][0] + " " + a[i][1]); } } /* 標準入力と標準出力が使えるかのチェック static void echo() { string echotest = Console.ReadLine(); Console.WriteLine(echotest); } static void HelloWorld(){ Console.WriteLine("Hello World!"); } */ } public class debug { //宣言時は、「 debug Debug = new debug(); 」推奨 bool debug_flag = true; public void Log(string str) { if (debug_flag == true) { Console.WriteLine(str); } } public void Log(int str) { if (debug_flag == true) { Console.WriteLine(str); } } public void Log(float str) { if (debug_flag == true) { Console.WriteLine(str); } } public void Log(object obj) { if (debug_flag == true) { Console.WriteLine(obj); } } public void Log(int[] arr) { if (debug_flag == true) { Console.WriteLine(string.Join(",", arr)); } } public void Log(string[] arr) { if (debug_flag == true) { Console.WriteLine(string.Join(",", arr)); } } public void Log(List<int> arr) { if (debug_flag == true) { string shuturyoku = ""; for (int i = 0; i < arr.Count; i++) { shuturyoku += arr[i] + ","; } Console.WriteLine(shuturyoku.TrimEnd(',')); } } public void Log(List<string> arr) { if (debug_flag == true) { string shuturyoku = ""; for (int i = 0; i < arr.Count; i++) { shuturyoku += arr[i] + ","; } Console.WriteLine(shuturyoku.TrimEnd(',')); } } public void Log(List<float> arr) { if (debug_flag == true) { string shuturyoku = ""; for (int i = 0; i < arr.Count; i++) { shuturyoku += arr[i] + ","; } Console.WriteLine(shuturyoku.TrimEnd(',')); } } public void Log() { if (debug_flag == true) { Console.WriteLine("アタイイレナサイ"); } } public void FlagFalse() { debug_flag = false; } public void FlagTrue() { debug_flag = true; } } }
[["-", 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, 75, 57, 0, 121], ["-", 8, 196, 0, 57, 75, 57, 75, 57, 0, 24], ["-", 75, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["-", 75, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["-", 75, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["-", 75, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["-", 15, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["-", 75, 57, 15, 16, 31, 213, 3, 4, 0, 21], ["-", 15, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["-", 75, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 57, 75, 57, 75, 57, 15, 16, 17, 60], ["-", 75, 57, 75, 57, 15, 16, 12, 5, 0, 62], ["-", 75, 57, 75, 57, 15, 16, 12, 5, 0, 222], ["-", 8, 196, 0, 57, 75, 57, 75, 57, 0, 25], ["+", 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], ["+", 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
1,211
26
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; namespace MyProject { class Program { static void Main(string[] args) { #if Local var sw = new Stopwatch(); sw.Start(); Console.SetIn(new StreamReader("input.in")); #endif var solver = new Solver(); solver.Solve(); #if Local Console.WriteLine($"{sw.ElapsedMilliseconds}ms"); #endif } } class Solver { public void Solve() { var N = int.Parse(Console.ReadLine()); var S = Console.ReadLine(); var dic = S.GroupBy(elem => elem) .ToDictionary(elem => elem.Key, elem => elem.Count(c => c == elem.Key)); var answer = (long)dic['R'] * dic['G'] * dic['B']; foreach (var i in Enumerable.Range(0, N)) { foreach (var j in Enumerable.Range(i + 1, N - i - 1)) { var k = j + j - i; if (k >= S.Length) { continue; } if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) { answer--; } } } Console.WriteLine(answer); } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; namespace MyProject { class Program { static void Main(string[] args) { #if Local var sw = new Stopwatch(); sw.Start(); Console.SetIn(new StreamReader("input.in")); #endif var solver = new Solver(); solver.Solve(); #if Local Console.WriteLine($"{sw.ElapsedMilliseconds}ms"); #endif } } class Solver { public void Solve() { var N = int.Parse(Console.ReadLine()); var S = Console.ReadLine(); var dic = S.GroupBy(elem => elem) .ToDictionary(elem => elem.Key, elem => elem.Count(c => c == elem.Key)); var answer = (long)dic.GetValueOrDefault('R') * dic.GetValueOrDefault('G') * dic.GetValueOrDefault('B'); foreach (var i in Enumerable.Range(0, N)) { foreach (var j in Enumerable.Range(i + 1, N - i - 1)) { var k = j + j - i; if (k >= S.Length) { continue; } if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) { answer--; } } } Console.WriteLine(answer); } } }
[["-", 31, 16, 31, 74, 51, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 74, 51, 213, 63, 214, 0, 131], ["+", 31, 16, 31, 74, 51, 213, 63, 214, 141, 22], ["+", 31, 16, 31, 74, 51, 213, 3, 4, 0, 24], ["-", 31, 16, 31, 74, 51, 204, 206, 207, 0, 73], ["+", 31, 16, 31, 74, 51, 213, 3, 4, 0, 25], ["-", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 212, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 212, 0, 16, 12, 213, 3, 4, 0, 25]]
8
309
18
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Math; using static System.Console; using static exMath; using static exReadLine; class Program { static void Main(string[] args) { long N; longReadLine(out N); string S = ReadLine(); long R, G, B; R = 0; G = 0; B = 0; for (int i = 0; i < N; i++) { if (S[i] == 'R') { R++; } else if (S[i] == 'G') { G++; } else { B++; } } long ans = R * G * B; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { int k = j + (j - i); if (k >= N) continue; if (S[i] == S[j] || S[i] == S[k] || S[j] == S[k]) { ans--; } } } WriteLine(ans); // ReadLine(); } } static class exReadLine { public static void intReadLine(out int a) { a = int.Parse(ReadLine()); } public static void intReadLine(out int a, out int b) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; } public static void intReadLine(out int a, out int b, out int c) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void intReadLine(out int a, out int b, out int c, out int d) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void longReadLine(out long a) { a = long.Parse(ReadLine()); } public static void longReadLine(out long a, out long b) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; } public static void longReadLine(out long a, out long b, out long c) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void longReadLine(out long a, out long b, out long c, out long d) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static int[] intArrayReadLine() { return ReadLine().Split().Select(int.Parse).ToArray(); } public static long[] longArrayReadLine() { return ReadLine().Split().Select(long.Parse).ToArray(); } public static List<int> intListReadLine() { return ReadLine().Split().Select(int.Parse).ToList(); } public static List<long> longListReadLine() { return ReadLine().Split().Select(long.Parse).ToList(); } } static class exMath { // 最大公約数 public static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } // 最小公倍数 public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); } public static long Lcm(long a, long b) { return a * b / Gcd(a, b); } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Math; using static System.Console; using static exMath; using static exReadLine; class Program { static void Main(string[] args) { long N; longReadLine(out N); string S = ReadLine(); long R, G, B; R = 0; G = 0; B = 0; for (int i = 0; i < N; i++) { if (S[i] == 'R') { R++; } else if (S[i] == 'G') { G++; } else { B++; } } long ans = R * G * B; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { int k = j + (j - i); if (k >= N) continue; if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) { ans--; } } } WriteLine(ans); // ReadLine(); } } static class exReadLine { public static void intReadLine(out int a) { a = int.Parse(ReadLine()); } public static void intReadLine(out int a, out int b) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; } public static void intReadLine(out int a, out int b, out int c) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void intReadLine(out int a, out int b, out int c, out int d) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void longReadLine(out long a) { a = long.Parse(ReadLine()); } public static void longReadLine(out long a, out long b) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; } public static void longReadLine(out long a, out long b, out long c) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void longReadLine(out long a, out long b, out long c, out long d) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static int[] intArrayReadLine() { return ReadLine().Split().Select(int.Parse).ToArray(); } public static long[] longArrayReadLine() { return ReadLine().Split().Select(long.Parse).ToArray(); } public static List<int> intListReadLine() { return ReadLine().Split().Select(int.Parse).ToList(); } public static List<long> longListReadLine() { return ReadLine().Split().Select(long.Parse).ToList(); } } static class exMath { // 最大公約数 public static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } // 最小公倍数 public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); } public static long Lcm(long a, long b) { return a * b / Gcd(a, b); } }
[["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 79], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 79], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79]]
8
976
10
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; namespace AtCoder.D { internal static class CR { public static string GetText() { return Console.ReadLine(); } public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long GetLong() { return long.Parse(Console.ReadLine()); } public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } } public class Program { public static long N { get; private set; } public static string S { get; private set; } public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { N = CR.GetLong(); S = CR.GetText(); var r = 0; var g = 0; var b = 0; for (int i = 0; i < N; i++) { switch (S[i]) { case 'R': r++; break; case 'G': g++; break; case 'B': b++; break; default: throw new Exception(); } } var x = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { var k = j * 2 - i; if (k < N && k > j) { if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) { x++; } } } } return r * g * b - x; } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; namespace AtCoder.D { internal static class CR { public static string GetText() { return Console.ReadLine(); } public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long GetLong() { return long.Parse(Console.ReadLine()); } public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } } public class Program { public static long N { get; private set; } public static string S { get; private set; } public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { N = CR.GetLong(); S = CR.GetText(); var r = 0; var g = 0; var b = 0; for (int i = 0; i < N; i++) { switch (S[i]) { case 'R': r++; break; case 'G': g++; break; case 'B': b++; break; default: throw new Exception(); } } var x = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { var k = j * 2 - i; if (k < N && k > j) { if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) { Debug.WriteLine($"{i} {j} {k}"); x++; } } } } return (long)r * (long)g * (long)b - (long)x; } } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["+", 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], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 16, 31, 16, 31, 16, 12, 74, 0, 25], ["+", 0, 37, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 37, 0, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 37, 0, 16, 31, 16, 12, 74, 0, 25], ["+", 8, 196, 0, 37, 0, 16, 12, 74, 0, 24], ["+", 8, 196, 0, 37, 0, 16, 12, 74, 39, 199], ["+", 8, 196, 0, 37, 0, 16, 12, 74, 0, 25]]
8
399
35
using System; using System.Collections.Generic; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine(); var r_num = s.Length - s.Replace("R", "").Length; var g_num = s.Length - s.Replace("G", "").Length; var b_num = s.Length - s.Replace("B", "").Length; var sum = r_num * g_num * b_num; for (var i = 2; i < n; i++) { var a = s[i]; for (var j = (i + 1) >> 1; j < i; j++) { var b = s[j]; var c = s[j - (i - j)]; if (a != b && b != c && c != a) { sum--; } } } Console.WriteLine(sum); } } }
using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine(); long r_num = s.Length - s.Replace("R", "").Length; long g_num = s.Length - s.Replace("G", "").Length; long b_num = s.Length - s.Replace("B", "").Length; long sum = r_num * g_num * b_num; for (var ri = 2; ri < n; ri++) { var a = s[ri]; for (var ce = (ri + 1) >> 1; ce < ri; ce++) { var b = s[ce]; var c = s[ce - (ri - ce)]; if (a != b && b != c && c != a) sum--; } } Console.WriteLine(sum); } } }
[["-", 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], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
218
43
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder.Beginner162 { public class ABC162D { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); char[] S = Console.ReadLine().ToArray(); List<int> Rs = new List<int>(); List<int> Gs = new List<int>(); List<int> Bs = new List<int>(); for (int i = 0; i < N; i++) { if (S[i] == 'R') Rs.Add(i); if (S[i] == 'G') Gs.Add(i); if (S[i] == 'B') Bs.Add(i); } long cnt = Rs.Count * Gs.Count * Bs.Count; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { var k = j + (j - i); if (k >= N) { continue; } if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) { cnt--; } } } Console.WriteLine(cnt); } } }
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder.Beginner162 { public class ABC162D { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); char[] S = Console.ReadLine().ToArray(); List<int> Rs = new List<int>(); List<int> Gs = new List<int>(); List<int> Bs = new List<int>(); for (int i = 0; i < N; i++) { if (S[i] == 'R') Rs.Add(i); if (S[i] == 'G') Gs.Add(i); if (S[i] == 'B') Bs.Add(i); } long cnt = (long)Rs.Count * (long)Gs.Count * (long)Bs.Count; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { var k = j + (j - i); if (k >= N) { continue; } if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) { cnt--; } } } Console.WriteLine(cnt); } } }
[["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 212, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 212, 0, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 212, 0, 16, 31, 16, 12, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25]]
8
293
9
using System; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); char[] S = Console.ReadLine().ToArray(); int R = 0, G = 0, B = 0, ans = 0; foreach (char i in S) switch (i) { case 'R': R++; break; case 'G': G++; break; case 'B': B++; break; } for (int i = 0; i < N - 2; i++) { switch (S[i]) { case 'R': R--; break; case 'G': G--; break; case 'B': B--; break; } int Rj = R, Gj = G, Bj = B; for (int j = i + 1; j < N - 1; j++) { switch (S[j]) { case 'R': Rj--; break; case 'G': Gj--; break; case 'B': Bj--; break; } if (S[i] != S[j]) { char dst = (char)('R' + 'G' + 'B' - S[i] - S[j]); switch (dst) { case 'R': ans += Rj; break; case 'G': ans += Gj; break; case 'B': ans += Bj; break; } if (j + j - i < N && S[j + j - i] == dst) ans--; } } } Console.WriteLine(ans); } }
using System; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); char[] S = Console.ReadLine().ToArray(); int R = 0, G = 0, B = 0; foreach (char i in S) switch (i) { case 'R': R++; break; case 'G': G++; break; case 'B': B++; break; } long ans = 0; for (int i = 0; i < N - 2; i++) { switch (S[i]) { case 'R': R--; break; case 'G': G--; break; case 'B': B--; break; } int Rj = R, Gj = G, Bj = B; for (int j = i + 1; j < N - 1; j++) { switch (S[j]) { case 'R': Rj--; break; case 'G': Gj--; break; case 'B': Bj--; break; } if (S[i] != S[j]) { char dst = (char)('R' + 'G' + 'B' - S[i] - S[j]); switch (dst) { case 'R': ans += Rj; break; case 'G': ans += Gj; break; case 'B': ans += Bj; break; } if (j + j - i < N && S[j + j - i] == dst) ans--; } } } Console.WriteLine(ans); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 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], ["+", 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
355
9
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } static class Solve { public static void Answer() { var N = IO_ShortCut.ReadInt; var S = ReadLine(); var RCount = S.Where(c => c.Equals('R')).Count(); var GCount = S.Where(c => c.Equals('G')).Count(); var BCount = S.Where(c => c.Equals('B')).Count(); var Cmb = RCount * GCount * BCount; for (int i = 0; i < N; i++) { for (int j = 1; j < N; j++) { if (i - j < 0) break; if (i + j >= N) break; if (S[i] != S[i - j] && S[i] != S[i + j] && S[i - j] != S[i + j]) Cmb--; } } WriteLine(Cmb); } } static class IO_ShortCut { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); #endregion } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } static class Solve { public static void Answer() { var N = IO_ShortCut.ReadInt; var S = ReadLine(); long RCount = S.Where(c => c.Equals('R')).Count(); long GCount = S.Where(c => c.Equals('G')).Count(); long BCount = S.Where(c => c.Equals('B')).Count(); long Cmb = RCount * GCount * BCount; for (int i = 0; i < N; i++) { for (int j = 1; j <= N; j++) { if (i - j < 0) break; if (i + j > N - 1) break; if (S[i] != S[i - j] && S[i] != S[i + j] && S[i - j] != S[i + j]) Cmb--; } } WriteLine(Cmb); } } static class IO_ShortCut { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); #endregion } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
8
492
14
using System; using System.Linq; using System.Collections.Generic; namespace Contest { class Program { static void Main(string[] args) { ABC162.F(); } class ABC162 { public static void A() { var N = Read.Int(); Console.WriteLine( N % 10 == 7 || N / 100 == 7 || (N / 10) % 10 == 7 ? "Yes" : "No"); } public static void B() { var N = Read.Int(); long sum = 0; for (int i = 1; i <= N; ++i) { if (i % 3 > 0 && i % 5 > 0) { sum += i; } } Console.WriteLine(sum); } public static void C() { var K = Read.Int(); long sum = 0; for (int a = 1; a <= K; ++a) { for (int b = 1; b <= K; ++b) { for (int c = 1; c <= K; ++c) { sum += Util.GCD(a, Util.GCD(b, c)); } } } Console.WriteLine(sum); } public static void D() { var N = Read.Int(); var S = Read.Str(); var Freq = Util.Frequency(S.ToArray()); var R = Freq.ContainsKey('R') ? Freq['R'] : 0; var G = Freq.ContainsKey('G') ? Freq['G'] : 0; var B = Freq.ContainsKey('B') ? Freq['B'] : 0; long total = (long)R * G * B; if (total == 0) { Console.WriteLine(0); return; } for (int d = 1; d < 2000; ++d) { for (int s = 0; s < 4000; ++s) { var s2 = s + d; var s3 = s + d * 2; if (s3 >= N) { break; } if (S[s] != S[s2] && S[s] != S[s3] && S[s2] != S[s3]) { total--; } } } Console.WriteLine(total); } public static void E() { var N = Read.Int(); var K = Read.Long(); MOD[] counter = new MOD[K + 1]; for (long i = K; i > K / 2; --i) { counter[i] = 1; } for (long i = K / 2; i >= 1; --i) { long biggerC = 0; MOD biggerS = 0; for (int m = 2;; ++m) { var j = i * m; if (j > K) { break; } biggerC++; biggerS += counter[j]; } MOD c = biggerC + 1; counter[i] = c.Power(N) - biggerS; } MOD total = 0; for (int i = 1; i <= K; ++i) { total += i * counter[i]; } Console.WriteLine(total.V); } public static void F() { var N = Read.Int(); var A = Read.LongN(); if (N % 2 == 0) { var dp = new long[N, 2]; dp[0, 0] = A[0]; dp[2, 0] = A[0] + A[2]; dp[1, 1] = A[1]; for (int i = 3; i < N; ++i) { dp[i, 0] = dp[i - 2, 0] + A[i]; dp[i, 1] = Math.Max(dp[i - 2, 1], dp[i - 3, 0]) + A[i]; } Console.WriteLine(Math.Max(dp[N - 1, 1], dp[N - 2, 0])); } else { var dp = new long[N, 4]; dp[0, 0] = A[0]; dp[2, 0] = A[0] + A[2]; dp[1, 1] = A[1]; dp[2, 2] = A[2]; if (N > 3) { dp[3, 1] = Math.Max(A[0], A[1]) + A[3]; // dp[3, 3] = A[3]; } for (int i = 4; i < N; ++i) { dp[i, 0] = dp[i - 2, 0] + A[i]; dp[i, 1] = Math.Max(dp[i - 2, 1], dp[i - 3, 0]) + A[i]; dp[i, 2] = Math.Max(dp[i - 2, 2], Math.Max(dp[i - 3, 1], dp[i - 4, 0])) + A[i]; } Console.WriteLine( Math.Max(dp[N - 1, 2], Math.Max(dp[N - 2, 1], dp[N - 3, 0]))); } } } class Util { public static long[] ASum(long[] array) { var res = new long[array.Length + 1]; for (int i = 0; i < array.Length; ++i) { res[i + 1] = res[i] + array[i]; } return res; } public static long GCD(long a, long b) { while (b > 0) { var c = a % b; a = b; b = c; } return a; } public static Dictionary<T, int> Frequency<T>(T[] array) { var dict = new Dictionary<T, int>(); foreach (var a in array) { if (!dict.ContainsKey(a)) { dict.Add(a, 0); } dict[a]++; } return dict; } public static long Inverse(long a, long p) { long b = p, c = 1, d = 0, e = 0, f = 0; while (b != 0) { e = a / b; f = b; b = a - e * b; a = f; f = d; d = c - e * d; c = f; } c %= p; return c + (c < 0 ? p : 0); } public static long[] Facts(int n, long p) { var facts = new long[n + 1]; facts[0] = 1; for (int i = 1; i <= n; ++i) { facts[i] = (i * facts[i - 1]) % p; } return facts; } public static Func<int, int, long> Combin(int n, long P) { var fact = Facts(n, P); var inv = fact.Select(x => Inverse(x, P)).ToArray(); return (N, M) => { if (N < 0 || N < M || M < 0) { return 0; } return (((fact[N] * inv[M]) % P) * inv[N - M]) % P; }; } } struct MOD { public static long P = 1000000007; public readonly long V; public MOD(long a) { this.V = a; } public static implicit operator MOD(long a) { return new MOD(a); } public static MOD operator +(MOD a, MOD b) { return new MOD((a.V + b.V) % P); } public static MOD operator -(MOD a, MOD b) { return new MOD((a.V - b.V + P) % P); } public static MOD operator *(MOD a, MOD b) { return new MOD((a.V * b.V) % P); } public static MOD operator /(MOD a, MOD b) { return new MOD((a.V * b.Inverse().V) % P); } // public MOD Inverse() { return Util.Inverse(V, P); } public MOD Inverse() { long a = V, p = P; long b = p, c = 1, d = 0, e = 0, f = 0; while (b != 0) { e = a / b; f = b; b = a - e * b; a = f; f = d; d = c - e * d; c = f; } c %= p; return c + (c < 0 ? p : 0); } // public MOD Power(long n) { return Util.Power(V, n, P); } public MOD Power(long n) { long a = V, p = P; long res = 1; long mult = a; for (int i = 0; i < 40; ++i) { if ((n & ((long)1 << i)) > 0) { res = (res * mult) % p; } mult = (mult * mult) % p; } return res; } public override string ToString() { return V.ToString(); } } static class Read { static Queue<string> queue = new Queue<string>(); static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } } public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); } public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); } public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); } public static int[] IntN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); } public static long[] LongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); } public static string[] StrN() { return Console.ReadLine().Split(' '); } public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); } public static long[,] LongMatrix(int r, int c) { var mat = new long[r, c]; for (int i = 0; i < r; ++i) { var x = Read.LongN(); for (int j = 0; j < c; ++j) { mat[i, j] = x[j]; } } return mat; } public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M, bool isDirectional = false) { Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new HashSet<int>()); } for (int i = 0; i < M; ++i) { var ab = Read.IntN(); dict[ab[0]].Add(ab[1]); if (!isDirectional) { dict[ab[1]].Add(ab[0]); } } return dict; } public static Dictionary<int, Dictionary<int, long>> AdjacencyListWithWeight(int N, int M) { Dictionary<int, Dictionary<int, long>> dict = new Dictionary<int, Dictionary<int, long>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new Dictionary<int, long>()); } for (int i = 0; i < M; ++i) { var ab = Read.IntN(); dict[ab[0]].Add(ab[1], ab[2]); dict[ab[1]].Add(ab[0], ab[2]); } return dict; } } } }
using System; using System.Linq; using System.Collections.Generic; namespace Contest { class Program { static void Main(string[] args) { ABC162.F(); } class ABC162 { public static void A() { var N = Read.Int(); Console.WriteLine( N % 10 == 7 || N / 100 == 7 || (N / 10) % 10 == 7 ? "Yes" : "No"); } public static void B() { var N = Read.Int(); long sum = 0; for (int i = 1; i <= N; ++i) { if (i % 3 > 0 && i % 5 > 0) { sum += i; } } Console.WriteLine(sum); } public static void C() { var K = Read.Int(); long sum = 0; for (int a = 1; a <= K; ++a) { for (int b = 1; b <= K; ++b) { for (int c = 1; c <= K; ++c) { sum += Util.GCD(a, Util.GCD(b, c)); } } } Console.WriteLine(sum); } public static void D() { var N = Read.Int(); var S = Read.Str(); var Freq = Util.Frequency(S.ToArray()); var R = Freq.ContainsKey('R') ? Freq['R'] : 0; var G = Freq.ContainsKey('G') ? Freq['G'] : 0; var B = Freq.ContainsKey('B') ? Freq['B'] : 0; long total = (long)R * G * B; if (total == 0) { Console.WriteLine(0); return; } for (int d = 1; d < 2000; ++d) { for (int s = 0; s < 4000; ++s) { var s2 = s + d; var s3 = s + d * 2; if (s3 >= N) { break; } if (S[s] != S[s2] && S[s] != S[s3] && S[s2] != S[s3]) { total--; } } } Console.WriteLine(total); } public static void E() { var N = Read.Int(); var K = Read.Long(); MOD[] counter = new MOD[K + 1]; for (long i = K; i > K / 2; --i) { counter[i] = 1; } for (long i = K / 2; i >= 1; --i) { long biggerC = 0; MOD biggerS = 0; for (int m = 2;; ++m) { var j = i * m; if (j > K) { break; } biggerC++; biggerS += counter[j]; } MOD c = biggerC + 1; counter[i] = c.Power(N) - biggerS; } MOD total = 0; for (int i = 1; i <= K; ++i) { total += i * counter[i]; } Console.WriteLine(total.V); } public static void F() { var N = Read.Int(); var A = Read.LongN(); if (N % 2 == 0) { if (N == 2) { Console.WriteLine(Math.Max(A[0], A[1])); return; } var dp = new long[N, 2]; dp[0, 0] = A[0]; dp[2, 0] = A[0] + A[2]; dp[1, 1] = A[1]; for (int i = 3; i < N; ++i) { dp[i, 0] = dp[i - 2, 0] + A[i]; dp[i, 1] = Math.Max(dp[i - 2, 1], dp[i - 3, 0]) + A[i]; } Console.WriteLine(Math.Max(dp[N - 1, 1], dp[N - 2, 0])); } else { var dp = new long[N, 4]; dp[0, 0] = A[0]; dp[2, 0] = A[0] + A[2]; dp[1, 1] = A[1]; dp[2, 2] = A[2]; if (N > 3) { dp[3, 1] = Math.Max(A[0], A[1]) + A[3]; // dp[3, 3] = A[3]; } for (int i = 4; i < N; ++i) { dp[i, 0] = dp[i - 2, 0] + A[i]; dp[i, 1] = Math.Max(dp[i - 2, 1], dp[i - 3, 0]) + A[i]; dp[i, 2] = Math.Max(dp[i - 2, 2], Math.Max(dp[i - 3, 1], dp[i - 4, 0])) + A[i]; } Console.WriteLine( Math.Max(dp[N - 1, 2], Math.Max(dp[N - 2, 1], dp[N - 3, 0]))); } } } class Util { public static long[] ASum(long[] array) { var res = new long[array.Length + 1]; for (int i = 0; i < array.Length; ++i) { res[i + 1] = res[i] + array[i]; } return res; } public static long GCD(long a, long b) { while (b > 0) { var c = a % b; a = b; b = c; } return a; } public static Dictionary<T, int> Frequency<T>(T[] array) { var dict = new Dictionary<T, int>(); foreach (var a in array) { if (!dict.ContainsKey(a)) { dict.Add(a, 0); } dict[a]++; } return dict; } public static long Inverse(long a, long p) { long b = p, c = 1, d = 0, e = 0, f = 0; while (b != 0) { e = a / b; f = b; b = a - e * b; a = f; f = d; d = c - e * d; c = f; } c %= p; return c + (c < 0 ? p : 0); } public static long[] Facts(int n, long p) { var facts = new long[n + 1]; facts[0] = 1; for (int i = 1; i <= n; ++i) { facts[i] = (i * facts[i - 1]) % p; } return facts; } public static Func<int, int, long> Combin(int n, long P) { var fact = Facts(n, P); var inv = fact.Select(x => Inverse(x, P)).ToArray(); return (N, M) => { if (N < 0 || N < M || M < 0) { return 0; } return (((fact[N] * inv[M]) % P) * inv[N - M]) % P; }; } } struct MOD { public static long P = 1000000007; public readonly long V; public MOD(long a) { this.V = a; } public static implicit operator MOD(long a) { return new MOD(a); } public static MOD operator +(MOD a, MOD b) { return new MOD((a.V + b.V) % P); } public static MOD operator -(MOD a, MOD b) { return new MOD((a.V - b.V + P) % P); } public static MOD operator *(MOD a, MOD b) { return new MOD((a.V * b.V) % P); } public static MOD operator /(MOD a, MOD b) { return new MOD((a.V * b.Inverse().V) % P); } // public MOD Inverse() { return Util.Inverse(V, P); } public MOD Inverse() { long a = V, p = P; long b = p, c = 1, d = 0, e = 0, f = 0; while (b != 0) { e = a / b; f = b; b = a - e * b; a = f; f = d; d = c - e * d; c = f; } c %= p; return c + (c < 0 ? p : 0); } // public MOD Power(long n) { return Util.Power(V, n, P); } public MOD Power(long n) { long a = V, p = P; long res = 1; long mult = a; for (int i = 0; i < 40; ++i) { if ((n & ((long)1 << i)) > 0) { res = (res * mult) % p; } mult = (mult * mult) % p; } return res; } public override string ToString() { return V.ToString(); } } static class Read { static Queue<string> queue = new Queue<string>(); static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } } public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); } public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); } public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); } public static int[] IntN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); } public static long[] LongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); } public static string[] StrN() { return Console.ReadLine().Split(' '); } public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); } public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); } public static long[,] LongMatrix(int r, int c) { var mat = new long[r, c]; for (int i = 0; i < r; ++i) { var x = Read.LongN(); for (int j = 0; j < c; ++j) { mat[i, j] = x[j]; } } return mat; } public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M, bool isDirectional = false) { Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new HashSet<int>()); } for (int i = 0; i < M; ++i) { var ab = Read.IntN(); dict[ab[0]].Add(ab[1]); if (!isDirectional) { dict[ab[1]].Add(ab[0]); } } return dict; } public static Dictionary<int, Dictionary<int, long>> AdjacencyListWithWeight(int N, int M) { Dictionary<int, Dictionary<int, long>> dict = new Dictionary<int, Dictionary<int, long>>(); for (int i = 0; i <= N; ++i) { dict.Add(i, new Dictionary<int, long>()); } for (int i = 0; i < M; ++i) { var ab = Read.IntN(); dict[ab[0]].Add(ab[1], ab[2]); dict[ab[1]].Add(ab[0], ab[2]); } return dict; } } } }
[["+", 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], ["+", 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], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 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, 21], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 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
3,005
30
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Threading.Tasks; using AtCoderBeginnerContest161.Questions; using AtCoderBeginnerContest161.Extensions; namespace AtCoderBeginnerContest161 { class Program { static void Main(string[] args) { IAtCoderQuestion question = new QuestionA(); // 問題に合わせて書き換え var answer = question.Solve(Console.In); Console.WriteLine(answer); } } } namespace AtCoderBeginnerContest161.Questions { // ここにQuestionクラスをコピペ public class QuestionA : AtCoderQuestionBase { public override IEnumerable<string> Solve(TextReader inputStream) { var n = inputStream.ReadIntArray(); Swap(ref n[0], ref n[1]); Swap(ref n[0], ref n[2]); yield return $"{n[0]} {n[1]} {n[2]}"; } private void Swap(ref int a, ref int b) { int temp = b; b = a; a = temp; } } #region Base Classes public interface IAtCoderQuestion { IEnumerable<string> Solve(string input); IEnumerable<string> Solve(TextReader inputStream); } public abstract class AtCoderQuestionBase : IAtCoderQuestion { public IEnumerable<string> Solve(string input) { var stream = new MemoryStream(Encoding.Unicode.GetBytes(input)); var reader = new StreamReader(stream, Encoding.Unicode); return Solve(reader); } public abstract IEnumerable<string> Solve(TextReader inputStream); } #endregion } #region Extensions namespace AtCoderBeginnerContest161.Extensions { internal static class TextReaderExtensions { internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader)); internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader)); internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader)); internal static string ReadString(this TextReader reader) => reader.ReadLine(); internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray(); internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray(); internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray(); internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator); } } #endregion
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Threading.Tasks; using AtCoderBeginnerContest161.Questions; using AtCoderBeginnerContest161.Extensions; namespace AtCoderBeginnerContest161 { class Program { static void Main(string[] args) { IAtCoderQuestion question = new QuestionA(); // 問題に合わせて書き換え var answers = question.Solve(Console.In); foreach (var answer in answers) { Console.WriteLine(answer); } } } } namespace AtCoderBeginnerContest161.Questions { // ここにQuestionクラスをコピペ public class QuestionA : AtCoderQuestionBase { public override IEnumerable<string> Solve(TextReader inputStream) { var n = inputStream.ReadIntArray(); Swap(ref n[0], ref n[1]); Swap(ref n[0], ref n[2]); yield return $"{n[0]} {n[1]} {n[2]}"; } private void Swap(ref int a, ref int b) { int temp = b; b = a; a = temp; } } #region Base Classes public interface IAtCoderQuestion { IEnumerable<string> Solve(string input); IEnumerable<string> Solve(TextReader inputStream); } public abstract class AtCoderQuestionBase : IAtCoderQuestion { public IEnumerable<string> Solve(string input) { var stream = new MemoryStream(Encoding.Unicode.GetBytes(input)); var reader = new StreamReader(stream, Encoding.Unicode); return Solve(reader); } public abstract IEnumerable<string> Solve(TextReader inputStream); } #endregion } #region Extensions namespace AtCoderBeginnerContest161.Extensions { internal static class TextReaderExtensions { internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader)); internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader)); internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader)); internal static string ReadString(this TextReader reader) => reader.ReadLine(); internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray(); internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray(); internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray(); internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator); } } #endregion
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 24], ["+", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 25], ["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46]]
8
538
11
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long bmod = 1000000007; static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static void Solve() { string S = GetStr(); var ans = (S[0] == S[1] && S[2] == S[3] && S[4] == S[5]).YesNo(); Console.WriteLine(ans); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; namespace AtCoder { partial class Program { static long bmod = 1000000007; static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(); Console.Out.Flush(); Console.ReadKey(); } //ここから static void Solve() { string S = GetStr(); var ans = (S[2] == S[3] && S[4] == S[5]).YesNo(); Console.WriteLine(ans); } } //拡張メソッド public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); } public static string yesno(this bool b) { return b ? "yes" : "no"; } public static string YesNo(this bool b) { return b ? "Yes" : "No"; } public static string YESNO(this bool b) { return b ? "YES" : "NO"; } } partial class Program { static public string GetStr() { return Console.ReadLine().Trim(); } static public char GetChar() { return Console.ReadLine().Trim()[0]; } static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } static public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } static public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } static public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } static public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } static public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } static public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } static public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } static public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } static public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } static public void WriteObjects<T>(IReadOnlyCollection<T> values) { var array = values.ToArray(); var num = array.Length; if (num == 0) return; Console.Write(array[0]); for (int i = 1; i < num; i++) { Console.Write(" " + array[i]); } Console.WriteLine(); } static bool eq<T, U>() => typeof(T).Equals(typeof(U)); static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); static void Multi<T>(out T a) => a = cv<T>(GetStr()); static void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } static void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } }
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 205, 23, 0, 16, 31, 16, 31, 16, 17, 60], ["-", 0, 16, 31, 16, 31, 16, 12, 204, 205, 22], ["-", 31, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["-", 63, 214, 205, 23, 0, 16, 31, 16, 17, 98], ["-", 0, 16, 31, 16, 12, 16, 31, 204, 205, 22], ["-", 31, 16, 12, 16, 31, 204, 206, 207, 0, 70]]
8
1,508
10
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var X = int.Parse(Console.ReadLine()); Console.WriteLine(Logic(X)); } private static int Logic(int X) { var remain = X; var Happiness = 0; foreach (var coin in Coins) { do { remain -= coin.Key; Happiness += coin.Value; } while (remain >= coin.Key); } return Happiness; } private static Dictionary<int, int> Coins = new Dictionary<int, int> { { 500, 1000 }, { 5, 5 }, { 1, 0 } }; } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var X = int.Parse(Console.ReadLine()); Console.WriteLine(Logic(X)); } private static int Logic(int X) { var remain = X; var Happiness = 0; foreach (var coin in Coins) { while (remain >= coin.Key) { remain -= coin.Key; Happiness += coin.Value; } } return Happiness; } private static Dictionary<int, int> Coins = new Dictionary<int, int> { { 500, 1000 }, { 5, 5 }, { 1, 0 } }; } }
[["-", 8, 196, 0, 210, 8, 196, 0, 82, 0, 170], ["+", 8, 196, 0, 210, 8, 196, 0, 52, 0, 89], ["+", 8, 196, 0, 210, 8, 196, 0, 52, 0, 24], ["+", 0, 210, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 210, 8, 196, 0, 52, 15, 16, 17, 20], ["+", 8, 196, 0, 52, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 52, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 52, 15, 16, 12, 214, 141, 22], ["+", 8, 196, 0, 210, 8, 196, 0, 52, 0, 25], ["-", 8, 196, 0, 210, 8, 196, 0, 82, 0, 89], ["-", 8, 196, 0, 210, 8, 196, 0, 82, 0, 24], ["-", 0, 210, 8, 196, 0, 82, 15, 16, 31, 22], ["-", 0, 210, 8, 196, 0, 82, 15, 16, 17, 20], ["-", 8, 196, 0, 82, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 82, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 82, 15, 16, 12, 214, 141, 22], ["-", 8, 196, 0, 210, 8, 196, 0, 82, 0, 25], ["-", 8, 196, 0, 210, 8, 196, 0, 82, 0, 35]]
8
156
18
using System; namespace abc160_1 { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine().Trim()); var happy = 0; happy += (int)Math.Floor((double)n / 500); happy += (int)Math.Floor((double)(n % 500) / 5); Console.WriteLine(happy); } } }
using System; namespace abc160_1 { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine().Trim()); var happy = 0; happy += (int)(n / 500) * 1000; happy += (int)(n % 500 / 5) * 5; Console.WriteLine(happy); } } }
[["-", 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], ["-", 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], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25], ["-", 0, 11, 12, 74, 51, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 16, 31, 74, 51, 23, 0, 25]]
8
90
18
using System; using System.Collections.Generic; using System.IO; using System.Text; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(" "); var K = int.Parse(input[0]); var N = int.Parse(input[1]); var A = new List<int>(); var line = Console.ReadLine().Split(" "); for (int i = 0; i < N; i++) { A.Add(int.Parse(line[i])); } var min = K - Math.Abs(A[N - 1] - K + A[0]); for (int i = 0; i < N - 1; i++) { var distance = K - Math.Abs(A[i + 1] - A[i]); if (min > distance) min = distance; } Console.WriteLine(min); } }
using System; using System.Collections.Generic; using System.IO; using System.Text; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(" "); var K = int.Parse(input[0]); var N = int.Parse(input[1]); var A = new List<int>(); var line = Console.ReadLine().Split(" "); for (int i = 0; i < N; i++) { A.Add(int.Parse(line[i])); } var min = K - (K - A[N - 1] + A[0]); for (int i = 0; i < N - 1; i++) { var distance = K - (A[i + 1] - A[i]); if (min > distance) min = distance; } Console.WriteLine(min); } }
[["-", 0, 212, 0, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 212, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22]]
8
216
10
using System; using System.Linq; using System.Collections.Generic; using static System.Console; class Program { static void Main() { var input = ReadLine().Split(' ').Select(int.Parse).ToArray(); var x = input[0]; var y = input[1]; var lake = ReadLine().Split(' ').Select(int.Parse).ToArray(); var road = new int[y]; for (var i = 0; i < y - 1; i++) { var t = lake[i] - road[i + 1]; road[i] = t; } road[y - 1] = lake[0] + x - lake[y - 1]; var z = road.Max(); Write(x - z); } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; class Program { static void Main() { var input = ReadLine().Split(' ').Select(int.Parse).ToArray(); var x = input[0]; var y = input[1]; var lake = ReadLine().Split(' ').Select(int.Parse).ToArray(); var road = new int[y]; for (var i = 0; i < y - 1; i++) { var t = lake[i + 1] - lake[i]; road[i] = t; } road[y - 1] = lake[0] + x - lake[y - 1]; var z = road.Max(); Write(x - z); } }
[["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
184
6
using System; using System.Linq; using System.Collections.Generic; namespace cs { class Program { static void Main(string[] args) { var pg = new Program(); pg.Execute(); } private void Execute() { var input = ReadLinesLongList; var ALists = ReadLinesLongList.ToList(); var K = input.ElementAt(0); var N = input.ElementAt(1); var subList = new List<long>(); for (int i = 0; i < ALists.Count() - 1; i++) { subList.Add(ALists[i + 1] - ALists[i]); } if (ALists.First() == 0) { ALists[0] = K; } subList.Add(Math.Abs(ALists.Last() - ALists.First())); var max = subList.Max(); OutputResult(subList.Sum() - max); } private void OutputResult<Type>(Type result) { Console.WriteLine(result); } static long ReadLineLong => long.Parse(Console.ReadLine()); static string ReadLineString => Console.ReadLine(); static IEnumerable<long> ReadLinesLongList => Console.ReadLine().Split(' ').Select(i => long.Parse(i)); static IEnumerable<string> ReadLinesStringList => Console.ReadLine().Split(' '); } }
using System; using System.Linq; using System.Collections.Generic; namespace cs { class Program { static void Main(string[] args) { var pg = new Program(); pg.Execute(); } private void Execute() { var input = ReadLinesLongList; var ALists = ReadLinesLongList.ToList(); var K = input.ElementAt(0); var N = input.ElementAt(1); var subList = new List<long>(); for (int i = 0; i < ALists.Count() - 1; i++) { subList.Add(ALists[i + 1] - ALists[i]); } subList.Add(K - ALists.Last() + ALists.First()); var max = subList.Max(); OutputResult(subList.Sum() - max); } private void OutputResult<Type>(Type result) { Console.WriteLine(result); } static long ReadLineLong => long.Parse(Console.ReadLine()); static string ReadLineString => Console.ReadLine(); static IEnumerable<long> ReadLinesLongList => Console.ReadLine().Split(' ').Select(i => long.Parse(i)); static IEnumerable<string> ReadLinesStringList => Console.ReadLine().Split(' '); } }
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["-", 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, 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], ["-", 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], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
8
296
28
using System; using System.Collections.Generic; public class TravelLake { public static void Main() { var input = Console.ReadLine().Split(' '); var total = int.Parse(input[0]); var house = int.Parse(input[1]); int distance = 0; int distance_r = 0; int distance_o = 0; int min = 0; var house_number = Console.ReadLine().Split(' '); for (var i = 0; i < house; i++) { if (i == 0) { distance = int.Parse(house_number[house - 1]) - int.Parse(house_number[i]); min = distance; distance = Math.Abs(int.Parse(house_number[1]) - total); } else { distance_r = (total - int.Parse(house_number[i]) + int.Parse(house_number[i - 1])); if (i != house - 1) { distance_o = int.Parse(house_number[i]) + total - int.Parse(house_number[i + 1]); } else { distance_o = int.Parse(house_number[i - 1]) + total - int.Parse(house_number[i]); } distance = ((distance_r > distance_o) ? distance_o : distance_r); } if (min > distance) { min = distance; } } Console.WriteLine(min); } }
using System; using System.Collections.Generic; public class TravelLake { public static void Main() { var input = Console.ReadLine().Split(' '); var total = int.Parse(input[0]); var house = int.Parse(input[1]); int distance = 0; int distance_r = 0; int distance_o = 0; int min = 0; var house_number = Console.ReadLine().Split(' '); for (var i = 0; i < house; i++) { if (i == 0) { distance = int.Parse(house_number[house - 1]) - int.Parse(house_number[i]); min = distance; distance = int.Parse(house_number[0]) + total - int.Parse(house_number[1]); } else { distance_r = (total - int.Parse(house_number[i]) + int.Parse(house_number[i - 1])); if (i != house - 1) { distance_o = int.Parse(house_number[i]) + total - int.Parse(house_number[i + 1]); } else { distance_o = int.Parse(house_number[i - 1]) + total - int.Parse(house_number[i]); } distance = ((distance_r > distance_o) ? distance_o : distance_r); } if (min > distance) { min = distance; } } Console.WriteLine(min); } }
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 12, 16, 31, 16, 31, 213, 63, 214, 205, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 12, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 12, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
8
301
15
using System; namespace AtCorder1 { class AtCorder160C { static void Main(string[] args) { string[] line = System.Console.ReadLine().Trim().Split(' '); var lakePerim = int.Parse(line[0]); var houseNum = int.Parse(line[1]); string[] meterFrmLake = System.Console.ReadLine().Trim().Split(' '); int meterBtwHouse = 0; int meterMax = 0; //二軒の家の間の距離が最も遠いものを求める(そこから反対周りに回ればよい) for (int i = 0; i < houseNum - 1; i++) { meterBtwHouse = int.Parse(meterFrmLake[i + 1]) - int.Parse(meterFrmLake[i]); if (meterBtwHouse > meterMax) { meterMax = meterBtwHouse; } } //配列の最後と最初の家の距離を求める int lastToFirst = lakePerim - int.Parse(meterFrmLake[houseNum - 1] + int.Parse(meterFrmLake[0])); if (lastToFirst > meterMax) { meterMax = lastToFirst; } Console.WriteLine(lakePerim - meterMax); } } }
using System; namespace AtCorder1 { class AtCorder160C { static void Main(string[] args) { string[] line = System.Console.ReadLine().Trim().Split(' '); var lakePerim = int.Parse(line[0]); var houseNum = int.Parse(line[1]); string[] meterFrmLake = System.Console.ReadLine().Trim().Split(' '); int meterMax = 0; //二軒の家の間の距離が最も遠いものを求める(そこから反対周りに回ればよい) for (int i = 0; i < houseNum - 1; i++) { int meterBtwHouse = int.Parse(meterFrmLake[i + 1]) - int.Parse(meterFrmLake[i]); if (meterBtwHouse > meterMax) { meterMax = meterBtwHouse; } } //配列の最後と最初の家の距離を求める int lastToFirst = lakePerim - int.Parse(meterFrmLake[houseNum - 1]) + int.Parse(meterFrmLake[0]); if (lastToFirst > meterMax) { meterMax = lastToFirst; } Console.WriteLine(lakePerim - meterMax); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
8
210
8
using System; using System.Collections.Generic; using System.Linq; class Ho { static void Main() { var aho = Console.ReadLine().Split(); var K = int.Parse(aho[0]); var N = int.Parse(aho[1]); var baka = Console.ReadLine().Split(); var a = new List<int>(); foreach (var ba in baka) { a.Add(int.Parse(ba)); } int saidai = a.Max(); int saigo = K - saidai; int atumari = 0; var deka = 0; atumari += saigo; for (var i = 0; i < a.Count - 1; i++) { atumari += a[i + 1] - a[i]; if ((a[i + 1] - a[i]) > deka) { deka = a[i + 1] - a[i]; } } if (deka > saigo) { Console.WriteLine(K - deka); } else { Console.WriteLine(K - saigo); } } }
using System; using System.Collections.Generic; using System.Linq; class Ho { static void Main() { var aho = Console.ReadLine().Split(); var K = int.Parse(aho[0]); var N = int.Parse(aho[1]); var baka = Console.ReadLine().Split(); var a = new List<int>(); foreach (var ba in baka) { a.Add(int.Parse(ba)); } int saidai = a.Max(); int saisyou = a.Min(); int saigo = K - saidai + saisyou; int atumari = 0; var deka = 0; atumari += saigo; for (var i = 0; i < a.Count - 1; i++) { atumari += a[i + 1] - a[i]; if ((a[i + 1] - a[i]) > deka) { deka = a[i + 1] - a[i]; } } if (deka > saigo) { Console.WriteLine(K - deka); } else { Console.WriteLine(K - saigo); } } }
[["+", 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], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
8
237
11