buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // https://atcoder.jp/contests/abc083/tasks/abc083_b class Abc_083_B { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int n = inputLongArray[0]; int a = inputLongArray[1]; int b = inputLongArray[2]; int result = 0; for (int i = 0; i < n; i++) { int sum = findSumOfDigits(n); if (sum >= a && sum <= b) { result += i; } } Console.WriteLine(result); Console.Out.Flush(); } // 各桁の和を計算する関数 private static int findSumOfDigits(int n) { int sum = 0; while (n > 0) { // n が 0 になるまで sum += n % 10; n /= 10; } return sum; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // https://atcoder.jp/contests/abc083/tasks/abc083_b class Abc_083_B { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int n = inputLongArray[0]; int a = inputLongArray[1]; int b = inputLongArray[2]; int result = 0; for (int i = 0; i <= n; i++) { int sum = findSumOfDigits(i); if (sum >= a && sum <= b) { result += i; } } Console.WriteLine(result); Console.Out.Flush(); } // 各桁の和を計算する関数 private static int findSumOfDigits(int n) { int sum = 0; while (n > 0) { // n が 0 になるまで sum += n % 10; n /= 10; } return sum; } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22]]
8
234
4
using System; namespace test { class atcorder123 { static void Main(string[] args) { int a, b, c; string[] str = Console.ReadLine().Split(' '); a = int.Parse(str[0]); b = int.Parse(str[1]); c = int.Parse(str[2]); int n = 0; for (int x = 1; x <= a; ++x) { int p = x; int q = p % 10; while (p >= 10) { p = p / 10; q = q + p % 10; } if (b <= q && q <= c) { n = n + q; } } Console.WriteLine(n); } } }
using System; namespace test { class atcorder123 { static void Main(string[] args) { int a, b, c; string[] str = Console.ReadLine().Split(' '); a = int.Parse(str[0]); b = int.Parse(str[1]); c = int.Parse(str[2]); int n = 0; for (int x = 1; x <= a; ++x) { int p = x; int q = p % 10; while (p >= 10) { p = p / 10; q = q + p % 10; } if (b <= q && q <= c) { n = n + x; } } Console.WriteLine(n); } } }
[["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
8
163
2
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main() { var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList(); var result = 0; for (int i = 1; i < input[0] + 1; i++) { var str = i.ToString(); var sum = 0; for (int j = 0; j < str.Length; j++) { sum += int.Parse(str.Substring(j, 1)); } if (sum >= input[1] && sum <= input[2]) { result += sum; } } Console.WriteLine(result); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main() { var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList(); var result = 0; for (int i = 1; i < input[0] + 1; i++) { var str = i.ToString(); var sum = 0; for (int j = 0; j < str.Length; j++) { sum += int.Parse(str.Substring(j, 1)); } if (sum >= input[1] && sum <= input[2]) { result += i; } } Console.WriteLine(result); } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
8
161
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Practice { class Program { static void Main(string[] args) { SolveA(); // SolveB(); // SolveC(); // SolveD(); } private const long MOD = 1000000007; static void SolveA() { var o = ReadAndParseIntArr(); int n = o[0]; int a = o[1]; int b = o[2]; Console.WriteLine(Calc(n, a, b)); } private static long Calc(int n, int a, int b) { long total = 0; for (int x = 0; x <= 9; ++x) { for (int y = 0; y <= 9; ++y) { for (int z = 0; z <= 9; ++z) { for (int w = 0; w <= 9; ++w) { int num = 1000 * x + 100 * y + 10 * z + w; if (num <= 0 || n < num) { continue; } int sum = x + y + z + w; if (a <= sum && sum <= b) { total += num; } } } } } if (a <= 1 && 1 <= b) { total += 10000; } return total; } #region よく使う便利関数 private static bool isPrime(long x) { if (x == 2) { return true; } if (x < 2 || x % 2 == 0) { return false; } long i = 3; while (i * i <= x) { if (x % i == 0) { return false; } i = i + 2; } return true; } private static long lcm(long x, long y) { return x / gcd(x, y) * y; } private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; } private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); } private static int[] ReadAndParseIntArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } private static long ReadAndParseLong() { return long.Parse(Console.ReadLine()); } private static long[] ReadAndParseLongArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } #endregion } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Practice { class Program { static void Main(string[] args) { SolveA(); // SolveB(); // SolveC(); // SolveD(); } private const long MOD = 1000000007; static void SolveA() { var o = ReadAndParseIntArr(); int n = o[0]; int a = o[1]; int b = o[2]; Console.WriteLine(Calc(n, a, b)); } private static long Calc(int n, int a, int b) { long total = 0; for (int x = 0; x <= 9; ++x) { for (int y = 0; y <= 9; ++y) { for (int z = 0; z <= 9; ++z) { for (int w = 0; w <= 9; ++w) { int num = 1000 * x + 100 * y + 10 * z + w; if (num <= 0 || n < num) { continue; } int sum = x + y + z + w; if (a <= sum && sum <= b) { total += num; } } } } } if (a <= 1 && 1 <= b && 10000 <= n) { total += 10000; } return total; } #region よく使う便利関数 private static bool isPrime(long x) { if (x == 2) { return true; } if (x < 2 || x % 2 == 0) { return false; } long i = 3; while (i * i <= x) { if (x % i == 0) { return false; } i = i + 2; } return true; } private static long lcm(long x, long y) { return x / gcd(x, y) * y; } private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; } private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); } private static int[] ReadAndParseIntArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } private static long ReadAndParseLong() { return long.Parse(Console.ReadLine()); } private static long[] ReadAndParseLongArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } #endregion } }
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
8
507
4
using System; using System.IO; class Solve { static void Main(string[] args) { var arr = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); long X = arr[0], Y = arr[1]; var answer = 1; while (X <= Y) { X *= 2; answer++; } var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(answer); Console.Out.Flush(); } }
using System; using System.IO; class Solve { static void Main(string[] args) { var arr = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); long X = arr[0], Y = arr[1]; var answer = 0; while (X <= Y) { X *= 2; answer++; } var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(answer); Console.Out.Flush(); } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
120
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC_C { class C083 { static void Main(string[] args) { string[] a0 = Console.ReadLine().Split(' '); long X = long.Parse(a0[0]), Y = long.Parse(a0[1]); long z = Y / X; // int max = (int)Math.Log(z, 2) + 1; int max = Log(2, z); Console.WriteLine(max); } //整数限定で厳密なLog(小数点以下切り捨て) // Math.Logは浮動小数演算による誤差が発生しうるので代替手段 public static int Log(int a, long n) { long x = 1; int counter = 0; while (x < n) { x *= a; counter++; } return counter; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC_C { class C083 { static void Main(string[] args) { string[] a0 = Console.ReadLine().Split(' '); long X = long.Parse(a0[0]), Y = long.Parse(a0[1]); long z = Y / X; // int max = (int)Math.Log(z, 2) + 1; int max = Log(2, z) + 1; Console.WriteLine(max); } //整数限定で厳密なLog(小数点以下切り捨て) // Math.Logは浮動小数演算による誤差が発生しうるので代替手段 public static int Log(int a, long n) { long x = 1; int counter = 0; while (x <= n) { x *= a; counter++; } return counter - 1; } } }
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 17, 33], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 12, 203]]
8
157
6
using System; class Program { static void Main() { string[] input = Console.ReadLine().Split( ' '); // Splitで区切り文字を指定して複数個受け取る。 int x = int.Parse(input[0]); int y = int.Parse(input[1]); int answer = 1; while (true) { if (x * 2 <= y) { x *= 2; answer++; } else break; } Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。 } }
using System; class Program { static void Main() { string[] input = Console.ReadLine().Split( ' '); // Splitで区切り文字を指定して複数個受け取る。 long x = long.Parse(input[0]); long y = long.Parse(input[1]); int answer = 1; while (true) { if (x * 2 <= y) { x *= 2; answer++; } else break; } Console.WriteLine(answer); // WriteLineをWriteとすると、改行なしで出力。 } }
[["-", 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
98
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC083C { class Program { static void Main(string[] args) { long[] input = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); long X = input[0]; long Y = input[1]; int answer = 0; while (X < Y) { answer++; X = X * 2; } Console.WriteLine(answer); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC083C { class Program { static void Main(string[] args) { long[] input = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); long X = input[0]; long Y = input[1]; int answer = 0; while (X <= Y) { answer++; X = X * 2; } Console.WriteLine(answer); } } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19]]
8
125
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace dwacon { class Program { static void Main(string[] args) { var read = Console.ReadLine(); var split = read.Split(' '); long a = long.Parse(split[0]); long b = long.Parse(split[1]); long looking = a; int output = 1; while (true) { if (looking * 2 < b) { looking *= 2; output++; } else break; } Console.WriteLine(output); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace dwacon { class Program { static void Main(string[] args) { var read = Console.ReadLine(); var split = read.Split(' '); long a = long.Parse(split[0]); long b = long.Parse(split[1]); long looking = a; int output = 1; while (true) { if (looking * 2 <= b) { looking *= 2; output++; } else break; } Console.WriteLine(output); } } }
[["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 19]]
8
136
2
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var s = ReadLine(); var N = s.Length; var ans = long.MaxValue / 2; for (var i = 0; i < N - 1; ++i) if (s[i] != s[i + 1]) ans = Min(ans, Max(i + 1, N - (i + 1))); WriteLine(ans); } static long Mod = (long)1e9 + 7; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var s = ReadLine(); var N = s.Length; var ans = N; for (var i = 0; i < N - 1; ++i) if (s[i] != s[i + 1]) ans = Min(ans, Max(i + 1, N - (i + 1))); WriteLine(ans); } static long Mod = (long)1e9 + 7; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
[["-", 0, 200, 0, 212, 0, 16, 31, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22]]
8
456
6
using System; public class Hello { public static void Main() { var s = Console.ReadLine().Trim(); var sL = s.Length; if (sL == 1) Console.WriteLine(1); else if (sL == 2) Console.WriteLine(check2(s)); else { var a = sL / 2; if (sL % 2 == 0) Console.WriteLine(a + check0(s, a)); else Console.WriteLine((sL + check1(s, a)) / 2); } } static int check2(string s) => s[0] == s[1] ? 2 : 1; static int check1(string s, int a) { var s0 = s[a]; var count = 1; for (int i = 1; i <= a; i++) { if (s[a - i] == s0 && s[a + i] == s0) count += 2; else return count; } return count; } static int check0(string s, int a) { if (s[a - 1] != s[a]) return 0; var s0 = s[a - 1]; var count = 2; for (int i = 1; i < a; i++) { if (s[a + i] == s0 && s[a - 1 - i] == s0) count++; else return count; } return count; } }
using System; public class Hello { public static void Main() { var s = Console.ReadLine().Trim(); var sL = s.Length; if (sL == 1) Console.WriteLine(1); else if (sL == 2) Console.WriteLine(check2(s)); else { var a = sL / 2; if (sL % 2 == 0) Console.WriteLine(a + check0(s, a)); else Console.WriteLine((sL + check1(s, a)) / 2); } } static int check2(string s) => s[0] == s[1] ? 2 : 1; static int check1(string s, int a) { var s0 = s[a]; var count = 1; for (int i = 1; i <= a; i++) { if (s[a - i] == s0 && s[a + i] == s0) count += 2; else return count; } return count; } static int check0(string s, int a) { if (s[a - 1] != s[a]) return 0; var s0 = s[a - 1]; var count = 1; for (int i = 1; i < a; i++) { if (s[a + i] == s0 && s[a - 1 - i] == s0) count++; else return count; } return count; } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
303
2
using System; using System.Collections.Generic; using static Assistant.Input; using static Assistant.Debug; using System.Linq; using Assistant; namespace ABC083D_2 { class Program { static void Main(string[] args) { var S = Console.ReadLine(); int min = int.MaxValue; for (int i = 0; i < S.Length - 1; i++) { if (S[i] != S[i + 1]) { int f = i + 1; int t = S.Length - i - 1; min = Math.Min(min, Math.Max(f, t)); } } if (min == int.MaxValue) min = 0; Console.WriteLine(min); } } } namespace Assistant { static class Input { static List<string> line = new List<string>(); static int index = 0; static String ReadNext() { if (line.Count <= index) line.AddRange(Console.ReadLine().Split()); return line[index++]; } public static int ReadInt => int.Parse(ReadNext()); public static long ReadLong => long.Parse(ReadNext()); public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).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; namespace ABC083D_2 { class Program { static void Main(string[] args) { var S = Console.ReadLine(); int min = int.MaxValue; for (int i = 0; i < S.Length - 1; i++) { if (S[i] != S[i + 1]) { int f = i + 1; int t = S.Length - i - 1; min = Math.Min(min, Math.Max(f, t)); } } if (min == int.MaxValue) min = S.Length; Console.WriteLine(min); } } } namespace Assistant { static class Input { static List<string> line = new List<string>(); static int index = 0; static String ReadNext() { if (line.Count <= index) line.AddRange(Console.ReadLine().Split()); return line[index++]; } public static int ReadInt => int.Parse(ReadNext()); public static long ReadLong => long.Parse(ReadNext()); public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).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, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 1, 0, 11, 12, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 11, 12, 214, 141, 22]]
8
611
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class Contest { public static void Main() { int n; string s; // MyIO.ReadMulti(out n); MyIO.ReadMulti(out s); int ans = s.Length; if (s.Length % 2 == 0) { int left = 0; int right = 0; if (s[s.Length / 2 - 1] == s[s.Length / 2]) { for (int i = s.Length / 2; i < s.Length; i++) { if (s[s.Length / 2] == s[i]) { right++; } else { break; } } for (int i = s.Length / 2 - 1; 0 <= i; i--) { if (s[s.Length / 2 - 1] == s[i]) { left++; } else { break; } } ans = s.Length / 2 + Math.Min(left + 1, right + 1); } else { ans = s.Length / 2; } } else { int left = 0; int right = 0; for (int i = s.Length / 2; i < s.Length; i++) { if (s[s.Length / 2] == s[i]) { right++; } else { break; } } for (int i = s.Length / 2; 0 <= i; i--) { if (s[s.Length / 2] == s[i]) { left++; } else { break; } } ans = s.Length / 2 + Math.Min(left, right); } MyIO.WriteMulti(ans); } } public struct VT<T, U> { public T Item1; public U Item2; public VT(T a, U b) { Item1 = a; Item2 = b; } } public struct VT<T, U, V> { public T Item1; public U Item2; public V Item3; public VT(T a, U b, V c) { Item1 = a; Item2 = b; Item3 = c; } } public struct VT<T, U, V, W> { public T Item1; public U Item2; public V Item3; public W Item4; public VT(T a, U b, V c, W d) { Item1 = a; Item2 = b; Item3 = c; Item4 = d; } } public class Printer : System.IO.StreamWriter { public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } } public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) {} public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) {} } public static class MyIO { private static char[] splitter = new char[] { ' ' }; private static bool eq<T, U>() => typeof(T).Equals(typeof(U)); private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); private static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse( s, System.Globalization.CultureInfo.InvariantCulture)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); public static string[] ReadMulti<T>(out T a) { var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries); a = cv<T>(ar[0]); return ar; } public static string[] ReadMulti<T, U>(out T a, out U b) { var ar = ReadMulti<T>(out a); b = cv<U>(ar[1]); return ar; } public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) { var ar = ReadMulti<T, U>(out a, out b); c = cv<V>(ar[2]); return ar; } public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = ReadMulti<T, U, V>(out a, out b, out c); d = cv<W>(ar[3]); return ar; } public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); e = cv<X>(ar[4]); return ar; } public static string[] ReadMulti<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 = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); f = cv<Y>(ar[5]); return ar; } public static string[] ReadArray<T>(out T[] a) { var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries); a = ar.Select(cv<T>).ToArray(); return ar; } public static string[][] ReadLines<T>(int n, out T[] a) { a = new T[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) arr[i] = ReadMulti(out a[i]); return arr; } public static string[][] ReadLines<T, U>(int n, out VT<T, U>[] a) { a = new VT<T, U>[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) { T o; U p; arr[i] = ReadMulti(out o, out p); a[i] = new VT<T, U>(o, p); } return arr; } public static string[][] ReadLines<T, U, V>(int n, out VT<T, U, V>[] a) { a = new VT<T, U, V>[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) { T o; U p; V q; arr[i] = ReadMulti(out o, out p, out q); a[i] = new VT<T, U, V>(o, p, q); } return arr; } public static string[][] ReadLines<T, U, V, W>(int n, out VT<T, U, V, W>[] a) { a = new VT<T, U, V, W>[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) { T o; U p; V q; W r; arr[i] = ReadMulti(out o, out p, out q, out r); a[i] = new VT<T, U, V, W>(o, p, q, r); } return arr; } public static string[][] ReadMatrix<T>(int n, out T[][] a) { a = new T[n][]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) arr[i] = ReadArray(out a[i]); return arr; } private static void wwp(Action act) { var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); act(); Console.Out.Flush(); sw.AutoFlush = true; Console.SetOut(sw); } private static string wfm(Type t) { return t.Equals(typeof(double)) ? "{0:F10}" : "{0}"; } public static void WriteMulti(params object[] a) { wwp(() => { for (int i = 0; i < a.Length; i++) { string fs = wfm(a[i].GetType()) + ((i < a.Length - 1) ? " " : Environment.NewLine); Console.Write(fs, a[i]); } }); } public static void WriteArray<T>(T[] a) { wwp(() => { string fs = wfm(typeof(T)); string fs1 = fs + " "; string fs2 = fs + Environment.NewLine; for (int i = 0; i < a.Length; i++) Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]); }); } public static void WriteLines<T>(T[] a) { wwp(() => { string fs = wfm(typeof(T)) + Environment.NewLine; foreach (T x in a) Console.Write(fs, x); }); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class Contest { public static void Main() { int n; string s; // MyIO.ReadMulti(out n); MyIO.ReadMulti(out s); int ans = s.Length; if (s.Length % 2 == 0) { int left = 0; int right = 0; if (s[s.Length / 2 - 1] == s[s.Length / 2]) { for (int i = s.Length / 2; i < s.Length; i++) { if (s[s.Length / 2] == s[i]) { right++; } else { break; } } for (int i = s.Length / 2 - 1; 0 <= i; i--) { if (s[s.Length / 2 - 1] == s[i]) { left++; } else { break; } } ans = s.Length / 2 + Math.Min(left, right); } else { ans = s.Length / 2; } } else { int left = 0; int right = 0; for (int i = s.Length / 2; i < s.Length; i++) { if (s[s.Length / 2] == s[i]) { right++; } else { break; } } for (int i = s.Length / 2; 0 <= i; i--) { if (s[s.Length / 2] == s[i]) { left++; } else { break; } } ans = s.Length / 2 + Math.Min(left, right); } MyIO.WriteMulti(ans); } } public struct VT<T, U> { public T Item1; public U Item2; public VT(T a, U b) { Item1 = a; Item2 = b; } } public struct VT<T, U, V> { public T Item1; public U Item2; public V Item3; public VT(T a, U b, V c) { Item1 = a; Item2 = b; Item3 = c; } } public struct VT<T, U, V, W> { public T Item1; public U Item2; public V Item3; public W Item4; public VT(T a, U b, V c, W d) { Item1 = a; Item2 = b; Item3 = c; Item4 = d; } } public class Printer : System.IO.StreamWriter { public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } } public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) {} public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) {} } public static class MyIO { private static char[] splitter = new char[] { ' ' }; private static bool eq<T, U>() => typeof(T).Equals(typeof(U)); private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); private static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse( s, System.Globalization.CultureInfo.InvariantCulture)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); public static string[] ReadMulti<T>(out T a) { var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries); a = cv<T>(ar[0]); return ar; } public static string[] ReadMulti<T, U>(out T a, out U b) { var ar = ReadMulti<T>(out a); b = cv<U>(ar[1]); return ar; } public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) { var ar = ReadMulti<T, U>(out a, out b); c = cv<V>(ar[2]); return ar; } public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = ReadMulti<T, U, V>(out a, out b, out c); d = cv<W>(ar[3]); return ar; } public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); e = cv<X>(ar[4]); return ar; } public static string[] ReadMulti<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 = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); f = cv<Y>(ar[5]); return ar; } public static string[] ReadArray<T>(out T[] a) { var ar = Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries); a = ar.Select(cv<T>).ToArray(); return ar; } public static string[][] ReadLines<T>(int n, out T[] a) { a = new T[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) arr[i] = ReadMulti(out a[i]); return arr; } public static string[][] ReadLines<T, U>(int n, out VT<T, U>[] a) { a = new VT<T, U>[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) { T o; U p; arr[i] = ReadMulti(out o, out p); a[i] = new VT<T, U>(o, p); } return arr; } public static string[][] ReadLines<T, U, V>(int n, out VT<T, U, V>[] a) { a = new VT<T, U, V>[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) { T o; U p; V q; arr[i] = ReadMulti(out o, out p, out q); a[i] = new VT<T, U, V>(o, p, q); } return arr; } public static string[][] ReadLines<T, U, V, W>(int n, out VT<T, U, V, W>[] a) { a = new VT<T, U, V, W>[n]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) { T o; U p; V q; W r; arr[i] = ReadMulti(out o, out p, out q, out r); a[i] = new VT<T, U, V, W>(o, p, q, r); } return arr; } public static string[][] ReadMatrix<T>(int n, out T[][] a) { a = new T[n][]; string[][] arr = new string[n][]; for (int i = 0; i < n; i++) arr[i] = ReadArray(out a[i]); return arr; } private static void wwp(Action act) { var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); act(); Console.Out.Flush(); sw.AutoFlush = true; Console.SetOut(sw); } private static string wfm(Type t) { return t.Equals(typeof(double)) ? "{0:F10}" : "{0}"; } public static void WriteMulti(params object[] a) { wwp(() => { for (int i = 0; i < a.Length; i++) { string fs = wfm(a[i].GetType()) + ((i < a.Length - 1) ? " " : Environment.NewLine); Console.Write(fs, a[i]); } }); } public static void WriteArray<T>(T[] a) { wwp(() => { string fs = wfm(typeof(T)); string fs1 = fs + " "; string fs2 = fs + Environment.NewLine; for (int i = 0; i < a.Length; i++) Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]); }); } public static void WriteLines<T>(T[] a) { wwp(() => { string fs = wfm(typeof(T)) + Environment.NewLine; foreach (T x in a) Console.Write(fs, x); }); } }
[["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
2,131
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC083D { class Program { static void Main(string[] args) { string S = Console.ReadLine(); int len = S.Length; int half = (len + 1) / 2; int center = (len % 2 == 0) ? len / 2 - 1 : len / 2; string mark = S.Substring(center, 1); bool ok = true; int i = 0; while (ok) { string low = (len % 2 == 0) ? S.Substring(center - i, 1) : S.Substring(center - i - 1, 1); string high = S.Substring(center + i + 1, 1); if (low != mark || high != mark) { ok = false; } else { i++; } } Console.WriteLine(half + i); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC083D { class Program { static void Main(string[] args) { string S = Console.ReadLine(); int len = S.Length; int half = (len + 1) / 2; int center = (len % 2 == 0) ? len / 2 - 1 : len / 2; string mark = S.Substring(center, 1); bool ok = true; int i = 0; while (ok && half + i < len) { string low = (len % 2 == 0) ? S.Substring(center - i, 1) : S.Substring(center - i - 1, 1); string high = S.Substring(center + i + 1, 1); if (low != mark || high != mark) { ok = false; } else { i++; } } Console.WriteLine(half + i); } } }
[["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 98], ["+", 0, 52, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 52, 15, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 52, 15, 16, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 12, 22]]
8
204
6
using System; class Program { private bool check(int[] s, int k) { return (s[k] != s[k + 1]) ? true : false; } public static void Main() { Program prog = new Program(); string str = Console.ReadLine(); int[] s = new int[str.Length]; for (int i = 0; i < str.Length; i++) s[i] = (int)Char.GetNumericValue(str[i]); int t = 114514; if (str.Length > 1) { for (int j = 0; j < str.Length - 1; j++) { if (prog.check(s, j)) if (Math.Max(j + 1, str.Length - j - 1) < t) t = Math.Max(j + 1, str.Length - j - 1); } } else t = 1; Console.WriteLine(t); } }
using System; class Program { private bool check(int[] s, int k) { return (s[k] != s[k + 1]) ? true : false; } public static void Main() { Program prog = new Program(); string str = Console.ReadLine(); int[] s = new int[str.Length]; for (int i = 0; i < str.Length; i++) s[i] = (int)Char.GetNumericValue(str[i]); int t = str.Length; if (str.Length > 1) { for (int j = 0; j < str.Length - 1; j++) { if (prog.check(s, j)) if (Math.Max(j + 1, str.Length - j - 1) < t) t = Math.Max(j + 1, str.Length - j - 1); } } else t = 1; Console.WriteLine(t); } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22]]
8
210
4
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection.Emit; using System.Security.Cryptography; using System.Text; using System.Threading; namespace Program { class MainClass { //////////////////////////////////////////////////////////// private string S; private const int def = 1145141919; void Solve() { S = io.String; var len = S.Length; var tmp = S.ToCharArray(); var cnt = def; for (int i = 0; i < tmp.Length - 1; ++i) { if (tmp[i] != tmp[i + 1]) { cnt = Math.Min(Math.Max(i + 1, len - (i + 1)), cnt); } } io.o(cnt == def ? 0 : cnt); } //////////////////////////////////////////////////////////// public static void Main() { new MainClass().Stream(); } IO io = new IO(); Mat mat = new Mat(); void Stream() { Solve(); io.writeFlush(); } // void Stream() { Test(); io.writeFlush(); } void Test() {} #region MockMacro // cannot use break,continue,goto void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); } void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); } #endregion //////////////////////////////////////////////////////////// } #region default class IO { string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' }; StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); } public string Next() { if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); BufferCnt = 0; return nextBuffer[BufferCnt++]; } public string String => Next(); public char Char => char.Parse(String); // public int Int => int.Parse(String); public int Int => String.toInt(); public long Long => String.toLong(); public double Double => double.Parse(String); public string[] arr => Console.ReadLine().Split(' '); public char[] arrChar => Array.ConvertAll(arr, char.Parse); // public int[] arrInt => Array.ConvertAll(arr, int.Parse); public int[] arrInt => arr.Select(v => v.toInt()).ToArray(); // public long[] arrLong => Array.ConvertAll(arr, long.Parse); public long[] arrLong => arr.Select(v => v.toLong()).ToArray(); public double[] arrDouble => Array.ConvertAll(arr, double.Parse); public T i<T>() { return suitType<T>(String); } public void i<T>(out T v) { v = suitType<T>(String); } public void i<T, U>(out T v1, out U v2) { i(out v1); i(out v2); } public void i<T, U, V>(out T v1, out U v2, out V v3) { i(out v1); i(out v2); i(out v3); } public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) { i(out v1); i(out v2); i(out v3); i(out v4); } public void i<T, U, V, W, X>(out T v1, out U v2, out V v3, out W v4, out X v5) { i(out v1); i(out v2); i(out v3); i(out v4); i(out v5); } public void ini<T>(out T[] a, int n) { a = new T[n]; for (int i = 0; i < n; ++i) a[i] = suitType<T>(String); } public void ini<T, U>(out T[] a, out U[] b, int n) { a = new T[n]; b = new U[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<U>(); } } public void ini<T, U, V>(out T[] a, out U[] b, out V[] c, int n) { a = new T[n]; b = new U[n]; c = new V[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<U>(); c[i] = i<V>(); } } public void ini<T, U>(out Tuple<T, U>[] t, int n) { t = new Tuple<T, U>[n]; for (int j = 0; j < n; ++j) { T i1; U i2; i(out i1); i(out i2); t[j] = Tuple.Create(i1, i2); } } public void ini<T, U, V>(out Tuple<T, U, V>[] t, int n) { t = new Tuple<T, U, V>[n]; for (int j = 0; j < n; ++j) { T i1; U i2; V i3; i(out i1); i(out i2); i(out i3); t[j] = Tuple.Create(i1, i2, i3); } } public void ini<T>(out T[,] a, int h, int w) { a = new T[h, w]; for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) a[i, j] = i<T>(); } public void o<T>(T v) { Console.WriteLine(v); } public void o<T>(params T[] a) { Array.ForEach(a, n => o(n)); } public void o<T>(T[,] a) { int a0 = a.GetLength(0), a1 = a.GetLength(1); for (int i = 0; i < a0; ++i) { for (int j = 0; j < a1 - 1; ++j) Console.Write(a[i, j] + " "); Console.WriteLine(a[i, a1 - 1]); } } public void YN(bool f) { o(f ? "YES" : "NO"); } public void Yn(bool f) { o(f ? "Yes" : "No"); } public void yn(bool f) { o(f ? "yes" : "no"); } public void ol<T>(params T[] a) { o(connect<T>(a)); } public void or<T>(T a) { Console.Write(a); } public void br() { o(""); } public void writeFlush() { Console.Out.Flush(); } private string connect<T>(params T[] s) { return string.Join(" ", s); } private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); } private T convertType<T, U>(U v) { return (T)Convert.ChangeType(v, typeof(T)); } private T suitType<T>(string s) { if (typeEQ<T, int>()) return convertType<T, int>(int.Parse(s)); if (typeEQ<T, long>()) return convertType<T, long>(long.Parse(s)); if (typeEQ<T, double>()) return convertType<T, double>(double.Parse(s)); if (typeEQ<T, char>()) return convertType<T, char>(char.Parse(s)); return convertType<T, string>(s); } } class Mat { public long mod = 1000000007; // 10^9+7 public long Pow(long a, long b) { if (b == 0) return 1; if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod; else return Pow(a * a % mod, b / 2) % mod; } public long Fact(long n) { long ret = 1; for (long i = 1; i <= n; i++) ret = (ret * i) % mod; return ret; } public long ModC(long n, long r) { if (r == 0 || n == r) return 1; if (n == 0) return 0; if (n < 0 || n < r) throw new ArgumentException("n,r invalid"); else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod; } public long[,] C(int N) { long[,] Co = new long[N + 1, N + 1]; (N + 1).REP(i => (i + 1).REP(j => Co[i, j] = (j == 0 || j == i) ? 1L : Co[i - 1, j - 1] + Co[i - 1, j])); return Co; } public long DupC(long n, long r) { return ModC(n + r - 1, r); } public long P(long n, long r) { return Fact(n) / (Fact(n - r)); } // test public bool isPrime(long n) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; for (long v = 3; v <= (long)Math.Sqrt(n); v += 2) if (n % v == 0) return false; return true; } public long LCM(long a, long b) { return a * (b / GCD(a, b)); } public long LCM(params long[] a) { return a.Aggregate((v, n) => LCM(v, n)); } public long GCD(long a, long b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); } public long GCD(params long[] array) { return array.Aggregate((v, n) => GCD(v, n)); } public T Max<T>(params T[] a) { return a.Max(); } public T Min<T>(params T[] a) { return a.Min(); } public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; } public double Dis(int x1, int y1, int x2, int y2) { return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)); } public int mDis(int x1, int y1, int x2, int y2) { return Math.Abs(x1 - x2) + Math.Abs(y1 - y2); } public int[] DigArr(int n) { int[] ret = new int[Digit(n)]; ret.Length.REP(i => ret[i] = DigVal(n, i + 1)); return ret; } public long DigArr2Num(IEnumerable<int> enu) { return enu.Aggregate((v, n) => v * 10 + n); } public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; } public int DigVal(int n, int dig) { return (n % (int)Pow(10, dig)) / (int)Pow(10, dig - 1); } public long Tousa(long a, long d, long n) { return a + (n - 1) * d; } public long TousaSum(long a, long d, long n) { return n * (2 * a + (n - 1) * d) / 2; } public long[] EnuDivsor(long N) { var ret = new SortedSet<long>(); for (long i = 1; i * i <= N; i++) if (N % i == 0) { ret.Add(i); ret.Add(N / i); } return ret.ToArray(); } public Dictionary<long, long> PrimeFactor(long n) { var ret = new Dictionary<long, long>(); for (int i = 2; i * i <= n; ++i) { if (!ret.ContainsKey(i)) ret[i] = 0; while (n % i == 0) { ++ret[i]; n /= i; } } return ret.Where(kp => kp.Value != 0) .ToDictionary(kp => kp.Key, kp => kp.Value); } } #endregion #region Ex static class StringEX { public static string Reversed(this string s) { return string.Join("", s.Reverse()); } public static string Repeat(this string s, int n) { return string.Concat(Enumerable.Repeat(s, n).ToArray()); } public static int toInt(this string s) { int n; return (int.TryParse(s.TrimStart('0'), out n)) ? n : 0; } public static int toInt(this char c) { return toInt(c.ToString()); } public static int toInt(this char[] c) { return toInt(new string(c)); } public static long[] toLong(this int[] a) { return a.Select(v => (long)v).ToArray(); } public static long[,] toLong(this int[,] m) { var h = m.GetLength(0); var w = m.GetLength(1); var ret = new long[h, w]; for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) ret[i, j] = (long)m[i, j]; return ret; } public static long toLong(this string s) { long n; return (long.TryParse(s.TrimStart('0'), out n)) ? n : (long)0; } public static long toLong(this char c) { return toLong(c.ToString()); } public static long toLong(this char[] c) { return toLong(new string(c)); } public static string toString(this char[] c) { return new string(c); } } static class NumericEx { public static string pad0<T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); } public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); } public static double RoundUp(this double v) { return Math.Ceiling(v); } public static double RoundDown(this double v) { return Math.Floor(v); } public static bool Odd(this int v) { return v % 2 != 0; } public static bool Odd(this long v) { return v % 2 != 0; } public static void REP(this int v, Action<int> act) { for (int i = 0; i < v; ++i) act(i); } public static void REPR(this int v, Action<int> act) { for (int i = v - 1; i >= 0; --i) act(i); } } static class ArrayEX { public static T[] Sort<T>(this T[] a) { Array.Sort(a); return a; } public static T[] SortR<T>(this T[] a) { Array.Sort(a); Array.Reverse(a); return a; } public static void Set<T>(this T[] a, T v) { a.Length.REP(i => a[i] = v); } public static void Set<T>(this T[,] a, T v) { a.GetLength(0).REP(i => a.GetLength(1).REP(j => a[i, j] = v)); } public static int[] toIntArr(this string a) { return a.Select(c => c.toInt()).ToArray(); } public static int[] toIntArr(this string[] a) { return Array.ConvertAll(a, int.Parse); } public static long[] toLongArr(this string a) { return a.Select(c => c.toLong()).ToArray(); } public static long[] toLongArr(this string[] a) { return Array.ConvertAll(a, long.Parse); } public static double[] toDoubleArr(this string[] a) { return Array.ConvertAll(a, double.Parse); } public static char[] toCharArr(this string[] a) { return Array.ConvertAll(a, char.Parse); } public static int LowerBound<T>(this T[] a, T x) where T : IComparable { Array.Sort(a); int lb = -1, ub = a.Length; while (ub - lb > 1) { int mid = (ub + lb) / 2; if (a[mid].CompareTo(x) >= 0) ub = mid; else lb = mid; } return ub; } public static int UpperBound<T>(this T[] a, T x) where T : IComparable { Array.Sort(a); int lb = -1, ub = a.Length; while (ub - lb > 1) { int mid = (ub + lb) / 2; if (a[mid].CompareTo(x) > 0) ub = mid; else lb = mid; } return ub; } } #endregion }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection.Emit; using System.Security.Cryptography; using System.Text; using System.Threading; namespace Program { class MainClass { //////////////////////////////////////////////////////////// private string S; private const int def = 1145141919; void Solve() { S = io.String; var len = S.Length; var tmp = S.ToCharArray(); var cnt = def; for (int i = 0; i < tmp.Length - 1; ++i) { if (tmp[i] != tmp[i + 1]) { cnt = Math.Min(Math.Max(i + 1, len - (i + 1)), cnt); } } io.o(cnt == def ? len : cnt); } //////////////////////////////////////////////////////////// public static void Main() { new MainClass().Stream(); } IO io = new IO(); Mat mat = new Mat(); void Stream() { Solve(); io.writeFlush(); } // void Stream() { Test(); io.writeFlush(); } void Test() {} #region MockMacro // cannot use break,continue,goto void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); } void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); } #endregion //////////////////////////////////////////////////////////// } #region default class IO { string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' }; StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); } public string Next() { if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); BufferCnt = 0; return nextBuffer[BufferCnt++]; } public string String => Next(); public char Char => char.Parse(String); // public int Int => int.Parse(String); public int Int => String.toInt(); public long Long => String.toLong(); public double Double => double.Parse(String); public string[] arr => Console.ReadLine().Split(' '); public char[] arrChar => Array.ConvertAll(arr, char.Parse); // public int[] arrInt => Array.ConvertAll(arr, int.Parse); public int[] arrInt => arr.Select(v => v.toInt()).ToArray(); // public long[] arrLong => Array.ConvertAll(arr, long.Parse); public long[] arrLong => arr.Select(v => v.toLong()).ToArray(); public double[] arrDouble => Array.ConvertAll(arr, double.Parse); public T i<T>() { return suitType<T>(String); } public void i<T>(out T v) { v = suitType<T>(String); } public void i<T, U>(out T v1, out U v2) { i(out v1); i(out v2); } public void i<T, U, V>(out T v1, out U v2, out V v3) { i(out v1); i(out v2); i(out v3); } public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) { i(out v1); i(out v2); i(out v3); i(out v4); } public void i<T, U, V, W, X>(out T v1, out U v2, out V v3, out W v4, out X v5) { i(out v1); i(out v2); i(out v3); i(out v4); i(out v5); } public void ini<T>(out T[] a, int n) { a = new T[n]; for (int i = 0; i < n; ++i) a[i] = suitType<T>(String); } public void ini<T, U>(out T[] a, out U[] b, int n) { a = new T[n]; b = new U[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<U>(); } } public void ini<T, U, V>(out T[] a, out U[] b, out V[] c, int n) { a = new T[n]; b = new U[n]; c = new V[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<U>(); c[i] = i<V>(); } } public void ini<T, U>(out Tuple<T, U>[] t, int n) { t = new Tuple<T, U>[n]; for (int j = 0; j < n; ++j) { T i1; U i2; i(out i1); i(out i2); t[j] = Tuple.Create(i1, i2); } } public void ini<T, U, V>(out Tuple<T, U, V>[] t, int n) { t = new Tuple<T, U, V>[n]; for (int j = 0; j < n; ++j) { T i1; U i2; V i3; i(out i1); i(out i2); i(out i3); t[j] = Tuple.Create(i1, i2, i3); } } public void ini<T>(out T[,] a, int h, int w) { a = new T[h, w]; for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) a[i, j] = i<T>(); } public void o<T>(T v) { Console.WriteLine(v); } public void o<T>(params T[] a) { Array.ForEach(a, n => o(n)); } public void o<T>(T[,] a) { int a0 = a.GetLength(0), a1 = a.GetLength(1); for (int i = 0; i < a0; ++i) { for (int j = 0; j < a1 - 1; ++j) Console.Write(a[i, j] + " "); Console.WriteLine(a[i, a1 - 1]); } } public void YN(bool f) { o(f ? "YES" : "NO"); } public void Yn(bool f) { o(f ? "Yes" : "No"); } public void yn(bool f) { o(f ? "yes" : "no"); } public void ol<T>(params T[] a) { o(connect<T>(a)); } public void or<T>(T a) { Console.Write(a); } public void br() { o(""); } public void writeFlush() { Console.Out.Flush(); } private string connect<T>(params T[] s) { return string.Join(" ", s); } private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); } private T convertType<T, U>(U v) { return (T)Convert.ChangeType(v, typeof(T)); } private T suitType<T>(string s) { if (typeEQ<T, int>()) return convertType<T, int>(int.Parse(s)); if (typeEQ<T, long>()) return convertType<T, long>(long.Parse(s)); if (typeEQ<T, double>()) return convertType<T, double>(double.Parse(s)); if (typeEQ<T, char>()) return convertType<T, char>(char.Parse(s)); return convertType<T, string>(s); } } class Mat { public long mod = 1000000007; // 10^9+7 public long Pow(long a, long b) { if (b == 0) return 1; if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod; else return Pow(a * a % mod, b / 2) % mod; } public long Fact(long n) { long ret = 1; for (long i = 1; i <= n; i++) ret = (ret * i) % mod; return ret; } public long ModC(long n, long r) { if (r == 0 || n == r) return 1; if (n == 0) return 0; if (n < 0 || n < r) throw new ArgumentException("n,r invalid"); else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod; } public long[,] C(int N) { long[,] Co = new long[N + 1, N + 1]; (N + 1).REP(i => (i + 1).REP(j => Co[i, j] = (j == 0 || j == i) ? 1L : Co[i - 1, j - 1] + Co[i - 1, j])); return Co; } public long DupC(long n, long r) { return ModC(n + r - 1, r); } public long P(long n, long r) { return Fact(n) / (Fact(n - r)); } // test public bool isPrime(long n) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; for (long v = 3; v <= (long)Math.Sqrt(n); v += 2) if (n % v == 0) return false; return true; } public long LCM(long a, long b) { return a * (b / GCD(a, b)); } public long LCM(params long[] a) { return a.Aggregate((v, n) => LCM(v, n)); } public long GCD(long a, long b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); } public long GCD(params long[] array) { return array.Aggregate((v, n) => GCD(v, n)); } public T Max<T>(params T[] a) { return a.Max(); } public T Min<T>(params T[] a) { return a.Min(); } public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; } public double Dis(int x1, int y1, int x2, int y2) { return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)); } public int mDis(int x1, int y1, int x2, int y2) { return Math.Abs(x1 - x2) + Math.Abs(y1 - y2); } public int[] DigArr(int n) { int[] ret = new int[Digit(n)]; ret.Length.REP(i => ret[i] = DigVal(n, i + 1)); return ret; } public long DigArr2Num(IEnumerable<int> enu) { return enu.Aggregate((v, n) => v * 10 + n); } public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; } public int DigVal(int n, int dig) { return (n % (int)Pow(10, dig)) / (int)Pow(10, dig - 1); } public long Tousa(long a, long d, long n) { return a + (n - 1) * d; } public long TousaSum(long a, long d, long n) { return n * (2 * a + (n - 1) * d) / 2; } public long[] EnuDivsor(long N) { var ret = new SortedSet<long>(); for (long i = 1; i * i <= N; i++) if (N % i == 0) { ret.Add(i); ret.Add(N / i); } return ret.ToArray(); } public Dictionary<long, long> PrimeFactor(long n) { var ret = new Dictionary<long, long>(); for (int i = 2; i * i <= n; ++i) { if (!ret.ContainsKey(i)) ret[i] = 0; while (n % i == 0) { ++ret[i]; n /= i; } } return ret.Where(kp => kp.Value != 0) .ToDictionary(kp => kp.Key, kp => kp.Value); } } #endregion #region Ex static class StringEX { public static string Reversed(this string s) { return string.Join("", s.Reverse()); } public static string Repeat(this string s, int n) { return string.Concat(Enumerable.Repeat(s, n).ToArray()); } public static int toInt(this string s) { int n; return (int.TryParse(s.TrimStart('0'), out n)) ? n : 0; } public static int toInt(this char c) { return toInt(c.ToString()); } public static int toInt(this char[] c) { return toInt(new string(c)); } public static long[] toLong(this int[] a) { return a.Select(v => (long)v).ToArray(); } public static long[,] toLong(this int[,] m) { var h = m.GetLength(0); var w = m.GetLength(1); var ret = new long[h, w]; for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) ret[i, j] = (long)m[i, j]; return ret; } public static long toLong(this string s) { long n; return (long.TryParse(s.TrimStart('0'), out n)) ? n : (long)0; } public static long toLong(this char c) { return toLong(c.ToString()); } public static long toLong(this char[] c) { return toLong(new string(c)); } public static string toString(this char[] c) { return new string(c); } } static class NumericEx { public static string pad0<T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); } public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); } public static double RoundUp(this double v) { return Math.Ceiling(v); } public static double RoundDown(this double v) { return Math.Floor(v); } public static bool Odd(this int v) { return v % 2 != 0; } public static bool Odd(this long v) { return v % 2 != 0; } public static void REP(this int v, Action<int> act) { for (int i = 0; i < v; ++i) act(i); } public static void REPR(this int v, Action<int> act) { for (int i = v - 1; i >= 0; --i) act(i); } } static class ArrayEX { public static T[] Sort<T>(this T[] a) { Array.Sort(a); return a; } public static T[] SortR<T>(this T[] a) { Array.Sort(a); Array.Reverse(a); return a; } public static void Set<T>(this T[] a, T v) { a.Length.REP(i => a[i] = v); } public static void Set<T>(this T[,] a, T v) { a.GetLength(0).REP(i => a.GetLength(1).REP(j => a[i, j] = v)); } public static int[] toIntArr(this string a) { return a.Select(c => c.toInt()).ToArray(); } public static int[] toIntArr(this string[] a) { return Array.ConvertAll(a, int.Parse); } public static long[] toLongArr(this string a) { return a.Select(c => c.toLong()).ToArray(); } public static long[] toLongArr(this string[] a) { return Array.ConvertAll(a, long.Parse); } public static double[] toDoubleArr(this string[] a) { return Array.ConvertAll(a, double.Parse); } public static char[] toCharArr(this string[] a) { return Array.ConvertAll(a, char.Parse); } public static int LowerBound<T>(this T[] a, T x) where T : IComparable { Array.Sort(a); int lb = -1, ub = a.Length; while (ub - lb > 1) { int mid = (ub + lb) / 2; if (a[mid].CompareTo(x) >= 0) ub = mid; else lb = mid; } return ub; } public static int UpperBound<T>(this T[] a, T x) where T : IComparable { Array.Sort(a); int lb = -1, ub = a.Length; while (ub - lb > 1) { int mid = (ub + lb) / 2; if (a[mid].CompareTo(x) > 0) ub = mid; else lb = mid; } return ub; } } #endregion }
[["-", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 22]]
8
4,086
2
using System; namespace ABC082 { class Program { static void Main(string[] args) { var input = Console.ReadLine(); A_RoundUptheMean.RoundUp(input); } } public class A_RoundUptheMean { public static int RoundUp(string input) { var s = input.Split(' '); var a = int.Parse(s[0]); var b = int.Parse(s[1]); return (int)Math.Ceiling((a + b) / 2.0); } } }
using System; namespace ABC082 { class Program { static void Main(string[] args) { var input = Console.ReadLine(); Console.WriteLine(A_RoundUptheMean.RoundUp(input)); } } public class A_RoundUptheMean { public static int RoundUp(string input) { var s = input.Split(' '); var a = int.Parse(s[0]); var b = int.Parse(s[1]); return (int)Math.Ceiling((a + b) / 2.0); } } }
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
108
5
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; using System.Threading.Tasks; class Sobaya { static void Main() { new Sobaya().calc(); return; } Scanner cin; void calc() { cin = new Scanner(); int a = cin.nextInt(); int b = cin.nextInt(); float x = (0.5f + a + b) / 2.0f; Console.WriteLine((int)x); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; using System.Threading.Tasks; class Sobaya { static void Main() { new Sobaya().calc(); return; } Scanner cin; void calc() { cin = new Scanner(); int a = cin.nextInt(); int b = cin.nextInt(); float x = (1.1f + a + b) / 2.0f; Console.WriteLine((int)x); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } }
[["-", 0, 16, 31, 23, 0, 16, 31, 16, 31, 250], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 31, 250]]
8
476
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Numerics; namespace AtcoderC { class Program { /*static void Main(string[] args) { }*/ // ABC132C //全探索法 /*static void Main() { BigInteger N = int.Parse(Console.ReadLine()); int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int min = input.Min(); int max = input.Max(); int countARC = 0; int countABC = 0; int Answer = 0; for (int i = min; i <= max; i++) { countABC = 0; countARC = 0; foreach (int n in input) { if (n > i) { countARC++; } else { countABC++; } } if (countABC == countARC) { Answer++; } } Console.WriteLine(Answer); }*/ // 2回目 /*static void Main() { int N = int.Parse(Console.ReadLine()); int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); Array.Sort(input); int min = input[(N / 2) - 1]; int max = input[N / 2]; Console.WriteLine(max - min); }*/ // ABC131C //ユーグリッドの互除法の応用 /*static void Main() { BigInteger[] input = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray(); BigInteger A = input[0]; BigInteger B = input[1]; BigInteger C = input[2]; BigInteger D = input[3]; BigInteger ans = (B / C) + (B / D); //最小公倍数 var ans2 = C * D / lcm(C, D); BigInteger ans3 = B / ans2; var BB = B - ans + ans3; ans = (A - 1) / C + (A - 1) / D; ans3 = (A - 1) / ans2; var AA = (A - 1) - ans + ans3; Console.WriteLine(BB - AA); } static public BigInteger lcm(BigInteger a, BigInteger b) { var r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; }*/ // 129C //動的計画法 // TLEになる時間がかかり過ぎる /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int M = input[1]; List<int> ttt = new List<int>(); for (int i = 0;i < M;i++) { var temp = int.Parse(Console.ReadLine()); ttt.Add(temp); } int[] dparray = new int[N+2]; dparray[N] = 1; dparray[N - 1] = 1; for (int i = N-1; i >= 0; i--) { if (ttt.Contains(i)) { dparray[i] = 0; } dparray[i] = (dparray[i + 1] + dparray[i + 2]) % 1000000007; } Console.WriteLine(dparray[0]); }*/ // ABC128 /*static void Main() { }*/ // ABC134A /*static void Main() { int r = int.Parse(Console.ReadLine()); var ans = 3 * r * r; Console.WriteLine(ans); }*/ // ABC134B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int D = input[1]; int count = 0; int ans = N; while (true) { ans = ans - (D * 2 + 1); count++; if (ans <= 0) { break; } } Console.WriteLine(count); }*/ // ABC134C /*static void Main() { int N = int.Parse(Console.ReadLine()); List<int> array = new List<int>(); for (int i =0;i<N; i++) { array.Add(int.Parse(Console.ReadLine())); } List<int> ans = new List<int>(); int max = array.Max(); var temp = new List<int>(); foreach (int n in array) { temp.Add(n); } temp.Sort(); temp.Reverse(); int second = temp[1]; foreach (int nn in array) { if (nn == max) { Console.WriteLine(second); } else { Console.WriteLine(max); } } }*/ // 134ABCD /*static void Main() { int N = int.Parse(Console.ReadLine()); int count = 0; int ans = 0; int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 0;i<N;i++) { for (int j =0;j<N; j++) { if ((j+1)%(i+1)==0) { count += input[j]; } } if (count % 2 == input[i]) { ans++; } count = 0; } if (ans != 0) { } }*/ // AGC036 /*static void Main() { long S = long.Parse(Console.ReadLine()); long X1 = 1000000000; long Y1 = 0; /*while (true) { Y1 = S / X1 + S % X1; } Y1 = S / X1 + S % X1; Console.WriteLine("0 0 " + X1 + " 0 0 " + Y1); /*int tempX = 0; List<long> ss = new List<long>(); while (tempX < S) { var ans = S % tempX; if (ans == 0) { ss.Add(ans); } tempX++; } Console.WriteLine(tempX);*/ /*long X1 = 0; long Y1 = 1; while (true) { X1 = S % Y1; if (X1 <= 1000000000) { break; } Y1++; } Console.WriteLine("0 0 "+X1+" 0 0 "+Y1); }*/ // ABC82A static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int a = input[0]; int b = input[1]; double sum = (a + b) / 2; Console.WriteLine(Math.Ceiling(sum)); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Numerics; namespace AtcoderC { class Program { /*static void Main(string[] args) { }*/ // ABC132C //全探索法 /*static void Main() { BigInteger N = int.Parse(Console.ReadLine()); int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int min = input.Min(); int max = input.Max(); int countARC = 0; int countABC = 0; int Answer = 0; for (int i = min; i <= max; i++) { countABC = 0; countARC = 0; foreach (int n in input) { if (n > i) { countARC++; } else { countABC++; } } if (countABC == countARC) { Answer++; } } Console.WriteLine(Answer); }*/ // 2回目 /*static void Main() { int N = int.Parse(Console.ReadLine()); int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); Array.Sort(input); int min = input[(N / 2) - 1]; int max = input[N / 2]; Console.WriteLine(max - min); }*/ // ABC131C //ユーグリッドの互除法の応用 /*static void Main() { BigInteger[] input = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray(); BigInteger A = input[0]; BigInteger B = input[1]; BigInteger C = input[2]; BigInteger D = input[3]; BigInteger ans = (B / C) + (B / D); //最小公倍数 var ans2 = C * D / lcm(C, D); BigInteger ans3 = B / ans2; var BB = B - ans + ans3; ans = (A - 1) / C + (A - 1) / D; ans3 = (A - 1) / ans2; var AA = (A - 1) - ans + ans3; Console.WriteLine(BB - AA); } static public BigInteger lcm(BigInteger a, BigInteger b) { var r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; }*/ // 129C //動的計画法 // TLEになる時間がかかり過ぎる /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int M = input[1]; List<int> ttt = new List<int>(); for (int i = 0;i < M;i++) { var temp = int.Parse(Console.ReadLine()); ttt.Add(temp); } int[] dparray = new int[N+2]; dparray[N] = 1; dparray[N - 1] = 1; for (int i = N-1; i >= 0; i--) { if (ttt.Contains(i)) { dparray[i] = 0; } dparray[i] = (dparray[i + 1] + dparray[i + 2]) % 1000000007; } Console.WriteLine(dparray[0]); }*/ // ABC128 /*static void Main() { }*/ // ABC134A /*static void Main() { int r = int.Parse(Console.ReadLine()); var ans = 3 * r * r; Console.WriteLine(ans); }*/ // ABC134B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int D = input[1]; int count = 0; int ans = N; while (true) { ans = ans - (D * 2 + 1); count++; if (ans <= 0) { break; } } Console.WriteLine(count); }*/ // ABC134C /*static void Main() { int N = int.Parse(Console.ReadLine()); List<int> array = new List<int>(); for (int i =0;i<N; i++) { array.Add(int.Parse(Console.ReadLine())); } List<int> ans = new List<int>(); int max = array.Max(); var temp = new List<int>(); foreach (int n in array) { temp.Add(n); } temp.Sort(); temp.Reverse(); int second = temp[1]; foreach (int nn in array) { if (nn == max) { Console.WriteLine(second); } else { Console.WriteLine(max); } } }*/ // 134ABCD /*static void Main() { int N = int.Parse(Console.ReadLine()); int count = 0; int ans = 0; int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 0;i<N;i++) { for (int j =0;j<N; j++) { if ((j+1)%(i+1)==0) { count += input[j]; } } if (count % 2 == input[i]) { ans++; } count = 0; } if (ans != 0) { } }*/ // AGC036 /*static void Main() { long S = long.Parse(Console.ReadLine()); long X1 = 1000000000; long Y1 = 0; /*while (true) { Y1 = S / X1 + S % X1; } Y1 = S / X1 + S % X1; Console.WriteLine("0 0 " + X1 + " 0 0 " + Y1); /*int tempX = 0; List<long> ss = new List<long>(); while (tempX < S) { var ans = S % tempX; if (ans == 0) { ss.Add(ans); } tempX++; } Console.WriteLine(tempX);*/ /*long X1 = 0; long Y1 = 1; while (true) { X1 = S % Y1; if (X1 <= 1000000000) { break; } Y1++; } Console.WriteLine("0 0 "+X1+" 0 0 "+Y1); }*/ // ABC82A static void Main() { double[] input = Console.ReadLine().Split().Select(double.Parse).ToArray(); double a = input[0]; double b = input[1]; double sum = (a + b) / 2; Console.WriteLine(Math.Ceiling(sum)); } } }
[["-", 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]]
8
139
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApp2 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); decimal a = Convert.ToDecimal(input[0]); decimal b = Convert.ToDecimal(input[0]); Console.WriteLine(Math.Ceiling((a + b) / 2)); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApp2 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); decimal a = Convert.ToDecimal(input[0]); decimal b = Convert.ToDecimal(input[1]); Console.WriteLine(Math.Ceiling((a + b) / 2)); } } }
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
8
101
2
using System; class Challenge { static void Main() { var input = Console.ReadLine().Split(); var a = int.Parse(input[0]); var b = int.Parse(input[1]); Console.WriteLine((a + b - 1) / 2); } }
using System; class Challenge { static void Main() { var input = Console.ReadLine().Split(); var a = int.Parse(input[0]); var b = int.Parse(input[1]); Console.WriteLine((a + b + 1) / 2); } }
[["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72]]
8
68
2
using System; class Atcoder70 { public static void Main() { string[] input = Console.ReadLine().Split(' '); double a = double.Parse(input[0]); double b = double.Parse(input[1]); double average = (a + b) / 2.0; Console.WriteLine(Math.Round(average)); } }
using System; class Atcoder70 { public static void Main() { string[] input = Console.ReadLine().Split(' '); double a = double.Parse(input[0]); double b = double.Parse(input[1]); double average = (a + b) / 2.0; Console.WriteLine(Math.Ceiling(average)); } }
[["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22]]
8
82
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string[] a = System.Console.ReadLine().Split(' '); float b = (int.Parse(a[0]) + int.Parse(a[1])) / 2f; int c = (int)(b + 0.5); Console.Write(b); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string[] a = System.Console.ReadLine().Split(' '); float b = (int.Parse(a[0]) + int.Parse(a[1])) / 2f; int c = (int)(b + 0.5); Console.Write(c); } } }
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
112
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp65 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); string t = Console.ReadLine(); var s_ = s.ToCharArray(); var t_ = t.ToCharArray(); Array.Sort(s_); Array.Sort(t_); t_ = t_.Reverse().ToArray(); // Console.WriteLine(string.Join("", s_)); // Console.WriteLine(string.Join("", t_)); int len_s = s_.Count(); int len_t = t_.Count(); for (int i = 0; i < Math.Min(len_s, len_t); i++) { if (s_[i] + 1 < t_[i] + 1) { Console.WriteLine("Yes"); return; } else if (s_[i] + 1 > t_[i] + 1) { Console.WriteLine("No"); return; } if (i == Math.Min(len_s, len_t) - 1 && len_s <= t_.Length) { Console.WriteLine("Yes"); return; } } Console.WriteLine("No"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp65 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); string t = Console.ReadLine(); var s_ = s.ToCharArray(); var t_ = t.ToCharArray(); Array.Sort(s_); Array.Sort(t_); t_ = t_.Reverse().ToArray(); // Console.WriteLine(string.Join("", s_)); // Console.WriteLine(string.Join("", t_)); int len_s = s_.Count(); int len_t = t_.Count(); for (int i = 0; i < Math.Min(len_s, len_t); i++) { if (s_[i] + 1 < t_[i] + 1) { Console.WriteLine("Yes"); return; } else if (s_[i] + 1 > t_[i] + 1) { Console.WriteLine("No"); return; } if (i == Math.Min(len_s, len_t) - 1 && len_s < t_.Length) { Console.WriteLine("Yes"); return; } } Console.WriteLine("No"); } } }
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18]]
8
253
2
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp9 { class Program { static void Main(string[] args) { char[] s = Console.ReadLine().ToArray(); char[] t = Console.ReadLine().ToArray(); Array.Sort(s); Array.Sort(t); string ans = null; int Length; int Lengthkind; if (s.Length >= t.Length) { Length = t.Length; Lengthkind = 0; } else { Length = s.Length; Lengthkind = 1; } for (int i = 0; i < Length; i++) { if (s[i] > t[t.Length - i - 1]) { ans = "NO"; break; } else if (s[i] < t[t.Length - i - 1]) { ans = "Yes"; break; } if (i == Length - 1) { if (Lengthkind == 0) ans = "NO"; else ans = "Yes"; break; } } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp9 { class Program { static void Main(string[] args) { char[] s = Console.ReadLine().ToArray(); char[] t = Console.ReadLine().ToArray(); Array.Sort(s); Array.Sort(t); string ans = null; int Length; int Lengthkind; if (s.Length >= t.Length) { Length = t.Length; Lengthkind = 0; } else { Length = s.Length; Lengthkind = 1; } for (int i = 0; i < Length; i++) { if (s[i] > t[t.Length - i - 1]) { ans = "No"; break; } else if (s[i] < t[t.Length - i - 1]) { ans = "Yes"; break; } if (i == Length - 1) { if (Lengthkind == 0) ans = "No"; else ans = "Yes"; break; } } Console.WriteLine(ans); } } }
[["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["-", 0, 57, 64, 1, 0, 11, 12, 5, 0, 222], ["+", 0, 57, 64, 1, 0, 11, 12, 5, 0, 222]]
8
235
4
using System; using System.Collections.Generic; using System.Linq; class Program { public static bool f = false, t = true; static void Main(string[] args) { long n = Read.Long(); long[] a = Read.longs(); long[] ans = new long[10000000]; long sum = 0; for (int i = 0; i < n; i++) { if (a[i] > ans.Length) { sum += 1; } else { ans[a[i]]++; } } for (long i = 0; i < ans.Length; i++) { if (ans[i] == 0) { } else if (ans[i] >= i) { sum = ans[i] - i; } else { sum += ans[i]; } } Console.WriteLine(sum); Console.ReadLine(); } public static long gcd(long a, long b) { while (true) { if (a == 0) { return b; } if (b == 0) { return a; } if (a > b) { a -= b; } else { b -= a; } } } public static long lcm(long a, long b) { return a / gcd(a, b) * b; } public static bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = Math.Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } } public static class Read { public static void outl(string n = "") { Console.WriteLine(n); return; } public static long Long() { return long.Parse(Console.ReadLine()); } public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static int Int() { return int.Parse(Console.ReadLine()); } public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); } public static string Str() { return Console.ReadLine(); } public static string[] Strs() { return Console.ReadLine().Split(); } }
using System; using System.Collections.Generic; using System.Linq; class Program { public static bool f = false, t = true; static void Main(string[] args) { long n = Read.Long(); long[] a = Read.longs(); long[] ans = new long[10000000]; long sum = 0; for (int i = 0; i < n; i++) { if (a[i] > ans.Length) { sum += 1; } else { ans[a[i]]++; } } for (long i = 0; i < ans.Length; i++) { if (ans[i] == 0) { } else if (ans[i] >= i) { sum += ans[i] - i; } else { sum += ans[i]; } } Console.WriteLine(sum); Console.ReadLine(); } public static long gcd(long a, long b) { while (true) { if (a == 0) { return b; } if (b == 0) { return a; } if (a > b) { a -= b; } else { b -= a; } } } public static long lcm(long a, long b) { return a / gcd(a, b) * b; } public static bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = Math.Sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } } public static class Read { public static void outl(string n = "") { Console.WriteLine(n); return; } public static long Long() { return long.Parse(Console.ReadLine()); } public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static int Int() { return int.Parse(Console.ReadLine()); } public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); } public static string Str() { return Console.ReadLine(); } public static string[] Strs() { return Console.ReadLine().Split(); } }
[["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107]]
8
535
2
using System; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var alist = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => x); var good = 0; var now = 0; var nowcount = 0; foreach (var a in alist) { if (a != now) { now = a; nowcount = 1; } nowcount += 1; if (nowcount == a) { good += a; } } Console.WriteLine(N - good); } } }
using System; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var alist = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => x); var good = 0; var now = 0; var nowcount = 0; foreach (var a in alist) { if (a != now) { now = a; nowcount = 0; } nowcount += 1; if (nowcount == a) { good += a; } } Console.WriteLine(N - good); } } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
8
136
2
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; using static System.Console; // using System.Numerics; // using static System.Math; class Program { static void Main() { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; void solve() { var S = ReadLine(); int X = cin.nextint + 10000; int Y = cin.nextint + 10000; int N = S.Length; var A = new List<int>(); var B = new List<int>(); bool first = true; bool modetate = false; int cnt = 0; for (int i = 0; i <= N; i++) { if (i == N) { if (cnt > 0) { if (modetate) { B.Add(cnt); } else { A.Add(cnt); } } } else if (first) { if (S[i] == 'F') { X--; } else { first = false; modetate = true; cnt = 0; } } else if (modetate) { if (S[i] == 'F') { cnt++; } else { if (cnt > 0) { B.Add(cnt); } modetate = false; cnt = 0; } } else { if (S[i] == 'F') { cnt++; } else { if (cnt > 0) { A.Add(cnt); } modetate = true; cnt = 0; } } } // WriteLine(); // WriteLine(X + " " + Y); // WriteLine(string.Join(" ", A.ToArray())); // WriteLine(string.Join(" ", B.ToArray())); var J = new bool[A.Count + 1, 20000 + 1]; J[0, 10000] = true; for (int i = 0; i < A.Count; i++) { for (int j = 0; j < 20000 + 1; j++) { if (J[i, j]) { // WriteLine(i + " " + j + " " + A[i] + "x"); if (j + A[i] < 20000 + 1) J[i + 1, j + A[i]] = true; if (j - A[i] >= 0) J[i + 1, j - A[i]] = true; } } } var K = new bool[B.Count + 1, 20000 + 1]; K[0, 10000] = true; for (int i = 0; i < B.Count; i++) { for (int j = 0; j < 20000 + 1; j++) { if (K[i, j]) { // WriteLine(i + " " + j + " " + B[i] + "y"); if (j + B[i] < 20000 + 1) K[i + 1, j + B[i]] = true; if (j - A[i] >= 0) K[i + 1, j - B[i]] = true; } } } if (X < 0 || X > 20000) { WriteLine("No"); } else if (J[A.Count, X] && K[B.Count, Y]) { WriteLine("Yes"); } else { WriteLine("No"); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; using static System.Console; // using System.Numerics; // using static System.Math; class Program { static void Main() { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; void solve() { var S = ReadLine(); int X = cin.nextint + 10000; int Y = cin.nextint + 10000; int N = S.Length; var A = new List<int>(); var B = new List<int>(); bool first = true; bool modetate = false; int cnt = 0; for (int i = 0; i <= N; i++) { if (i == N) { if (cnt > 0) { if (modetate) { B.Add(cnt); } else { A.Add(cnt); } } } else if (first) { if (S[i] == 'F') { X--; } else { first = false; modetate = true; cnt = 0; } } else if (modetate) { if (S[i] == 'F') { cnt++; } else { if (cnt > 0) { B.Add(cnt); } modetate = false; cnt = 0; } } else { if (S[i] == 'F') { cnt++; } else { if (cnt > 0) { A.Add(cnt); } modetate = true; cnt = 0; } } } // WriteLine(); // WriteLine(X + " " + Y); // WriteLine(string.Join(" ", A.ToArray())); // WriteLine(string.Join(" ", B.ToArray())); var J = new bool[A.Count + 1, 20000 + 1]; J[0, 10000] = true; for (int i = 0; i < A.Count; i++) { for (int j = 0; j < 20000 + 1; j++) { if (J[i, j]) { // WriteLine(i + " " + j + " " + A[i] + "x"); if (j + A[i] < 20000 + 1) J[i + 1, j + A[i]] = true; if (j - A[i] >= 0) J[i + 1, j - A[i]] = true; } } } var K = new bool[B.Count + 1, 20000 + 1]; K[0, 10000] = true; for (int i = 0; i < B.Count; i++) { for (int j = 0; j < 20000 + 1; j++) { if (K[i, j]) { // WriteLine(i + " " + j + " " + B[i] + "y"); if (j + B[i] < 20000 + 1) K[i + 1, j + B[i]] = true; if (j - B[i] >= 0) K[i + 1, j - B[i]] = true; } } } if (X < 0 || X > 20000) { WriteLine("No"); } else if (J[A.Count, X] && K[B.Count, Y]) { WriteLine("Yes"); } else { WriteLine("No"); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }
[["-", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22]]
8
930
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder02 { class Program { static void Main(string[] args) { Console.WriteLine(Console.ReadLine().Split().Sum(x => int.Parse(x))); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder02 { class Program { static void Main(string[] args) { Console.WriteLine( Console.ReadLine().ToCharArray().Sum(x => int.Parse(x.ToString()))); } } }
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
73
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionD { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var s = Console.ReadLine(); s.Replace("0", ""); Console.WriteLine(s.Length); Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionD { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var s = Console.ReadLine(); s = s.Replace("0", ""); Console.WriteLine(s.Length); Console.Out.Flush(); } } }
[["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22]]
8
117
2
using System; namespace ChokudaiScanner { class MainClass { static void Main() { Scanner cin = new Scanner(); string s = cin.Next(); int ans = 0; if (s[0] == '1') ans++; if (s[1] == '1') ans++; if (s[2] == '2') ans++; 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 string[] ArrayNext(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = Next(); } return Array; } public int NextInt() { return int.Parse(Next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = NextInt() + add; } return Array; } public long NextLong() { return long.Parse(Next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } } }
using System; namespace ChokudaiScanner { class MainClass { static void Main() { Scanner cin = new Scanner(); string s = cin.Next(); int ans = 0; if (s[0] == '1') ans++; if (s[1] == '1') ans++; if (s[2] == '1') ans++; 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 string[] ArrayNext(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = Next(); } return Array; } public int NextInt() { return int.Parse(Next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = NextInt() + add; } return Array; } public long NextLong() { return long.Parse(Next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } } }
[["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253]]
8
489
2
using System; namespace myApp { class Program { static void Main() { string s = Console.ReadLine(); s.Replace("0", ""); Console.WriteLine(s.Length); } } }
using System; namespace myApp { class Program { static void Main() { string s = Console.ReadLine(); s = s.Replace("0", ""); Console.WriteLine(s.Length); // string[] input = Console.ReadLine().Split(); // int a= int.Parse(input[0]); // int b=int.Parse(input[1]); // int c = a*b; // if(c%2==0){Console.WriteLine("Even");} // else if(c%2==1){Console.WriteLine("Odd");} // else{} } } }
[["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22]]
8
48
2
using System; class Program { static void Main(string[] args) { string s = Console.ReadLine(); int count = 0; if (s[0] == 1) count++; if (s[1] == 1) count++; if (s[2] == 1) count++; Console.WriteLine(count.ToString()); } }
using System; class Program { static void Main(string[] args) { string s = Console.ReadLine(); int count = 0; if (s[0] == '1') count++; if (s[1] == '1') count++; if (s[2] == '1') count++; Console.WriteLine(count.ToString()); } }
[["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104]]
8
79
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { string w = Console.ReadLine(); int n = 0; for (int i = 0; i < 3; i++) { if (w[0] == '1') n++; } Console.WriteLine(n); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { string w = Console.ReadLine(); int n = 0; for (int i = 0; i < 3; i++) { if (w[i] == '1') n++; } Console.WriteLine(n); } } }
[["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22]]
8
97
2
using static System.Console; class Program { static void Main(string[] args) { string s = ReadLine(); int ans = 0; foreach (char a in s) { if (a == '0') { ans++; } } WriteLine(ans); } }
using static System.Console; class Program { static void Main(string[] args) { string s = ReadLine(); int ans = 0; foreach (char a in s) { if (a == '1') { ans++; } } WriteLine(ans); } }
[["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253]]
8
60
2
using System; class Program { static void Main(string[] args) { int cnt; int bollNum = 0; string massNum; massNum = Console.ReadLine(); for (cnt = 0; cnt < 3; cnt++) { if (massNum[cnt] == 1) { bollNum++; } } Console.WriteLine(bollNum); } }
using System; class Program { static void Main(string[] args) { int cnt; int bollNum = 0; string massNum; massNum = Console.ReadLine(); for (cnt = 0; cnt < 3; cnt++) { if (massNum[cnt] == '1') { bollNum++; } } Console.WriteLine(bollNum); } }
[["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104]]
8
73
2
using System; class Program { static void Main(string[] args) { var inputLine = Console.ReadLine(); var b = 0; foreach (var c in inputLine) { if (inputLine[0] == '1') b++; } Console.WriteLine(b); } }
using System; class Program { static void Main(string[] args) { var inputLine = Console.ReadLine(); var b = 0; foreach (var c in inputLine) { if (c == '1') b++; } Console.WriteLine(b); } }
[["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22]]
8
62
5
using System; namespace Sample101 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); int counter = 0; if (s[0] == '1') ++counter; if (s[1] == '1') ++counter; if (s[2] == '2') ++counter; Console.WriteLine(counter); } } }
using System; namespace Sample101 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); int counter = 0; if (s[0] == '1') ++counter; if (s[1] == '1') ++counter; if (s[2] == '1') ++counter; Console.WriteLine(counter); } } }
[["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253]]
8
85
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication92 { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = 0; if (a == 111) b = 3; else if (a == 100 || a == 010 || a == 001) b = 2; else if (a == 000) b = 0; else if (a == 011 || a == 101 || a == 110) b = 1; Console.WriteLine(b); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication92 { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = 0; if (a == 111) b = 3; else if (a == 100 || a == 010 || a == 001) b = 1; else if (a == 000) b = 0; else if (a == 011 || a == 101 || a == 110) b = 2; Console.WriteLine(b); } } }
[["-", 0, 57, 75, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 57, 64, 1, 0, 11, 12, 203], ["-", 75, 57, 75, 57, 64, 1, 0, 11, 12, 203], ["+", 75, 57, 75, 57, 64, 1, 0, 11, 12, 203]]
8
131
4
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 = 0; var i = cin.ReadInt; int[] list = new int[i]; for (var x = 0; x < i; x = x + 1) { list[x] = cin.ReadInt; } var fla = false; for (var x = 0; true; x = x + 1) { for (var c = 0; c < 3; c = c + 1) { if (list[c] % 2 == 1 || list[c] == 0) { a = x; fla = true; break; } list[c] = list[c] / 2; } if (fla == true) { break; } } WriteLine(a.ToString()); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var a = 0; var i = cin.ReadInt; int[] list = new int[i]; for (var x = 0; x < i; x = x + 1) { list[x] = cin.ReadInt; } var fla = false; for (var x = 0; true; x = x + 1) { for (var c = 0; c < i; c = c + 1) { if (list[c] % 2 == 1 || list[c] == 0) { a = x; fla = true; break; } list[c] = list[c] / 2; } if (fla == true) { break; } } WriteLine(a.ToString()); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22]]
8
577
2
using System; using System.Collections.Generic; using System.Linq; namespace ABC081B { class Input { /// <summary> /// 1行の入力を取得する /// </summary> /// <returns>文字列</returns> public void String(out string s) { s = Console.ReadLine(); } /// <summary> /// 複数行の入力を取得 /// </summary> /// <returns>文字列の配列</returns> public void String(long rowNumber, out string[] s) { s = new String[rowNumber]; for (long i = 0; i < rowNumber; i++) { String(out s[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>int型の値</returns> public void Int(out int i) { string s; String(out s); i = int.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <param name="a"></param> public void Long(out long a) { string s; String(out s); a = long.Parse(s); } /// <summary> /// 2つの整数が1行に書かれている入力を、2つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> public void Long(out long a, out long b) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; } /// <summary> /// 3つの整数が1行に書かれている入力を、3つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(out long a, out long b, out long c) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; } /// <summary> /// 4つの整数が1行に書かれている入力を、4つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(out long a, out long b, out long c, out long d) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; d = lArr[3]; } public void Long(out long[] lArr) { lArr = Split().Select(long.Parse).ToArray(); } public void Long(long rowNumber, out long[] lArr) { lArr = new long[rowNumber]; for (long i = 0; i < rowNumber; i++) { Long(out lArr[i]); } } /// <summary> /// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> public void Long(long rowNumber, out long[] a, out long[] b) { a = new long[rowNumber]; b = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i]); } } /// <summary> /// 3つの整数が複数行に書かれている入力を、3つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i]); } } /// <summary> /// 4つの整数が複数行に書かれている入力を、4つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c, out long[] d) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; d = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i], out d[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の値</returns> public void Double(out double d) { string s; String(out s); d = double.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の配列</returns> public void Double(out double[] dArr) { dArr = Split().Select(double.Parse).ToArray(); } private IEnumerable<string> Split() { string s; String(out s); return s.Split(' '); } } class Program { static void Main(string[] args) { Solver solver = new Solver(); solver.Solve(); } } class Solver { public Solver() { Input input = new Input(); input.Long(out N); input.Long(out A); } private long N; private long[] A; public void Solve() { int cnt = 0; while (true) { bool can = true; for (long i = 0; i < N; i++) { if (A[i] % 2 == 0) { A[i] /= 2; } else { can = false; } } if (!can) { break; } } Console.WriteLine(cnt); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC081B { class Input { /// <summary> /// 1行の入力を取得する /// </summary> /// <returns>文字列</returns> public void String(out string s) { s = Console.ReadLine(); } /// <summary> /// 複数行の入力を取得 /// </summary> /// <returns>文字列の配列</returns> public void String(long rowNumber, out string[] s) { s = new String[rowNumber]; for (long i = 0; i < rowNumber; i++) { String(out s[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>int型の値</returns> public void Int(out int i) { string s; String(out s); i = int.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <param name="a"></param> public void Long(out long a) { string s; String(out s); a = long.Parse(s); } /// <summary> /// 2つの整数が1行に書かれている入力を、2つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> public void Long(out long a, out long b) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; } /// <summary> /// 3つの整数が1行に書かれている入力を、3つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(out long a, out long b, out long c) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; } /// <summary> /// 4つの整数が1行に書かれている入力を、4つのlongで受け取る /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(out long a, out long b, out long c, out long d) { long[] lArr; Long(out lArr); a = lArr[0]; b = lArr[1]; c = lArr[2]; d = lArr[3]; } public void Long(out long[] lArr) { lArr = Split().Select(long.Parse).ToArray(); } public void Long(long rowNumber, out long[] lArr) { lArr = new long[rowNumber]; for (long i = 0; i < rowNumber; i++) { Long(out lArr[i]); } } /// <summary> /// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> public void Long(long rowNumber, out long[] a, out long[] b) { a = new long[rowNumber]; b = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i]); } } /// <summary> /// 3つの整数が複数行に書かれている入力を、3つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i]); } } /// <summary> /// 4つの整数が複数行に書かれている入力を、4つのlong[]で受け取る /// </summary> /// <param name="rowNumber"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <param name="d"></param> public void Long(long rowNumber, out long[] a, out long[] b, out long[] c, out long[] d) { a = new long[rowNumber]; b = new long[rowNumber]; c = new long[rowNumber]; d = new long[rowNumber]; for (int i = 0; i < rowNumber; i++) { Long(out a[i], out b[i], out c[i], out d[i]); } } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の値</returns> public void Double(out double d) { string s; String(out s); d = double.Parse(s); } /// <summary> /// 1行の入力を取得 /// </summary> /// <returns>double型の配列</returns> public void Double(out double[] dArr) { dArr = Split().Select(double.Parse).ToArray(); } private IEnumerable<string> Split() { string s; String(out s); return s.Split(' '); } } class Program { static void Main(string[] args) { Solver solver = new Solver(); solver.Solve(); } } class Solver { public Solver() { Input input = new Input(); input.Long(out N); input.Long(out A); } private long N; private long[] A; public void Solve() { int cnt = 0; while (true) { bool can = true; for (long i = 0; i < N; i++) { if (A[i] % 2 == 0) { A[i] /= 2; } else { can = false; } } if (!can) { break; } cnt++; } Console.WriteLine(cnt); } } }
[["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
8
940
3
using System; using System.IO; using System.Collections.Generic; using System.Linq; namespace PastQuestions { class Program { static void Main(string[] args) { new Program().Solve(new Input(Console.In)); } public void Solve(Input input) { var n = input.ReadLine; var a = input.ReadLongArray; var count = 0; while (a.Count(l => l % 2 != 0) > 0) { a = a.Select(l => l / 2).ToArray(); count++; } Console.WriteLine(count); } } public class Input { private TextReader Stream { get; } private char Separator { get; } private Queue<string> InputStream { get; } public Input(TextReader stream, char separator = ' ') { Stream = stream; Separator = separator; InputStream = new Queue<string>(); } public string Read { get { if (InputStream.Count != 0) return InputStream.Dequeue(); string[] tmp = Stream.ReadLine().Split(Separator); for (int i = 0; i < tmp.Length; ++i) InputStream.Enqueue(tmp[i]); return InputStream.Dequeue(); } } public string ReadLine => Stream.ReadLine(); public int ReadInt => int.Parse(Read); public long ReadLong => long.Parse(Read); public double ReadDouble => double.Parse(Read); public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray(); } }
using System; using System.IO; using System.Collections.Generic; using System.Linq; namespace PastQuestions { class Program { static void Main(string[] args) { new Program().Solve(new Input(Console.In)); } public void Solve(Input input) { var n = input.ReadLine; var a = input.ReadLongArray; var count = 0; while (a.Count(l => l % 2 != 0) == 0) { a = a.Select(b => b / 2).ToArray(); count++; } Console.WriteLine(count); } } public class Input { private TextReader Stream { get; } private char Separator { get; } private Queue<string> InputStream { get; } public Input(TextReader stream, char separator = ' ') { Stream = stream; Separator = separator; InputStream = new Queue<string>(); } public string Read { get { if (InputStream.Count != 0) return InputStream.Dequeue(); string[] tmp = Stream.ReadLine().Split(Separator); for (int i = 0; i < tmp.Length; ++i) InputStream.Enqueue(tmp[i]); return InputStream.Dequeue(); } } public string ReadLine => Stream.ReadLine(); public int ReadInt => int.Parse(Read); public long ReadLong => long.Parse(Read); public double ReadDouble => double.Parse(Read); public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray(); } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 60], ["-", 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]]
8
339
6
using System; namespace MyApp { class Contest { public static int Main() { string[] ar = Console.ReadLine().Split(' '); string[] g = Console.ReadLine().Split(' '); int n = int.Parse(ar[0]); int[] t = new int[n]; for (int i = 0; i < n; ++i) { t[i] = int.Parse(g[i]); } int count = 0; while (true) { bool x = false; for (int i = 0; i < n; ++i) { if (t[i] % 2 == 0) { x = true; break; } t[i] = t[i] / 2; } if (x) { break; } count++; } Console.WriteLine(count); return 0; } } }
using System; namespace MyApp { class Contest { public static int Main() { string[] ar = Console.ReadLine().Split(' '); string[] g = Console.ReadLine().Split(' '); int n = int.Parse(ar[0]); int[] t = new int[n]; for (int i = 0; i < n; ++i) { t[i] = int.Parse(g[i]); } int count = 0; while (true) { bool x = false; for (int i = 0; i < n; ++i) { if (t[i] % 2 != 0) { x = true; break; } t[i] = t[i] / 2; } if (x) { break; } count++; } Console.WriteLine(count); return 0; } } }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79]]
8
194
2
using System; using System.Linq; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] numbers = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int count = 0; bool cond = true; while (cond) { for (int i = 0; i < n; i++) { if (numbers[i] % 2 == 1) { cond = false; break; } else { numbers[i] /= 2; } } if (!cond) { count++; } } Console.WriteLine(count); } }
using System; using System.Linq; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] numbers = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int count = 0; bool cond = true; while (cond) { for (int i = 0; i < n; i++) { if (numbers[i] % 2 == 1) { cond = false; break; } else { numbers[i] /= 2; } } if (cond) { count++; } } Console.WriteLine(count); } }
[["-", 0, 52, 8, 196, 0, 57, 15, 241, 0, 111]]
8
149
1
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Atcoder { public class Class1 { static void Main(string[] args) { int count = 0; int c = 1; var f = 0; var b = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(','); for (;;) { for (int i = 0; i < b; i++) { var d = int.Parse(a[i]) / c; if (d % 2 != 0) { f++; break; } if (i == b - 1) { count++; c = 2 * c; } } if (f != 0) { break; } } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Atcoder { public class Class1 { static void Main(string[] args) { int count = 0; int c = 1; var f = 0; var b = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(' '); for (;;) { for (int i = 0; i < b; i++) { var d = int.Parse(a[i]) / c; if (d % 2 != 0) { f++; break; } if (i == b - 1) { count++; c = 2 * c; } } if (f != 0) { break; } } Console.WriteLine(count); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253]]
8
176
2
using System; using System.Linq; namespace AtCoder.ABC10 { class Program { static void Main(string[] args) { var b081 = new B081(); b081.Answer(); } } public class B081 { public void Answer() { string _ = Console.ReadLine(); int[] numbers = Console.ReadLine() .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(s => int.Parse(s)) .ToArray(); int ans = Answer(numbers); Console.WriteLine(ans); } public int Answer(int[] numbers) { return numbers.Select(n => Divide2WhileEven(n)).Max(); } private int Divide2WhileEven(int x) { int ans = 0; while (true) { if (x % 2 != 0) { return ans; } x = x / 2; ans++; } } } }
using System; using System.Linq; namespace AtCoder.ABC10 { class Program { static void Main(string[] args) { var b081 = new B081(); b081.Answer(); } } public class B081 { public void Answer() { string _ = Console.ReadLine(); int[] numbers = Console.ReadLine() .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(s => int.Parse(s)) .ToArray(); int ans = Answer(numbers); Console.WriteLine(ans); } public int Answer(int[] numbers) { return numbers.Select(n => Divide2WhileEven(n)).Min(); } private int Divide2WhileEven(int x) { int ans = 0; while (true) { if (x % 2 != 0) { return ans; } x = x / 2; ans++; } } } }
[["-", 8, 196, 0, 37, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 37, 0, 213, 63, 214, 141, 22]]
8
193
2
using System; class Program { static void Main(string[] args) { int num = Int32.Parse(Console.ReadLine()); string[] arr = Console.ReadLine().Split(' '); int[] intarr = new int[num]; int i = 0; foreach (string s in arr) { intarr[i] = Int32.Parse(s); if (intarr[i] % 2 == 1) { Console.WriteLine(0); return; } i++; } for (i = 0; i < num; i++) { for (int j = 0; j < num; j++) { intarr[j] = intarr[j] / 2; if (intarr[j] % 2 != 0) { Console.WriteLine(i + 1); return; } } } } }
using System; class Program { static void Main(string[] args) { int num = Int32.Parse(Console.ReadLine()); string[] arr = Console.ReadLine().Split(' '); int[] intarr = new int[num]; int i = 0; foreach (string s in arr) { intarr[i] = Int32.Parse(s); if (intarr[i] % 2 == 1) { Console.WriteLine(0); return; } i++; } for (i = 0;; i++) { for (int j = 0; j < num; j++) { intarr[j] = intarr[j] / 2; if (intarr[j] % 2 != 0) { Console.WriteLine(i + 1); return; } } } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
8
179
3
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { Console.ReadLine(); var num = Console.ReadLine() .Split() .Select(int.Parse) .Aggregate(0, (p, n) => p | n, p => Convert.ToString((p & -p) - 1, 2)) .Count(); Console.WriteLine(num); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { Console.ReadLine(); var num = Console.ReadLine() .Split() .Select(int.Parse) .Aggregate(0, (p, n) => p | n, p => Convert.ToString((p & -p), 2)) .Count() - 1; Console.WriteLine(num); } } }
[["-", 8, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 8, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
8
104
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { var line = Console.ReadLine(); int n = int.Parse(line); int sum = 0; for (int i = 0; i < line.Length - 1; i++) { sum += (n % (int)Math.Pow(10, i + 1)) / (int)Math.Pow(10, i); } if (n % sum == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { var line = Console.ReadLine(); int n = int.Parse(line); int sum = 0; for (int i = 0; i < line.Length; i++) { sum += (n % (int)Math.Pow(10, i + 1)) / (int)Math.Pow(10, i); } if (n % sum == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } }
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
142
2
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.IO; using System.Text; using System.Diagnostics; using static util; using P = pair<int, int>; using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.BinaryExpression>; using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>; class Program { static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static Scan sc = new Scan(); const int M = 1000000007; const double eps = 1e-11; static readonly int[] dd = { 0, 1, 0, -1, 0 }; static void Main() { int n = sc.Int; int sum = 0; foreach (var item in n.ToString()) { sum += item - 'a'; } Prt(n % sum == 0 ? "Yes" : "No"); sw.Flush(); } static void DBG(string a) => Console.WriteLine(a); static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a)); static void DBG(params object[] a) => DBG(string.Join(" ", a)); static void Prt(string a) => sw.WriteLine(a); static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a)); static void Prt(params object[] a) => Prt(string.Join(" ", a)); } class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T v1; public U v2; public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; } public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2); public override string ToString() => v1 + " " + v2; } static class util { public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2); public static T sqr<T>(T a) => Operator<T>.Multiply(a, a); public static T Max<T>(params T[] a) => a.Max(); public static T Min<T>(params T[] a) => a.Min(); public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; } public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; } public static T[] copy<T>(this IList<T> a) { var ret = new T[a.Count]; for (int i = 0; i < a.Count; i++) ret[i] = a[i]; return ret; } } static class Operator<T> { static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x"); static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y"); public static readonly Func<T, T, T> Add = Lambda(Expression.Add); public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract); public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply); public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide); public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus); public static readonly Func<T, T> Negate = Lambda(Expression.Negate); public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile(); public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile(); } class Scan { public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public string Str => Console.ReadLine().Trim(); public P Pii { get { var ar = IntArr; return new P(ar[0], ar[1]); } } public int[] IntArr => StrArr.Select(int.Parse).ToArray(); public long[] LongArr => StrArr.Select(long.Parse).ToArray(); public double[] DoubleArr => StrArr.Select(double.Parse).ToArray(); public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries); bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); public void Multi<T>(out T a) => a = cv<T>(Str); public void Multi<T, U>(out T a, out U b) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); } public void Multi<T, U, V>(out T a, out U b, out V c) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } public 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 = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } static class mymath { public static long Mod = 1000000007; public static bool isprime(long a) { if (a < 2) return false; for (long i = 2; i * i <= a; i++) if (a % i == 0) return false; return true; } public static bool[] sieve(int n) { var p = new bool[n + 1]; for (int i = 2; i <= n; i++) p[i] = true; for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false; return p; } public static List<int> getprimes(int n) { var prs = new List<int>(); var p = sieve(n); for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i); return prs; } public static long[][] E(int n) { var ret = new long[n][]; for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; } return ret; } public static double[][] dE(int n) { var ret = new double[n][]; for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; } return ret; } public static long[][] pow(long[][] A, long n) { if (n == 0) return E(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double[][] pow(double[][] A, long n) { if (n == 0) return dE(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double dot(double[] x, double[] y) { int n = x.Length; double ret = 0; for (int i = 0; i < n; i++) ret += x[i] * y[i]; return ret; } public static double _dot(double[] x, double[] y) { int n = x.Length; double ret = 0, r = 0; for (int i = 0; i < n; i++) { double s = ret + (x[i] * y[i] + r); r = (x[i] * y[i] + r) - (s - ret); ret = s; } return ret; } public static long dot(long[] x, long[] y) { int n = x.Length; long ret = 0; for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod; return ret; } public static T[][] trans<T>(T[][] A) { int n = A[0].Length, m = A.Length; var ret = new T[n][]; for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; } return ret; } public static double[] mul(double[][] A, double[] x) { int n = A.Length; var ret = new double[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static long[] mul(long[][] A, long[] x) { int n = A.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static long[][] mul(long[][] A, long[][] B) { int n = A.Length; var Bt = trans(B); var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static double[][] mul(double[][] A, double[][] B) { int n = A.Length; var Bt = trans(B); var ret = new double[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static long[] add(long[] x, long[] y) { int n = x.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod; return ret; } public static long[][] add(long[][] A, long[][] B) { int n = A.Length; var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]); return ret; } public static long pow(long a, long b) { if (a >= Mod) return pow(a % Mod, b); if (a == 0) return 0; if (b == 0) return 1; var t = pow(a, b / 2); if ((b & 1) == 0) return t * t % Mod; return t * t % Mod * a % Mod; } public static long inv(long a) => pow(a, Mod - 2); public static long gcd(long a, long b) { while (b > 0) { var t = a % b; a = b; b = t; } return a; } // a x + b y = gcd(a, b) public static long extgcd(long a, long b, out long x, out long y) { long g = a; x = 1; y = 0; if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; } return g; } public static long lcm(long a, long b) => a / gcd(a, b) * b; static long[] facts; public static long[] setfacts(int n) { facts = new long[n + 1]; facts[0] = 1; for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod; return facts; } public static long comb(int n, int r) { if (n < 0 || r < 0 || r > n) return 0; if (n - r < r) r = n - r; if (r == 0) return 1; if (r == 1) return n; if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod; int[] numer = new int[r], denom = new int[r]; for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; } for (int p = 2; p <= r; p++) { int piv = denom[p - 1]; if (piv > 1) { int ofst = (n - r) % p; for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; } } } long ret = 1; for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod; return ret; } public static long[][] getcombs(int n) { var ret = new long[n + 1][]; for (int i = 0; i <= n; i++) { ret[i] = new long[i + 1]; ret[i][0] = ret[i][i] = 1; for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod; } return ret; } // nC0, nC2, ..., nCn public static long[] getcomb(int n) { var ret = new long[n + 1]; ret[0] = 1; for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod; return ret; } }
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.IO; using System.Text; using System.Diagnostics; using static util; using P = pair<int, int>; using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.BinaryExpression>; using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>; class Program { static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static Scan sc = new Scan(); const int M = 1000000007; const double eps = 1e-11; static readonly int[] dd = { 0, 1, 0, -1, 0 }; static void Main() { int n = sc.Int; int sum = 0; foreach (var item in n.ToString()) { sum += item - '0'; } Prt(n % sum == 0 ? "Yes" : "No"); sw.Flush(); } static void DBG(string a) => Console.WriteLine(a); static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a)); static void DBG(params object[] a) => DBG(string.Join(" ", a)); static void Prt(string a) => sw.WriteLine(a); static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a)); static void Prt(params object[] a) => Prt(string.Join(" ", a)); } class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T v1; public U v2; public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; } public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2); public override string ToString() => v1 + " " + v2; } static class util { public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2); public static T sqr<T>(T a) => Operator<T>.Multiply(a, a); public static T Max<T>(params T[] a) => a.Max(); public static T Min<T>(params T[] a) => a.Min(); public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; } public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; } public static T[] copy<T>(this IList<T> a) { var ret = new T[a.Count]; for (int i = 0; i < a.Count; i++) ret[i] = a[i]; return ret; } } static class Operator<T> { static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x"); static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y"); public static readonly Func<T, T, T> Add = Lambda(Expression.Add); public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract); public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply); public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide); public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus); public static readonly Func<T, T> Negate = Lambda(Expression.Negate); public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile(); public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile(); } class Scan { public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public string Str => Console.ReadLine().Trim(); public P Pii { get { var ar = IntArr; return new P(ar[0], ar[1]); } } public int[] IntArr => StrArr.Select(int.Parse).ToArray(); public long[] LongArr => StrArr.Select(long.Parse).ToArray(); public double[] DoubleArr => StrArr.Select(double.Parse).ToArray(); public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries); bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); public void Multi<T>(out T a) => a = cv<T>(Str); public void Multi<T, U>(out T a, out U b) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); } public void Multi<T, U, V>(out T a, out U b, out V c) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } public 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 = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } static class mymath { public static long Mod = 1000000007; public static bool isprime(long a) { if (a < 2) return false; for (long i = 2; i * i <= a; i++) if (a % i == 0) return false; return true; } public static bool[] sieve(int n) { var p = new bool[n + 1]; for (int i = 2; i <= n; i++) p[i] = true; for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false; return p; } public static List<int> getprimes(int n) { var prs = new List<int>(); var p = sieve(n); for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i); return prs; } public static long[][] E(int n) { var ret = new long[n][]; for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; } return ret; } public static double[][] dE(int n) { var ret = new double[n][]; for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; } return ret; } public static long[][] pow(long[][] A, long n) { if (n == 0) return E(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double[][] pow(double[][] A, long n) { if (n == 0) return dE(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double dot(double[] x, double[] y) { int n = x.Length; double ret = 0; for (int i = 0; i < n; i++) ret += x[i] * y[i]; return ret; } public static double _dot(double[] x, double[] y) { int n = x.Length; double ret = 0, r = 0; for (int i = 0; i < n; i++) { double s = ret + (x[i] * y[i] + r); r = (x[i] * y[i] + r) - (s - ret); ret = s; } return ret; } public static long dot(long[] x, long[] y) { int n = x.Length; long ret = 0; for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod; return ret; } public static T[][] trans<T>(T[][] A) { int n = A[0].Length, m = A.Length; var ret = new T[n][]; for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; } return ret; } public static double[] mul(double[][] A, double[] x) { int n = A.Length; var ret = new double[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static long[] mul(long[][] A, long[] x) { int n = A.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static long[][] mul(long[][] A, long[][] B) { int n = A.Length; var Bt = trans(B); var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static double[][] mul(double[][] A, double[][] B) { int n = A.Length; var Bt = trans(B); var ret = new double[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static long[] add(long[] x, long[] y) { int n = x.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod; return ret; } public static long[][] add(long[][] A, long[][] B) { int n = A.Length; var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]); return ret; } public static long pow(long a, long b) { if (a >= Mod) return pow(a % Mod, b); if (a == 0) return 0; if (b == 0) return 1; var t = pow(a, b / 2); if ((b & 1) == 0) return t * t % Mod; return t * t % Mod * a % Mod; } public static long inv(long a) => pow(a, Mod - 2); public static long gcd(long a, long b) { while (b > 0) { var t = a % b; a = b; b = t; } return a; } // a x + b y = gcd(a, b) public static long extgcd(long a, long b, out long x, out long y) { long g = a; x = 1; y = 0; if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; } return g; } public static long lcm(long a, long b) => a / gcd(a, b) * b; static long[] facts; public static long[] setfacts(int n) { facts = new long[n + 1]; facts[0] = 1; for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod; return facts; } public static long comb(int n, int r) { if (n < 0 || r < 0 || r > n) return 0; if (n - r < r) r = n - r; if (r == 0) return 1; if (r == 1) return n; if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod; int[] numer = new int[r], denom = new int[r]; for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; } for (int p = 2; p <= r; p++) { int piv = denom[p - 1]; if (piv > 1) { int ofst = (n - r) % p; for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; } } } long ret = 1; for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod; return ret; } public static long[][] getcombs(int n) { var ret = new long[n + 1][]; for (int i = 0; i <= n; i++) { ret[i] = new long[i + 1]; ret[i][0] = ret[i][i] = 1; for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod; } return ret; } // nC0, nC2, ..., nCn public static long[] getcomb(int n) { var ret = new long[n + 1]; ret[0] = 1; for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod; return ret; } }
[["-", 0, 1, 0, 11, 12, 16, 12, 252, 0, 253], ["+", 0, 1, 0, 11, 12, 16, 12, 252, 0, 253]]
8
3,860
2
#region using directives using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static System.Console; using static System.Convert; #endregion class Program { static void Main() { int n = ToInt32(ReadLine()); int s = 0, t = n; while (t > 0) { s += t % 10; t /= 10; } if (n % s == 0) Console.WriteLine("YES"); else Console.WriteLine("NO"); } }
#region using directives using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static System.Console; using static System.Convert; #endregion class Program { static void Main() { int n = ToInt32(ReadLine()); int s = 0, t = n; while (t > 0) { s += t % 10; t /= 10; } if (n % s == 0) Console.WriteLine("Yes"); else Console.WriteLine("No"); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
124
4
using System; using System.Linq; using System.Collections.Generic; namespace Contest { class Program { static void Main(string[] args) { ABC080.C(); } class ABC080 { public static void A() { var N = Read.Int(); var A = Read.Int(); var B = Read.Int(); Console.WriteLine(Math.Min(N * A, B)); } public static void B() { var N = Read.Int(); int h = 0, x = N; while (x > 0) { h += x % 10; x /= 10; } Console.WriteLine(N % h == 0 ? "Yes" : "No"); } public static void C() { var N = Read.Int(); var F = Read.LongMatrix(N, 10); var P = Read.LongMatrix(N, 10); var max = Int64.MinValue; for (int i = 1; i < 1024; ++i) { long sum = 0; for (int j = 0; j < N; ++j) { int count = 0; for (int k = 0; k < 10; ++k) { if (F[j, k] > 0 && (i & (1 << k)) > 0) { count++; } } sum += P[j, count]; } max = Math.Max(max, sum); } Console.WriteLine(max); } public static void D() {} } class Util { public static T[,] Gen<T>(int r, int c, T v) { var matrix = new T[r, c]; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { matrix[i, j] = v; } } return matrix; } public static long[] 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[,] ASum(long[,] matrix) { var N = matrix.GetLength(0); var M = matrix.GetLength(1); var res = new long[N + 1, M + 1]; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { res[i + 1, j + 1] = res[i, j + 1] + res[i + 1, j] - res[i, j] + matrix[i, j]; } } return res; } public static Dictionary<T, long> Frequency<T>(T[] array) { var dict = new Dictionary<T, long>(); foreach (var a in array) { if (!dict.ContainsKey(a)) { dict.Add(a, 0); } dict[a]++; } return dict; } public static bool IsPrime(long x) { var fact = Factorize(x); return fact.Count == 1 && fact.Values.ElementAt(0) == 1; } public static Dictionary<long, int> Factorize(long x) { var dict = new Dictionary<long, int>(); long minp = 2; while (x > 1) { bool ok = false; for (long p = minp; p * p <= x; ++p) { if (x % p == 0) { if (!dict.ContainsKey(p)) { dict.Add(p, 0); } dict[p]++; minp = p; x /= p; ok = true; break; } } if (!ok) { if (!dict.ContainsKey(x)) { dict.Add(x, 0); } dict[x]++; break; } } return dict; } public static HashSet<int> GenPrimes(int max) { var primes = new HashSet<int>(Enumerable.Range(2, max - 1)); for (int i = 2; i <= max; ++i) { if (primes.Contains(i)) { for (int j = 2;; ++j) { if (i * j > max) { break; } primes.Remove(i * j); } } } return primes; } } 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 ulong[] ULongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToUInt64(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(); if (!dict[ab[0]].Contains(ab[1])) { dict[ab[0]].Add(ab[1]); } if (!isDirectional && !dict[ab[1]].Contains(ab[0])) { 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) { ABC080.C(); } class ABC080 { public static void A() { var N = Read.Int(); var A = Read.Int(); var B = Read.Int(); Console.WriteLine(Math.Min(N * A, B)); } public static void B() { var N = Read.Int(); int h = 0, x = N; while (x > 0) { h += x % 10; x /= 10; } Console.WriteLine(N % h == 0 ? "Yes" : "No"); } public static void C() { var N = Read.Int(); var F = Read.LongMatrix(N, 10); var P = Read.LongMatrix(N, 11); var max = Int64.MinValue; for (int i = 1; i < 1024; ++i) { long sum = 0; for (int j = 0; j < N; ++j) { int count = 0; for (int k = 0; k < 10; ++k) { if (F[j, k] > 0 && (i & (1 << k)) > 0) { count++; } } sum += P[j, count]; } max = Math.Max(max, sum); } Console.WriteLine(max); } public static void D() {} } class Util { public static T[,] Gen<T>(int r, int c, T v) { var matrix = new T[r, c]; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { matrix[i, j] = v; } } return matrix; } public static long[] 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[,] ASum(long[,] matrix) { var N = matrix.GetLength(0); var M = matrix.GetLength(1); var res = new long[N + 1, M + 1]; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { res[i + 1, j + 1] = res[i, j + 1] + res[i + 1, j] - res[i, j] + matrix[i, j]; } } return res; } public static Dictionary<T, long> Frequency<T>(T[] array) { var dict = new Dictionary<T, long>(); foreach (var a in array) { if (!dict.ContainsKey(a)) { dict.Add(a, 0); } dict[a]++; } return dict; } public static bool IsPrime(long x) { var fact = Factorize(x); return fact.Count == 1 && fact.Values.ElementAt(0) == 1; } public static Dictionary<long, int> Factorize(long x) { var dict = new Dictionary<long, int>(); long minp = 2; while (x > 1) { bool ok = false; for (long p = minp; p * p <= x; ++p) { if (x % p == 0) { if (!dict.ContainsKey(p)) { dict.Add(p, 0); } dict[p]++; minp = p; x /= p; ok = true; break; } } if (!ok) { if (!dict.ContainsKey(x)) { dict.Add(x, 0); } dict[x]++; break; } } return dict; } public static HashSet<int> GenPrimes(int max) { var primes = new HashSet<int>(Enumerable.Range(2, max - 1)); for (int i = 2; i <= max; ++i) { if (primes.Contains(i)) { for (int j = 2;; ++j) { if (i * j > max) { break; } primes.Remove(i * j); } } } return primes; } } 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 ulong[] ULongN() { return Console.ReadLine() .Split(' ') .Select(s => Convert.ToUInt64(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(); if (!dict[ab[0]].Contains(ab[1])) { dict[ab[0]].Add(ab[1]); } if (!isDirectional && !dict[ab[1]].Contains(ab[0])) { 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; } } } }
[["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203]]
8
2,073
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using static Input; using static Util; class Program { static int N; static bool[][] B; static int[][] P; static void INPUT() { N = NextInt(); B = new bool [N][]; P = new int [N][]; for (int i = 0; i < N; i++) B[i] = LineInt().Select(__ => __ == 1).ToArray(); for (int i = 0; i < N; i++) P[i] = LineInt(); } static void OUT() { var max = int.MinValue; for (var b = 1; b < (1 << 10) - 1; b++) { var sum = 0; for (var n = 0; n < N; n++) { var nn = 0; for (var i = 0; i < 10; i++) { if ((b >> i) % 2 == 1) { if (B[n][i]) nn++; } } sum += P[n][nn]; } max = Math.Max(max, sum); } Console.WriteLine(max); } static void Main(string[] args) { #if DEBUG TESTINPUT(); INPUT(); #else INPUT(); #endif OUT(); } static void TESTINPUT() { // S = "1222"; } } public class Input { public const long MOD = 1000000007; public const int INF = 1000000007; private static Queue<string> q = new Queue<string>(); private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); } public static string NextString() { Confirm(); return q.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } } class Util {}
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using static Input; using static Util; class Program { static int N; static bool[][] B; static int[][] P; static void INPUT() { N = NextInt(); B = new bool [N][]; P = new int [N][]; for (int i = 0; i < N; i++) B[i] = LineInt().Select(__ => __ == 1).ToArray(); for (int i = 0; i < N; i++) P[i] = LineInt(); } static void OUT() { var max = int.MinValue; for (var b = 1; b < (1 << 10); b++) { var sum = 0; for (var n = 0; n < N; n++) { var nn = 0; for (var i = 0; i < 10; i++) { if ((b >> i) % 2 == 1) { if (B[n][i]) nn++; } } sum += P[n][nn]; } max = Math.Max(max, sum); } Console.WriteLine(max); } static void Main(string[] args) { #if DEBUG TESTINPUT(); INPUT(); #else INPUT(); #endif OUT(); } static void TESTINPUT() { // S = "1222"; } } public class Input { public const long MOD = 1000000007; public const int INF = 1000000007; private static Queue<string> q = new Queue<string>(); private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); } public static string NextString() { Confirm(); return q.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } } class Util {}
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
635
2
using System; using System.Collections; using System.Collections.Generic; using System.Text; public class C { public static void Main() { int N = Int32.Parse(Console.ReadLine()); string[] args; int[] F = new int[N]; for (int i = 0; i < N; i++) { args = Console.ReadLine().Split(' '); for (int j = 0; j < 5; j++) { for (int k = 0; k < 2; k++) { int term = 2 * j + k; F[i] |= (Int32.Parse(args[term]) << term); } } } int[,] P = new int[N, 10]; for (int i = 0; i < N; i++) { args = Console.ReadLine().Split(' '); for (int j = 0; j < 10; j++) { P[i, j] = Int32.Parse(args[j]); } } int ans = Int32.MinValue; for (int mask = 1; mask < (1 << 10); mask++) { int tmp = 0; for (int i = 0; i < N; i++) { int num = (int)popcount((ulong)(mask & F[i])); tmp += P[i, num]; } ans = Math.Max(ans, tmp); } Console.WriteLine(ans); } private static ulong popcount(ulong x) { ulong c = 0; c = (x & 0x5555555555555555) + ((x >> 1) & 0x5555555555555555); c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333); c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f); c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff); c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff); c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff); return (c); } }
using System; using System.Collections; using System.Collections.Generic; using System.Text; public class C { public static void Main() { int N = Int32.Parse(Console.ReadLine()); string[] args; int[] F = new int[N]; for (int i = 0; i < N; i++) { args = Console.ReadLine().Split(' '); for (int j = 0; j < 5; j++) { for (int k = 0; k < 2; k++) { int term = 2 * j + k; F[i] |= (Int32.Parse(args[term]) << term); } } } int[,] P = new int[N, 11]; for (int i = 0; i < N; i++) { args = Console.ReadLine().Split(' '); for (int j = 0; j <= 10; j++) { P[i, j] = Int32.Parse(args[j]); } } int ans = Int32.MinValue; for (int mask = 1; mask < (1 << 10); mask++) { int tmp = 0; for (int i = 0; i < N; i++) { int num = (int)popcount((ulong)(mask & F[i])); tmp += P[i, num]; } ans = Math.Max(ans, tmp); } Console.WriteLine(ans); } private static ulong popcount(ulong x) { ulong c = 0; c = (x & 0x5555555555555555) + ((x >> 1) & 0x5555555555555555); c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333); c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f); c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff); c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff); c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff); return (c); } }
[["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
8
456
4
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc80_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[][] f = new int [n][]; int[][] p = new int [n][]; for (int i = 0; i < n; i++) { int[] tmp = ReadLine().Split().Select(int.Parse).ToArray(); f[i] = tmp; } for (int i = 0; i < n; i++) { int[] tmp = ReadLine().Split().Select(int.Parse).ToArray(); p[i] = tmp; } int max = int.MinValue; for (int i = 1; i < (1 << 10); i++) { int cc = 0; for (int j = 0; j < n; j++) { int c = 0; for (int k = 0; k < 10; k++) { if (((i >> j & 1) == 1) && f[j][k] == 1) { c++; } } cc += p[j][c]; } max = Max(max, cc); } WriteLine(max); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc80_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[][] f = new int [n][]; int[][] p = new int [n][]; for (int i = 0; i < n; i++) { int[] tmp = ReadLine().Split().Select(int.Parse).ToArray(); f[i] = tmp; } for (int i = 0; i < n; i++) { int[] tmp = ReadLine().Split().Select(int.Parse).ToArray(); p[i] = tmp; } int max = int.MinValue; for (int i = 1; i < (1 << 10); i++) { int cc = 0; for (int j = 0; j < n; j++) { int c = 0; for (int k = 0; k < 10; k++) { if (((i >> k & 1) == 1) && f[j][k] == 1) { c++; } } cc += p[j][c]; } max = Max(max, cc); } WriteLine(max); } } }
[["-", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22]]
8
331
2
using System; using System.Linq; class P { static void Main() { var i = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); var d = i[1] - i[2]; long c; if (i[0] <= i[1]) c = 1; if (d <= 0) c = -1; else c = (((i[0] - i[1]) / d) + ((i[0] - i[1]) % d != 0 ? 1 : 0)) * 2 + 1; Console.WriteLine(c); } }
using System; using System.Linq; class P { static void Main() { var i = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); var d = i[1] - i[2]; long c; if (i[0] <= i[1]) c = 1; else if (d <= 0) c = -1; else c = (((i[0] - i[1]) / d) + ((i[0] - i[1]) % d != 0 ? 1 : 0)) * 2 + 1; Console.WriteLine(c); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
8
148
1
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 ProblemB { 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 S = NS; if (S == "AKIHABARA") Console.WriteLine("YES"); else if (S == "KIHABARA") Console.WriteLine("YES"); else if (S == "AKIHBARA") Console.WriteLine("YES"); else if (S == "KIHBARA") Console.WriteLine("YES"); else if (S == "AKIHABRA") Console.WriteLine("YES"); else if (S == "KIHABRA") Console.WriteLine("YES"); else if (S == "AKIHBRA") Console.WriteLine("YES"); else if (S == "KIHBRA") Console.WriteLine("YES"); else if (S == "AKIHABAR") Console.WriteLine("YES"); else if (S == "KIHABAR") Console.WriteLine("YES"); else if (S == "AKIHBAR") Console.WriteLine("YES"); else if (S == "KIHBAR") Console.WriteLine("YES"); else if (S == "AKIHABR") Console.WriteLine("YES"); else if (S == "KIHABR") Console.WriteLine("YES"); else if (S == "AKIHBR") Console.WriteLine("YES"); else if (S == "KIHBR") Console.WriteLine("YES"); Console.WriteLine("NO"); } 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 { 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 ProblemB { 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 S = NS; if (S == "AKIHABARA") Console.WriteLine("YES"); else if (S == "KIHABARA") Console.WriteLine("YES"); else if (S == "AKIHBARA") Console.WriteLine("YES"); else if (S == "KIHBARA") Console.WriteLine("YES"); else if (S == "AKIHABRA") Console.WriteLine("YES"); else if (S == "KIHABRA") Console.WriteLine("YES"); else if (S == "AKIHBRA") Console.WriteLine("YES"); else if (S == "KIHBRA") Console.WriteLine("YES"); else if (S == "AKIHABAR") Console.WriteLine("YES"); else if (S == "KIHABAR") Console.WriteLine("YES"); else if (S == "AKIHBAR") Console.WriteLine("YES"); else if (S == "KIHBAR") Console.WriteLine("YES"); else if (S == "AKIHABR") Console.WriteLine("YES"); else if (S == "KIHABR") Console.WriteLine("YES"); else if (S == "AKIHBR") Console.WriteLine("YES"); else if (S == "KIHBR") Console.WriteLine("YES"); else Console.WriteLine("NO"); } 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 { 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()); } }
[["+", 75, 57, 75, 57, 75, 57, 75, 57, 0, 95]]
8
1,704
1
using System; using System.Linq; using System.Collections.Generic; using System.IO; using static System.Console; namespace atcorder2 { class Program { public static long Read() { return long.Parse(ReadLine()); } public static long[] Reads() { return ReadLine().Split().Select(long.Parse).ToArray(); } public static long gcd(long x, long y) { if (y < x) gcd(y, x); while (y != 0) { var z = x % y; x = y; y = z; } return x; } static void Main(string[] args) { var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var s = ReadLine().ToArray(); var n = s.Length; var d = new Dictionary<char, long>(); d.Add('a', 0); d.Add('b', 0); d.Add('c', 0); for (int i = 0; i < n; i++) { d[s[i]]++; } if (Math.Abs(d['a'] - d['b']) <= 1 && Math.Abs(d['b'] - d['c']) <= 1 && Math.Abs(d['c'] - d['a']) <= 1) WriteLine("Yes"); else WriteLine("No"); Console.Out.Flush(); } } }
using System; using System.Linq; using System.Collections.Generic; using System.IO; using static System.Console; namespace atcorder2 { class Program { public static long Read() { return long.Parse(ReadLine()); } public static long[] Reads() { return ReadLine().Split().Select(long.Parse).ToArray(); } public static long gcd(long x, long y) { if (y < x) gcd(y, x); while (y != 0) { var z = x % y; x = y; y = z; } return x; } static void Main(string[] args) { var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var s = ReadLine().ToArray(); var n = s.Length; var d = new Dictionary<char, long>(); d.Add('a', 0); d.Add('b', 0); d.Add('c', 0); for (int i = 0; i < n; i++) { d[s[i]]++; } if (Math.Abs(d['a'] - d['b']) <= 1 && Math.Abs(d['b'] - d['c']) <= 1 && Math.Abs(d['c'] - d['a']) <= 1) WriteLine("YES"); else WriteLine("NO"); Console.Out.Flush(); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
345
4
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Numerics; using System.Xml.Schema; using System.Threading; using System.Diagnostics.CodeAnalysis; namespace AtCoder { public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); } public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); } public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); } public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); } public static int BuildBitCount(this int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } } partial class AtCoder { public string GetStr() { return Console.ReadLine().Trim(); } public char GetChar() { return Console.ReadLine().Trim()[0]; } public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<int>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; dic[a].Add(b); if (isDirected == false) dic[b].Add(a); } return dic; } Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<Edge>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<Edge>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; var c = input[2]; dic[a].Add(new Edge(b, c)); if (isDirected == false) dic[b].Add(new Edge(a, c)); } return dic; } bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); void Multi<T>(out T a) => a = cv<T>(GetStr()); void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } class Edge { public Edge(int to, long length) { To = to; Length = length; } public int To { get; set; } public long Length { get; set; } } partial class Program { static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new AtCoder().Solve(); Console.Out.Flush(); Console.Read(); } } public partial class AtCoder { public void Solve() { var S = GetStr(); var num = Enumerable.Range(0, 2) .Select(s => S.Count(c => c == (char)('a' + s))) .ToArray(); var ans = num.Max() - num.Min() <= 1 ? true : false; ans.YESNO(); } } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Numerics; using System.Xml.Schema; using System.Threading; using System.Diagnostics.CodeAnalysis; namespace AtCoder { public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); } public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); } public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); } public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); } public static int BuildBitCount(this int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } } partial class AtCoder { public string GetStr() { return Console.ReadLine().Trim(); } public char GetChar() { return Console.ReadLine().Trim()[0]; } public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<int>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; dic[a].Add(b); if (isDirected == false) dic[b].Add(a); } return dic; } Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<Edge>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<Edge>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; var c = input[2]; dic[a].Add(new Edge(b, c)); if (isDirected == false) dic[b].Add(new Edge(a, c)); } return dic; } bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); void Multi<T>(out T a) => a = cv<T>(GetStr()); void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } class Edge { public Edge(int to, long length) { To = to; Length = length; } public int To { get; set; } public long Length { get; set; } } partial class Program { static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new AtCoder().Solve(); Console.Out.Flush(); Console.Read(); } } public partial class AtCoder { public void Solve() { var S = GetStr(); var num = Enumerable.Range(0, 3) .Select(s => S.Count(c => c == (char)('a' + s))) .ToArray(); var ans = num.Max() - num.Min() <= 1 ? true : false; ans.YESNO(); } } }
[["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203]]
8
1,921
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace proconRCO2017 { class Program { static void Main(string[] args) { // var string = var input = Console.ReadLine(); var expected = "AKIHABARA"; var answer = ""; var inputIndex = 0; var expectedIndex = 0; for (var i = 0; i < expected.Length; i++) { if (inputIndex <= input.Length - 1 && input[inputIndex] == expected[expectedIndex]) { answer += input[inputIndex]; inputIndex++; } else { answer += 'A'; } expectedIndex++; } if (answer == expected && input.Length == expected.Length) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace proconRCO2017 { class Program { static void Main(string[] args) { // var string = var input = Console.ReadLine(); var expected = "AKIHABARA"; var answer = ""; var inputIndex = 0; var expectedIndex = 0; for (var i = 0; i < expected.Length; i++) { if (inputIndex <= input.Length - 1 && input[inputIndex] == expected[expectedIndex]) { answer += input[inputIndex]; inputIndex++; } else { answer += 'A'; } expectedIndex++; } if (answer == expected && input.Length <= expected.Length) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } } }
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19]]
8
178
2
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { string s = Console.ReadLine(); Console.WriteLine(s[1] == s[2] && s[1] == s[0] || s[1] == s[3] ? "Yes" : "No"); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { string s = Console.ReadLine(); Console.WriteLine((s[1] == s[2] && (s[1] == s[0] || s[1] == s[3])) ? "Yes" : "No"); } }
[["+", 3, 4, 0, 28, 0, 41, 15, 23, 0, 24], ["+", 0, 41, 15, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 41, 15, 23, 0, 16, 12, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 41, 15, 23, 0, 25]]
8
82
4
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace AtCoder { class Program { static void Main(string[] args) { //[summary]A - Good Integer string n = Console.ReadLine(); if (IsGoodInteger(n)) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } static bool IsGoodInteger(string n) { for (int i = 1; i <= 9; i++) { string s = i.ToString(); string good = s + s + s; if (n.StartsWith(good) | n.EndsWith(good)) { return true; } } return false; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace AtCoder { class Program { static void Main(string[] args) { //[summary]A - Good Integer string n = Console.ReadLine(); if (IsGoodInteger(n)) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } static bool IsGoodInteger(string n) { for (int i = 0; i <= 9; i++) { string s = i.ToString(); string good = s + s + s; if (n.StartsWith(good) | n.EndsWith(good)) { return true; } } return false; } } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
8
148
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ziyuutyou { class Program { static void Main(string[] args) { var x = Console.ReadLine(); if (x[0] == x[1] && x[1] == x[2] || x[0] == x[1] && x[2] == x[3]) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ziyuutyou { class Program { static void Main(string[] args) { var x = Console.ReadLine(); if (x[0] == x[1] && x[1] == x[2] || x[1] == x[2] && x[2] == x[3]) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
8
113
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace At { class Program { static void Main(string[] args) { var x = Read(); var list = new List<string>() { "111", "222", "333", "444", "555", "666", "777", "888", "999" }; foreach (var item in list) { if (x.Contains(item)) { WriteLine("Yes"); return; } } WriteLine("No"); } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace At { class Program { static void Main(string[] args) { var x = Read(); var list = new List<string>() { "000", "111", "222", "333", "444", "555", "666", "777", "888", "999" }; foreach (var item in list) { if (x.Contains(item)) { WriteLine("Yes"); return; } } WriteLine("No"); } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
[["+", 0, 212, 0, 230, 10, 229, 0, 5, 0, 222], ["+", 0, 212, 0, 230, 10, 229, 0, 5, 0, 62], ["+", 0, 200, 0, 212, 0, 230, 10, 229, 0, 21]]
8
314
4
using System; class A { public static void Main() { var s = Console.ReadLine(); Console.WriteLine(s[1] == s[2] && (s[0] == s[1] || s[0] == s[3]) ? "Yes" : "No"); } }
using System; class A { public static void Main() { var s = Console.ReadLine(); Console.WriteLine(s[1] == s[2] && (s[1] == s[0] || s[1] == s[3]) ? "Yes" : "No"); } }
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203]]
8
69
6
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main() { string s_data = Console.ReadLine(); string judge = string.Empty; bool result = false; for (int i = 0; i < 10; i++) { foreach (var x in Enumerable.Repeat(i, 3)) judge += x; result = s_data.Contains(judge); if (result) { Console.WriteLine("Yes"); break; } } if (!result) Console.WriteLine("No"); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main() { string s_data = Console.ReadLine(); string judge = string.Empty; bool result = false; for (int i = 0; i < 10; i++) { foreach (var x in Enumerable.Repeat(i, 3)) judge += x; result = s_data.Contains(judge); if (result) { Console.WriteLine("Yes"); break; } judge = string.Empty; } if (!result) Console.WriteLine("No"); } }
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 214, 205, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
8
121
6
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var N = Sarray()[0]; var Li_2 = 2L; var Li_1 = 1L; var Li = 0L; for (var i = 2; i <= N; ++i) { Li = Li_1 + Li_2; Li_2 = Li_1; Li_1 = Li; } WriteLine(Li); } static long Mod = (long)1e9 + 7; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var N = Sarray()[0]; var Li_2 = 2L; var Li_1 = 1L; var Li = 1L; for (var i = 2; i <= N; ++i) { Li = Li_1 + Li_2; Li_2 = Li_1; Li_1 = Li; } WriteLine(Li); } static long Mod = (long)1e9 + 7; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
436
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { static class Program { static void Main() { Solve(); Console.ReadKey(); } static void Solve() { var N = GetInt(); var L = new int[N + 1]; L[0] = 2; L[1] = 1; for (int i = 2; i < N + 1; i++) { L[i] = L[i - 2] + L[i - 1]; } var ans = L[N]; Console.WriteLine(ans); } static public string GetStr() { return Console.ReadLine(); } static public int GetInt() { return int.Parse(Console.ReadLine()); } static public long GetLong() { return long.Parse(Console.ReadLine()); } static public string[] GetStrArray() { return Console.ReadLine().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); } static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } } static string yesno(this bool b) { return b ? "yes" : "no"; } static string YesNo(this bool b) { return b ? "Yes" : "No"; } static string YESNO(this bool b) { return b ? "YES" : "NO"; } 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]); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { static class Program { static void Main() { Solve(); Console.ReadKey(); } static void Solve() { var N = GetInt(); var L = new long[N + 1]; L[0] = 2; L[1] = 1; for (int i = 2; i < N + 1; i++) { L[i] = L[i - 2] + L[i - 1]; } var ans = L[N]; Console.WriteLine(ans); } static public string GetStr() { return Console.ReadLine(); } static public int GetInt() { return int.Parse(Console.ReadLine()); } static public long GetLong() { return long.Parse(Console.ReadLine()); } static public string[] GetStrArray() { return Console.ReadLine().Split(' '); } static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); } static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } } static string yesno(this bool b) { return b ? "yes" : "no"; } static string YesNo(this bool b) { return b ? "Yes" : "No"; } static string YESNO(this bool b) { return b ? "YES" : "NO"; } 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]); } } }
[["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199]]
8
742
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Atcoderrrrrrr { static void Main(string[] args) { string N = Console.ReadLine(); List<double> lucas = new List<double>(); for (int i = 0; i < 87; i++) { if (i == 0) { lucas.Add(2); } else if (i == 1) { lucas.Add(1); } else { lucas.Add(lucas[i - 1] + lucas[i - 2]); } } Console.WriteLine(lucas[int.Parse(N)]); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Atcoderrrrrrr { static void Main(string[] args) { string N = Console.ReadLine(); List<long> lucas = new List<long>(); for (int i = 0; i < 87; i++) { if (i == 0) { lucas.Add(2); } else if (i == 1) { lucas.Add(1); } else { lucas.Add(lucas[i - 1] + lucas[i - 2]); } } Console.WriteLine(lucas[int.Parse(N)]); } } }
[["-", 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]]
8
153
4
using System; public class Hello { public static void Main() { int N = int.Parse(Console.ReadLine()); long[] num = new long[N]; num[0] = 1; num[1] = 0; for (int x = 2; x < N; x++) { num[x] = num[x - 1] + num[x - 2]; } Console.WriteLine(num[N - 1]); } }
using System; public class Hello { public static void Main() { int N = int.Parse(Console.ReadLine()); long[] num = new long[100]; num[0] = 2; num[1] = 1; for (int x = 2; x <= N; x++) { num[x] = num[x - 1] + num[x - 2]; } Console.WriteLine(num[N]); } }
[["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
102
10
using System; class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); long[] L = new long[N]; L[0] = 2; L[1] = 1; if (N >= 2) { for (int i = 2; i <= N; i++) { L[i] = L[i - 1] + L[i - 2]; } } Console.WriteLine(L[N]); } }
using System; class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); long[] L = new long[N + 1]; L[0] = 2; L[1] = 1; if (N >= 2) { for (int i = 2; i <= N; i++) { L[i] = L[i - 1] + L[i - 2]; } } Console.WriteLine(L[N]); } }
[["+", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203]]
8
107
2
using System; using System.Collections.Generic; using System.Linq; namespace ziyuutyou { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var str = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); var list = new List<int>(); var count = 0; var flag = true; for (var x = 0; x < N; x++) list.Add(str[x]); while (flag == true) { for (var x = 0; x < N; x++) { if (list[x] % 2 != 0) { flag = false; break; } else { list[x] = list[x] / 2; } } count++; } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ziyuutyou { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var str = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); var list = new List<int>(); var count = 0; var flag = true; for (var x = 0; x < N; x++) list.Add(str[x]); while (flag) { for (var x = 0; x < N; x++) { if (list[x] % 2 != 0) { flag = false; break; } else { list[x] = list[x] / 2; } } if (flag) count++; } Console.WriteLine(count); } } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 60], ["-", 8, 196, 0, 52, 15, 16, 12, 211, 0, 146], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 15, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25]]
8
183
6
using System; class Program { static void Main(string[] args) { int num = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int count = 0; bool canContinue = true; while (canContinue) { for (int i = 0; i < num; i++) { int value = int.Parse(input[i]); if (value % 2 == 0) { input[i] = (value / 2).ToString(); } else { canContinue = false; break; } } count++; } //出力 Console.WriteLine(count); } }
using System; class Program { static void Main(string[] args) { int num = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int count = 0; bool canContinue = true; while (canContinue) { for (int i = 0; i < num; i++) { int value = int.Parse(input[i]); if (value % 2 == 0) { input[i] = (value / 2).ToString(); } else { canContinue = false; break; } } if (canContinue) { count++; } } //出力 Console.WriteLine(count); } }
[["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 15, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
8
140
6
using System; namespace Beginner081_B { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] fuge = Console.ReadLine().Split(' '); long[] hoge = {}; for (int i = 0; i < n; i++) { hoge[i] = long.Parse(fuge[i]); } int cnt = 0; bool flag = true; while (flag) { for (int j = 0; j < n; j++) { if (hoge[j] % 2 == 0) { hoge[j] /= 2; } else flag = false; } if (flag) cnt++; } Console.WriteLine(cnt); } } }
using System; namespace Beginner081_B { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] fuge = Console.ReadLine().Split(' '); long[] hoge = new long[n]; for (int i = 0; i < n; i++) { hoge[i] = long.Parse(fuge[i]); } int cnt = 0; bool flag = true; while (flag) { for (int j = 0; j < n; j++) { if (hoge[j] % 2 == 0) { hoge[j] /= 2; } else flag = false; } if (flag) cnt++; } Console.WriteLine(cnt); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 229, 0, 45], ["-", 0, 198, 0, 200, 0, 212, 0, 229, 0, 46], ["+", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73]]
8
164
7
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.IO; using System.Text; using System.Diagnostics; using static util; using P = pair<int, int>; using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.BinaryExpression>; using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>; class Program { static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static Scan sc = new Scan(); const int M = 1000000007; // const int M = 998244353; const long LM = (long)1e18; const double eps = 1e-11; static readonly int[] dd = { 0, 1, 0, -1, 0 }; static void Main() { int n = sc.Int; var a = sc.IntArr; int ans = 0; for (int i = 0; i < n; i++) { for (int j = 1; j < 31; j++) { if ((a[i] & (1 << j) - 1) == 0) { ans = Math.Max(ans, j); } } } Prt(ans); sw.Flush(); } static void DBG(string a) => Console.WriteLine(a); static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a)); static void DBG(params object[] a) => DBG(string.Join(" ", a)); static void Prt(string a) => sw.WriteLine(a); static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a)); static void Prt(params object[] a) => Prt(string.Join(" ", a)); } class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T v1; public U v2; public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; } public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2); public override string ToString() => v1 + " " + v2; } static class util { public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]); public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2); public static T sqr<T>(T a) => Operator<T>.Multiply(a, a); public static T Max<T>(params T[] a) => a.Max(); public static T Min<T>(params T[] a) => a.Min(); public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; } public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; } public static T[] copy<T>(this IList<T> a) { var ret = new T[a.Count]; for (int i = 0; i < a.Count; i++) ret[i] = a[i]; return ret; } } static class Operator<T> { static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x"); static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y"); public static readonly Func<T, T, T> Add = Lambda(Expression.Add); public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract); public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply); public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide); public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus); public static readonly Func<T, T> Negate = Lambda(Expression.Negate); public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile(); public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile(); } class Scan { public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public string Str => Console.ReadLine().Trim(); public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U> { T a; U b; Multi(out a, out b); return make_pair(a, b); } public int[] IntArr => StrArr.Select(int.Parse).ToArray(); public long[] LongArr => StrArr.Select(long.Parse).ToArray(); public double[] DoubleArr => StrArr.Select(double.Parse).ToArray(); public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries); bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); public void Multi<T>(out T a) => a = cv<T>(Str); public void Multi<T, U>(out T a, out U b) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); } public void Multi<T, U, V>(out T a, out U b, out V c) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } public 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 = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } static class mymath { public static long Mod = 1000000007; public static bool isprime(long a) { if (a < 2) return false; for (long i = 2; i * i <= a; i++) if (a % i == 0) return false; return true; } public static bool[] sieve(int n) { var p = new bool[n + 1]; for (int i = 2; i <= n; i++) p[i] = true; for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false; return p; } public static List<int> getprimes(int n) { var prs = new List<int>(); var p = sieve(n); for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i); return prs; } public static long[][] E(int n) { var ret = new long[n][]; for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; } return ret; } public static double[][] dE(int n) { var ret = new double[n][]; for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; } return ret; } public static long[][] pow(long[][] A, long n) { if (n == 0) return E(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double[][] pow(double[][] A, long n) { if (n == 0) return dE(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double dot(double[] x, double[] y) { int n = x.Length; double ret = 0; for (int i = 0; i < n; i++) ret += x[i] * y[i]; return ret; } public static double _dot(double[] x, double[] y) { int n = x.Length; double ret = 0, r = 0; for (int i = 0; i < n; i++) { double s = ret + (x[i] * y[i] + r); r = (x[i] * y[i] + r) - (s - ret); ret = s; } return ret; } public static long dot(long[] x, long[] y) { int n = x.Length; long ret = 0; for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod; return ret; } public static T[][] trans<T>(T[][] A) { int n = A[0].Length, m = A.Length; var ret = new T[n][]; for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; } return ret; } public static double[] mul(double a, double[] x) { int n = x.Length; var ret = new double[n]; for (int i = 0; i < n; i++) ret[i] = a * x[i]; return ret; } public static long[] mul(long a, long[] x) { int n = x.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod; return ret; } public static double[] mul(double[][] A, double[] x) { int n = A.Length; var ret = new double[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static long[] mul(long[][] A, long[] x) { int n = A.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static double[][] mul(double a, double[][] A) { int n = A.Length; var ret = new double[n][]; for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]); return ret; } public static long[][] mul(long a, long[][] A) { int n = A.Length; var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]); return ret; } public static double[][] mul(double[][] A, double[][] B) { int n = A.Length; var Bt = trans(B); var ret = new double[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static long[][] mul(long[][] A, long[][] B) { int n = A.Length; var Bt = trans(B); var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static long[] add(long[] x, long[] y) { int n = x.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod; return ret; } public static long[][] add(long[][] A, long[][] B) { int n = A.Length; var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]); return ret; } public static long pow(long a, long b) { if (a >= Mod) return pow(a % Mod, b); if (a == 0) return 0; if (b == 0) return 1; var t = pow(a, b / 2); if ((b & 1) == 0) return t * t % Mod; return t * t % Mod * a % Mod; } public static long inv(long a) => pow(a, Mod - 2); public static long gcd(long a, long b) { while (b > 0) { var t = a % b; a = b; b = t; } return a; } // a x + b y = gcd(a, b) public static long extgcd(long a, long b, out long x, out long y) { long g = a; x = 1; y = 0; if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; } return g; } public static long lcm(long a, long b) => a / gcd(a, b) * b; static long[] facts; public static long[] setfacts(int n) { facts = new long[n + 1]; facts[0] = 1; for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod; return facts; } public static long comb(int n, int r) { if (n < 0 || r < 0 || r > n) return 0; if (n - r < r) r = n - r; if (r == 0) return 1; if (r == 1) return n; if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod; int[] numer = new int[r], denom = new int[r]; for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; } for (int p = 2; p <= r; p++) { int piv = denom[p - 1]; if (piv > 1) { int ofst = (n - r) % p; for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; } } } long ret = 1; for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod; return ret; } public static long[][] getcombs(int n) { var ret = new long[n + 1][]; for (int i = 0; i <= n; i++) { ret[i] = new long[i + 1]; ret[i][0] = ret[i][i] = 1; for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod; } return ret; } // nC0, nC2, ..., nCn public static long[] getcomb(int n) { var ret = new long[n + 1]; ret[0] = 1; for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod; return ret; } }
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.IO; using System.Text; using System.Diagnostics; using static util; using P = pair<int, int>; using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.BinaryExpression>; using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>; class Program { static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static Scan sc = new Scan(); const int M = 1000000007; // const int M = 998244353; const long LM = (long)1e18; const double eps = 1e-11; static readonly int[] dd = { 0, 1, 0, -1, 0 }; static void Main() { int n = sc.Int; var a = sc.IntArr; int ans = 100; for (int i = 0; i < n; i++) { for (int j = 1; j < 31; j++) { if ((a[i] & (1 << j) - 1) != 0) { ans = Math.Min(ans, j - 1); } } } Prt(ans); sw.Flush(); } static void DBG(string a) => Console.WriteLine(a); static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a)); static void DBG(params object[] a) => DBG(string.Join(" ", a)); static void Prt(string a) => sw.WriteLine(a); static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a)); static void Prt(params object[] a) => Prt(string.Join(" ", a)); } class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T v1; public U v2; public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; } public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2); public override string ToString() => v1 + " " + v2; } static class util { public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]); public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2); public static T sqr<T>(T a) => Operator<T>.Multiply(a, a); public static T Max<T>(params T[] a) => a.Max(); public static T Min<T>(params T[] a) => a.Min(); public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; } public static void swap<T>(this IList<T> a, int i, int j) { var t = a[i]; a[i] = a[j]; a[j] = t; } public static T[] copy<T>(this IList<T> a) { var ret = new T[a.Count]; for (int i = 0; i < a.Count; i++) ret[i] = a[i]; return ret; } } static class Operator<T> { static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x"); static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y"); public static readonly Func<T, T, T> Add = Lambda(Expression.Add); public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract); public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply); public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide); public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus); public static readonly Func<T, T> Negate = Lambda(Expression.Negate); public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile(); public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile(); } class Scan { public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public string Str => Console.ReadLine().Trim(); public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U> { T a; U b; Multi(out a, out b); return make_pair(a, b); } public int[] IntArr => StrArr.Select(int.Parse).ToArray(); public long[] LongArr => StrArr.Select(long.Parse).ToArray(); public double[] DoubleArr => StrArr.Select(double.Parse).ToArray(); public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries); bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); public void Multi<T>(out T a) => a = cv<T>(Str); public void Multi<T, U>(out T a, out U b) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); } public void Multi<T, U, V>(out T a, out U b, out V c) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } public 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 = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } static class mymath { public static long Mod = 1000000007; public static bool isprime(long a) { if (a < 2) return false; for (long i = 2; i * i <= a; i++) if (a % i == 0) return false; return true; } public static bool[] sieve(int n) { var p = new bool[n + 1]; for (int i = 2; i <= n; i++) p[i] = true; for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false; return p; } public static List<int> getprimes(int n) { var prs = new List<int>(); var p = sieve(n); for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i); return prs; } public static long[][] E(int n) { var ret = new long[n][]; for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; } return ret; } public static double[][] dE(int n) { var ret = new double[n][]; for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; } return ret; } public static long[][] pow(long[][] A, long n) { if (n == 0) return E(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double[][] pow(double[][] A, long n) { if (n == 0) return dE(A.Length); var t = pow(A, n / 2); if ((n & 1) == 0) return mul(t, t); return mul(mul(t, t), A); } public static double dot(double[] x, double[] y) { int n = x.Length; double ret = 0; for (int i = 0; i < n; i++) ret += x[i] * y[i]; return ret; } public static double _dot(double[] x, double[] y) { int n = x.Length; double ret = 0, r = 0; for (int i = 0; i < n; i++) { double s = ret + (x[i] * y[i] + r); r = (x[i] * y[i] + r) - (s - ret); ret = s; } return ret; } public static long dot(long[] x, long[] y) { int n = x.Length; long ret = 0; for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod; return ret; } public static T[][] trans<T>(T[][] A) { int n = A[0].Length, m = A.Length; var ret = new T[n][]; for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; } return ret; } public static double[] mul(double a, double[] x) { int n = x.Length; var ret = new double[n]; for (int i = 0; i < n; i++) ret[i] = a * x[i]; return ret; } public static long[] mul(long a, long[] x) { int n = x.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod; return ret; } public static double[] mul(double[][] A, double[] x) { int n = A.Length; var ret = new double[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static long[] mul(long[][] A, long[] x) { int n = A.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]); return ret; } public static double[][] mul(double a, double[][] A) { int n = A.Length; var ret = new double[n][]; for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]); return ret; } public static long[][] mul(long a, long[][] A) { int n = A.Length; var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]); return ret; } public static double[][] mul(double[][] A, double[][] B) { int n = A.Length; var Bt = trans(B); var ret = new double[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static long[][] mul(long[][] A, long[][] B) { int n = A.Length; var Bt = trans(B); var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]); return ret; } public static long[] add(long[] x, long[] y) { int n = x.Length; var ret = new long[n]; for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod; return ret; } public static long[][] add(long[][] A, long[][] B) { int n = A.Length; var ret = new long[n][]; for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]); return ret; } public static long pow(long a, long b) { if (a >= Mod) return pow(a % Mod, b); if (a == 0) return 0; if (b == 0) return 1; var t = pow(a, b / 2); if ((b & 1) == 0) return t * t % Mod; return t * t % Mod * a % Mod; } public static long inv(long a) => pow(a, Mod - 2); public static long gcd(long a, long b) { while (b > 0) { var t = a % b; a = b; b = t; } return a; } // a x + b y = gcd(a, b) public static long extgcd(long a, long b, out long x, out long y) { long g = a; x = 1; y = 0; if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; } return g; } public static long lcm(long a, long b) => a / gcd(a, b) * b; static long[] facts; public static long[] setfacts(int n) { facts = new long[n + 1]; facts[0] = 1; for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod; return facts; } public static long comb(int n, int r) { if (n < 0 || r < 0 || r > n) return 0; if (n - r < r) r = n - r; if (r == 0) return 1; if (r == 1) return n; if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod; int[] numer = new int[r], denom = new int[r]; for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; } for (int p = 2; p <= r; p++) { int piv = denom[p - 1]; if (piv > 1) { int ofst = (n - r) % p; for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; } } } long ret = 1; for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod; return ret; } public static long[][] getcombs(int n) { var ret = new long[n + 1][]; for (int i = 0; i <= n; i++) { ret[i] = new long[i + 1]; ret[i][0] = ret[i][i] = 1; for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod; } return ret; } // nC0, nC2, ..., nCn public static long[] getcomb(int n) { var ret = new long[n + 1]; ret[0] = 1; for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod; return ret; } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
4,243
8
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; using static System.Console; // using System.Numerics; // using static System.Math; class Program { static void Main() { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; void solve() { int max = 0; int N = cin.nextint; var A = cin.scanint; for (int i = 0; i < N; i++) { int cnt = 0; while (A[i] % 2 == 0) { A[i] /= 2; cnt++; } max = Math.Max(cnt, max); } WriteLine(max); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; using static System.Console; // using System.Numerics; // using static System.Math; class Program { static void Main() { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; void solve() { int max = int.MaxValue; int N = cin.nextint; var A = cin.scanint; for (int i = 0; i < N; i++) { int cnt = 0; while (A[i] % 2 == 0) { A[i] /= 2; cnt++; } max = Math.Min(cnt, max); } WriteLine(max); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22]]
8
430
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderA { static void Main() { var sc = new Scanner(); int n = sc.NextInt(); int k = sc.NextInt(); int[] a = sc.IntArray(); Dictionary<int, int> dic = new Dictionary<int, int>(); foreach (var num in a) { if (!dic.ContainsKey(num)) { dic.Add(num, 0); } dic[num]++; } List<int> list = dic.OrderBy(item => item.Value).Select(item => item.Value).ToList(); int answer = 0; for (int i = 0; i < list.Count - k; i++) { answer += list.IndexOf(i); } Console.WriteLine(answer); } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderA { static void Main() { var sc = new Scanner(); int n = sc.NextInt(); int k = sc.NextInt(); int[] a = sc.IntArray(); Dictionary<int, int> dic = new Dictionary<int, int>(); foreach (var num in a) { if (!dic.ContainsKey(num)) { dic.Add(num, 0); } dic[num]++; } List<int> list = dic.OrderBy(item => item.Value).Select(item => item.Value).ToList(); int answer = 0; for (int i = 0; i < list.Count - k; i++) { answer += list[i]; } Console.WriteLine(answer); } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73]]
8
488
6
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; namespace abc81_c { class Program { static void Main(string[] args) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); int[] nums = ReadLine().Split().Select(int.Parse).ToArray(); var dic = new Dictionary<int, int>(); foreach (var item in nums) { if (dic.ContainsKey(item)) dic[item]++; else dic[item] = 1; } int cnt = 0; if (dic.Count <= input[1]) { WriteLine(0); } else { var array = dic.OrderBy((x) => x.Value).ToArray(); for (int i = 0; i <= dic.Count - input[1]; i++) { cnt += array[i].Value; } WriteLine(cnt); } } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; namespace abc81_c { class Program { static void Main(string[] args) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); int[] nums = ReadLine().Split().Select(int.Parse).ToArray(); var dic = new Dictionary<int, int>(); foreach (var item in nums) { if (dic.ContainsKey(item)) dic[item]++; else dic[item] = 1; } int cnt = 0; if (dic.Count <= input[1]) { WriteLine(0); } else { var array = dic.OrderBy((x) => x.Value).ToArray(); for (int i = 0; i < dic.Count - input[1]; i++) { cnt += array[i].Value; } WriteLine(cnt); } } } }
[["-", 0, 57, 75, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 17, 18]]
8
221
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC080A { class Program { static void Main(string[] args) { int n, a, b, p1, p2, x; var word = Console.ReadLine().Split(' '); n = int.Parse(word[0]); a = int.Parse(word[1]); b = int.Parse(word[2]); p1 = n * a; p2 = b; if (p1 > p2) x = p1; else x = p2; Console.WriteLine(x); Console.ReadLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC080A { class Program { static void Main(string[] args) { int n, a, b, p1, p2, x; var word = Console.ReadLine().Split(' '); n = int.Parse(word[0]); a = int.Parse(word[1]); b = int.Parse(word[2]); p1 = n * a; p2 = b; if (p1 < p2) x = p1; else x = p2; Console.WriteLine(x); Console.ReadLine(); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18]]
8
149
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC080A { class Program { static void Main(string[] args) { int n, a, b, p1, p2, x; var word = Console.ReadLine().Split(' '); n = int.Parse(word[0]); a = int.Parse(word[1]); b = int.Parse(word[2]); p1 = a * n; p2 = b; x = p1 - p2; if (p1 < p2) Console.WriteLine(p1); else Console.WriteLine(p2); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC080A { class Program { static void Main(string[] args) { int n, a, b, p1, p2, x; var word = Console.ReadLine().Split(' '); n = int.Parse(word[0]); a = int.Parse(word[1]); b = int.Parse(word[2]); p1 = a * n; p2 = b; x = p1 - p2; if (p1 < p2) Console.WriteLine(p1); else Console.WriteLine(p2); Console.ReadKey(); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253]]
8
154
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC080A { class Program { static void Main(string[] args) { int n, a, b, p1, p2, x = 0; var word = Console.ReadLine().Split(' '); n = int.Parse(word[0]); a = int.Parse(word[1]); b = int.Parse(word[2]); p1 = n * a; p2 = b; if (p1 < p2) x = p1; else if (p1 > p2) x = p2; Console.WriteLine(x); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC080A { class Program { static void Main(string[] args) { int n, a, b, p1, p2, x = 0; var word = Console.ReadLine().Split(' '); n = int.Parse(word[0]); a = int.Parse(word[1]); b = int.Parse(word[2]); p1 = n * a; p2 = b; if (p1 < p2) x = p1; else x = p2; Console.WriteLine(x); Console.ReadKey(); } } }
[["-", 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, 47], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25]]
8
157
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class aaaa { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int A = int.Parse(input[1]); int B = int.Parse(input[2]); int planA = N * A; if (planA > B) { Console.WriteLine(B); } else { Console.WriteLine(A); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class aaaa { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int A = int.Parse(input[1]); int B = int.Parse(input[2]); int planA = N * A; if (planA > B) { Console.WriteLine(B); } else { Console.WriteLine(planA); } } } }
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
135
2
using System; using System.Linq; public class Test { public static void Main() { int[] n = System.Console.ReadLine() .Trim() .Split(' ') .Select(x => int.Parse(x)) .ToArray(); int[] m = { n[0] * n[1], n[2] }; System.Console.WriteLine(m.Max()); } }
using System; using System.Linq; public class Test { public static void Main() { int[] n = System.Console.ReadLine() .Trim() .Split(' ') .Select(x => int.Parse(x)) .ToArray(); int[] m = { n[0] * n[1], n[2] }; System.Console.WriteLine(m.Min()); } }
[["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22]]
8
96
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc080 { class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int A = int.Parse(input[1]); int B = int.Parse(input[1]); int ans = N * A <= B ? N * A : B; Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc080 { class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int A = int.Parse(input[1]); int B = int.Parse(input[2]); int ans = N * A <= B ? N * A : B; Console.WriteLine(ans); } } }
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
8
123
2
using System; class Program { static void Main(string[] args) { // スペース区切りの整数の入力 string[] input = Console.ReadLine().Split(' '); int _N = int.Parse(input[0]); int _A = int.Parse(input[1]); int _B = int.Parse(input[2]); Console.WriteLine((int)Math.Max(_N * _A, _B)); } }
using System; class Program { static void Main(string[] args) { // スペース区切りの整数の入力 string[] input = Console.ReadLine().Split(' '); int _N = int.Parse(input[0]); int _A = int.Parse(input[1]); int _B = int.Parse(input[2]); // int d=0; // if (_N*_A >_B){ // }else{ // } Console.WriteLine(Math.Min(_N * _A, _B)); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["-", 0, 28, 0, 74, 51, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22]]
8
95
5
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace AtCoder.Contest.B { static class Program { public static void Solve(Scanner cin) { long n = cin.ReadLong(); long fn = 0; long m = n; while (m > 1) { fn += m % 10; m /= 10; } YesNo(n % fn == 0); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) { if (condition) Console.WriteLine("YES"); else Console.WriteLine("NO"); } public static void YesNo(bool condition) { if (condition) Console.WriteLine("Yes"); else Console.WriteLine("No"); } public static void yesno(bool condition) { if (condition) Console.WriteLine("yes"); else Console.WriteLine("no"); } } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace AtCoder.Contest.B { static class Program { public static void Solve(Scanner cin) { long n = cin.ReadLong(); long fn = 0; long m = n; while (m > 0) { fn += m % 10; m /= 10; } YesNo(n % fn == 0); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) { if (condition) Console.WriteLine("YES"); else Console.WriteLine("NO"); } public static void YesNo(bool condition) { if (condition) Console.WriteLine("Yes"); else Console.WriteLine("No"); } public static void yesno(bool condition) { if (condition) Console.WriteLine("yes"); else Console.WriteLine("no"); } } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203]]
8
2,565
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass { public const long Giri = 1000000007; public const long DpInf = 99999999999999; public static void Main(string[] args) { var s = Console.ReadLine(); var x = s.ToInt(); long wa = 0; for (int i = 0; i < s.Length; i++) { wa += (s[i] - '0'); } if (wa % x == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } static long GCD(long a, long b) { var v = new[] { a, b }; while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; } return v[0]; } public static string[] Input() { return Console.ReadLine().Split(); } } public static class Smarter { public static int ToInt(this string str) { return int.Parse(str); } public static long ToLong(this string str) { return long.Parse(str); } public static int[] ToInt(this string[] str, int offset = 0) { var r = new int[str.Length]; for (int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset; return r; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass { public const long Giri = 1000000007; public const long DpInf = 99999999999999; public static void Main(string[] args) { var s = Console.ReadLine(); var x = s.ToLong(); long wa = 0; for (int i = 0; i < s.Length; i++) { wa += (s[i] - '0'); } if (x % wa == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } static long GCD(long a, long b) { var v = new[] { a, b }; while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; } return v[0]; } public static string[] Input() { return Console.ReadLine().Split(); } } public static class Smarter { public static int ToInt(this string str) { return int.Parse(str); } public static long ToLong(this string str) { return long.Parse(str); } public static int[] ToInt(this string[] str, int offset = 0) { var r = new int[str.Length]; for (int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset; return r; } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 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, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22]]
8
330
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Atcoderrrrrrr { static void Main(string[] args) { string N = Console.ReadLine(); int obj = 0; for (int i = 0; i < N.Length - 1; i++) { obj += int.Parse(N[i].ToString()); } Console.WriteLine(int.Parse(N) % obj == 0 ? "Yes" : "No"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Atcoderrrrrrr { static void Main(string[] args) { string N = Console.ReadLine(); int obj = 0; for (int i = 0; i < N.Length; i++) { obj += int.Parse(N[i].ToString()); } Console.WriteLine(int.Parse(N) % obj == 0 ? "Yes" : "No"); } } }
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
120
2
using System; using System.Collections.Generic; using System.Linq; using System.IO; using static System.Console; using static System.Int32; using static System.Math; class Program { static void Main(string[] args) { label: WriteLine(hoge() ? "Yes" : "No"); } static bool hoge() { var org = Parse(ReadLine()); int f = 0; for (int n = org; 0 < n; n /= 10) { f += org % 10; } return org % f == 0; } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using static System.Console; using static System.Int32; using static System.Math; class Program { static void Main(string[] args) { label: WriteLine(hoge() ? "Yes" : "No"); } static bool hoge() { var org = Parse(ReadLine()); int f = 0; for (int n = org; 0 < n; n /= 10) { f += n % 10; } return org % f == 0; } }
[["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22]]
8
122
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { public class ABC_080_B { public static int SumDigits(int num) { int sum = 0; while (num != 0) { sum += num % 10; num /= 10; } return sum; } public static void Main() { var n = int.Parse(Console.ReadLine()); var sum = SumDigits(n); if (n % sum == 0) { Console.WriteLine("yes"); } else { Console.WriteLine("no"); } Console.Read(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { public class ABC_080_B { public static int SumDigits(int num) { int sum = 0; while (num != 0) { sum += num % 10; num /= 10; } return sum; } public static void Main() { var n = int.Parse(Console.ReadLine()); var sum = SumDigits(n); if (n % sum == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } Console.Read(); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
132
4
using System; using System.Collections.Generic; using System.Linq; namespace arc084_c { class Program { static List<int> Back(List<int> list, int max, int limitlen) { if (list.Last() == 1) { list.RemoveAt(list.Count - 1); } else { list[list.Count - 1]--; if (list.Count != limitlen) list.Add(max); } return list; } static void Main(string[] args) { int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (x[0] % 2 == 0) { Console.Write(x[0] / 2); for (int i = 1; i < x[1]; i++) Console.Write(" " + x[0]); Console.WriteLine(); } else { List<int> list = new List<int>(); for (int i = 0; i < x[1]; i++) list.Add(x[0] / 2 + 1); for (int i = 0; i < x[1] / 2; i++) { list = Back(list, x[0], x[1]); } Console.WriteLine(string.Join(" ", list)); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace arc084_c { class Program { static List<int> Back(List<int> list, int max, int limitlen) { if (list.Last() == 1) { list.RemoveAt(list.Count - 1); } else { list[list.Count - 1]--; while (list.Count != limitlen) list.Add(max); } return list; } static void Main(string[] args) { int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (x[0] % 2 == 0) { Console.Write(x[0] / 2); for (int i = 1; i < x[1]; i++) Console.Write(" " + x[0]); Console.WriteLine(); } else { List<int> list = new List<int>(); for (int i = 0; i < x[1]; i++) list.Add(x[0] / 2 + 1); for (int i = 0; i < x[1] / 2; i++) { list = Back(list, x[0], x[1]); } Console.WriteLine(string.Join(" ", list)); } } } }
[["-", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 52, 0, 89]]
8
299
2
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public void Solve() { if (K % 2 == 0) { int[] ans = new int[N]; ans[0] = K / 2; for (int i = 1; i < N; i++) ans[i] = K; Console.WriteLine(String.Join(" ", ans)); } else { int[] ans = new int[N]; for (int i = 0; i < N; i++) ans[i] = (K + 1) / 2; int nn = (N - 1 + 1) / 2; int b = N - 1; for (int i = 0; i < nn; i++) { while (ans[b] == 0) b--; ans[b]--; if (ans[b] > 0) { b++; for (; b < N; b++) ans[b] = K; } } List<int> a = ans.ToList(); while (a[a.Count - 1] == 0) a.RemoveAt(a.Count - 1); Console.WriteLine(String.Join(" ", a)); } } int K, N; public Sol() { var d = ria(); K = d[0]; N = d[1]; } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); } static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); } static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); } static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public void Solve() { if (K % 2 == 0) { int[] ans = new int[N]; ans[0] = K / 2; for (int i = 1; i < N; i++) ans[i] = K; Console.WriteLine(String.Join(" ", ans)); } else { int[] ans = new int[N]; for (int i = 0; i < N; i++) ans[i] = (K + 1) / 2; int nn = (N - 1 + 1) / 2; int b = N - 1; for (int i = 0; i < nn; i++) { while (ans[b] == 0) b--; ans[b]--; if (ans[b] > 0) { b++; for (; b < N; b++) ans[b] = K; b = N - 1; } } List<int> a = ans.ToList(); while (a[a.Count - 1] == 0) a.RemoveAt(a.Count - 1); Console.WriteLine(String.Join(" ", a)); } } int K, N; public Sol() { var d = ria(); K = d[0]; N = d[1]; } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); } static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); } static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); } static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); } }
[["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
559
6
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Xml.Schema; namespace AtCoder { public class Solver { private readonly IInputReader _inputReader; private readonly IOutputWriter _outputWriter; public Solver(IInputReader inputReader, IOutputWriter outputWriter) { _inputReader = inputReader; _outputWriter = outputWriter; } public void Solve() { var R = _inputReader.ReadLine().ToInt(); var G = _inputReader.ReadLine().ToInt(); _outputWriter.WriteLine((G - R) * 2 + R.ToString()); } } public static class Combination { public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) { if (k == 1) { foreach (var item in items) yield return new T[] { item }; yield break; } foreach (var item in items) { var leftside = new T[] { item }; // item よりも前のものを除く (順列と組み合わせの違い) // 重複を許さないので、unusedから item そのものも取り除く var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList(); foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) { yield return leftside.Concat(rightside).ToArray(); } } } } internal class Program { static void Main(string[] args) { var reader = new ConsoleInputReader(); var writer = new ConsoleOutputWriter(); new Solver(reader, writer).Solve(); } } public interface IInputReader { string ReadLine(); } public interface IOutputWriter { void WriteLine(string output); } internal class ConsoleInputReader : IInputReader { public string ReadLine() => Console.ReadLine(); } internal class ConsoleOutputWriter : IOutputWriter { public void WriteLine(string output) => Console.WriteLine(output); } public static class StringExtensions { public static char ToChar(this string text) => text[0]; public static string[] ToStringArray(this string text) => text.Split(' ').ToArray(); public static int ToInt(this string text) => int.Parse(text); public static int[] ToIntArray(this string text) => text.Split(' ').Select(txt => txt.ToInt()).ToArray(); public static (int, int) ToInt2(this string text) { var arr = text.ToIntArray(); return (arr[0], arr[1]); } public static (int, int, int) ToInt3(this string text) { var arr = text.ToIntArray(); return (arr[0], arr[1], arr[2]); } public static long ToLong(this string text) => long.Parse(text); public static long[] ToLongArray(this string text) => text.Split(' ').Select(txt => txt.ToLong()).ToArray(); public static string ToJoinedString(this string[] texts, string separator = "") => string.Join(separator, texts); public static string ToJoinedString(this char[] chars) => string.Join("", chars); public static string ToYESNO(this bool b) => b ? "YES" : "NO"; public static string ToYesNo(this bool b) => b ? "Yes" : "No"; } public struct ModLong : IEquatable<ModLong> { private const long Mod = 1000000007; private readonly long _value; public ModLong(long value) { _value = (value % Mod + Mod) % Mod; } public bool Equals(ModLong other) { return _value == other._value; } public override bool Equals(object obj) { return obj is ModLong other && Equals(other); } public override int GetHashCode() { return _value.GetHashCode(); } public static bool operator ==(ModLong left, ModLong right) { return left.Equals(right); } public static bool operator !=(ModLong left, ModLong right) { return !left.Equals(right); } public static ModLong operator +(ModLong left, ModLong right) { return (ModLong)(left._value + right._value); } public static ModLong operator -(ModLong left, ModLong right) { return (ModLong)(left._value - right._value); } public static ModLong operator *(ModLong left, ModLong right) { return (ModLong)(left._value * right._value); } public static ModLong operator /(ModLong left, ModLong right) { return (ModLong)(left._value * Util.ModInv(right._value, Mod)); } public static explicit operator long(ModLong num) { return num._value; } public static explicit operator ModLong(long num) { return new ModLong(num); } public override string ToString() => _value.ToString(); } public class ModCombination { private const int Max = 510000; private const long Mod = 1000000007; private long[] fac = new long[Max]; private long[] finv = new long[Max]; private long[] inv = new long[Max]; public ModCombination() { fac[0] = 1; fac[1] = 1; finv[0] = 1; finv[1] = 1; inv[1] = 1; for (var 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; } } /// <summary> /// mCn 組み合わせ /// </summary> /// <param name="m"></param> /// <param name="n"></param> /// <returns></returns> public long Combination(long m, long n) { if (m < n) return 0; if (m < 0 || n < 0) return 0; return fac[m] * (finv[n] * finv[m - n] % Mod) % Mod; } } public class Util { /// <summary> /// a^n mod を計算する /// </summary> /// <param name="a"></param> /// <param name="n"></param> /// <param name="mod"></param> /// <returns></returns> public static long ModPow(long a, long n, long mod) { long res = 1; while (n > 0) { if ((n & 1) == 1) { res = res * a % mod; } a = a * a % mod; n >>= 1; } return res; } /// <summary> /// a^{-1} mod を計算する /// </summary> /// <param name="a"></param> /// <param name="mod"></param> /// <returns></returns> public static long ModInv(long a, long mod) { return ModPow(a, mod - 2, mod); } /// <summary> /// 階乗 /// </summary> /// <param name="n"></param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public static long ModFactional(long n) { if (n < 0) throw new ArgumentOutOfRangeException(nameof(n)); ModLong result = (ModLong)1; for (var i = 1; i <= n; i++) { result *= (ModLong)i; } return (long)result; } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Xml.Schema; namespace AtCoder { public class Solver { private readonly IInputReader _inputReader; private readonly IOutputWriter _outputWriter; public Solver(IInputReader inputReader, IOutputWriter outputWriter) { _inputReader = inputReader; _outputWriter = outputWriter; } public void Solve() { var R = _inputReader.ReadLine().ToInt(); var G = _inputReader.ReadLine().ToInt(); _outputWriter.WriteLine(((G - R) * 2 + R).ToString()); } } public static class Combination { public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) { if (k == 1) { foreach (var item in items) yield return new T[] { item }; yield break; } foreach (var item in items) { var leftside = new T[] { item }; // item よりも前のものを除く (順列と組み合わせの違い) // 重複を許さないので、unusedから item そのものも取り除く var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList(); foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) { yield return leftside.Concat(rightside).ToArray(); } } } } internal class Program { static void Main(string[] args) { var reader = new ConsoleInputReader(); var writer = new ConsoleOutputWriter(); new Solver(reader, writer).Solve(); } } public interface IInputReader { string ReadLine(); } public interface IOutputWriter { void WriteLine(string output); } internal class ConsoleInputReader : IInputReader { public string ReadLine() => Console.ReadLine(); } internal class ConsoleOutputWriter : IOutputWriter { public void WriteLine(string output) => Console.WriteLine(output); } public static class StringExtensions { public static char ToChar(this string text) => text[0]; public static string[] ToStringArray(this string text) => text.Split(' ').ToArray(); public static int ToInt(this string text) => int.Parse(text); public static int[] ToIntArray(this string text) => text.Split(' ').Select(txt => txt.ToInt()).ToArray(); public static (int, int) ToInt2(this string text) { var arr = text.ToIntArray(); return (arr[0], arr[1]); } public static (int, int, int) ToInt3(this string text) { var arr = text.ToIntArray(); return (arr[0], arr[1], arr[2]); } public static long ToLong(this string text) => long.Parse(text); public static long[] ToLongArray(this string text) => text.Split(' ').Select(txt => txt.ToLong()).ToArray(); public static string ToJoinedString(this string[] texts, string separator = "") => string.Join(separator, texts); public static string ToJoinedString(this char[] chars) => string.Join("", chars); public static string ToYESNO(this bool b) => b ? "YES" : "NO"; public static string ToYesNo(this bool b) => b ? "Yes" : "No"; } public struct ModLong : IEquatable<ModLong> { private const long Mod = 1000000007; private readonly long _value; public ModLong(long value) { _value = (value % Mod + Mod) % Mod; } public bool Equals(ModLong other) { return _value == other._value; } public override bool Equals(object obj) { return obj is ModLong other && Equals(other); } public override int GetHashCode() { return _value.GetHashCode(); } public static bool operator ==(ModLong left, ModLong right) { return left.Equals(right); } public static bool operator !=(ModLong left, ModLong right) { return !left.Equals(right); } public static ModLong operator +(ModLong left, ModLong right) { return (ModLong)(left._value + right._value); } public static ModLong operator -(ModLong left, ModLong right) { return (ModLong)(left._value - right._value); } public static ModLong operator *(ModLong left, ModLong right) { return (ModLong)(left._value * right._value); } public static ModLong operator /(ModLong left, ModLong right) { return (ModLong)(left._value * Util.ModInv(right._value, Mod)); } public static explicit operator long(ModLong num) { return num._value; } public static explicit operator ModLong(long num) { return new ModLong(num); } public override string ToString() => _value.ToString(); } public class ModCombination { private const int Max = 510000; private const long Mod = 1000000007; private long[] fac = new long[Max]; private long[] finv = new long[Max]; private long[] inv = new long[Max]; public ModCombination() { fac[0] = 1; fac[1] = 1; finv[0] = 1; finv[1] = 1; inv[1] = 1; for (var 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; } } /// <summary> /// mCn 組み合わせ /// </summary> /// <param name="m"></param> /// <param name="n"></param> /// <returns></returns> public long Combination(long m, long n) { if (m < n) return 0; if (m < 0 || n < 0) return 0; return fac[m] * (finv[n] * finv[m - n] % Mod) % Mod; } } public class Util { /// <summary> /// a^n mod を計算する /// </summary> /// <param name="a"></param> /// <param name="n"></param> /// <param name="mod"></param> /// <returns></returns> public static long ModPow(long a, long n, long mod) { long res = 1; while (n > 0) { if ((n & 1) == 1) { res = res * a % mod; } a = a * a % mod; n >>= 1; } return res; } /// <summary> /// a^{-1} mod を計算する /// </summary> /// <param name="a"></param> /// <param name="mod"></param> /// <returns></returns> public static long ModInv(long a, long mod) { return ModPow(a, mod - 2, mod); } /// <summary> /// 階乗 /// </summary> /// <param name="n"></param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public static long ModFactional(long n) { if (n < 0) throw new ArgumentOutOfRangeException(nameof(n)); ModLong result = (ModLong)1; for (var i = 1; i <= n; i++) { result *= (ModLong)i; } return (long)result; } } }
[["+", 205, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 213, 63, 214, 205, 23, 0, 25]]
8
1,410
2
using System; using System.Linq; using System.Collections.Generic; namespace program { class Program { static void Main() { int n = Input.ScanInt(); int m = Input.ScanInt(); Console.WriteLine(m + (m - n) * 2); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(' '); } } static class MyMath { public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong GCD(ulong a, ulong b) { Func<ulong, ulong, ulong> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); } } }
using System; using System.Linq; using System.Collections.Generic; namespace program { class Program { static void Main() { int n = Input.ScanInt(); int m = Input.ScanInt(); Console.WriteLine(n + (m - n) * 2); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(' '); } } static class MyMath { public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong GCD(ulong a, ulong b) { Func<ulong, ulong, ulong> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22]]
8
594
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int n = int.Parse(System.Console.ReadLine()); int m = int.Parse(System.Console.ReadLine()); System.Console.WriteLine((m - n) * 2); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int n = int.Parse(System.Console.ReadLine()); int m = int.Parse(System.Console.ReadLine()); System.Console.WriteLine(n + (m - n) * 2); } } }
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
8
93
2
using System; class Problem { public static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var k = int.Parse(Console.ReadLine()); var min = 0; for (var i = 0; i < n; i++) min = Math.Min(min * 2, min + k); Console.WriteLine($"{min}"); } }
using System; class Problem { public static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var k = int.Parse(Console.ReadLine()); var min = 1; for (var i = 0; i < n; i++) min = Math.Min(min * 2, min + k); Console.WriteLine($"{min}"); } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
92
2
using System; using static System.Math; class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); var k = long.Parse(Console.ReadLine()); var count = 0L; for (int i = 0; i < n; i++) { count = Min(count * 2, count + k); } Console.WriteLine(count); } }
using System; using static System.Math; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); var count = 1L; for (int i = 0; i < n; i++) { count = Min(count * 2, count + k); } Console.WriteLine(count); } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
93
10
using System; using System.Collections.Generic; using System.Linq; public class Program { static public void Main() { var s = new Sol(); s.Solve1(); s.Solve2(); s.Solve3(); } } public class Sol { // ARC076 C Dubious Document2 // https://atcoder.jp/contests/abc076/tasks/abc076_c public void Solve1() { string s = Console.ReadLine(); string t = Console.ReadLine(); var L = new List<string>(); // sの始点 for (int i = 0; i <= s.Length - t.Length; i++) { bool ok = true; // tと比較 for (int j = 0; j < t.Length; j++) { if (s[i + j] == '?') continue; if (s[i + j] != t[j]) ok = false; break; } if (ok) { string ans = ""; for (int j = 0; j < i; j++) { if (s[j] == '?') ans += 'a'; else ans += s[j]; } ans += t; for (int j = i + t.Length; j < s.Length; j++) { if (s[j] == '?') ans += 'a'; else ans += s[j]; } L.Add(ans); } } if (L.Count > 0) Console.WriteLine(L[L.Count - 1]); else Console.WriteLine("UNRESTORABLE"); } // // public void Solve2() {} // // public void Solve3() {} }
using System; using System.Collections.Generic; using System.Linq; public class Program { static public void Main() { var s = new Sol(); s.Solve1(); s.Solve2(); s.Solve3(); } } public class Sol { // ARC076 C Dubious Document2 // https://atcoder.jp/contests/abc076/tasks/abc076_c public void Solve1() { string s = Console.ReadLine(); string t = Console.ReadLine(); var L = new List<string>(); // sの始点 for (int i = 0; i <= s.Length - t.Length; i++) { bool ok = true; // tと比較 for (int j = 0; j < t.Length; j++) { if (s[i + j] == '?') continue; if (s[i + j] == t[j]) continue; ok = false; } if (ok) { string ans = ""; for (int j = 0; j < i; j++) { if (s[j] == '?') ans += 'a'; else ans += s[j]; } ans += t; for (int j = i + t.Length; j < s.Length; j++) { if (s[j] == '?') ans += 'a'; else ans += s[j]; } L.Add(ans); } } if (L.Count > 0) Console.WriteLine(L[L.Count - 1]); else Console.WriteLine("UNRESTORABLE"); } // // public void Solve2() {} // // public void Solve3() {} }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 94]]
8
340
6
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; class MainClass { static void Main() { string S = ReadLine(); string T = ReadLine(); int N = S.Length; int M = T.Length; for (int i = N - M; i >= 0; i++) { bool frag = true; for (int j = 0; j < M; j++) { if (S[i + j] == '?' || S[i + j] == T[j]) continue; frag = false; break; } if (frag) { var ans = S.ToCharArray(); for (int j = 0; j < M; j++) { ans[i + j] = T[j]; } ans = ans.Select(_ => _ == '?' ? 'a' : _).ToArray(); WriteLine(string.Join("", ans)); return; } } WriteLine("UNRESTORABLE"); } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; class MainClass { static void Main() { string S = ReadLine(); string T = ReadLine(); int N = S.Length; int M = T.Length; for (int i = N - M; i >= 0; i--) { bool frag = true; for (int j = 0; j < M; j++) { if (S[i + j] == '?' || S[i + j] == T[j]) continue; frag = false; break; } if (frag) { var ans = S.ToCharArray(); for (int j = 0; j < M; j++) { ans[i + j] = T[j]; } ans = ans.Select(_ => _ == '?' ? 'a' : _).ToArray(); WriteLine(string.Join("", ans)); return; } } WriteLine("UNRESTORABLE"); } }
[["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68]]
8
228
2
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()); Out.Flush(); } } } public class Solve { public static void Answer() { var S = ReadLine(); var T = ReadLine(); int idx = -1; for (int i = 0; i < S.Length - T.Length + 1; i++) { bool f = true; for (int j = 0; j < T.Length; j++) { if (S[i + j] == '?') continue; else if (S[i + j] == T[j]) continue; else f = false; } if (f) idx = i; } if (idx == -1) { WriteLine("UNRESTORABLE"); return; } var sb = new StringBuilder(); for (int i = 0; i < S.Length; i++) { if (i == idx) { sb.Append(T); i += T.Length; continue; } if (S[i] == '?') sb.Append('a'); else sb.Append(S[i]); } WriteLine(sb.ToString()); } } 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()); Out.Flush(); } } } public class Solve { public static void Answer() { var S = ReadLine(); var T = ReadLine(); int idx = -1; for (int i = 0; i < S.Length - T.Length + 1; i++) { bool f = true; for (int j = 0; j < T.Length; j++) { if (S[i + j] == '?') continue; else if (S[i + j] == T[j]) continue; else f = false; } if (f) idx = i; } if (idx == -1) { WriteLine("UNRESTORABLE"); return; } var sb = new StringBuilder(); for (int i = 0; i < S.Length; i++) { if (i == idx) { sb.Append(T); i += T.Length - 1; continue; } if (S[i] == '?') sb.Append('a'); else sb.Append(S[i]); } WriteLine(sb.ToString()); } } 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 } }
[["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
8
689
2