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
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleTest { class Program { static void Main(string[] args) { int[] p = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); // Console.WriteLine(string.Join(',', p.Select(i => i.ToString()))); var n = p[0] / (p[1] + p[2]); var mod = p[0] % (p[1] + p[2]); var result = n * p[1] + Math.Min(mod, p[1]); Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleTest { class Program { static void Main(string[] args) { long[] p = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); // Console.WriteLine(string.Join(',', p.Select(i => i.ToString()))); long n = p[0] / (p[1] + p[2]); long mod = p[0] % (p[1] + p[2]); long result = n * p[1] + Math.Min(mod, p[1]); Console.WriteLine(result); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
138
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { static void Main(string[] args) { string[] input_line = Console.ReadLine().Split(' '); long a = long.Parse(input_line[0]); long b = long.Parse(input_line[1]); long c = long.Parse(input_line[2]); long ballNum = (a / (b + c)) * c + Math.Min(a % (b + c), b); Console.WriteLine(ballNum); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { static void Main(string[] args) { string[] input_line = Console.ReadLine().Split(' '); long a = long.Parse(input_line[0]); long b = long.Parse(input_line[1]); long c = long.Parse(input_line[2]); long ballNum = ((a / (b + c)) * b) + Math.Min(a % (b + c), b); Console.WriteLine(ballNum); } } }
[["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25]]
8
140
using System; namespace ConsoleApp2 { class Program { static void Main() { var info = Console.ReadLine().Split(' '); var range = Int32.Parse(info[0]); var blue = Int32.Parse(info[1]); var red = Int32.Parse(info[2]); if (blue + red == 0) { Console.WriteLine(0); } else { int time = range / (blue + red); var ans = time * blue; var rem = range % (blue + red); if (rem >= blue) { ans += blue; } else { ans += rem; } Console.WriteLine(ans); } // Console.ReadKey(); } } }
using System; namespace ConsoleApp2 { class Program { static void Main() { var info = Console.ReadLine().Split(' '); var range = Int64.Parse(info[0]); var blue = Int64.Parse(info[1]); var red = Int64.Parse(info[2]); if (blue + red == 0) { Console.WriteLine(0); } else { Int64 time = range / (blue + red); var ans = time * blue; var rem = range % (blue + red); if (rem >= blue) { ans += blue; } else { ans += rem; } Console.WriteLine(ans); } // Console.ReadKey(); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 22]]
8
149
using System; using System.Collections.Generic; using System.Linq; namespace Hayadoki20200309A { 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 { private Input input = new Input(); private long N; private long A; private long B; public Solver() { input.Long(out N, out A, out B); } public void Solve() { long loop = N / (A + B); Console.WriteLine(loop * A + Math.Min(B, N % (A + B))); } } }
using System; using System.Collections.Generic; using System.Linq; namespace Hayadoki20200309A { 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 { private Input input = new Input(); private long N; private long A; private long B; public Solver() { input.Long(out N, out A, out B); } public void Solve() { long loop = N / (A + B); Console.WriteLine(loop * A + Math.Min(A, N % (A + B))); } } }
[["-", 0, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 22]]
8
901
using System; using System.Linq; namespace CSharp { class Program { static void Main() { var input = Console.ReadLine().Split().Select(long.Parse).ToArray(); var N = input[0]; var A = input[1]; var B = input[2]; var result = A * N / (A + B) + Math.Min(A, N % (A + B)); Console.WriteLine(result); } } }
using System; using System.Linq; namespace CSharp { class Program { static void Main() { var input = Console.ReadLine().Split().Select(long.Parse).ToArray(); var N = input[0]; var A = input[1]; var B = input[2]; var result = N / (A + B) * A + Math.Min(A, N % (A + B)); Console.WriteLine(result); } } }
[["-", 0, 212, 0, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 212, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22]]
8
106
using static System.Console; using System; namespace Main { class Program { static void Main(string[] args) { string line = ReadLine(); string[] l = line.Split(' '); long N = int.Parse(l[0]); long A = int.Parse(l[1]); long B = int.Parse(l[2]); long tmp1 = N / (A + B); long tmp2 = N % (A + B); WriteLine(tmp1 * A + Math.Min(tmp2, A)); } } }
using static System.Console; using System; namespace Main { class Program { static void Main(string[] args) { string line = ReadLine(); string[] l = line.Split(' '); long N = long.Parse(l[0]); long A = long.Parse(l[1]); long B = long.Parse(l[2]); long tmp1 = N / (A + B); long tmp2 = N % (A + B); WriteLine(tmp1 * A + Math.Min(tmp2, A)); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
8
126
using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main(string[] args) { var vals = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); if (vals[0] > vals[1] + vals[2]) { var tmp = vals[0] % (vals[1] + vals[2]); var tmp2 = Math.Floor((double)vals[0] / (vals[1] + vals[2])); Console.WriteLine(tmp > vals[1] ? vals[1] + vals[1] * (int)tmp2 : tmp + vals[1] * (int)tmp2); } else { Console.WriteLine(vals[0] > vals[1] ? vals[1] : vals[0]); } } }
using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main(string[] args) { var vals = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); if (vals[0] > vals[1] + vals[2]) { var tmp = vals[0] % (vals[1] + vals[2]); var tmp2 = Math.Floor((double)vals[0] / (vals[1] + vals[2])); Console.WriteLine(tmp > vals[1] ? vals[1] + vals[1] * (long)tmp2 : tmp + vals[1] * (long)tmp2); } else { Console.WriteLine(vals[0] > vals[1] ? vals[1] : vals[0]); } } }
[["-", 0, 41, 64, 16, 12, 16, 12, 74, 39, 199], ["+", 0, 41, 64, 16, 12, 16, 12, 74, 39, 199], ["-", 0, 41, 75, 16, 12, 16, 12, 74, 39, 199], ["+", 0, 41, 75, 16, 12, 16, 12, 74, 39, 199]]
8
198
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Text; class Program { static void Main(string[] args) { // 入力 long[] nab = Console.ReadLine().Split().Select(long.Parse).ToArray(); long n = nab[0]; long a = nab[1]; long b = nab[2]; long c = n / (a + b); long d = n % (a + b); long ans = 0; if (d <= a) { ans = (c * a) + d; } else { ans = c * a + (d - a); } if (a == 0) { ans = 0; } Console.WriteLine(ans); } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Text; class Program { static void Main(string[] args) { // 入力 long[] nab = Console.ReadLine().Split().Select(long.Parse).ToArray(); long n = nab[0]; long a = nab[1]; long b = nab[2]; long c = n / (a + b); long d = n % (a + b); long ans = 0; if (d <= a) { ans = (c * a) + d; } else { ans = c * a + a; } if (a == 0) { ans = 0; } Console.WriteLine(ans); } }
[["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
8
170
using System; using static System.Console; using System.Linq; namespace AC { public class shiokara { static void Main(string[] args) { int[] n = new int[3]; n = ReadLine().Split(' ').Select(int.Parse).ToArray(); if (n[1] == 0) { WriteLine(0); return; } else if (n[2] == 0) { WriteLine(n[0]); return; } int ans1 = n[0] / (n[1] + n[2]); int ans2 = n[0] % (n[1] + n[2]); int ans = 0; if (ans2 <= n[1]) { ans = ans1 * n[1] + ans2; } else { ans = ans1 * n[1] + n[1]; } WriteLine(ans); } } }
using System; using static System.Console; using System.Linq; namespace AC { public class shiokara { static void Main(string[] args) { long[] n = new long[3]; n = ReadLine().Split(' ').Select(long.Parse).ToArray(); if (n[1] == 0) { WriteLine(0); return; } else if (n[2] == 0) { WriteLine(n[0]); return; } long ans1 = n[0] / (n[1] + n[2]); long ans2 = n[0] % (n[1] + n[2]); long ans = 0; if (ans2 <= n[1]) { ans = ans1 * n[1] + ans2; } else { ans = ans1 * n[1] + n[1]; } WriteLine(ans); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 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
199
using System; class Program { static void Main(string[] args) { var line = Console.ReadLine(); var list = line.Split(' '); var sum = long.Parse(list[0]); var blue = long.Parse(list[1]); var red = long.Parse(list[2]); if (blue != 0 && red != 0) { var perfectSet = sum / (blue + red); var ans = perfectSet * blue; var allAmari = sum; if (perfectSet > 0) { allAmari = sum % (blue + red); } if (allAmari > blue) { ans += blue; } else { ans += allAmari; } Console.WriteLine(ans); } else { Console.WriteLine(0); } } }
using System; class Program { static void Main(string[] args) { var line = Console.ReadLine(); var list = line.Split(' '); var sum = long.Parse(list[0]); var blue = long.Parse(list[1]); var red = long.Parse(list[2]); if (blue != 0 || red != 0) { var perfectSet = sum / (blue + red); var ans = perfectSet * blue; var allAmari = sum; if (perfectSet > 0) { allAmari = sum % (blue + red); } if (allAmari > blue) { ans += blue; } else { ans += allAmari; } Console.WriteLine(ans); } else { Console.WriteLine(0); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106]]
8
167
using System; using System.Collections.Generic; using System.Linq; public class ABC158_B { public static void Main() { int n = 0, b = 0, r = 0, result; InLine(ref n, ref b, ref r); if (n < b) result = n; else if (n < b + r) result = b; else { int c = n / (b + r), p = n % (b + r); result = b * c; if (p > b) result += b; else result += p; } Out(result); } /* Template */ private static object[] nullobj = null; //文字コード変換 public static int ConvertInt(char c) { return c; } //入力:1入力配列 public static A[] InArgs<A>(int count) { A[] var = default(A[]); InArgs(count, ref var, ref nullobj, ref nullobj); return var; } //入力:1入力配列 public static void InArgs<A>(int count, ref A[] var) { InArgs(count, ref var, ref nullobj, ref nullobj); } //入力:2入力配列 public static void InArgs<A, B>(int count, ref A[] var1, ref B[] var2) { InArgs(count, ref var1, ref var2, ref nullobj); } //入力:3入力配列 public static void InArgs<A, B, C>(int count, ref A[] var1, ref B[] var2, ref C[] var3) { A a = default(A); B b = default(B); C c = default(C); for (int i = 0; i < count; i++) { InLine(ref a, ref b, ref c); var1[i] = a; if (var2 != null) var2[i] = b; if (var3 != null) var3[i] = c; } } //入力:1入力 public static A InLine<A>() { A var = default(A); InLine(ref var); return var; } //入力:1入力 public static void InLine<A>(ref A var) { InLine(ref var, ref nullobj, ref nullobj); } //入力:2入力 public static void InLine<A, B>(ref A var1, ref B var2) { InLine(ref var1, ref var2, ref nullobj); } //入力:3入力 public static void InLine<A, B, C>(ref A var1, ref B var2, ref C var3) { object[] o = new object[] { var1, var2, var3 }; Type[] t = new Type[] { typeof(A), typeof(B), typeof(C) }; if (var3 == null) { if (var2 == null) o = new object[] { var1 }; else o = new object[] { var1, var2 }; } var line = Console.ReadLine(); string[] s; if (o.Length == 1) s = new string[1] { line }; else s = line.Split(' '); for (int i = 0; i < s.Length; i++) { if (typeof(int) == t[i]) o[i] = int.Parse(s[i]); else if (typeof(long) == t[i]) o[i] = long.Parse(s[i]); else if (typeof(double) == t[i]) o[i] = double.Parse(s[i]); else o[i] = s[i]; } var1 = (A)o[0]; if (var2 != null) var2 = (B)o[1]; if (var3 != null) var3 = (C)o[2]; } //入力:1行配列 public static A[] InLineArg<A>() { A[] var = default(A[]); InLineArg(ref var); return var; } //入力:1行配列 public static void InLineArg<A>(ref A[] arg) { object obj = null; Type t = typeof(A); string[] line = Console.ReadLine().Split(' '); if (typeof(int) == t) obj = line.Select(int.Parse).ToArray(); else if (typeof(long) == t) obj = line.Select(long.Parse).ToArray(); else if (typeof(double) == t) obj = line.Select(double.Parse).ToArray(); else obj = line; arg = (A[])obj; } //文字列結合 public static string JoinString(object[] obj, string sep) { return string.Join(sep, obj.Select(i => i.ToString()).ToArray()); } //出力 public static void Out(object o) { Console.WriteLine(o); } //出力:Yes public static void OutYes() { Console.WriteLine("Yes"); } //出力:No public static void OutNo() { Console.WriteLine("No"); } //出力:YES public static void OutYES() { Console.WriteLine("YES"); } //出力:NO public static void OutNO() { Console.WriteLine("NO"); } //辞書生成 private static Dictionary<A, B> PutDict<A, B>(A[] key, B[] value) { if (key.Length != value.Length) return null; var dic = new Dictionary<A, B>(); for (int i = 0; i < key.Length; i++) { if (!dic.ContainsKey(key[i])) dic.Add(key[i], value[i]); else dic[key[i]] = value[i]; } return dic; } //公約数 public static int[] CommonDivisor(int num) { return CommonDivisor((long)num).Select(i => (int)i).ToArray(); } public static long[] CommonDivisor(long num) { long l = 2, n = num; long[] result = new long[0]; while (l * l <= num) { if (n % l == 0) { n /= l; Array.Resize(ref result, result.Length + 1); result[result.Length - 1] = l; } else l++; } if (n != 1) { Array.Resize(ref result, result.Length + 1); result[result.Length - 1] = n; } return result; } //大小比較 public static bool Compare(bool equal, long a, long x) { return Compare(equal, a, x, long.MaxValue, true); } public static bool Compare(long x, long b, bool equal) { return Compare(true, long.MinValue, x, b, equal); } public static bool Compare(bool lequal, long a, long x, long b, bool requal) { if (a <= x && x <= b) { if (!lequal && x == a) return false; else if (!requal && x == b) return false; else return true; } return false; } //割り切る public static bool IsDivisible(long a, long b) { return a % b == 0; } //互いに素 public static bool IsRelativelyPrime(long a, long b) { bool result = false; if (a > 1 && b > 1) result = CommonDivisor(a).Intersect(CommonDivisor(b)).ToArray().Length == 0; return result; } //素数判定 public static bool IsPrimeNumber(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 int GCD(int a, int b) { return (int)GCD((long)a, b); } public static long GCD(long a, long b) { long[] acd = CommonDivisor(a).ToArray(), bcd = CommonDivisor(b).ToArray(); Dictionary<long, int> dic1 = new Dictionary<long, int>(), dic2 = new Dictionary<long, int>(); int count = 0; long n = 0, result = 1; for (int i = 0; i < acd.Length; i++) { if (n == acd[i]) count++; else { if (n != 0) dic1.Add(n, count); n = acd[i]; count = 1; } } dic1.Add(n, count); n = 0; count = 0; for (int i = 0; i < bcd.Length; i++) { if (n == bcd[i]) count++; else { if (dic1.ContainsKey(n)) dic2[n] = Math.Max(count, dic1[n]); n = bcd[i]; count = 1; } } if (dic1.ContainsKey(n)) dic2[n] = Math.Max(count, dic1[n]); foreach (long l in dic2.Keys) { result *= (long)Math.Pow(l, dic2[l]); Console.WriteLine($"{l}, {dic2[l]}"); } return result; } //最小公倍数 public static long LCM(long a, long b) { long[] acd = CommonDivisor(a).ToArray(), bcd = CommonDivisor(b).ToArray(); var dic = new Dictionary<long, int>(); int count = 0; long n = 0, result = 1; for (int i = 0; i < acd.Length; i++) { if (n == acd[i]) count++; else { if (n != 0) dic.Add(n, count); n = acd[i]; count = 1; } } dic.Add(n, count); n = 0; count = 0; for (int i = 0; i < bcd.Length; i++) { if (n == bcd[i]) count++; else { if (dic.ContainsKey(n)) dic[n] = Math.Max(count, dic[n]); else if (n != 0) dic.Add(n, count); n = bcd[i]; count = 1; } } if (dic.ContainsKey(n)) dic[n] = Math.Max(count, dic[n]); else dic.Add(n, count); foreach (long l in dic.Keys) result *= (long)Math.Pow(l, dic[l]); return result; } //組合せ数(nCr) public static double Combination(int n, int r) { if (n / 2 < r) r = n - r; return TotalPower(n, r + 1) / TotalPower(n - r); } //組合せ数総和(Σ(k=1,n,nCk)) public static double CombinationSum(int n) { return Math.Pow(2, n); } //重複組合せ数(nHr) public static double RepetitionCombination(int n, int r) { return Combination(n + r - 1, r); } //重複組合せ数総和(Σ(k=1,n,nHk)) public static double RepetitionCombinationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += RepetitionCombination(n, i); } return result; } //順列数(nPr) public static double Permutation(int n, int r) { return TotalPower(n, r + 1); } //順列数総和(Σ(k=1,n,nPk)) public static double PermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += Permutation(n, i); } return result; } //円順列数 public static double CircularPermutation(int n) { return TotalPower(n - 1); } //円順列数総和 public static double CircularPermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += CircularPermutation(i); } return result; } //数珠順列数 public static double NecklacePermutation(int n) { return CircularPermutation(n - 1) / 2; } //数珠順列数総和 public static double NecklacePermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += NecklacePermutation(i); } return result; } //重複順列数(nΠr) public static double RepetitionPermutation(int n, int r) { return Math.Pow(n, r); } //重複順列数総和(Σ(k=1,n,nΠk)) public static double RepetitionPermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += RepetitionPermutation(n, i); } return result; } //総乗 public static double TotalPower(int max) { return TotalPower(max, 1); } public static double TotalPower(int max, int min) { double result = 1; for (int i = min; i <= max; i++) result *= i; return result; } public static double TotalPower(int[] ints) { double result = 1; foreach (int i in ints) result *= i; return result; } //総和 public static double TotalSum(int max) { return TotalSum(max, 1); } public static double TotalSum(int max, int min) { double result = 1; for (int i = min; i <= max; i++) result += i; return result; } public static double TotalSum(int[] ints) { double result = 1; foreach (int i in ints) result += i; return result; } }
using System; using System.Collections.Generic; using System.Linq; public class ABC158_B { public static void Main() { long n = 0, b = 0, r = 0, result; InLine(ref n, ref b, ref r); if (n < b) result = n; else if (n < b + r) result = b; else { long c = n / (b + r), p = n % (b + r); result = b * c; if (p > b) result += b; else result += p; } Out(result); } /* Template */ private static object[] nullobj = null; //文字コード変換 public static int ConvertInt(char c) { return c; } //入力:1入力配列 public static A[] InArgs<A>(int count) { A[] var = default(A[]); InArgs(count, ref var, ref nullobj, ref nullobj); return var; } //入力:1入力配列 public static void InArgs<A>(int count, ref A[] var) { InArgs(count, ref var, ref nullobj, ref nullobj); } //入力:2入力配列 public static void InArgs<A, B>(int count, ref A[] var1, ref B[] var2) { InArgs(count, ref var1, ref var2, ref nullobj); } //入力:3入力配列 public static void InArgs<A, B, C>(int count, ref A[] var1, ref B[] var2, ref C[] var3) { A a = default(A); B b = default(B); C c = default(C); for (int i = 0; i < count; i++) { InLine(ref a, ref b, ref c); var1[i] = a; if (var2 != null) var2[i] = b; if (var3 != null) var3[i] = c; } } //入力:1入力 public static A InLine<A>() { A var = default(A); InLine(ref var); return var; } //入力:1入力 public static void InLine<A>(ref A var) { InLine(ref var, ref nullobj, ref nullobj); } //入力:2入力 public static void InLine<A, B>(ref A var1, ref B var2) { InLine(ref var1, ref var2, ref nullobj); } //入力:3入力 public static void InLine<A, B, C>(ref A var1, ref B var2, ref C var3) { object[] o = new object[] { var1, var2, var3 }; Type[] t = new Type[] { typeof(A), typeof(B), typeof(C) }; if (var3 == null) { if (var2 == null) o = new object[] { var1 }; else o = new object[] { var1, var2 }; } var line = Console.ReadLine(); string[] s; if (o.Length == 1) s = new string[1] { line }; else s = line.Split(' '); for (int i = 0; i < s.Length; i++) { if (typeof(int) == t[i]) o[i] = int.Parse(s[i]); else if (typeof(long) == t[i]) o[i] = long.Parse(s[i]); else if (typeof(double) == t[i]) o[i] = double.Parse(s[i]); else o[i] = s[i]; } var1 = (A)o[0]; if (var2 != null) var2 = (B)o[1]; if (var3 != null) var3 = (C)o[2]; } //入力:1行配列 public static A[] InLineArg<A>() { A[] var = default(A[]); InLineArg(ref var); return var; } //入力:1行配列 public static void InLineArg<A>(ref A[] arg) { object obj = null; Type t = typeof(A); string[] line = Console.ReadLine().Split(' '); if (typeof(int) == t) obj = line.Select(int.Parse).ToArray(); else if (typeof(long) == t) obj = line.Select(long.Parse).ToArray(); else if (typeof(double) == t) obj = line.Select(double.Parse).ToArray(); else obj = line; arg = (A[])obj; } //文字列結合 public static string JoinString(object[] obj, string sep) { return string.Join(sep, obj.Select(i => i.ToString()).ToArray()); } //出力 public static void Out(object o) { Console.WriteLine(o); } //出力:Yes public static void OutYes() { Console.WriteLine("Yes"); } //出力:No public static void OutNo() { Console.WriteLine("No"); } //出力:YES public static void OutYES() { Console.WriteLine("YES"); } //出力:NO public static void OutNO() { Console.WriteLine("NO"); } //辞書生成 private static Dictionary<A, B> PutDict<A, B>(A[] key, B[] value) { if (key.Length != value.Length) return null; var dic = new Dictionary<A, B>(); for (int i = 0; i < key.Length; i++) { if (!dic.ContainsKey(key[i])) dic.Add(key[i], value[i]); else dic[key[i]] = value[i]; } return dic; } //公約数 public static int[] CommonDivisor(int num) { return CommonDivisor((long)num).Select(i => (int)i).ToArray(); } public static long[] CommonDivisor(long num) { long l = 2, n = num; long[] result = new long[0]; while (l * l <= num) { if (n % l == 0) { n /= l; Array.Resize(ref result, result.Length + 1); result[result.Length - 1] = l; } else l++; } if (n != 1) { Array.Resize(ref result, result.Length + 1); result[result.Length - 1] = n; } return result; } //大小比較 public static bool Compare(bool equal, long a, long x) { return Compare(equal, a, x, long.MaxValue, true); } public static bool Compare(long x, long b, bool equal) { return Compare(true, long.MinValue, x, b, equal); } public static bool Compare(bool lequal, long a, long x, long b, bool requal) { if (a <= x && x <= b) { if (!lequal && x == a) return false; else if (!requal && x == b) return false; else return true; } return false; } //割り切る public static bool IsDivisible(long a, long b) { return a % b == 0; } //互いに素 public static bool IsRelativelyPrime(long a, long b) { bool result = false; if (a > 1 && b > 1) result = CommonDivisor(a).Intersect(CommonDivisor(b)).ToArray().Length == 0; return result; } //素数判定 public static bool IsPrimeNumber(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 int GCD(int a, int b) { return (int)GCD((long)a, b); } public static long GCD(long a, long b) { long[] acd = CommonDivisor(a).ToArray(), bcd = CommonDivisor(b).ToArray(); Dictionary<long, int> dic1 = new Dictionary<long, int>(), dic2 = new Dictionary<long, int>(); int count = 0; long n = 0, result = 1; for (int i = 0; i < acd.Length; i++) { if (n == acd[i]) count++; else { if (n != 0) dic1.Add(n, count); n = acd[i]; count = 1; } } dic1.Add(n, count); n = 0; count = 0; for (int i = 0; i < bcd.Length; i++) { if (n == bcd[i]) count++; else { if (dic1.ContainsKey(n)) dic2[n] = Math.Max(count, dic1[n]); n = bcd[i]; count = 1; } } if (dic1.ContainsKey(n)) dic2[n] = Math.Max(count, dic1[n]); foreach (long l in dic2.Keys) { result *= (long)Math.Pow(l, dic2[l]); Console.WriteLine($"{l}, {dic2[l]}"); } return result; } //最小公倍数 public static long LCM(long a, long b) { long[] acd = CommonDivisor(a).ToArray(), bcd = CommonDivisor(b).ToArray(); var dic = new Dictionary<long, int>(); int count = 0; long n = 0, result = 1; for (int i = 0; i < acd.Length; i++) { if (n == acd[i]) count++; else { if (n != 0) dic.Add(n, count); n = acd[i]; count = 1; } } dic.Add(n, count); n = 0; count = 0; for (int i = 0; i < bcd.Length; i++) { if (n == bcd[i]) count++; else { if (dic.ContainsKey(n)) dic[n] = Math.Max(count, dic[n]); else if (n != 0) dic.Add(n, count); n = bcd[i]; count = 1; } } if (dic.ContainsKey(n)) dic[n] = Math.Max(count, dic[n]); else dic.Add(n, count); foreach (long l in dic.Keys) result *= (long)Math.Pow(l, dic[l]); return result; } //組合せ数(nCr) public static double Combination(int n, int r) { if (n / 2 < r) r = n - r; return TotalPower(n, r + 1) / TotalPower(n - r); } //組合せ数総和(Σ(k=1,n,nCk)) public static double CombinationSum(int n) { return Math.Pow(2, n); } //重複組合せ数(nHr) public static double RepetitionCombination(int n, int r) { return Combination(n + r - 1, r); } //重複組合せ数総和(Σ(k=1,n,nHk)) public static double RepetitionCombinationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += RepetitionCombination(n, i); } return result; } //順列数(nPr) public static double Permutation(int n, int r) { return TotalPower(n, r + 1); } //順列数総和(Σ(k=1,n,nPk)) public static double PermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += Permutation(n, i); } return result; } //円順列数 public static double CircularPermutation(int n) { return TotalPower(n - 1); } //円順列数総和 public static double CircularPermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += CircularPermutation(i); } return result; } //数珠順列数 public static double NecklacePermutation(int n) { return CircularPermutation(n - 1) / 2; } //数珠順列数総和 public static double NecklacePermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += NecklacePermutation(i); } return result; } //重複順列数(nΠr) public static double RepetitionPermutation(int n, int r) { return Math.Pow(n, r); } //重複順列数総和(Σ(k=1,n,nΠk)) public static double RepetitionPermutationSum(int n) { double result = 0; for (int i = 1; i <= n; i++) { result += RepetitionPermutation(n, i); } return result; } //総乗 public static double TotalPower(int max) { return TotalPower(max, 1); } public static double TotalPower(int max, int min) { double result = 1; for (int i = min; i <= max; i++) result *= i; return result; } public static double TotalPower(int[] ints) { double result = 1; foreach (int i in ints) result *= i; return result; } //総和 public static double TotalSum(int max) { return TotalSum(max, 1); } public static double TotalSum(int max, int min) { double result = 1; for (int i = min; i <= max; i++) result += i; return result; } public static double TotalSum(int[] ints) { double result = 1; foreach (int i in ints) result += i; return result; } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 75, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 75, 57, 75, 196, 0, 197, 0, 198, 39, 199]]
8
2,853
using System; using System.Linq; public class ABC158_B { private static void Main(string[] args) { var input = ReadIntsAsArray(); var n = input[0]; var a = input[1]; var b = input[2]; var quotient = n / (a + b); var remainder = n % (a + b); var answer = quotient * a + Math.Min(a, remainder); Console.WriteLine(answer); } private static int[] ReadIntsAsArray() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray(); }
using System; using System.Linq; public class ABC158_B { private static void Main(string[] args) { var input = ReadLongsAsArray(); var n = input[0]; var a = input[1]; var b = input[2]; var quotient = n / (a + b); var remainder = n % (a + b); var answer = quotient * a + Math.Min(a, remainder); Console.WriteLine(answer); } private static long[] ReadLongsAsArray() => Console.ReadLine().Trim().Split().Select(x => long.Parse(x)).ToArray(); }
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 0, 235, 8, 201, 0, 195, 39, 224, 39, 199], ["+", 0, 235, 8, 201, 0, 195, 39, 224, 39, 199], ["-", 0, 208, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 141, 22], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
8
140
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ABC157 { public class B { static void Main(string[] args) { var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var c = inputs[0]; var between = inputs[1] + inputs[2]; var answer = c / between * inputs[1] + Math.Min(c % between, inputs[1]); Console.WriteLine(answer); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ABC157 { public class B { static void Main(string[] args) { var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); var c = inputs[0]; var between = inputs[1] + inputs[2]; var answer = c / between * inputs[1] + Math.Min(c % between, inputs[1]); Console.WriteLine(answer); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
121
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 p = Input(); var n = p[0].ToLong(); var a = p[1].ToLong(); var b = p[2].ToLong(); if (n <= a + b) { Console.WriteLine(Math.Min(n, a)); return; } else { long k = a + b; long c = n / k; long d = n % k; if (d <= a) { Console.WriteLine(c * a + d); } else { Console.WriteLine(c * a); } } } 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 p = Input(); var n = p[0].ToLong(); var a = p[1].ToLong(); var b = p[2].ToLong(); if (n <= a + b) { Console.WriteLine(Math.Min(n, a)); return; } else { long k = a + b; long c = n / k; long d = n % k; if (d <= a) { Console.WriteLine(c * a + d); } else { Console.WriteLine(c * a + a); } } } 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, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
8
369
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Library; using static Library.Input; namespace AtCoderTemplate { class ProgramB { static void Main() { int N = NextInt, A = NextInt, B = NextInt; int value = (N / (A + B)) * A; N = N % (A + B); value += Math.Min(N, A); System.Console.WriteLine(value); } } } namespace Library { class Input { static IEnumerator<string> enumerator = new string[] {}.AsEnumerable().GetEnumerator(); public static string Line => Console.ReadLine(); public static string[] StrArr => Line.Split(' '); public static int NextInt => int.Parse(NextWord()); public static long NextLong => long.Parse(NextWord()); public static List<int> IntList => StrArr.Select(int.Parse).ToList(); public static List<long> LongList => StrArr.Select(long.Parse).ToList(); public static IEnumerable<long[]> TakeLine(int N) { return Enumerable.Repeat(0, N).Select( _ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()); } public static string NextWord() { while (!enumerator.MoveNext()) { enumerator = StrArr.AsEnumerable().GetEnumerator(); } return enumerator.Current; } } } namespace Library { class Modular { public const int mod = 1000000007; public readonly long value; public Modular(long value) { this.value = value; } public static implicit operator Modular(long a) { var m = a % mod; return new Modular((m < 0) ? m + mod : m); } public static Modular operator +(Modular a, Modular b) { return a.value + b.value; } public static Modular operator -(Modular a, Modular b) { return a.value - b.value; } public static Modular operator *(Modular a, Modular b) { return a.value * b.value; } public static Modular Pow(Modular a, int n) { switch (n) { case 0: return 1; case 1: return a; default: var p = Pow(a, n / 2); return p * p * Pow(a, n % 2); } } public static Modular operator /(Modular a, Modular b) { return a * Pow(b, mod - 2); } private static readonly List<int> facs = new List<int> { 1 }; private static Modular Fac(int n) { for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % mod)); } return facs[n]; } public static Modular Ncr(int n, int r) { return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r)); } public static explicit operator int(Modular a) { return (int)a.value; } } } namespace Library { class MyMath { public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); } public static long Sqrt(long n) { if (n < 0) return 0; long a = 0, tmp = 0, b = 0; for (int i = 62; i >= 0; i -= 2) { tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0; a = a << 1 | tmp; n -= (((b << 1) + 1) * tmp) << i; b = (b << 1) + tmp + tmp; } return a; } public static long Nck(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return n * Nck(n - 1, k - 1) / k; } } } namespace Library { public class PriorityQueue<T> { readonly List<T> _heap = new List<T>(); readonly Comparison<T> _comparison; public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; } public PriorityQueue() : this(Comparer<T>.Default.Compare) {} public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {} public void Enqueue(T item) { _heap.Add(item); int childID = _heap.Count - 1; int parentID = (childID - 1) / 2; while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); childID = parentID; parentID = (parentID - 1) / 2; } } public T Dequeue() { var first = _heap.First(); _heap[0] = _heap.Last(); _heap.RemoveAt(_heap.Count - 1); int parentID = 0; int childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; while (childID < _heap.Count && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); parentID = childID; childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; } return first; } void Swap(int parent, int child) { var tmp = _heap[parent]; _heap[parent] = _heap[child]; _heap[child] = tmp; } public T Peek() { return _heap[0]; } public int Count => _heap.Count; public bool Any() { return _heap.Any(); } public List<T> Data => _heap; } } namespace Library { public class UnionFind { public int[] Parents { get; set; } public UnionFind(int size) { Parents = Enumerable.Repeat(-1, size).ToArray(); } public int Find(int num) { if (Parents[num] < 0) return num; Parents[num] = Find(Parents[num]); return Parents[num]; } public int Size(int num) { return -Parents[Find(num)]; } public bool Same(int a, int b) { return Find(a) == Find(b); } public void Unite(int a, int b) { int x = Find(a), y = Find(b); if (Size(x) > Size(y)) { Parents[x] += Parents[y]; Parents[y] = x; } else { Parents[y] += Parents[x]; Parents[x] = y; } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Library; using static Library.Input; namespace AtCoderTemplate { class ProgramB { static void Main() { long N = NextLong, A = NextLong, B = NextLong; long value = (N / (A + B)) * A; N = N % (A + B); value += Math.Min(N, A); System.Console.WriteLine(value); } } } namespace Library { class Input { static IEnumerator<string> enumerator = new string[] {}.AsEnumerable().GetEnumerator(); public static string Line => Console.ReadLine(); public static string[] StrArr => Line.Split(' '); public static int NextInt => int.Parse(NextWord()); public static long NextLong => long.Parse(NextWord()); public static List<int> IntList => StrArr.Select(int.Parse).ToList(); public static List<long> LongList => StrArr.Select(long.Parse).ToList(); public static IEnumerable<long[]> TakeLine(int N) { return Enumerable.Repeat(0, N).Select( _ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()); } public static string NextWord() { while (!enumerator.MoveNext()) { enumerator = StrArr.AsEnumerable().GetEnumerator(); } return enumerator.Current; } } } namespace Library { class Modular { public const int mod = 1000000007; public readonly long value; public Modular(long value) { this.value = value; } public static implicit operator Modular(long a) { var m = a % mod; return new Modular((m < 0) ? m + mod : m); } public static Modular operator +(Modular a, Modular b) { return a.value + b.value; } public static Modular operator -(Modular a, Modular b) { return a.value - b.value; } public static Modular operator *(Modular a, Modular b) { return a.value * b.value; } public static Modular Pow(Modular a, int n) { switch (n) { case 0: return 1; case 1: return a; default: var p = Pow(a, n / 2); return p * p * Pow(a, n % 2); } } public static Modular operator /(Modular a, Modular b) { return a * Pow(b, mod - 2); } private static readonly List<int> facs = new List<int> { 1 }; private static Modular Fac(int n) { for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % mod)); } return facs[n]; } public static Modular Ncr(int n, int r) { return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r)); } public static explicit operator int(Modular a) { return (int)a.value; } } } namespace Library { class MyMath { public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); } public static long Sqrt(long n) { if (n < 0) return 0; long a = 0, tmp = 0, b = 0; for (int i = 62; i >= 0; i -= 2) { tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0; a = a << 1 | tmp; n -= (((b << 1) + 1) * tmp) << i; b = (b << 1) + tmp + tmp; } return a; } public static long Nck(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return n * Nck(n - 1, k - 1) / k; } } } namespace Library { public class PriorityQueue<T> { readonly List<T> _heap = new List<T>(); readonly Comparison<T> _comparison; public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; } public PriorityQueue() : this(Comparer<T>.Default.Compare) {} public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {} public void Enqueue(T item) { _heap.Add(item); int childID = _heap.Count - 1; int parentID = (childID - 1) / 2; while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); childID = parentID; parentID = (parentID - 1) / 2; } } public T Dequeue() { var first = _heap.First(); _heap[0] = _heap.Last(); _heap.RemoveAt(_heap.Count - 1); int parentID = 0; int childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; while (childID < _heap.Count && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); parentID = childID; childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; } return first; } void Swap(int parent, int child) { var tmp = _heap[parent]; _heap[parent] = _heap[child]; _heap[child] = tmp; } public T Peek() { return _heap[0]; } public int Count => _heap.Count; public bool Any() { return _heap.Any(); } public List<T> Data => _heap; } } namespace Library { public class UnionFind { public int[] Parents { get; set; } public UnionFind(int size) { Parents = Enumerable.Repeat(-1, size).ToArray(); } public int Find(int num) { if (Parents[num] < 0) return num; Parents[num] = Find(Parents[num]); return Parents[num]; } public int Size(int num) { return -Parents[Find(num)]; } public bool Same(int a, int b) { return Find(a) == Find(b); } public void Unite(int a, int b) { int x = Find(a), y = Find(b); if (Size(x) > Size(y)) { Parents[x] += Parents[y]; Parents[y] = x; } else { Parents[y] += Parents[x]; Parents[x] = y; } } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22]]
8
1,487
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var n = cin.nextLong(); var a = cin.nextLong(); var b = cin.nextLong(); var w = n / (a + b); var m = n % (a + b); if (m <= b) { Console.WriteLine(a * w + m); } else { Console.WriteLine(a * w + a); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] s) => new Solver().Solve(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var n = cin.nextLong(); var a = cin.nextLong(); var b = cin.nextLong(); var w = n / (a + b); var m = n % (a + b); if (m <= a) { Console.WriteLine(a * w + m); } else { Console.WriteLine(a * w + a); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] s) => new Solver().Solve(); } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
8
621
using System; using CompLib.Util; public class Program { public void Solve() { var sc = new Scanner(); int n = sc.NextInt(); long a = sc.NextInt(); long b = sc.NextInt(); if (a + b == 0) { Console.WriteLine(0); return; } long d = n / (a + b); long ans = d * a; long m = n % (a + b); ans += Math.Min(m, a); Console.WriteLine(ans); } public static void Main(string[] args) => new Program().Solve(); } namespace CompLib.Util { using System; using System.Linq; class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
using System; using CompLib.Util; public class Program { public void Solve() { var sc = new Scanner(); var n = sc.NextLong(); long a = sc.NextLong(); long b = sc.NextLong(); if (a + b == 0) { Console.WriteLine(0); return; } long d = n / (a + b); long ans = d * a; long m = n % (a + b); ans += Math.Min(m, a); Console.WriteLine(ans); } public static void Main(string[] args) => new Program().Solve(); } namespace CompLib.Util { using System; using System.Linq; class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
8
449
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using static System.Console; using static System.Math; class program { static public int mod = 1000000007; static void Main() { var z = inta(); var a = new int[2]; var b = new int[2]; a[1] = (int)Ceiling((double)z[0] * 100 / 8); a[1] = (int)Ceiling((double)(z[0] + 1) * 100 / 8); b[0] = z[1] * 10; b[1] = b[0] + 10; if (a[1] <= b[0] || b[1] <= a[0]) { Write(-1); } else { Write(Max(a[0], b[0])); } } static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; } static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } } static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using static System.Console; using static System.Math; class program { static public int mod = 1000000007; static void Main() { var z = inta(); var a = new int[2]; var b = new int[2]; a[0] = (int)Ceiling((double)z[0] * 100 / 8); a[1] = (int)Ceiling((double)(z[0] + 1) * 100 / 8); b[0] = z[1] * 10; b[1] = b[0] + 10; if (a[1] <= b[0] || b[1] <= a[0]) { Write(-1); } else { Write(Max(a[0], b[0])); } } static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; } static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } } static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); } }
[["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203]]
8
864
using System; using System.Linq; using System.Collections.Generic; namespace Sample { class Sample { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); double A = double.Parse(str[0]); double B = double.Parse(str[1]); for (int i = 1; i <= 1250; i++) { if (((int)(i * 0.08) == A) && ((int)(i * 0.1) == B)) { Console.WriteLine((int)A / 0.08); break; } if (i == 1250) { Console.WriteLine(-1); } } } } }
using System; using System.Linq; using System.Collections.Generic; namespace Sample { class Sample { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); double A = double.Parse(str[0]); double B = double.Parse(str[1]); for (int i = 1; i <= 1250; i++) { if (((int)(i * 0.08) == A) && ((int)(i * 0.1) == B)) { Console.WriteLine(i); break; } if (i == 1250) { Console.WriteLine(-1); } } } } }
[["-", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 51, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 250], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
154
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel.Design; using System.Globalization; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml.Schema; using static System.Console; namespace ConsoleApp2 { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<int> Slist() { var t = ReadLine(); if (t.Trim().Length == 0) return new List<int>(); return new List<int>(t.Split().Select(int.Parse)); } static void Main(string[] args) { var ab = Sarray(); var a = ab[0]; var b = ab[1]; var ans = -1; for (var i = 0; i < 101; i++) { var aa = (int)(i * 0.08); var bb = (int)(i * 0.1); if (aa == a && bb == b) { ans = i; break; } } WriteLine(ans); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel.Design; using System.Globalization; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml.Schema; using static System.Console; namespace ConsoleApp2 { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<int> Slist() { var t = ReadLine(); if (t.Trim().Length == 0) return new List<int>(); return new List<int>(t.Split().Select(int.Parse)); } static void Main(string[] args) { var ab = Sarray(); var a = ab[0]; var b = ab[1]; var ans = -1; for (var i = 0; i < 1500; i++) { var aa = (int)(i * 0.08); var bb = (int)(i * 0.1); if (aa == a && bb == b) { ans = i; break; } } WriteLine(ans); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
282
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray(); var a = (int)(Math.Ceiling((double)ab[0] * 12.5)); var b = ab[1] * 10; for (var i = 0; i < 10; i++) { for (var j = 0; j <= (ab[0] % 2 == 0 ? 12 : 11); j++) { if (a + i == b + j) { Console.WriteLine(a + i); return; } } } Console.WriteLine(-1); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray(); var a = (int)(Math.Ceiling((double)ab[0] * 12.5)); var b = ab[1] * 10; for (var i = 0; i < 10; i++) { for (var j = 0; j <= (ab[0] % 2 == 0 ? 12 : 11); j++) { if (a + j == b + i) { Console.WriteLine(a + j); return; } } } Console.WriteLine(-1); } } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
8
180
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using static Math2; using static Output; public class CP { public void Solve() { Input sc = new Input(); int a, b; sc.mul(out a, out b); for (int i = 0; i < 1000; ++i) { if (((i * 108) / 100 - i) == a && ((i * 110) / 100 - i) == b) { Put(i); return; } } Put(-1); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const long MOD2 = 998244353; public static long Power(long a, long b, long MOD = 1000000007) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } public static long Power2(long a, long b) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a; a = a * a; b >>= 1; } return res; } public static long GCD(long a, long b) { if (a == 0) return b; while (b > 0) { var r = a % b; a = b; b = r; } return a; } public static long LCM(long a, long b) => (b / GCD(a, b)) * a; public static long Comb(long n, long r, int MOD = 1000000007) { if (r > n - r) r = n - r; long Nume = 1; long Deno = 1; if (r > n - r) r = n - r; for (long i = 1; i <= r; ++i) { Deno = (Deno * i) % MOD; Nume = Nume * (n - i + 1) % MOD; } return (Nume * inv(Deno)) % MOD; } public static long Comb2(long n, long r) { long Nume = 1; long Deno = 1; if (r > n - r) r = n - r; for (long i = 1; i <= r; ++i) { Deno *= i; Nume *= n - i + 1; } return Nume / Deno; } public static long inv(long x, int MOD = 1000000007) { return Power(x, MOD - 2, MOD); } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(string N) { int ret = 0; for (int i = 0; i < N.Length; ++i) ret += N[i] - '0'; return ret; } public static string ConvertBase(long N, int K) { StringBuilder ret = new StringBuilder(); while (N > 0) { var r = N % K; N /= K; ret.Append(r); } return new string(ret.ToString().ToCharArray().Reverse().ToArray()); } public static bool NextPermutation<T>(IList<T> lis, Comparison<T> cmp) { int n = lis.Count; int i = n - 1; while (i - 1 >= 0) { if (cmp(lis[i - 1], lis[i]) < 0) break; --i; } if (i == 0) return false; int j = i; while (j + 1 < n) { if (cmp(lis[i - 1], lis[j + 1]) > 0) break; ++j; } var _q = lis[j]; lis[i - 1] = lis[j]; lis[i - 1] = _q; int k = i; int l = n - 1; while (k < l) { var _p = lis[k]; lis[l] = lis[k]; lis[l] = _p; ++k; --l; } return true; } public static bool NextPermutation<T>(IList<T> lis) => NextPermutation(lis, Comparer<T>.Default.Compare); } public class PriorityQueue<T> { List<T> _item; public int Count { get { return _item.Count; } } bool _isascend { get; set; } public T Peek { get { return _item[0]; } } Comparison<T> Comp; public PriorityQueue(bool IsAscend = true, IEnumerable<T> list = null) : this(Comparer<T>.Default.Compare, IsAscend, list) {} public PriorityQueue(Comparison<T> cmp, bool IsAscend = true, IEnumerable<T> list = null) { _item = new List<T>(); _isascend = IsAscend; this.Comp = cmp; if (list != null) { _item.AddRange(list); Build(); } } private int Compare(int i, int j) => (_isascend ? -1 : 1) * Comp(_item[i], _item[j]); private void Swap(int i, int j) { var t = _item[i]; _item[i] = _item[j]; _item[j] = t; } private int Parent(int i) => (i - 1) >> 1; private int Left(int i) => (i << 1) + 1; public T Enqueue(T val) { int i = _item.Count; _item.Add(val); while (i > 0) { int p = Parent(i); if (Compare(i, p) > 0) Swap(i, p); i = p; } return val; } private void Heapify(int index) { for (int i = index, j; (j = Left(i)) < _item.Count; i = j) { if (j != _item.Count - 1 && Compare(j, j + 1) < 0) j++; if (Compare(i, j) < 0) Swap(i, j); } } public T Dequeue() { T val = _item[0]; _item[0] = _item[_item.Count - 1]; _item.RemoveAt(_item.Count - 1); Heapify(0); return val; } private void Build() { for (var i = (_item.Count >> 1) - 1; i >= 0; i--) Heapify(i); } public bool Any() => Count > 0; } class Program { static void Main(string[] args) { var CP = new CP(); CP.Solve(); } } public static class Output { public static void Put(string a) => Console.WriteLine(a); public static void Put(params object[] i) => Put(string.Join(" ", i)); public static void Put<T>(IEnumerable<T> a) => Put(string.Join(" ", a)); public static void PutV<T>(IEnumerable<T> a) { foreach (var z in a) Put(z); } public static void YN(bool i) { if (i) Put("Yes"); else Put("No"); } } public class Input { public static string Str => Console.ReadLine(); public static bool IsTypeEqual<T, U>() => typeof(T).Equals(typeof(U)); public static T ConvertType<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); public static T Cast<T>(string s) { if (IsTypeEqual<T, int>()) return ConvertType<T, int>(int.Parse(s)); else if (IsTypeEqual<T, long>()) return ConvertType<T, long>(long.Parse(s)); else if (IsTypeEqual<T, double>()) return ConvertType<T, double>(double.Parse(s)); else if (IsTypeEqual<T, char>()) return ConvertType<T, char>(char.Parse(s)); else return ConvertType<T, string>(s); } public static T[] Castarr<T>(string[] s) { var ret = new T[s.Length]; int i = 0; if (IsTypeEqual<T, char>()) { var list = new List<T>(); foreach (var t in s) { foreach (var u in t) { list.Add(ConvertType<T, char>(char.Parse(u.ToString()))); } } return list.ToArray(); } foreach (var t in s) { if (IsTypeEqual<T, int>()) ret[i++] = ConvertType<T, int>(int.Parse(t)); else if (IsTypeEqual<T, long>()) ret[i++] = ConvertType<T, long>(long.Parse(t)); else if (IsTypeEqual<T, double>()) ret[i++] = ConvertType<T, double>(double.Parse(t)); else ret[i++] = ConvertType<T, string>(t); } return ret; } Queue<string> q = new Queue<string>(); void next() { var ss = Str.Split(' '); foreach (var item in ss) q.Enqueue(item); } public T cin<T>() { if (!q.Any()) next(); return Cast<T>(q.Dequeue()); } public void mul<T>(out T t) { t = cin<T>(); } public void mul<T, U>(out T t, out U u) { t = cin<T>(); u = cin<U>(); } public void mul<T, U, V>(out T t, out U u, out V v) { t = cin<T>(); u = cin<U>(); v = cin<V>(); } public void mul<T, U, V, W>(out T t, out U u, out V v, out W w) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); } public void mul<T, U, V, W, X>(out T t, out U u, out V v, out W w, out X x) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); x = cin<X>(); } public void mul<T, U, V, W, X, Y>(out T t, out U u, out V v, out W w, out X x, out Y y) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); x = cin<X>(); y = cin<Y>(); } public void mul<T, U, V, W, X, Y, Z>(out T t, out U u, out V v, out W w, out X x, out Y y, out Z z) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); x = cin<X>(); y = cin<Y>(); z = cin<Z>(); } public T[] cinarr<T>() { return Castarr<T>(Str.Split(' ')); } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using static Math2; using static Output; public class CP { public void Solve() { Input sc = new Input(); int a, b; sc.mul(out a, out b); for (int i = 0; i < 10000; ++i) { if (((i * 108) / 100 - i) == a && ((i * 110) / 100 - i) == b) { Put(i); return; } } Put(-1); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const long MOD2 = 998244353; public static long Power(long a, long b, long MOD = 1000000007) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } public static long Power2(long a, long b) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a; a = a * a; b >>= 1; } return res; } public static long GCD(long a, long b) { if (a == 0) return b; while (b > 0) { var r = a % b; a = b; b = r; } return a; } public static long LCM(long a, long b) => (b / GCD(a, b)) * a; public static long Comb(long n, long r, int MOD = 1000000007) { if (r > n - r) r = n - r; long Nume = 1; long Deno = 1; if (r > n - r) r = n - r; for (long i = 1; i <= r; ++i) { Deno = (Deno * i) % MOD; Nume = Nume * (n - i + 1) % MOD; } return (Nume * inv(Deno)) % MOD; } public static long Comb2(long n, long r) { long Nume = 1; long Deno = 1; if (r > n - r) r = n - r; for (long i = 1; i <= r; ++i) { Deno *= i; Nume *= n - i + 1; } return Nume / Deno; } public static long inv(long x, int MOD = 1000000007) { return Power(x, MOD - 2, MOD); } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(string N) { int ret = 0; for (int i = 0; i < N.Length; ++i) ret += N[i] - '0'; return ret; } public static string ConvertBase(long N, int K) { StringBuilder ret = new StringBuilder(); while (N > 0) { var r = N % K; N /= K; ret.Append(r); } return new string(ret.ToString().ToCharArray().Reverse().ToArray()); } public static bool NextPermutation<T>(IList<T> lis, Comparison<T> cmp) { int n = lis.Count; int i = n - 1; while (i - 1 >= 0) { if (cmp(lis[i - 1], lis[i]) < 0) break; --i; } if (i == 0) return false; int j = i; while (j + 1 < n) { if (cmp(lis[i - 1], lis[j + 1]) > 0) break; ++j; } var _q = lis[j]; lis[i - 1] = lis[j]; lis[i - 1] = _q; int k = i; int l = n - 1; while (k < l) { var _p = lis[k]; lis[l] = lis[k]; lis[l] = _p; ++k; --l; } return true; } public static bool NextPermutation<T>(IList<T> lis) => NextPermutation(lis, Comparer<T>.Default.Compare); } public class PriorityQueue<T> { List<T> _item; public int Count { get { return _item.Count; } } bool _isascend { get; set; } public T Peek { get { return _item[0]; } } Comparison<T> Comp; public PriorityQueue(bool IsAscend = true, IEnumerable<T> list = null) : this(Comparer<T>.Default.Compare, IsAscend, list) {} public PriorityQueue(Comparison<T> cmp, bool IsAscend = true, IEnumerable<T> list = null) { _item = new List<T>(); _isascend = IsAscend; this.Comp = cmp; if (list != null) { _item.AddRange(list); Build(); } } private int Compare(int i, int j) => (_isascend ? -1 : 1) * Comp(_item[i], _item[j]); private void Swap(int i, int j) { var t = _item[i]; _item[i] = _item[j]; _item[j] = t; } private int Parent(int i) => (i - 1) >> 1; private int Left(int i) => (i << 1) + 1; public T Enqueue(T val) { int i = _item.Count; _item.Add(val); while (i > 0) { int p = Parent(i); if (Compare(i, p) > 0) Swap(i, p); i = p; } return val; } private void Heapify(int index) { for (int i = index, j; (j = Left(i)) < _item.Count; i = j) { if (j != _item.Count - 1 && Compare(j, j + 1) < 0) j++; if (Compare(i, j) < 0) Swap(i, j); } } public T Dequeue() { T val = _item[0]; _item[0] = _item[_item.Count - 1]; _item.RemoveAt(_item.Count - 1); Heapify(0); return val; } private void Build() { for (var i = (_item.Count >> 1) - 1; i >= 0; i--) Heapify(i); } public bool Any() => Count > 0; } class Program { static void Main(string[] args) { var CP = new CP(); CP.Solve(); } } public static class Output { public static void Put(string a) => Console.WriteLine(a); public static void Put(params object[] i) => Put(string.Join(" ", i)); public static void Put<T>(IEnumerable<T> a) => Put(string.Join(" ", a)); public static void PutV<T>(IEnumerable<T> a) { foreach (var z in a) Put(z); } public static void YN(bool i) { if (i) Put("Yes"); else Put("No"); } } public class Input { public static string Str => Console.ReadLine(); public static bool IsTypeEqual<T, U>() => typeof(T).Equals(typeof(U)); public static T ConvertType<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); public static T Cast<T>(string s) { if (IsTypeEqual<T, int>()) return ConvertType<T, int>(int.Parse(s)); else if (IsTypeEqual<T, long>()) return ConvertType<T, long>(long.Parse(s)); else if (IsTypeEqual<T, double>()) return ConvertType<T, double>(double.Parse(s)); else if (IsTypeEqual<T, char>()) return ConvertType<T, char>(char.Parse(s)); else return ConvertType<T, string>(s); } public static T[] Castarr<T>(string[] s) { var ret = new T[s.Length]; int i = 0; if (IsTypeEqual<T, char>()) { var list = new List<T>(); foreach (var t in s) { foreach (var u in t) { list.Add(ConvertType<T, char>(char.Parse(u.ToString()))); } } return list.ToArray(); } foreach (var t in s) { if (IsTypeEqual<T, int>()) ret[i++] = ConvertType<T, int>(int.Parse(t)); else if (IsTypeEqual<T, long>()) ret[i++] = ConvertType<T, long>(long.Parse(t)); else if (IsTypeEqual<T, double>()) ret[i++] = ConvertType<T, double>(double.Parse(t)); else ret[i++] = ConvertType<T, string>(t); } return ret; } Queue<string> q = new Queue<string>(); void next() { var ss = Str.Split(' '); foreach (var item in ss) q.Enqueue(item); } public T cin<T>() { if (!q.Any()) next(); return Cast<T>(q.Dequeue()); } public void mul<T>(out T t) { t = cin<T>(); } public void mul<T, U>(out T t, out U u) { t = cin<T>(); u = cin<U>(); } public void mul<T, U, V>(out T t, out U u, out V v) { t = cin<T>(); u = cin<U>(); v = cin<V>(); } public void mul<T, U, V, W>(out T t, out U u, out V v, out W w) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); } public void mul<T, U, V, W, X>(out T t, out U u, out V v, out W w, out X x) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); x = cin<X>(); } public void mul<T, U, V, W, X, Y>(out T t, out U u, out V v, out W w, out X x, out Y y) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); x = cin<X>(); y = cin<Y>(); } public void mul<T, U, V, W, X, Y, Z>(out T t, out U u, out V v, out W w, out X x, out Y y, out Z z) { t = cin<T>(); u = cin<U>(); v = cin<V>(); w = cin<W>(); x = cin<X>(); y = cin<Y>(); z = cin<Z>(); } public T[] cinarr<T>() { return Castarr<T>(Str.Split(' ')); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
2,663
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace ConsoleApp2 { class Program { static void Main(string[] args) { // var N = long.Parse(Console.ReadLine()); var NKM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); var A = NKM[0]; var B = NKM[1]; var ans = -1; for (int i = 0; i < 1000; i++) { if (Floor(i * 0.08) == A && Floor(i * 0.1) == B) { ans = i; break; } } Console.WriteLine(ans); } } }
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace ConsoleApp2 { class Program { static void Main(string[] args) { // var N = long.Parse(Console.ReadLine()); var NKM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); var A = NKM[0]; var B = NKM[1]; var ans = -1; for (int i = 0; i < 100000; i++) { if (Floor(i * 0.08) == A && Floor(i * 0.1) == B) { ans = i; break; } } Console.WriteLine(ans); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
157
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace DigitsParades { class Programk { static void Main(string[] args) { var AB = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); var A = AB[0]; var B = AB[1]; var ans = -1; for (double i = 1; i <= 100; i++) { if (Floor(i * 0.08) == A && Floor(i * 0.1) == B) { ans = (int)i; break; } } Console.WriteLine(ans); // var NM = Console.ReadLine(); } } #region スキャナー class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region スペース区切りで取得 public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region 型変換 private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region 配列取得 public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion } #endregion }
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace DigitsParades { class Programk { static void Main(string[] args) { var AB = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); var A = AB[0]; var B = AB[1]; var ans = -1; for (double i = 1; i <= 100000; i++) { if (Floor(i * 0.08) == A && Floor(i * 0.1) == B) { ans = (int)i; break; } } Console.WriteLine(ans); // var NM = Console.ReadLine(); } } #region スキャナー class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region スペース区切りで取得 public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region 型変換 private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region 配列取得 public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion } #endregion }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
582
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; namespace AtCoder { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static readonly long Mod = 1000000000 + 7; static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); var AB = Sarray(); var A = AB[0]; var B = AB[1]; for (var i = 0L; i <= 100; ++i) { if ((long)(i * 0.08) == A && (long)(i * 0.10) == B) { WriteLine(i); return; } } WriteLine(-1); // Out.Flush(); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; namespace AtCoder { class Program { static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static readonly long Mod = 1000000000 + 7; static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); var AB = Sarray(); var A = AB[0]; var B = AB[1]; for (var i = 0L; i <= 1250; ++i) { if ((long)(i * 0.08) == A && (long)(i * 0.10) == B) { WriteLine(i); return; } } WriteLine(-1); // Out.Flush(); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
206
using System; using System.Linq; class Program { static void Main(string[] args) { long[] inp = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); long a, b; a = inp[0]; b = inp[1]; long ans = -1; for (int i = 1; i < 101; i++) { if (Math.Floor(i * 0.08) == a && Math.Floor(i * 0.1) == b) { ans = i; break; } } Console.WriteLine(ans); } }
using System; using System.Linq; class Program { static void Main(string[] args) { long[] inp = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); long a, b; a = inp[0]; b = inp[1]; long ans = -1; for (int i = 1; i < 2001; i++) { if (Math.Floor(i * 0.08) == a && Math.Floor(i * 0.1) == b) { ans = i; break; } } Console.WriteLine(ans); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
137
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionC { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); long a = inputLongArray[0]; long b = inputLongArray[1]; for (long x = 0; x < 1000; x++) { var y10 = (int)(x * 0.1); var y8 = (int)(x * 0.08); if (y8 == a && y10 == b) { Console.WriteLine(x); Console.Out.Flush(); return; } } Console.WriteLine(-1); Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { class QuestionC { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); // 整数配列の入力 var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); long a = inputLongArray[0]; long b = inputLongArray[1]; for (long x = 0; x < 15000; x++) { var y10 = (int)(x * 0.1); var y8 = (int)(x * 0.08); if (y8 == a && y10 == b) { Console.WriteLine(x); Console.Out.Flush(); return; } } Console.WriteLine(-1); Console.Out.Flush(); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
212
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { class C { public static void Main() { var ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int a = ab[0]; int b = ab[1]; int i; for (i = 1; i <= 100; i++) if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) break; if (i > 100) Console.WriteLine("-1"); else Console.WriteLine(i); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { class C { public static void Main() { var ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int a = ab[0]; int b = ab[1]; int i; for (i = 1; i <= 1250; i++) if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) break; if (i > 1250) Console.WriteLine("-1"); else Console.WriteLine(i); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
8
156
using System; namespace TaxIncrease { class Program { static void Main(string[] args) { var str = Console.ReadLine().Split(' '); int eight = int.Parse(str[0]); double ten = int.Parse(str[1]); int kotae = -1; for (int i = 0; i < 1000; i++) { if ((Math.Floor(i * 0.08) == eight) && (Math.Floor(i * 0.1) == ten)) { kotae = i; break; } } Console.WriteLine(kotae.ToString()); } } }
using System; namespace TaxIncrease { class Program { static void Main(string[] args) { var str = Console.ReadLine().Split(' '); int eight = int.Parse(str[0]); double ten = int.Parse(str[1]); int kotae = -1; for (int i = 0; i <= 1000; i++) { if ((Math.Floor(i * 0.08) == eight) && (Math.Floor(i * 0.1) == ten)) { kotae = i; break; } } Console.WriteLine(kotae.ToString()); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
133
using System; class Test { public static void Main() { var str = Console.ReadLine().Split(' '); double tax8 = double.Parse(str[0]); double tax10 = double.Parse(str[1]); double val8 = Math.Ceiling(tax8 / 0.08); double val10 = Math.Ceiling(tax8 / 0.1); if (val8 >= val10) { if (Math.Floor(val8 * 0.1) == tax10) { Console.WriteLine(val8); } else { Console.WriteLine(-1); } } else { if (Math.Floor(val10 * 0.08) == tax8) { Console.WriteLine(val10); } else { Console.WriteLine(-1); } } } }
using System; class Test { public static void Main() { var str = Console.ReadLine().Split(' '); double tax8 = double.Parse(str[0]); double tax10 = double.Parse(str[1]); double val8 = Math.Ceiling(tax8 / 0.08); double val10 = Math.Ceiling(tax10 / 0.1); if (val8 >= val10) { if (Math.Floor(val8 * 0.1) == tax10) { Console.WriteLine(val8); } else { Console.WriteLine(-1); } } else { if (Math.Floor(val10 * 0.08) == tax8) { Console.WriteLine(val10); } else { Console.WriteLine(-1); } } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22]]
8
158
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; /// <summary> /// todo: /// https://atcoder.jp/contests/abc158/tasks/abc158_c /// </summary> namespace ABC_Training { public class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); var ans = -1; foreach (var x in Enumerable.Range(1, 100)) { var c = Math.Floor(x * 0.08); var d = Math.Floor(x * 0.1); if (a == c && b == d) { ans = x; break; } } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; /// <summary> /// todo: /// https://atcoder.jp/contests/abc158/tasks/abc158_c /// </summary> namespace ABC_Training { public class Program { static void Main(string[] args) { var ab = Console.ReadLine().Split(' '); var a = int.Parse(ab[0]); var b = int.Parse(ab[1]); var ans = -1; foreach (var x in Enumerable.Range(1, 1250)) { var c = Math.Floor(x * 0.08); var d = Math.Floor(x * 0.1); if (a == c && b == d) { ans = x; break; } } Console.WriteLine(ans); } } }
[["-", 0, 210, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 210, 12, 213, 3, 4, 0, 28, 0, 203]]
8
164
using System; namespace A { class Program { static void Main(string[] args) { var A = Console.ReadLine().Split(' '); var a = int.Parse(A[0]); var b = int.Parse(A[1]); for (int i = 0; i < 1500; i++) { if (a == Math.Floor(i / 0.08) && b == Math.Floor(i / 0.1)) { Console.WriteLine(i); break; } if (i == 1500) { Console.WriteLine("-1"); } } } } }
using System; namespace A { class Program { static void Main(string[] args) { var A = Console.ReadLine().Split(' '); var a = int.Parse(A[0]); var b = int.Parse(A[1]); for (int i = 0; i < 1500; i++) { if (a == Math.Floor(i * 0.08) && b == Math.Floor(i * 0.1)) { Console.WriteLine(i); break; } if (i == 1300) { Console.WriteLine("-1"); } } } } }
[["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
8
132
using System; namespace ABC158c { class Program { static void Main(string[] args) { var s = Console.ReadLine().Split(' '); int a = int.Parse(s[0]); int b = int.Parse(s[1]); for (int i = 1; i <= 100; i++) { int g1 = (int)Math.Floor(i * 0.08); if (g1 != a) { continue; } int g2 = (int)Math.Floor(i * 0.1); if (g2 != b) { continue; } Console.WriteLine(i); return; } Console.WriteLine(-1); } } }
using System; namespace ABC158c { class Program { static void Main(string[] args) { var s = Console.ReadLine().Split(' '); int a = int.Parse(s[0]); int b = int.Parse(s[1]); for (int i = 1; i <= 1009; i++) { int g1 = (int)Math.Floor(i * 0.08); if (g1 != a) { continue; } int g2 = (int)Math.Floor(i * 0.1); if (g2 != b) { continue; } Console.WriteLine(i); return; } Console.WriteLine(-1); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
147
using System; using static System.Console; using System.Linq; namespace AC { public class shiokara { static void Main(string[] args) { int[] n = ReadLine().Split(' ').Select(int.Parse).ToArray(); int[] b = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; for (int i = 0; i < 10; i++) { b[i] += n[1] * 10; } int ans = check(b, n[0]); WriteLine(ans); } static int check(int[] b, int a) { for (int i = 0; i < 10; i++) { double s = b[i] * 0.08; if (Math.Ceiling(s) == a) { return b[i]; } } return -1; } } }
using System; using static System.Console; using System.Linq; namespace AC { public class shiokara { static void Main(string[] args) { int[] n = ReadLine().Split(' ').Select(int.Parse).ToArray(); int[] b = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; for (int i = 0; i < 10; i++) { b[i] += n[1] * 10; } int ans = check(b, n[0]); WriteLine(ans); } static int check(int[] b, int a) { for (int i = 0; i < 10; i++) { double s = b[i] * 0.08; if (Math.Floor(s) == a) { return b[i]; } } return -1; } } }
[["-", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22]]
8
201
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var A = cin.ReadInt; var B = cin.ReadInt; bool existAnswer = false; var ans = 0; for (var i = 1; i <= 100; i++) { int checkA = (int)(i * 0.08); int checkB = (int)(i * 0.10); if (checkA == A && checkB == B) { existAnswer = true; ans = i; break; } } WriteLine(existAnswer ? ans : -1); } } 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 = cin.ReadInt; var B = cin.ReadInt; bool existAnswer = false; var ans = 0; for (var i = 1; i <= 1000; i++) { int checkA = (int)(i * 0.08); int checkB = (int)(i * 0.10); if (checkA == A && checkB == B) { existAnswer = true; ans = i; break; } } WriteLine(existAnswer ? ans : -1); } } 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, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
520
using System; using System.Linq; class Program { public static void Main() { int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); double a = input[0] * 100 / 8, b = input[1] * 10; if (a > b) { if (a < (input[1] + 1) * 10) { Console.WriteLine(Math.Ceiling(a)); } else { Console.WriteLine(-1); } } else { if (b < (input[0] + 1) * 100 / 8) { Console.WriteLine(Math.Ceiling(b)); } else { Console.WriteLine(-1); } } } }
using System; using System.Linq; class Program { public static void Main() { double[] input = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); double a = input[0] * 100 / 8, b = input[1] * 10; if (a > b) { if (a < (input[1] + 1) * 10) { Console.WriteLine(Math.Ceiling(a)); } else { Console.WriteLine(-1); } } else { if (b < (input[0] + 1) * 100 / 8) { Console.WriteLine(Math.Ceiling(b)); } else { Console.WriteLine(-1); } } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
8
168
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { input_iter = LazyLoadAllLines(); //------------------------------------------------// // var n = Read<long>(); // var s = Read(); // var als = Read<long>(n); // var sls = Read(n); /*List<Tuple<string, long>> scls = new List<Tuple<string, long>>(); for (int i = 0; i < m; ++i) { scls.Add(Tuple.Create(Read(), Read<long>())); }*/ // List<List<long>> abls = new List<List<long>>(); // List<long> cls = new List<long>(); /*List<long> edgeNum = Enumerable.Repeat(0L, (int)n).ToList(); for (int i = 0; i < n - 1; ++i) { abls.Add(Read<long>(2)); abls[i].Add(i); abls[i].Add(-1); --abls[i][0]; --abls[i][1]; //cls.Add(Read<long>()); ++edgeNum[(int)abls[i][0]]; ++edgeNum[(int)abls[i][1]]; }*/ // als.Sort((l, r) => (r - l)); // sls.Sort(StringComparer.OrdinalIgnoreCase); var a = Read<int>(); var b = Read<int>(); Tuple<double, double> aRange = Tuple.Create(1.0 * a / 0.08, 1.0 * (a + 1) / 0.08); Tuple<double, double> bRange = Tuple.Create(1.0 * b / 0.1, 1.0 * (b + 1) / 0.1); var mayValue = Math.Max(Math.Ceiling(aRange.Item1), Math.Ceiling(bRange.Item1)); if (mayValue > aRange.Item2 || mayValue > bRange.Item2) mayValue = -1; Console.WriteLine(mayValue); } static IEnumerator<string> input_iter; static IEnumerator<string> LazyLoadAllLines(bool doSplit = true) { string line; if (doSplit) { do { line = Console.ReadLine(); foreach (var s in line.Split(' ')) yield return s; } while (line != null); } else { do { line = Console.ReadLine(); yield return line; } while (line != null); } } // single 1 elem. static _T Read<_T>() where _T : struct { input_iter.MoveNext(); return (_T)Convert.ChangeType(input_iter.Current, typeof(_T)); } static string Read() { input_iter.MoveNext(); return input_iter.Current; } // single n-elems. static List<_T> Read<_T>(long num) where _T : struct { List<_T> res = new List<_T>(); for (long i = 0; i < num; ++i) { input_iter.MoveNext(); res.Add((_T)Convert.ChangeType(input_iter.Current, typeof(_T))); } return res; } static List<string> Read(long num) { List<string> res = new List<string>(); for (long i = 0; i < num; ++i) { input_iter.MoveNext(); res.Add(input_iter.Current); } return res; } // multiple(single type) n-elems. (Range, Edge etc.) static List<List<_T>> Read<_T>(long elemNum, long typeNum, bool toSort = false) where _T : struct { List<List<_T>> res = new List<List<_T>>(); for (int i = 0; i < elemNum; ++i) { var elem = Read<_T>(typeNum); if (toSort) elem.Sort(); res.Add(elem); } return res; } // multiple(multiple type) n-elems. static List<Tuple<_T1, _T2>> Read<_T1, _T2>(long num) where _T1 : struct where _T2 : struct { List<Tuple<_T1, _T2>> res = new List<Tuple<_T1, _T2>>(); for (int i = 0; i < num; ++i) { res.Add(Tuple.Create(Read<_T1>(), Read<_T2>())); } return res; } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { input_iter = LazyLoadAllLines(); //------------------------------------------------// // var n = Read<long>(); // var s = Read(); // var als = Read<long>(n); // var sls = Read(n); /*List<Tuple<string, long>> scls = new List<Tuple<string, long>>(); for (int i = 0; i < m; ++i) { scls.Add(Tuple.Create(Read(), Read<long>())); }*/ // List<List<long>> abls = new List<List<long>>(); // List<long> cls = new List<long>(); /*List<long> edgeNum = Enumerable.Repeat(0L, (int)n).ToList(); for (int i = 0; i < n - 1; ++i) { abls.Add(Read<long>(2)); abls[i].Add(i); abls[i].Add(-1); --abls[i][0]; --abls[i][1]; //cls.Add(Read<long>()); ++edgeNum[(int)abls[i][0]]; ++edgeNum[(int)abls[i][1]]; }*/ // als.Sort((l, r) => (r - l)); // sls.Sort(StringComparer.OrdinalIgnoreCase); var a = Read<int>(); var b = Read<int>(); Tuple<double, double> aRange = Tuple.Create(1.0 * a / 0.08, 1.0 * (a + 0.999999) / 0.08); Tuple<double, double> bRange = Tuple.Create(1.0 * b / 0.1, 1.0 * (b + 0.999999) / 0.1); var mayValue = Math.Max(Math.Ceiling(aRange.Item1), Math.Ceiling(bRange.Item1)); if (mayValue > aRange.Item2 || mayValue > bRange.Item2) mayValue = -1; Console.WriteLine((int)mayValue); } static IEnumerator<string> input_iter; static IEnumerator<string> LazyLoadAllLines(bool doSplit = true) { string line; if (doSplit) { do { line = Console.ReadLine(); foreach (var s in line.Split(' ')) yield return s; } while (line != null); } else { do { line = Console.ReadLine(); yield return line; } while (line != null); } } // single 1 elem. static _T Read<_T>() where _T : struct { input_iter.MoveNext(); return (_T)Convert.ChangeType(input_iter.Current, typeof(_T)); } static string Read() { input_iter.MoveNext(); return input_iter.Current; } // single n-elems. static List<_T> Read<_T>(long num) where _T : struct { List<_T> res = new List<_T>(); for (long i = 0; i < num; ++i) { input_iter.MoveNext(); res.Add((_T)Convert.ChangeType(input_iter.Current, typeof(_T))); } return res; } static List<string> Read(long num) { List<string> res = new List<string>(); for (long i = 0; i < num; ++i) { input_iter.MoveNext(); res.Add(input_iter.Current); } return res; } // multiple(single type) n-elems. (Range, Edge etc.) static List<List<_T>> Read<_T>(long elemNum, long typeNum, bool toSort = false) where _T : struct { List<List<_T>> res = new List<List<_T>>(); for (int i = 0; i < elemNum; ++i) { var elem = Read<_T>(typeNum); if (toSort) elem.Sort(); res.Add(elem); } return res; } // multiple(multiple type) n-elems. static List<Tuple<_T1, _T2>> Read<_T1, _T2>(long num) where _T1 : struct where _T2 : struct { List<Tuple<_T1, _T2>> res = new List<Tuple<_T1, _T2>>(); for (int i = 0; i < num; ++i) { res.Add(Tuple.Create(Read<_T1>(), Read<_T2>())); } return res; } } }
[["-", 0, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 250], ["+", 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]]
8
666
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace CsharpSpiral { partial class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true }; Console.SetOut(sw); new Program().Solve(new ConsoleInput(Console.In, ' ')); Console.Out.Flush(); } public void Solve(ConsoleInput cin) { var A = cin.ReadInt; var B = cin.ReadInt; var R = Enumerable.Range(1, 100) .Where(i => i * 8 / 100 == A) .Where(i => i * 10 / 100 == B); var ans = R.Any() ? R.Min() : -1; Console.WriteLine(ans); } } static class ExtendClass { public static void Swap<T>(this T[] X, int i, int j) { T tmp = X[i]; X[i] = X[j]; X[j] = tmp; } public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X); public static S[] Clone<S>(this S[] src) where S : struct { var res = new S[src.Length]; Array.Copy(src, res, src.Length); return res; } } class ConsoleInput { private readonly TextReader _stream; private readonly char _separator = ' '; private readonly Queue<string> inputStream; public ConsoleInput(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.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace CsharpSpiral { partial class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true }; Console.SetOut(sw); new Program().Solve(new ConsoleInput(Console.In, ' ')); Console.Out.Flush(); } public void Solve(ConsoleInput cin) { var A = cin.ReadInt; var B = cin.ReadInt; var R = Enumerable.Range(1, 1300) .Where(i => i * 8 / 100 == A) .Where(i => i * 10 / 100 == B); var ans = R.Any() ? R.Min() : -1; Console.WriteLine(ans); } } static class ExtendClass { public static void Swap<T>(this T[] X, int i, int j) { T tmp = X[i]; X[i] = X[j]; X[j] = tmp; } public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X); public static S[] Clone<S>(this S[] src) where S : struct { var res = new S[src.Length]; Array.Copy(src, res, src.Length); return res; } } class ConsoleInput { private readonly TextReader _stream; private readonly char _separator = ' '; private readonly Queue<string> inputStream; public ConsoleInput(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; } } }
[["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203]]
8
646
using System; using System.Linq; using System.Collections.Generic; public class AtCoderC { static void Main() { long a; long b; { var line = Console.ReadLine(); var words = line.Split(' '); a = long.Parse(words[0]); b = long.Parse(words[1]); } int answer = -1; for (int i = 0; i < 150; i++) { int priceA = (i * 8 / 100); int priceB = (i * 10 / 100); if (priceA == a && priceB == b) { answer = i; break; } } Console.WriteLine(answer); } }
using System; using System.Linq; using System.Collections.Generic; public class AtCoderC { static void Main() { long a; long b; { var line = Console.ReadLine(); var words = line.Split(' '); a = long.Parse(words[0]); b = long.Parse(words[1]); } int answer = -1; for (int i = 0; i <= 1000; i++) { int priceA = (i * 8 / 100); int priceB = (i * 10 / 100); if (priceA == a && priceB == b) { answer = i; break; } } Console.WriteLine(answer); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
149
using System; using System.Diagnostics; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { #if DEBUG MyDebugger.Test(process, "../TextFile1.txt"); // MyDebugger.Test(process, "../TextFile2.txt"); // MyDebugger.MakeTestCase("../TextFile2.txt"); #else object ret = process(new StreamReader(Console.OpenStandardInput())); Console.WriteLine(ret); #endif } static object process(TextReader input) { var spl = input.ReadLine().Split(' '); var a = long.Parse(spl[0]); var b = long.Parse(spl[1]); for (int i = 0; i <= 100; i++) { if ((int)((double)i * 0.080) == a && (int)((double)i * 0.100) == b) return i; } return -1; } }
using System; using System.Diagnostics; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { #if DEBUG MyDebugger.Test(process, "../TextFile1.txt"); // MyDebugger.Test(process, "../TextFile2.txt"); // MyDebugger.MakeTestCase("../TextFile2.txt"); #else object ret = process(new StreamReader(Console.OpenStandardInput())); Console.WriteLine(ret); #endif } static object process(TextReader input) { var spl = input.ReadLine().Split(' '); var a = long.Parse(spl[0]); var b = long.Parse(spl[1]); for (int i = 0; i <= 2000; i++) { if ((int)((double)i * 0.080) == a && (int)((double)i * 0.100) == b) return i; } return -1; } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
192
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Runtime.CompilerServices; using System.Text; using System.Diagnostics; using System.Numerics; using static System.Console; using static System.Convert; using static System.Math; using static Template; using Pi = Pair<int, int>; class Solver { public void Solve(Scanner sc) { int A, B; sc.Make(out A, out B); for (int i = 1; i < 1000; i++) { if (i * 8 / 100 == A && i * 10 / 100 == B) Fail(i); } WriteLine(-1); } } #region Template public static class Template { static void Main(string[] args) { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver().Solve(new Scanner()); Console.Out.Flush(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == 1) { a = b; return true; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == -1) { a = b; return true; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; } public static T[] Shuffle<T>(this IList<T> A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; } public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); } } public class Scanner { public string Str => Console.ReadLine().Trim(); public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray(); public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray(); public char[][] Grid(int n) => Create(n, () => Str.ToCharArray()); public int[] ArrInt1D(int n) => Create(n, () => Int); public long[] ArrLong1D(int n) => Create(n, () => Long); public int[][] ArrInt2D(int n) => Create(n, () => ArrInt); public long[][] ArrLong2D(int n) => Create(n, () => ArrLong); private Queue<string> q = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); } public void Make<T1>(out T1 v1) => v1 = Next<T1>(); public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); } public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); } public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); } public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); } public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); } // public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, // v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, // out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3, // T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, // v3, v4); } } public class Pair<T1, T2> : IComparable<Pair<T1, T2>> { public T1 v1; public T2 v2; public Pair() {} public Pair(T1 v1, T2 v2) { this.v1 = v1; this.v2 = v2; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(Pair<T1, T2> p) { var c = Comparer<T1>.Default.Compare(v1, p.v1); if (c == 0) c = Comparer<T2>.Default.Compare(v2, p.v2); return c; } public override string ToString() => $"{v1.ToString()} {v2.ToString()}"; public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; } } public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> { public T3 v3; public Pair() : base() {} public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(Pair<T1, T2, T3> p) { var c = base.CompareTo(p); if (c == 0) c = Comparer<T3>.Default.Compare(v3, p.v3); return c; } public override string ToString() => $"{base.ToString()} {v3.ToString()}"; public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; } } #endregion
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Runtime.CompilerServices; using System.Text; using System.Diagnostics; using System.Numerics; using static System.Console; using static System.Convert; using static System.Math; using static Template; using Pi = Pair<int, int>; class Solver { public void Solve(Scanner sc) { int A, B; sc.Make(out A, out B); for (int i = 1; i <= 1000; i++) { if (i * 8 / 100 == A && i * 10 / 100 == B) Fail(i); } WriteLine(-1); } } #region Template public static class Template { static void Main(string[] args) { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver().Solve(new Scanner()); Console.Out.Flush(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == 1) { a = b; return true; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == -1) { a = b; return true; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; } public static T[] Shuffle<T>(this IList<T> A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; } public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); } } public class Scanner { public string Str => Console.ReadLine().Trim(); public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray(); public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray(); public char[][] Grid(int n) => Create(n, () => Str.ToCharArray()); public int[] ArrInt1D(int n) => Create(n, () => Int); public long[] ArrLong1D(int n) => Create(n, () => Long); public int[][] ArrInt2D(int n) => Create(n, () => ArrInt); public long[][] ArrLong2D(int n) => Create(n, () => ArrLong); private Queue<string> q = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); } public void Make<T1>(out T1 v1) => v1 = Next<T1>(); public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); } public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); } public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); } public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); } public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); } // public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, // v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, // out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3, // T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, // v3, v4); } } public class Pair<T1, T2> : IComparable<Pair<T1, T2>> { public T1 v1; public T2 v2; public Pair() {} public Pair(T1 v1, T2 v2) { this.v1 = v1; this.v2 = v2; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(Pair<T1, T2> p) { var c = Comparer<T1>.Default.Compare(v1, p.v1); if (c == 0) c = Comparer<T2>.Default.Compare(v2, p.v2); return c; } public override string ToString() => $"{v1.ToString()} {v2.ToString()}"; public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; } } public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> { public T3 v3; public Pair() : base() {} public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(Pair<T1, T2, T3> p) { var c = base.CompareTo(p); if (c == 0) c = Comparer<T3>.Default.Compare(v3, p.v3); return c; } public override string ToString() => $"{base.ToString()} {v3.ToString()}"; public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; } } #endregion
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
1,558
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace D { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var s = Console.ReadLine(); var q = int.Parse(Console.ReadLine()); var rightBuilder = new StringBuilder(); var leftBuilder = new StringBuilder(); var isReverse = false; Func<string, string> reverse = str => { var builder = new StringBuilder(str.Length); for (var i = str.Length - 1; i >= 0; i--) { builder.Append(str[i]); } return builder.ToString(); }; for (var i = 0; i < q; i++) { var query = Console.ReadLine().Trim().Split(' '); if (query[0] == "2") { if (query[1] == "1") { if (isReverse) rightBuilder.Append(query[2]); else leftBuilder.Append(query[2]); } else if (query[1] == "2") { if (isReverse) leftBuilder.Append(query[2]); else rightBuilder.Append(query[2]); } } else { isReverse = !isReverse; } } var right = rightBuilder.ToString(); var left = leftBuilder.ToString(); var result = isReverse ? reverse(right) + s + left : reverse(left) + s + right; Console.WriteLine(result); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace D { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var s = Console.ReadLine(); var q = int.Parse(Console.ReadLine()); var rightBuilder = new StringBuilder(s); var leftBuilder = new StringBuilder(); var isReverse = false; Func<string, string> reverse = str => { var builder = new StringBuilder(str.Length); for (var i = str.Length - 1; i >= 0; i--) { builder.Append(str[i]); } return builder.ToString(); }; for (var i = 0; i < q; i++) { var query = Console.ReadLine().Trim().Split(' '); if (query[0] == "2") { if (query[1] == "1") { if (isReverse) rightBuilder.Append(query[2]); else leftBuilder.Append(query[2]); } else if (query[1] == "2") { if (isReverse) leftBuilder.Append(query[2]); else rightBuilder.Append(query[2]); } } else { isReverse = !isReverse; } } var right = rightBuilder.ToString(); var left = leftBuilder.ToString(); var result = isReverse ? reverse(right) + left : reverse(left) + right; Console.WriteLine(result); } } }
[["+", 0, 212, 0, 230, 3, 4, 0, 28, 0, 22], ["-", 0, 212, 0, 41, 64, 16, 31, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 41, 64, 16, 17, 72], ["-", 0, 212, 0, 41, 75, 16, 31, 16, 17, 72], ["-", 0, 212, 0, 41, 75, 16, 31, 16, 12, 22]]
8
382
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var bodystr = Console.ReadLine(); var bodyArray = bodystr.Split(); var countNum = int.Parse(Console.ReadLine()); var endArray = new string[200000]; var firstArray = new string[200000]; var firstPlace = 0; var endPlace = 0; var gyaku = false; for (var i = 0; i < countNum; i++) { var allShiji = Console.ReadLine(); var shijiList = allShiji.Split(' '); if (shijiList[0] == "1") { gyaku = !gyaku; } else { if (shijiList[1] == "1") { if (gyaku) { endArray[endPlace] = shijiList[2]; endPlace++; } else { firstArray[firstPlace] = shijiList[2]; firstPlace++; } } else { if (!gyaku) { endArray[endPlace] = shijiList[2]; endPlace++; } else { firstArray[firstPlace] = shijiList[2]; firstPlace++; } } } } var str = ""; if (gyaku) { str = string.Join("", endArray.Reverse()) + string.Join("", bodyArray.Reverse()) + string.Join("", firstArray); } else { str = string.Join("", firstArray.Reverse()) + string.Join("", bodyArray) + string.Join("", endArray); } Console.WriteLine(str); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var bodystr = Console.ReadLine(); var bodyArray = bodystr.ToCharArray(); var countNum = int.Parse(Console.ReadLine()); var endArray = new string[200000]; var firstArray = new string[200000]; var firstPlace = 0; var endPlace = 0; var gyaku = false; for (var i = 0; i < countNum; i++) { var allShiji = Console.ReadLine(); var shijiList = allShiji.Split(' '); if (shijiList[0] == "1") { gyaku = !gyaku; } else { if (shijiList[1] == "1") { if (gyaku) { endArray[endPlace] = shijiList[2]; endPlace++; } else { firstArray[firstPlace] = shijiList[2]; firstPlace++; } } else { if (!gyaku) { endArray[endPlace] = shijiList[2]; endPlace++; } else { firstArray[firstPlace] = shijiList[2]; firstPlace++; } } } } var str = ""; if (gyaku) { str = string.Join("", endArray.Reverse()) + string.Join("", bodyArray.Reverse()) + string.Join("", firstArray); } else { str = string.Join("", firstArray.Reverse()) + string.Join("", bodyArray) + string.Join("", endArray); } Console.WriteLine(str); } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
8
338
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var sol = new Solve(); sol.Exec(); } } class Solve { public void Exec() { var S = Console.ReadLine().ToCharArray(); var Q = int.Parse(Console.ReadLine()); var first = new Stack<char>(); var last = new Stack<char>(); foreach (var c in S) first.Push(c); for (var i = 0; i < Q; i++) { var l = Console.ReadLine().Split().ToArray(); if (int.Parse(l[0]) == 1) { var tmp = first; first = last; last = tmp; } else { if (int.Parse(l[1]) == 1) { first.Push(l[2][0]); } else { last.Push(l[2][0]); } } } Console.WriteLine(string.Join("", first) + string.Join("", last.Reverse())); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var sol = new Solve(); sol.Exec(); } } class Solve { public void Exec() { var S = Console.ReadLine().ToCharArray(); var Q = int.Parse(Console.ReadLine()); var first = new Stack<char>(); var last = new Stack<char>(); foreach (var c in S) last.Push(c); for (var i = 0; i < Q; i++) { var l = Console.ReadLine().Split().ToArray(); if (int.Parse(l[0]) == 1) { var tmp = first; first = last; last = tmp; } else { if (int.Parse(l[1]) == 1) { first.Push(l[2][0]); } else { last.Push(l[2][0]); } } } Console.WriteLine(string.Join("", first) + string.Join("", last.Reverse())); } }
[["-", 0, 210, 8, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 210, 8, 1, 0, 213, 63, 214, 205, 22]]
8
257
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { var s = Console.ReadLine(); var q = int.Parse(Console.ReadLine()); Deque<char> deque = new Deque<char>(); foreach (var c in s) { deque.PushBack(c); } int front = 0; for (int i = 0; i < q; i++) { var query = Console.ReadLine(); if (query == "1") { front ^= 1; } else { if (query[2] == '1' ^ front == 0) { deque.PushFront(query[4]); } else { deque.PushBack(query[4]); } } } Console.WriteLine(string.Join("", front != 0 ? deque : deque.Reverse())); } } class Deque<T> : IEnumerable<T> { public int Count; T[] data; int FrontInd, BackInd; [MethodImpl(MethodImplOptions.AggressiveInlining)] public Deque() { data = new T[1 << 16]; FrontInd = 0; BackInd = data.Length - 1; Count = 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Deque(T[] elem) { int s = elem.Length; s |= s >> 1; s |= s >> 2; s |= s >> 4; s |= s >> 8; s |= s >> 16; data = new T[++s]; elem.CopyTo(data, 0); FrontInd = 0; BackInd = elem.Length - 1; Count = elem.Length; } public T Front { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { ValidateNoEmpty(); return data[FrontInd]; } } public T Back { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { ValidateNoEmpty(); return data[BackInd]; } } public T this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (index >= Count) throw new Exception(); return data[FrontInd + index & data.Length - 1]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { if (index >= Count) throw new Exception(); data[FrontInd + index & data.Length - 1] = value; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushFront(T elem) { if (Count == data.Length) Extend(data.Length << 1); Count++; data[FrontInd = (FrontInd - 1) & data.Length - 1] = elem; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopFront() { var res = Front; FrontInd = (FrontInd + 1) & data.Length - 1; Count--; return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushBack(T elem) { if (Count == data.Length) Extend(data.Length << 1); Count++; data[BackInd = (BackInd + 1) & data.Length - 1] = elem; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopBack() { var res = Back; BackInd = (BackInd - 1) & data.Length - 1; Count--; return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void Extend(int newSize) { T[] newData = new T[newSize]; if (0 < Count) { if (FrontInd <= BackInd) Array.Copy(data, FrontInd, newData, 0, Count); else { Array.Copy(data, FrontInd, newData, 0, data.Length - FrontInd); Array.Copy(data, 0, newData, data.Length - FrontInd, BackInd + 1); } } data = newData; FrontInd = 0; BackInd = Count - 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ValidateNoEmpty() { if (Count == 0) throw new Exception(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public IEnumerator<T> GetEnumerator() { for (int i = FrontInd; i != BackInd; i = i + 1 & data.Length - 1) yield return data[i]; yield return data[BackInd]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { var s = Console.ReadLine(); var q = int.Parse(Console.ReadLine()); Deque<char> deque = new Deque<char>(); foreach (var c in s) { deque.PushBack(c); } int front = 0; for (int i = 0; i < q; i++) { var query = Console.ReadLine(); if (query == "1") { front ^= 1; } else { if (query[2] == '1' ^ front == 0) { deque.PushBack(query[4]); } else { deque.PushFront(query[4]); } } } Console.WriteLine(string.Join("", front == 0 ? deque : deque.Reverse())); } } class Deque<T> : IEnumerable<T> { public int Count; T[] data; int FrontInd, BackInd; [MethodImpl(MethodImplOptions.AggressiveInlining)] public Deque() { data = new T[1 << 1]; FrontInd = 0; BackInd = data.Length - 1; Count = 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Deque(T[] elem) { int s = elem.Length; s |= s >> 1; s |= s >> 2; s |= s >> 4; s |= s >> 8; s |= s >> 16; data = new T[++s]; elem.CopyTo(data, 0); FrontInd = 0; BackInd = elem.Length - 1; Count = elem.Length; } public T Front { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { ValidateNoEmpty(); return data[FrontInd]; } } public T Back { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { ValidateNoEmpty(); return data[BackInd]; } } public T this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (index >= Count) throw new Exception(); return data[FrontInd + index & data.Length - 1]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { if (index >= Count) throw new Exception(); data[FrontInd + index & data.Length - 1] = value; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushFront(T elem) { if (Count == data.Length) Extend(data.Length << 1); Count++; data[FrontInd = (FrontInd - 1) & data.Length - 1] = elem; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopFront() { var res = Front; FrontInd = (FrontInd + 1) & data.Length - 1; Count--; return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushBack(T elem) { if (Count == data.Length) Extend(data.Length << 1); Count++; data[BackInd = (BackInd + 1) & data.Length - 1] = elem; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopBack() { var res = Back; BackInd = (BackInd - 1) & data.Length - 1; Count--; return res; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void Extend(int newSize) { T[] newData = new T[newSize]; if (0 < Count) { if (FrontInd <= BackInd) Array.Copy(data, FrontInd, newData, 0, Count); else { Array.Copy(data, FrontInd, newData, 0, data.Length - FrontInd); Array.Copy(data, 0, newData, data.Length - FrontInd, BackInd + 1); } } data = newData; FrontInd = 0; BackInd = Count - 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ValidateNoEmpty() { if (Count == 0) throw new Exception(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public IEnumerator<T> GetEnumerator() { for (int i = FrontInd; i != BackInd; i = i + 1 & data.Length - 1) yield return data[i]; yield return data[BackInd]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } }
[["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 79], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["-", 12, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 12, 227, 39, 224, 225, 226, 0, 16, 12, 203]]
8
963
using System; using System.Numerics; using System.Linq; using System.Collections.Generic; using System.Text; class ProgramD { static void Main(string[] args) { //入力 string s = Console.ReadLine(); StringBuilder f = new StringBuilder(); StringBuilder l = new StringBuilder(); int n = int.Parse(Console.ReadLine()); int flag = 0; for (int i = 0; i < n; i++) { string[] temp = Console.ReadLine().Split(' '); if (int.Parse(temp[0]) == 1) { if (flag == 1) flag = 0; else flag = 1; } else { if (flag == 1) { if (int.Parse(temp[1]) == 2) f.Append(temp[2]); else l.Append(temp[2]); } else { if (int.Parse(temp[1]) == 1) f.Insert(0, temp[2]); else l.Append(temp[2]); } } } string s2 = new string(f.ToString().Reverse().ToArray()) + s + l.ToString(); if (flag == 1) { var t = s2.Reverse(); s2 = string.Join("", t); } Console.WriteLine(s2); } }
using System; using System.Numerics; using System.Linq; using System.Collections.Generic; using System.Text; class ProgramD { static void Main(string[] args) { //入力 string s = Console.ReadLine(); StringBuilder f = new StringBuilder(); StringBuilder l = new StringBuilder(); int n = int.Parse(Console.ReadLine()); int flag = 0; for (int i = 0; i < n; i++) { string[] temp = Console.ReadLine().Split(' '); if (int.Parse(temp[0]) == 1) { if (flag == 1) flag = 0; else flag = 1; } else { if (flag == 1) { if (int.Parse(temp[1]) == 2) f.Append(temp[2]); else l.Append(temp[2]); } else { if (int.Parse(temp[1]) == 1) f.Append(temp[2]); else l.Append(temp[2]); } } } string s2 = new string(f.ToString().Reverse().ToArray()) + s + l.ToString(); if (flag == 1) { var t = s2.Reverse(); s2 = string.Join("", t); } Console.WriteLine(s2); } }
[["-", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 57, 64, 1, 0, 213, 3, 4, 0, 21]]
8
301
using System; using System.Text; using System.Linq; public class ABC158_D { private static void Main(string[] args) { var s = ReadStr(); var q = ReadInt(); var isReversed = false; var sbHead = new StringBuilder(""); var sbTail = new StringBuilder(""); for (int i = 0; i < q; i++) { var query = ReadStrsAsArray(); var t = query[0]; if (t == "1") { isReversed = !isReversed; } else { var f = query[1]; var c = query[2]; if (IsHead(f, isReversed)) sbHead.Append(c); else sbTail.Append(c); } } var head = (isReversed) ? sbTail.ToString() : sbHead.ToString(); head = new string(head.Reverse().ToArray()); var tail = (isReversed) ? sbHead.ToString() : sbTail.ToString(); if (isReversed) s = new string(head.Reverse().ToArray()); var answer = head + s + tail; Console.WriteLine(answer); } private static string ReadStr() => Console.ReadLine().Trim(); private static string[] ReadStrsAsArray() => Console.ReadLine().Trim().Split(); private static int ReadInt() => int.Parse(Console.ReadLine().Trim()); private static bool IsHead(string f, bool isReversed) => (((f == "2") && (isReversed)) || ((f == "1") && (!isReversed))); }
using System; using System.Text; using System.Linq; public class ABC158_D { private static void Main(string[] args) { var s = ReadStr(); var q = ReadInt(); var isReversed = false; var sbHead = new StringBuilder(""); var sbTail = new StringBuilder(""); for (int i = 0; i < q; i++) { var query = ReadStrsAsArray(); var t = query[0]; if (t == "1") { isReversed = !isReversed; } else { var f = query[1]; var c = query[2]; if (IsHead(f, isReversed)) sbHead.Append(c); else sbTail.Append(c); } } var head = (isReversed) ? sbTail.ToString() : sbHead.ToString(); head = new string(head.Reverse().ToArray()); var tail = (isReversed) ? sbHead.ToString() : sbTail.ToString(); if (isReversed) s = new string(s.Reverse().ToArray()); var answer = head + s + tail; Console.WriteLine(answer); } private static string ReadStr() => Console.ReadLine().Trim(); private static string[] ReadStrsAsArray() => Console.ReadLine().Trim().Split(); private static int ReadInt() => int.Parse(Console.ReadLine().Trim()); private static bool IsHead(string f, bool isReversed) => (((f == "2") && (isReversed)) || ((f == "1") && (!isReversed))); }
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22]]
8
353
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; internal static class CR { public static string GetText() { return Console.ReadLine(); } public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long GetLong() { return long.Parse(Console.ReadLine()); } public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } } namespace AtCoder.D { public class Program { public static string S { get; private set; } public static long Q { get; private set; } public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { S = CR.GetText(); Q = CR.GetLong(); var sbPrefix = new StringBuilder(); var sbSuffix = new StringBuilder(); var isReverse = false; for (int i = 0; i < Q; i++) { var q = CR.GetTexts(); if (q[0] == "1") { isReverse = !isReverse; var temp = sbPrefix; sbPrefix = sbSuffix; sbSuffix = temp; continue; } if (q[1] == "1") { sbPrefix.Append(q[2]); } else { sbSuffix.Append(q[2]); } } return new string(sbPrefix.ToString().Reverse().ToArray()) + new string(S.Reverse().ToArray()) + sbSuffix.ToString(); } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; internal static class CR { public static string GetText() { return Console.ReadLine(); } public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long GetLong() { return long.Parse(Console.ReadLine()); } public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } } namespace AtCoder.D { public class Program { public static string S { get; private set; } public static long Q { get; private set; } public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { S = CR.GetText(); Q = CR.GetLong(); var sbPrefix = new StringBuilder(); var sbSuffix = new StringBuilder(); var isReverse = false; for (int i = 0; i < Q; i++) { var q = CR.GetTexts(); if (q[0] == "1") { isReverse = !isReverse; var temp = sbPrefix; sbPrefix = sbSuffix; sbSuffix = temp; continue; } if (q[1] == "1") { sbPrefix.Append(q[2]); } else { sbSuffix.Append(q[2]); } } return new string(sbPrefix.ToString().Reverse().ToArray()) + (isReverse ? new string(S.Reverse().ToArray()) : S) + sbSuffix.ToString(); } } }
[["+", 0, 37, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 15, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 75, 22]]
8
376
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderD { static void Main() { string s = Console.ReadLine(); int q = int.Parse(Console.ReadLine()); bool isReverse = false; StringBuilder sbAfter = new StringBuilder(); StringBuilder sbBefore = new StringBuilder(); for (int i = 0; i < q; i++) { string line = Console.ReadLine(); var words = line.Split(' '); int type1 = int.Parse(words[0]); if (type1 == 1) { isReverse = !isReverse; } else { int type2 = int.Parse(words[1]); string str = words[2]; if ((!isReverse && (type2 == 2)) || (isReverse && (type2 == 1))) { sbAfter.Append(str); } else { sbBefore.Append(str); } } } string answer = ""; if (isReverse) { answer = Reverse(sbAfter.ToString()) + s + sbBefore.ToString(); } else { answer = Reverse(sbBefore.ToString()) + s + sbAfter.ToString(); } Console.WriteLine(answer); } private static string Reverse(string s) { return string.Join("", s.Reverse()); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderD { static void Main() { string s = Console.ReadLine(); int q = int.Parse(Console.ReadLine()); bool isReverse = false; StringBuilder sbAfter = new StringBuilder(); StringBuilder sbBefore = new StringBuilder(); for (int i = 0; i < q; i++) { string line = Console.ReadLine(); var words = line.Split(' '); int type1 = int.Parse(words[0]); if (type1 == 1) { isReverse = !isReverse; } else { int type2 = int.Parse(words[1]); string str = words[2]; if ((!isReverse && (type2 == 2)) || (isReverse && (type2 == 1))) { sbAfter.Append(str); } else { sbBefore.Append(str); } } } string answer = ""; if (isReverse) { answer = Reverse(sbAfter.ToString()) + Reverse(s) + sbBefore.ToString(); } else { answer = Reverse(sbBefore.ToString()) + s + sbAfter.ToString(); } Console.WriteLine(answer); } private static string Reverse(string s) { return string.Join("", s.Reverse()); } }
[["+", 0, 11, 12, 16, 31, 16, 12, 213, 63, 22], ["+", 12, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 16, 31, 16, 12, 213, 3, 4, 0, 25]]
8
290
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 ABC158D { 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; var Q = NN; var deq = new LIB_Deque<char>(); foreach (var item in S) { deq.PushBack(item); } var han = false; for (var i = 0; i < Q; i++) { var t = NN; if (t == 1) { han = !han; } else { var F = NN; var C = NS; if ((F == 1) ^ !han) { deq.PushFront(C[0]); } else { deq.PushBack(C[0]); } } } for (var i = 0; i < deq.Count; i++) { if (!han) Console.Write(deq[deq.Count - i - 1]); else Console.Write(deq[i]); } Console.WriteLine(); } static class Console_ { static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); } static long NN => long.Parse(Console_.NextString()); static double ND => double.Parse(Console_.NextString()); static string NS => Console_.NextString(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library { class LIB_Deque<T> { T[] array; int front, cap; public int Count; public T this[long i] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return array[GetIndex((int)i)]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { array[GetIndex((int)i)] = value; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_Deque(long cap = 16) { array = new T[this.cap = (int)cap]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] int GetIndex(int i) { if (i >= cap) throw new Exception(); var r = front + i; return r >= cap ? r - cap : r; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushFront(T x) { if (Count == cap) Extend(); if (--front < 0) front += array.Length; array[front] = x; ++Count; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopFront() { if (Count-- == 0) throw new Exception(); var r = array[front++]; if (front >= cap) front -= cap; return r; } public T Front => array[front]; [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushBack(T x) { if (Count == cap) Extend(); var i = front + Count++; array[i >= cap ? i - cap : i] = x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopBack() { if (Count == 0) throw new Exception(); return array[GetIndex(--Count)]; } public T Back => array[GetIndex(Count - 1)]; [MethodImpl(MethodImplOptions.AggressiveInlining)] void Extend() { T[] nb = new T[cap << 1]; if (front > cap - Count) { var l = array.Length - front; Array.Copy(array, front, nb, 0, l); Array.Copy(array, 0, nb, l, Count - l); } else Array.Copy(array, front, nb, 0, Count); array = nb; front = 0; cap <<= 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Insert(long i, T x) { if (i > Count) throw new Exception(); this.PushFront(x); for (int j = 0; j < i; j++) this[j] = this[j + 1]; this[i] = x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T RemoveAt(long i) { if (i < 0 || i >= Count) throw new Exception(); var r = this[i]; for (var j = i; j > 0; j--) this[j] = this[j - 1]; this.PopFront(); return r; } } }
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 ABC158D { 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; var Q = NN; var deq = new LIB_Deque<char>(); foreach (var item in S) { deq.PushBack(item); } var han = false; for (var i = 0; i < Q; i++) { var t = NN; if (t == 1) { han = !han; } else { var F = NN; var C = NS; if ((F == 1) ^ (han)) { deq.PushFront(C[0]); } else { deq.PushBack(C[0]); } } } for (var i = 0; i < deq.Count; i++) { if (han) Console.Write(deq[deq.Count - i - 1]); else Console.Write(deq[i]); } Console.WriteLine(); } static class Console_ { static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); } static long NN => long.Parse(Console_.NextString()); static double ND => double.Parse(Console_.NextString()); static string NS => Console_.NextString(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library { class LIB_Deque<T> { T[] array; int front, cap; public int Count; public T this[long i] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return array[GetIndex((int)i)]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { array[GetIndex((int)i)] = value; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_Deque(long cap = 16) { array = new T[this.cap = (int)cap]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] int GetIndex(int i) { if (i >= cap) throw new Exception(); var r = front + i; return r >= cap ? r - cap : r; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushFront(T x) { if (Count == cap) Extend(); if (--front < 0) front += array.Length; array[front] = x; ++Count; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopFront() { if (Count-- == 0) throw new Exception(); var r = array[front++]; if (front >= cap) front -= cap; return r; } public T Front => array[front]; [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PushBack(T x) { if (Count == cap) Extend(); var i = front + Count++; array[i >= cap ? i - cap : i] = x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PopBack() { if (Count == 0) throw new Exception(); return array[GetIndex(--Count)]; } public T Back => array[GetIndex(Count - 1)]; [MethodImpl(MethodImplOptions.AggressiveInlining)] void Extend() { T[] nb = new T[cap << 1]; if (front > cap - Count) { var l = array.Length - front; Array.Copy(array, front, nb, 0, l); Array.Copy(array, 0, nb, l, Count - l); } else Array.Copy(array, front, nb, 0, Count); array = nb; front = 0; cap <<= 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Insert(long i, T x) { if (i > Count) throw new Exception(); this.PushFront(x); for (int j = 0; j < i; j++) this[j] = this[j + 1]; this[i] = x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T RemoveAt(long i) { if (i < 0 || i >= Count) throw new Exception(); var r = this[i]; for (var j = i; j > 0; j--) this[j] = this[j - 1]; this.PopFront(); return r; } } }
[["-", 75, 196, 0, 57, 15, 16, 12, 241, 0, 111], ["+", 75, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["+", 75, 196, 0, 57, 15, 16, 12, 23, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111]]
8
1,615
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } static void Solve() { var N = sc.ReadInt(); var P = sc.ReadInt(); var S = sc.ReadStr(); var ans = 0L; if (P == 2 || P == 5) { for (int i = 0; i < N; i++) { if (P == 2 && (S[i] - '0') % 2 == 0) ans += i + 1; if (P == 5 && (S[i] == '0' || S[i] == 5)) ans += i + 1; } Console.WriteLine(ans); return; } var mul = 1; var T = new string(S.Reverse().ToArray()); var sum = new long[N + 1]; for (int i = 0; i < N; i++) { sum[i + 1] = sum[i] + (T[i] - '0') * mul; sum[i + 1] %= P; mul *= 10; mul %= P; } var count = new int[P]; for (int i = 0; i < N + 1; i++) { ans += count[sum[i]]; count[sum[i]]++; } Console.WriteLine(ans); } static Scanner sc = new Scanner(); } class Scanner { string[] S = new string[0]; int Index = 0; char[] Separators = new char[] { ' ' }; public string Next() { if (this.Index < this.S.Length) return this.S[this.Index++]; var line = ""; while (line == "") line = Console.ReadLine(); this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries); if (this.S.Length == 0) return this.Next(); this.Index = 0; return this.S[this.Index++]; } public string ReadStr() { return this.Next(); } public char ReadChar() { return this.Next()[0]; } public int ReadInt() { return int.Parse(this.Next()); } public uint ReadUInt() { return uint.Parse(this.Next()); } public long ReadLong() { return long.Parse(this.Next()); } public double ReadDouble() { return double.Parse(this.Next()); } public Tuple<int, int> ReadTup(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add); } public Tuple<long, long> ReadTupLong(int add = 0) { return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add); } public Tuple<int, int, int> ReadTup3(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public Tuple<int, int, int, int> ReadTup4(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public int[] ReadIntArray(int n) { var array = new int[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadInt(); } return array; } public long[] ReadLongArray(int n) { var array = new long[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadLong(); } return array; } public double[] ReadDoubleArray(int n) { var array = new double[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadDouble(); } return array; } public char[] ReadCharArray(int n) { var array = new char[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadChar(); } return array; } public string[] ReadStrArray(int n) { var array = new string[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadStr(); } return array; } public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) { var array = new Tuple<long, long>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTupLong(add); } return array; } public Tuple<int, int>[] ReadTupArray(int n, int add = 0) { var array = new Tuple<int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup(add); } return array; } public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) { var array = new Tuple<int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup3(add); } return array; } public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) { var array = new Tuple<int, int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup4(add); } return array; } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } static void Solve() { var N = sc.ReadInt(); var P = sc.ReadInt(); var S = sc.ReadStr(); var ans = 0L; if (P == 2 || P == 5) { for (int i = 0; i < N; i++) { if (P == 2 && (S[i] - '0') % 2 == 0) ans += i + 1; if (P == 5 && (S[i] == '0' || S[i] == '5')) ans += i + 1; } Console.WriteLine(ans); return; } var mul = 1; var T = new string(S.Reverse().ToArray()); var sum = new long[N + 1]; for (int i = 0; i < N; i++) { sum[i + 1] = sum[i] + (T[i] - '0') * mul; sum[i + 1] %= P; mul *= 10; mul %= P; } var count = new int[P]; for (int i = 0; i < N + 1; i++) { ans += count[sum[i]]; count[sum[i]]++; } Console.WriteLine(ans); } static Scanner sc = new Scanner(); } class Scanner { string[] S = new string[0]; int Index = 0; char[] Separators = new char[] { ' ' }; public string Next() { if (this.Index < this.S.Length) return this.S[this.Index++]; var line = ""; while (line == "") line = Console.ReadLine(); this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries); if (this.S.Length == 0) return this.Next(); this.Index = 0; return this.S[this.Index++]; } public string ReadStr() { return this.Next(); } public char ReadChar() { return this.Next()[0]; } public int ReadInt() { return int.Parse(this.Next()); } public uint ReadUInt() { return uint.Parse(this.Next()); } public long ReadLong() { return long.Parse(this.Next()); } public double ReadDouble() { return double.Parse(this.Next()); } public Tuple<int, int> ReadTup(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add); } public Tuple<long, long> ReadTupLong(int add = 0) { return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add); } public Tuple<int, int, int> ReadTup3(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public Tuple<int, int, int, int> ReadTup4(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public int[] ReadIntArray(int n) { var array = new int[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadInt(); } return array; } public long[] ReadLongArray(int n) { var array = new long[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadLong(); } return array; } public double[] ReadDoubleArray(int n) { var array = new double[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadDouble(); } return array; } public char[] ReadCharArray(int n) { var array = new char[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadChar(); } return array; } public string[] ReadStrArray(int n) { var array = new string[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadStr(); } return array; } public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) { var array = new Tuple<long, long>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTupLong(add); } return array; } public Tuple<int, int>[] ReadTupArray(int n, int add = 0) { var array = new Tuple<int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup(add); } return array; } public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) { var array = new Tuple<int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup3(add); } return array; } public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) { var array = new Tuple<int, int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup4(add); } return array; } }
[["+", 12, 23, 0, 16, 12, 16, 12, 252, 0, 104]]
8
1,325
using System; namespace ABC_157_A_Csharp_ver { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); if (N % 2 == 0) Console.WriteLine(N / 2); if (N % 2 != 0) Console.WriteLine(N % 2 + 1); Console.ReadKey(); } } }
using System; namespace ABC_157_A_Csharp_ver { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); if (N % 2 == 0) Console.WriteLine(N / 2); if (N % 2 != 0) Console.WriteLine(N % 2 + N / 2); Console.ReadKey(); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 12, 203]]
8
78
using System; class Progarm { static void Main() { var n = Int32.Parse(Console.ReadLine()); int ans; if (n / 2 != 0) { ans = n / 2 + 1; } else { ans = n / 2; } Console.WriteLine(ans); } }
using System; class Progarm { static void Main() { var n = Int32.Parse(Console.ReadLine()); int ans; if (n % 2 == 1) { ans = n / 2 + 1; } else { ans = n / 2; } Console.WriteLine(ans); } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
8
65
using System; namespace AtCoder { class Program { static void Main(string[] args) { var line = Console.ReadLine(); var i = int.Parse(line); Console.WriteLine(i / 2); } } }
using System; namespace AtCoder { class Program { static void Main(string[] args) { var line = Console.ReadLine(); var i = int.Parse(line); Console.WriteLine((i + 1) / 2); } } }
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25]]
8
50
using System; class Program { static void Main() { String[] arr = Console.ReadLine().Split(); double A = double.Parse(arr[0]); Console.WriteLine(Math.Ceiling(A)); } }
using System; class Program { static void Main() { String[] arr = Console.ReadLine().Split(); double A = double.Parse(arr[0]); Console.WriteLine(Math.Ceiling(A / 2)); } }
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
54
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); Console.WriteLine(a / 2 + 1); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); Console.WriteLine(a / 2 + a % 2); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 109], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 12, 203]]
8
71
using System; namespace Atcorder { class Program { static void Main(string[] args) { double N = double.Parse(Console.ReadLine()); double a = N / 4; Console.WriteLine(Math.Ceiling(a)); } } }
using System; namespace Atcorder { class Program { static void Main(string[] args) { double N = double.Parse(Console.ReadLine()); double a = N / 2; Console.WriteLine(Math.Ceiling(a)); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
8
55
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); Console.WriteLine((N - (N % 2)) / 2); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); Console.WriteLine((N + (N % 2)) / 2); } }
[["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72]]
8
61
using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { double a, b, c; a = double.Parse( Console.ReadLine()); //標準入力 // string[] str = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 b = // int.Parse(str[0]); // //数値で受け取りたい場合は変換する c = // int.Parse(str[1]); Console.Write("改行なし a = // {0} b = {1} c = {2}", a, b, c)//改行なし出力 // Console.WriteLine("改行あり a = {0} b = {1} c = // {2}", a, b, c);//改行付き出力 Console.WriteLine(Math.Round(a / 2)); } } }
using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { double a; a = double.Parse( Console.ReadLine()); //標準入力 // string[] str = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 b = // int.Parse(str[0]); // //数値で受け取りたい場合は変換する c = // int.Parse(str[1]); Console.Write("改行なし a = // {0} b = {1} c = {2}", a, b, c)//改行なし出力 // Console.WriteLine("改行あり a = {0} b = {1} c = // {2}", a, b, c);//改行付き出力 Console.WriteLine(Math.Ceiling(a / 2)); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22]]
8
65
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0027 { class Program { static void Main(string[] args) { List<string> strs = new List<string>(); for (int i = 0; i < 3; i++) { strs.Add(Console.ReadLine()); } int N = int.Parse(Console.ReadLine()); List<int> bns = new List<int>(); for (int j = 0; j < N; j++) { bns.Add(int.Parse(Console.ReadLine())); } List<int[]> bingos = new List<int[]>(); for (int i = 0; i < 3; i++) { int[] tmp = { int.Parse(strs[i].Split(' ')[0]), int.Parse(strs[i].Split(' ')[1]), int.Parse(strs[i].Split(' ')[2]) }; bingos.Add(tmp); } for (int i = 0; i < N; i++) { for (int j = 0; j < 3; j++) { if (bns[i] == bingos[j][0]) { bingos[j][0] = -1; } else if (bns[i] == bingos[j][1]) { bingos[j][1] = -1; } else if (bns[i] == bingos[j][2]) { bingos[j][2] = -1; } } } for (int i = 0; i < 3; i++) { if (-1 == bingos[i][0] && -1 == bingos[i][1] && -1 == bingos[i][2]) { Console.WriteLine("Yes"); return; } if (-1 == bingos[0][i] && -1 == bingos[1][i] && -1 == bingos[2][i]) { Console.WriteLine("Yes"); return; } } if (-1 == bingos[0][0] && -1 == bingos[1][1] && -1 == bingos[2][2]) { Console.WriteLine("Yes"); return; } if (-1 == bingos[2][2] && -1 == bingos[1][1] && -1 == bingos[0][0]) { Console.WriteLine("Yes"); return; } Console.WriteLine("No"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0027 { class Program { static void Main(string[] args) { List<string> strs = new List<string>(); for (int i = 0; i < 3; i++) { strs.Add(Console.ReadLine()); } int N = int.Parse(Console.ReadLine()); List<int> bns = new List<int>(); for (int j = 0; j < N; j++) { bns.Add(int.Parse(Console.ReadLine())); } List<int[]> bingos = new List<int[]>(); for (int i = 0; i < 3; i++) { int[] tmp = { int.Parse(strs[i].Split(' ')[0]), int.Parse(strs[i].Split(' ')[1]), int.Parse(strs[i].Split(' ')[2]) }; bingos.Add(tmp); } for (int i = 0; i < N; i++) { for (int j = 0; j < 3; j++) { if (bns[i] == bingos[j][0]) { bingos[j][0] = -1; } else if (bns[i] == bingos[j][1]) { bingos[j][1] = -1; } else if (bns[i] == bingos[j][2]) { bingos[j][2] = -1; } } } for (int i = 0; i < 3; i++) { if (-1 == bingos[i][0] && -1 == bingos[i][1] && -1 == bingos[i][2]) { Console.WriteLine("Yes"); return; } if (-1 == bingos[0][i] && -1 == bingos[1][i] && -1 == bingos[2][i]) { Console.WriteLine("Yes"); return; } } if (-1 == bingos[0][0] && -1 == bingos[1][1] && -1 == bingos[2][2]) { Console.WriteLine("Yes"); return; } if (-1 == bingos[2][0] && -1 == bingos[1][1] && -1 == bingos[0][2]) { Console.WriteLine("Yes"); return; } Console.WriteLine("No"); } } }
[["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
8
590
using System; namespace q1 { class q2 { static void Main() { string[] nyuuryoku = Console.ReadLine().Split(); int sanka = int.Parse(nyuuryoku[0]); int Rating = int.Parse(nyuuryoku[1]); if (sanka < 10) { Console.WriteLine(Rating - 100 * (10 - sanka)); } else { Console.WriteLine(Rating); } } } }
using System; namespace q1 { class q2 { static void Main() { string[] nyuuryoku = Console.ReadLine().Split(); int sanka = int.Parse(nyuuryoku[0]); int Rating = int.Parse(nyuuryoku[1]); if (sanka < 10) { Console.WriteLine(Rating + 100 * (10 - sanka)); } else { Console.WriteLine(Rating); } } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
8
92
using System; using System.Linq; namespace AtCoderPractice0704 { class MainClass { public static void Main(string[] args) { int[] NR = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int N = NR[0]; int R = NR[1]; int ans; if (N >= 10) { ans = R; } else { ans = R + 100 * (100 - N); } Console.WriteLine(ans); } } }
using System; using System.Linq; namespace AtCoderPractice0704 { class MainClass { public static void Main(string[] args) { long[] NR = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray(); long N = NR[0]; long R = NR[1]; long ans; if (N >= 10) { ans = R; } else { ans = R + 100 * (10 - N); } Console.WriteLine(ans); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 12, 16, 12, 16, 12, 23, 0, 16, 31, 203], ["+", 12, 16, 12, 16, 12, 23, 0, 16, 31, 203]]
8
115
using System; namespace abc156_a { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int k = int.Parse(input[0]); int r = int.Parse(input[1]); if (k >= 10) { Console.WriteLine(r); } else { Console.WriteLine(r - 100 * (10 - k)); } Console.Read(); } } }
using System; namespace abc156_a { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int k = int.Parse(input[0]); int r = int.Parse(input[1]); if (k >= 10) { Console.WriteLine(r); } else { Console.WriteLine(r + 100 * (10 - k)); } Console.Read(); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
8
105
using System; namespace Sample { class Sample { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int R = int.Parse(input[1]); if (N >= 10) { Console.WriteLine(R); } else { int nr = R + 1000 - 10 * N; Console.WriteLine(nr); } } } }
using System; namespace Sample { class Sample { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int R = int.Parse(input[1]); if (N >= 10) { Console.WriteLine(R); } else { int nr = R + 1000 - 100 * N; Console.WriteLine(nr); } } } }
[["-", 0, 200, 0, 212, 0, 16, 12, 16, 31, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 31, 203]]
8
102
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { var NR = IO_ShortCut.ReadSplitLong; var N = NR[0]; var R = NR[1]; var ans = R + N < 10 ? (10 - N) * 100 : 0; WriteLine(ans); } } public class IO_ShortCut { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); #endregion } /// <summary> /// 正の数の四則演算のみ対応 /// </summary> public class Mod { // 割る数の定義 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; } public class MathLib {} }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { var NR = IO_ShortCut.ReadSplitLong; var N = NR[0]; var R = NR[1]; var ans = R + (N < 10 ? (10 - N) * 100 : 0); WriteLine(ans); } } public class IO_ShortCut { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); #endregion } /// <summary> /// 正の数の四則演算のみ対応 /// </summary> public class Mod { // 割る数の定義 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; } public class MathLib {} }
[["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25]]
8
469
using System; using static System.Console; using System.Linq; namespace Main { class main { static void Main(string[] args) { int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray(); WriteLine(tmp[0] >= 10 ? tmp[1] : tmp[1] - 100 * (10 - tmp[0])); } } }
using System; using static System.Console; using System.Linq; namespace Main { class main { static void Main(string[] args) { int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray(); WriteLine(tmp[0] >= 10 ? tmp[1] : tmp[1] + 100 * (10 - tmp[0])); } } }
[["-", 3, 4, 0, 28, 0, 41, 75, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 41, 75, 16, 17, 72]]
8
91
namespace AtCoderCS { using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Linq; using static System.Console; using static System.Math; using static Macro; using static Library; class Program { void Solve() { var N = IN.Int; var R = IN.Int; if (N >= 10) { WriteLine(R); } else { WriteLine(R + 100 * (10 - R)); } } private SimpleInput IN = new SimpleInput(); private SimpleOutput OUT = new SimpleOutput(); void Stream() { Solve(); OUT.Flush(); } static void Main(string[] args) => new Program().Stream(); } #region IO class SimpleInput { private string[] _nextBuffer; private int _bufferCnt; private readonly char[] _cs = new char[] {' ', '"', ','}; public SimpleInput() { _nextBuffer = new string[0]; _bufferCnt = 0; } string Next() { if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++]; var st = ReadLine(); while (st == string.Empty) st = ReadLine(); if (st != null) _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 long Long => long.Parse(String); public double Double => double.Parse(String); } class SimpleOutput { private readonly StreamWriter _sw = new StreamWriter(OpenStandardOutput()) { #if DEBUG AutoFlush = true #else AutoFlush = false #endif }; public SimpleOutput() { SetOut(_sw); } public void Flush() => Out.Flush(); } #endregion #region MACRO static class Macro { public static void FOR(int a, int b, int n, Action<int> f) { for (int i = a; i < b; i += n) f(i); } public static void FOR(int a, int b, Action<int> f) => FOR(a, b, 1, f); public static void REP(int a, Action<int> f) => FOR(0, a, f); } #endregion #region Library static class Library { public static int BinarySearch(int ng, int ok, Func<int, bool> f) { while (Math.Abs(ok - ng) > 1) { var mid = (ok + ng) / 2; if (f(mid)) ok = mid; else ng = mid; } return ok; } public static int LowerBound<T>(IReadOnlyList<T> a, T x) where T : IComparable<T> => BinarySearch(-1, a.Count, (m) => a[m].CompareTo(x) >= 0); public static int UpperBound<T>(IReadOnlyList<T> a, T x) where T : IComparable<T> => BinarySearch(-1, a.Count(), (m) => a[m].CompareTo(x) > 0); } class UnionFind { private int[] data; public UnionFind(int n) { data = new int[n + 1]; for (var i = 0; i < n + 1; ++i) data[i] = -1; } public void Unite(int x, int y) { x = Root(x); y = Root(y); if (x == y) return; if (data[y] < data[x]) Swap(ref x, ref y); data[x] += data[y]; data[y] = x; } public bool Find(int x, int y) => Root(x) == Root(y); public int Root(int x) => data[x] < 0 ? x : Root(data[x]); public int Size(int x) => -data[Root(x)]; private void Swap(ref int a, ref int b) { var tmp = b; b = a; a = tmp; } } #endregion }
namespace AtCoderCS { using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Linq; using static System.Console; using static System.Math; using static Macro; using static Library; class Program { void Solve() { var N = IN.Int; var R = IN.Int; if (N >= 10) { WriteLine(R); } else { WriteLine(R + 100 * (10 - N)); } } private SimpleInput IN = new SimpleInput(); private SimpleOutput OUT = new SimpleOutput(); void Stream() { Solve(); OUT.Flush(); } static void Main(string[] args) => new Program().Stream(); } #region IO class SimpleInput { private string[] _nextBuffer; private int _bufferCnt; private readonly char[] _cs = new char[] {' ', '"', ','}; public SimpleInput() { _nextBuffer = new string[0]; _bufferCnt = 0; } string Next() { if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++]; var st = ReadLine(); while (st == string.Empty) st = ReadLine(); if (st != null) _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 long Long => long.Parse(String); public double Double => double.Parse(String); } class SimpleOutput { private readonly StreamWriter _sw = new StreamWriter(OpenStandardOutput()) { #if DEBUG AutoFlush = true #else AutoFlush = false #endif }; public SimpleOutput() { SetOut(_sw); } public void Flush() => Out.Flush(); } #endregion #region MACRO static class Macro { public static void FOR(int a, int b, int n, Action<int> f) { for (int i = a; i < b; i += n) f(i); } public static void FOR(int a, int b, Action<int> f) => FOR(a, b, 1, f); public static void REP(int a, Action<int> f) => FOR(0, a, f); } #endregion #region Library static class Library { public static int BinarySearch(int ng, int ok, Func<int, bool> f) { while (Math.Abs(ok - ng) > 1) { var mid = (ok + ng) / 2; if (f(mid)) ok = mid; else ng = mid; } return ok; } public static int LowerBound<T>(IReadOnlyList<T> a, T x) where T : IComparable<T> => BinarySearch(-1, a.Count, (m) => a[m].CompareTo(x) >= 0); public static int UpperBound<T>(IReadOnlyList<T> a, T x) where T : IComparable<T> => BinarySearch(-1, a.Count(), (m) => a[m].CompareTo(x) > 0); } class UnionFind { private int[] data; public UnionFind(int n) { data = new int[n + 1]; for (var i = 0; i < n + 1; ++i) data[i] = -1; } public void Unite(int x, int y) { x = Root(x); y = Root(y); if (x == y) return; if (data[y] < data[x]) Swap(ref x, ref y); data[x] += data[y]; data[y] = x; } public bool Find(int x, int y) => Root(x) == Root(y); public int Root(int x) => data[x] < 0 ? x : Root(data[x]); public int Size(int x) => -data[Root(x)]; private void Swap(ref int a, ref int b) { var tmp = b; b = a; a = tmp; } } #endregion }
[["-", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22]]
8
895
using System; class test { public static void Main() { var str = Console.ReadLine().Split(' '); if (int.Parse(str[0]) >= 10) { Console.Write(str[1]); } else { Console.Write(int.Parse(str[1]) - (100 * (10 - int.Parse(str[0])))); } } }
using System; class test { public static void Main() { var str = Console.ReadLine().Split(' '); if (int.Parse(str[0]) >= 10) { Console.Write(str[1]); } else { Console.Write(int.Parse(str[1]) + (100 * (10 - int.Parse(str[0])))); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
8
93
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.ABC_156 { class A { static void Main(string[] args) { var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false }; SetOut(sw); Method(args); Out.Flush(); } static void Method(string[] args) { int[] nr = ReadInts(); int n = nr[0]; int r = nr[1]; WriteLine(n <= 10 ? r - 100 * (10 - n) : r); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.ABC_156 { class A { static void Main(string[] args) { var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false }; SetOut(sw); Method(args); Out.Flush(); } static void Method(string[] args) { int[] nr = ReadInts(); int n = nr[0]; int r = nr[1]; WriteLine(n <= 10 ? r + 100 * (10 - n) : r); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
[["-", 3, 4, 0, 28, 0, 41, 64, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 41, 64, 16, 17, 72]]
8
326
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); int N = cin.nextInt(); int K = cin.nextInt(); if (N < 11) K -= (100 * (10 - N)); Console.WriteLine(K); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); int N = cin.nextInt(); int K = cin.nextInt(); if (N < 11) K += (100 * (10 - N)); Console.WriteLine(K); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
[["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107]]
8
726
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; using static System.Console; namespace AtCoder_1 { class Program { static void Main(string[] args) { var n = CinTAr(); if (n[0] >= 10) { Cout(n[1]); } else { Cout(n[1] + (100 * (10 - n[1]))); } Cin(); } static Random Rand = new Random(); static string[] AlphabetTable = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; static int GetDigits(long num) { return (int)Math.Floor(Math.Log10(num)) + 1; } static int GetNumByDigit(long num, int digit) { return (int)((num / ((int)Math.Pow(10, digit - 1))) % 10); } static int loop(int num, int max) { if (num > max) { return num % max; } else if (num < 0) { return max - (-num) % max; } else { return num; } } static long GCD(long a, long b) { if (a < b) { swap(ref a, ref b); } if (a % b == 0) { return b; } else { return GCD(b, a % b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; } static readonly int MOD10_9_7 = (1000000000 + 7); static bool IsInt(double d) { return (int)d == d; } static string Cin() { return ReadLine(); } static string[] CinAr() { return ReadLine().Split(' '); } static int CinT() { return S2i(Cin()); } static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); } static long CinL() { return S2L(Cin()); } static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); } static double CinD() { return S2D(Cin()); } static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); } static int S2i(string s) { return int.Parse(s); } static long S2L(string s) { return long.Parse(s); } static double S2D(string s) { return double.Parse(s); } static void Cout(object s) { WriteLine(s); } static long[] yakusuu(long n) { if (n == 1) { return new long[] { 1 }; } List<long> res = new List<long>(); res.Add(1); for (long i = 2; i <= n / 2 + 1; i++) { if (n % i == 0) { res.Add(i); } } res.Add(n); return res.ToArray(); } static bool isPrime(long num) { if (num == 1) { return false; } for (long i = 2; i <= Math.Sqrt(num) + 1; i++) { if (num % i == 0) { return false; } } return true; } static void CoutAr<Type>(IEnumerable<Type> types) { WriteLine(string.Join(" ", types)); } public static long nCr(int n, int r) { // naive: return Factorial(n) / (Factorial(r) * Factorial(n - r)); return nPr(n, r) / Factorial(r); } public static long nPr(int n, int r) { // naive: return Factorial(n) / Factorial(n - r); return FactorialDivision(n, n - r); } private static long FactorialDivision(int topFactorial, int divisorFactorial) { long result = 1; for (int i = topFactorial; i > divisorFactorial; i--) result *= i; return result; } private static long Factorial(int i) { if (i <= 1) return 1; return i * Factorial(i - 1); } } public struct Pair<T> { public T a; public T b; public T c; public Pair(T _a, T _b) { a = _a; b = _b; c = default(T); } public Pair(T _a, T _b, T _c) { a = _a; b = _b; c = _c; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; using static System.Console; namespace AtCoder_1 { class Program { static void Main(string[] args) { var n = CinTAr(); if (n[0] >= 10) { Cout(n[1]); } else { Cout(n[1] + (100 * (10 - n[0]))); } Cin(); } static Random Rand = new Random(); static string[] AlphabetTable = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; static int GetDigits(long num) { return (int)Math.Floor(Math.Log10(num)) + 1; } static int GetNumByDigit(long num, int digit) { return (int)((num / ((int)Math.Pow(10, digit - 1))) % 10); } static int loop(int num, int max) { if (num > max) { return num % max; } else if (num < 0) { return max - (-num) % max; } else { return num; } } static long GCD(long a, long b) { if (a < b) { swap(ref a, ref b); } if (a % b == 0) { return b; } else { return GCD(b, a % b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; } static readonly int MOD10_9_7 = (1000000000 + 7); static bool IsInt(double d) { return (int)d == d; } static string Cin() { return ReadLine(); } static string[] CinAr() { return ReadLine().Split(' '); } static int CinT() { return S2i(Cin()); } static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); } static long CinL() { return S2L(Cin()); } static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); } static double CinD() { return S2D(Cin()); } static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); } static int S2i(string s) { return int.Parse(s); } static long S2L(string s) { return long.Parse(s); } static double S2D(string s) { return double.Parse(s); } static void Cout(object s) { WriteLine(s); } static long[] yakusuu(long n) { if (n == 1) { return new long[] { 1 }; } List<long> res = new List<long>(); res.Add(1); for (long i = 2; i <= n / 2 + 1; i++) { if (n % i == 0) { res.Add(i); } } res.Add(n); return res.ToArray(); } static bool isPrime(long num) { if (num == 1) { return false; } for (long i = 2; i <= Math.Sqrt(num) + 1; i++) { if (num % i == 0) { return false; } } return true; } static void CoutAr<Type>(IEnumerable<Type> types) { WriteLine(string.Join(" ", types)); } public static long nCr(int n, int r) { // naive: return Factorial(n) / (Factorial(r) * Factorial(n - r)); return nPr(n, r) / Factorial(r); } public static long nPr(int n, int r) { // naive: return Factorial(n) / Factorial(n - r); return FactorialDivision(n, n - r); } private static long FactorialDivision(int topFactorial, int divisorFactorial) { long result = 1; for (int i = topFactorial; i > divisorFactorial; i--) result *= i; return result; } private static long Factorial(int i) { if (i <= 1) return 1; return i * Factorial(i - 1); } } public struct Pair<T> { public T a; public T b; public T c; public Pair(T _a, T _b) { a = _a; b = _b; c = default(T); } public Pair(T _a, T _b, T _c) { a = _a; b = _b; c = _c; } } }
[["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
8
1,122
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var r = ReadIntArray(); var N = r[0]; var R = r[1]; if (N < 10) { Console.WriteLine(R - (100 * (10 - N))); } else { Console.WriteLine(R); } } private static readonly Func<string> Read = () => Console.ReadLine(); private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split(); private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine()); private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine()); private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray(); private static readonly Action<string> Cw = str => Console.WriteLine(str); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var r = ReadIntArray(); var N = r[0]; var R = r[1]; if (N < 10) { Console.WriteLine(R + (100 * (10 - N))); } else { Console.WriteLine(R); } } private static readonly Func<string> Read = () => Console.ReadLine(); private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split(); private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine()); private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine()); private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray(); private static readonly Action<string> Cw = str => Console.WriteLine(str); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
8
285
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { //文字列を読み込む int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int N = input[0]; int R = input[1]; if (N < 9) { R += 100 * (10 - N); } Console.WriteLine(R); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { //文字列を読み込む int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); int N = input[0]; int R = input[1]; if (N < 10) { R += 100 * (10 - N); } Console.WriteLine(R); } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
8
106
using System; class Program { static void Main(string[] args) {   string s = Console.ReadLine(); int count = int.Parse(s.Split(' ')[0]); int rate = int.Parse(s.Split(' ')[1]); if (count < 10) { rate = rate - 100 * (10 - count); } Console.WriteLine(rate); } }
using System; class Program { static void Main(string[] args) { string s = Console.ReadLine(); int count = int.Parse(s.Split(' ')[0]); int rate = int.Parse(s.Split(' ')[1]); if (count < 10) { rate = rate + 100 * (10 - count); } Console.WriteLine(rate); } }
[["-", 0, 208, 0, 235, 8, 201, 0, 195, 8, 196], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 197], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 198], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 199, 0, 200], ["-", 0, 197, 0, 198, 39, 199, 0, 200, 0, 197], ["-", 0, 198, 39, 199, 0, 200, 0, 197, 0, 198], ["-", 39, 199, 0, 200, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 197, 0, 198, 39, 199, 0, 200], ["-", 0, 197, 0, 198, 39, 199, 0, 200, 0, 57], ["-", 0, 198, 39, 199, 0, 200, 0, 57, 15, 16], ["-", 39, 199, 0, 200, 0, 57, 15, 16, 31, 22], ["-", 0, 200, 0, 57, 15, 16, 31, 22, 12, 203], ["-", 0, 57, 15, 16, 31, 22, 12, 203, 64, 196], ["-", 15, 16, 31, 22, 12, 203, 64, 196, 0, 1], ["-", 31, 22, 12, 203, 64, 196, 0, 1, 0, 1], ["-", 12, 203, 64, 196, 0, 1, 0, 1, 0, 213], ["-", 64, 196, 0, 1, 0, 1, 0, 213, 63, 214], ["-", 0, 1, 0, 1, 0, 213, 63, 214, 3, 4], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72]]
8
95
using System; using System.Collections.Generic; using System.Linq; public class ABC156_A { public static void Main() { int a = 0, b = 0; InLine(ref a, ref b); if (a < 10) b += 100 * (10 - a); else Out(b); } // Template private static object[] nullobjs = null; private static object nullobj = null; public static int ConvertInt(char c) { return c; } public static void InArgs<A>(int count, ref A[] var) { InArgs(count, ref var, ref nullobjs, ref nullobjs); } public static void InArgs<A, B>(int count, ref A[] var1, ref B[] var2) { InArgs(count, ref var1, ref var2, ref nullobjs); } public static void InArgs<A, B, C>(int count, ref A[] var1, ref B[] var2, ref C[] var3) { A a = default(A); B b = default(B); C c = default(C); for (int i = 0; i < count; i++) { InLine(ref a, ref b, ref c); var1[i] = a; if (var2 != null) var2[i] = b; if (var3 != null) var3[i] = c; } } public static void InLine<A>(ref A var) { InLine(ref var, ref nullobj, ref nullobj); } public static void InLine<A, B>(ref A var1, ref B var2) { InLine(ref var1, ref var2, ref nullobj); } public static void InLine<A, B, C>(ref A var1, ref B var2, ref C var3) { object[] o = new object[] { var1, var2, var3 }; Type[] t = new Type[] { typeof(A), typeof(B), typeof(C) }; if (var3 == null) { if (var2 == null) o = new object[] { var1 }; else o = new object[] { var1, var2 }; } string[] s = Console.ReadLine().Split(' '); for (int i = 0; i < s.Length; i++) { if (typeof(int) == t[i]) o[i] = int.Parse(s[i]); else if (typeof(long) == t[i]) o[i] = long.Parse(s[i]); else if (typeof(double) == t[i]) o[i] = double.Parse(s[i]); else o[i] = s[i]; } var1 = (A)o[0]; if (var2 != null) var2 = (B)o[1]; if (var3 != null) var3 = (C)o[2]; } public static string JoinString(object[] obj, string sep) { return string.Join(sep, obj.Select(i => i.ToString()).ToArray()); } public static void Out(object o) { Console.WriteLine(o); } public static void OutYes() { Console.WriteLine("Yes"); } public static void OutNo() { Console.WriteLine("No"); } public static void OutYES() { Console.WriteLine("YES"); } public static void OutNO() { Console.WriteLine("NO"); } private static Dictionary<A, B> PutDict<A, B>(A[] key, B[] value) { if (key.Length != value.Length) return null; var dic = new Dictionary<A, B>(); for (int i = 0; i < key.Length; i++) { if (!dic.ContainsKey(key[i])) dic.Add(key[i], value[i]); else dic[key[i]] = value[i]; } return dic; } }
using System; using System.Collections.Generic; using System.Linq; public class ABC156_A { public static void Main() { int a = 0, b = 0; InLine(ref a, ref b); if (a < 10) b += 100 * (10 - a); Out(b); } // Template private static object[] nullobjs = null; private static object nullobj = null; public static int ConvertInt(char c) { return c; } public static void InArgs<A>(int count, ref A[] var) { InArgs(count, ref var, ref nullobjs, ref nullobjs); } public static void InArgs<A, B>(int count, ref A[] var1, ref B[] var2) { InArgs(count, ref var1, ref var2, ref nullobjs); } public static void InArgs<A, B, C>(int count, ref A[] var1, ref B[] var2, ref C[] var3) { A a = default(A); B b = default(B); C c = default(C); for (int i = 0; i < count; i++) { InLine(ref a, ref b, ref c); var1[i] = a; if (var2 != null) var2[i] = b; if (var3 != null) var3[i] = c; } } public static void InLine<A>(ref A var) { InLine(ref var, ref nullobj, ref nullobj); } public static void InLine<A, B>(ref A var1, ref B var2) { InLine(ref var1, ref var2, ref nullobj); } public static void InLine<A, B, C>(ref A var1, ref B var2, ref C var3) { object[] o = new object[] { var1, var2, var3 }; Type[] t = new Type[] { typeof(A), typeof(B), typeof(C) }; if (var3 == null) { if (var2 == null) o = new object[] { var1 }; else o = new object[] { var1, var2 }; } string[] s = Console.ReadLine().Split(' '); for (int i = 0; i < s.Length; i++) { if (typeof(int) == t[i]) o[i] = int.Parse(s[i]); else if (typeof(long) == t[i]) o[i] = long.Parse(s[i]); else if (typeof(double) == t[i]) o[i] = double.Parse(s[i]); else o[i] = s[i]; } var1 = (A)o[0]; if (var2 != null) var2 = (B)o[1]; if (var3 != null) var3 = (C)o[2]; } public static string JoinString(object[] obj, string sep) { return string.Join(sep, obj.Select(i => i.ToString()).ToArray()); } public static void Out(object o) { Console.WriteLine(o); } public static void OutYes() { Console.WriteLine("Yes"); } public static void OutNo() { Console.WriteLine("No"); } public static void OutYES() { Console.WriteLine("YES"); } public static void OutNO() { Console.WriteLine("NO"); } private static Dictionary<A, B> PutDict<A, B>(A[] key, B[] value) { if (key.Length != value.Length) return null; var dic = new Dictionary<A, B>(); for (int i = 0; i < key.Length; i++) { if (!dic.ContainsKey(key[i])) dic.Add(key[i], value[i]); else dic[key[i]] = value[i]; } return dic; } }
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
8
869
using System; using System.Linq; class Program { static void Main(string[] args) { // 入力 long[] nr = Console.ReadLine().Split().Select(long.Parse).ToArray(); // abcがすべて異なる場合 if (nr[0] <= 10) { Console.WriteLine((100 - (10 - nr[0])) + nr[1]); } else { Console.WriteLine(nr[1]); } } }
using System; using System.Linq; class Program { static void Main(string[] args) { // 入力 long[] nr = Console.ReadLine().Split().Select(long.Parse).ToArray(); // abcがすべて異なる場合 if (nr[0] <= 10) { Console.WriteLine((100 * (10 - nr[0])) + nr[1]); } else { Console.WriteLine(nr[1]); } } }
[["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 48]]
8
98
using System; using System.Linq; namespace ABC156A { class MainClass { public static void Main(string[] args) { int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(nk[0] >= 10 ? nk[1] : nk[1] - (100 * (10 - nk[0]))); } } }
using System; using System.Linq; namespace ABC156A { class MainClass { public static void Main(string[] args) { int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(nk[0] >= 10 ? nk[1] : nk[1] + (100 * (10 - nk[0]))); } } }
[["-", 3, 4, 0, 28, 0, 41, 75, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 41, 75, 16, 17, 72]]
8
89
using System; using System.Collections.Generic; using System.IO; using System.Linq; class A { static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { int N, R; Input(out N, out R); if (N >= 10) { Console.WriteLine(R); } else { Console.WriteLine(R - 100 * (10 - N)); } } static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T)); static void Input<A>(out A a) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); } static void Input<A, B>(out A a, out B b) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); } static void Input<A, B, C>(out A a, out B b, out C c) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); } static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); d = ChangeT<D>(words[3]); } static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); d = ChangeT<D>(words[3]); e = ChangeT<E>(words[4]); } static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); d = ChangeT<D>(words[3]); e = ChangeT<E>(words[4]); f = ChangeT<F>(words[5]); } static void InputArray<T>(out T[] array) { array = Console.ReadLine() .Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries) .Select(s => ChangeT<T>(s)) .ToArray(); } static void Print<T>(T s) => Out.WriteLine(s); static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s)); static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e)); }
using System; using System.Collections.Generic; using System.IO; using System.Linq; class A { static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { int N, R; Input(out N, out R); if (N >= 10) { Console.WriteLine(R); } else { Console.WriteLine(R + 100 * (10 - N)); } } static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T)); static void Input<A>(out A a) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); } static void Input<A, B>(out A a, out B b) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); } static void Input<A, B, C>(out A a, out B b, out C c) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); } static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); d = ChangeT<D>(words[3]); } static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); d = ChangeT<D>(words[3]); e = ChangeT<E>(words[4]); } static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) { var words = Console.ReadLine().Split( new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries); a = ChangeT<A>(words[0]); b = ChangeT<B>(words[1]); c = ChangeT<C>(words[2]); d = ChangeT<D>(words[3]); e = ChangeT<E>(words[4]); f = ChangeT<F>(words[5]); } static void InputArray<T>(out T[] array) { array = Console.ReadLine() .Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries) .Select(s => ChangeT<T>(s)) .ToArray(); } static void Print<T>(T s) => Out.WriteLine(s); static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s)); static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e)); }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
8
866
using System; namespace AtCoder { class Program { static void Main() { var line = Console.ReadLine().Split(' '); var N = int.Parse(line[0]); var R = int.Parse(line[1]); var result = R; if (N < 9) { Console.WriteLine(R + (100 * (10 - N))); } else { Console.WriteLine(R); } } } }
using System; namespace AtCoder { class Program { static void Main() { var line = Console.ReadLine().Split(' '); var N = int.Parse(line[0]); var R = int.Parse(line[1]); var result = R; if (N <= 9) { Console.WriteLine(R + (100 * (10 - N))); } else { Console.WriteLine(R); } } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19]]
8
100
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var n = cin.nextInt(); var r = cin.nextInt(); if (n >= 10) { Console.WriteLine(r); } else { var ans = r - (100 * (10 - n)); Console.WriteLine(ans); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] s) => new Solver().Solve(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var n = cin.nextInt(); var r = cin.nextInt(); if (n >= 10) { Console.WriteLine(r); } else { var ans = r + (100 * (10 - n)); Console.WriteLine(ans); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] s) => new Solver().Solve(); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72]]
8
597
using CompLib.Util; using System; using System.Linq; public class Program { public void Solve() { var sc = new Scanner(); int n = sc.NextInt(); int r = sc.NextInt(); if (n >= 10) { Console.WriteLine(r); } else { // q - 100 * (10-n) = r Console.WriteLine(r + 100 * (10 - r)); } } public static void Main(string[] args) => new Program().Solve(); } namespace CompLib.Util { using System; using System.Linq; class Scanner { private int _index; private string[] _line; const char separator = ' '; public Scanner() { _index = 0; _line = new string[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 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(); } }
using CompLib.Util; using System; using System.Linq; public class Program { public void Solve() { var sc = new Scanner(); int n = sc.NextInt(); int r = sc.NextInt(); if (n >= 10) { Console.WriteLine(r); } else { Console.WriteLine(r + 100 * (10 - n)); } } public static void Main(string[] args) => new Program().Solve(); } namespace CompLib.Util { using System; using System.Linq; class Scanner { private int _index; private string[] _line; const char separator = ' '; public Scanner() { _index = 0; _line = new string[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 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(); } }
[["-", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22]]
8
374
using System; using System.Linq; class Program { static void Main(string[] args) { var l1 = ReadIntArray(); int n = l1[0]; int r = l1[1]; var result = n >= 10 ? r : r - 100 * (10 - n); Console.WriteLine(result); } static string[] ReadStringArray() { return Console.ReadLine().Trim().Split(' '); } static int[] ReadIntArray() { return ReadStringArray().Select(_ => int.Parse(_)).ToArray(); } static long[] ReadLongArray() { return ReadStringArray().Select(_ => long.Parse(_)).ToArray(); } }
using System; using System.Linq; class Program { static void Main(string[] args) { var l1 = ReadIntArray(); int n = l1[0]; int r = l1[1]; var result = n >= 10 ? r : r + 100 * (10 - n); Console.WriteLine(result); } static string[] ReadStringArray() { return Console.ReadLine().Trim().Split(' '); } static int[] ReadIntArray() { return ReadStringArray().Select(_ => int.Parse(_)).ToArray(); } static long[] ReadLongArray() { return ReadStringArray().Select(_ => long.Parse(_)).ToArray(); } }
[["-", 0, 200, 0, 212, 0, 41, 75, 16, 17, 33], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 17, 72]]
8
159
using System; public class Program { public static void Main(string[] args) { // 整数の入力 string[] input = Console.ReadLine().Split(' '); int b = int.Parse(input[0]); int c = int.Parse(input[1]); //出力 Console.WriteLine(b > 10 ? c : c - (100 * (10 - b))); } }
using System; public class Program { public static void Main(string[] args) { // 整数の入力 string[] input = Console.ReadLine().Split(' '); int b = int.Parse(input[0]); int c = int.Parse(input[1]); //出力 Console.WriteLine(b > 10 ? c : c + (100 * (10 - b))); } }
[["-", 3, 4, 0, 28, 0, 41, 75, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 41, 75, 16, 17, 72]]
8
89
using System; using System.Linq; using System.Collections.Generic; using static System.Console; class Program { static void Main() { var input = ReadLine().Split(' ').Select(double.Parse).ToArray(); Write(Math.Ceiling(Math.Log(input[0], input[1]))); } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; class Program { static void Main() { var input = ReadLine().Split(' ').Select(double.Parse).ToArray(); Write(Math.Floor(Math.Log(input[0], input[1])) + 1); } }
[["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
80
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace ConsoleApp2 { class Program { static string[] S; static long H; static long W; static long K; static void Main(string[] args) { var HWK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); H = HWK[0]; W = HWK[1]; var ans = 0; while (H == 0) { H /= W; ans++; } Console.WriteLine(ans); } static long Cul(int i) { if (i == 6) { var r = 8; } var used = new bool[W]; var tmp = Convert.ToString(i, 2).Reverse<char>().ToArray(); var top = 0; var end = 0; var ans = 0; for (int j = 0; j < tmp.Length; j++) { if (tmp[j] == '1') { ans++; var sum = 0; for (int k = 0; k < W; k++) { if (used[k]) { sum = 0; } var tmp2 = 0; for (int l = top; l <= end; l++) { if (S[l][k] == '1') { tmp2++; } } if (sum + tmp2 > K) { if (tmp2 > K) return H * W; sum = tmp2; if (!used[k]) { ans++; used[k] = true; } } else { sum += tmp2; } } top = end + 1; } end++; } var sum2 = 0; end = (int)H - 1; for (int k = 0; k < W; k++) { if (used[k]) { sum2 = 0; } var tmp2 = 0; for (int l = top; l <= end; l++) { if (S[l][k] == '1') tmp2++; } if (sum2 + tmp2 > K) { if (tmp2 > K) return H * W; sum2 = tmp2; if (!used[k]) { ans++; used[k] = true; } } else { sum2 += tmp2; } } return ans; } } }
using System; using System.Text; using System.Collections.Generic; using static System.Math; using System.Linq; using static System.Array; namespace ConsoleApp2 { class Program { static string[] S; static long H; static long W; static long K; static void Main(string[] args) { var HWK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); H = HWK[0]; W = HWK[1]; var ans = 0; while (H != 0) { H /= W; ans++; } Console.WriteLine(ans); } static long Cul(int i) { if (i == 6) { var r = 8; } var used = new bool[W]; var tmp = Convert.ToString(i, 2).Reverse<char>().ToArray(); var top = 0; var end = 0; var ans = 0; for (int j = 0; j < tmp.Length; j++) { if (tmp[j] == '1') { ans++; var sum = 0; for (int k = 0; k < W; k++) { if (used[k]) { sum = 0; } var tmp2 = 0; for (int l = top; l <= end; l++) { if (S[l][k] == '1') { tmp2++; } } if (sum + tmp2 > K) { if (tmp2 > K) return H * W; sum = tmp2; if (!used[k]) { ans++; used[k] = true; } } else { sum += tmp2; } } top = end + 1; } end++; } var sum2 = 0; end = (int)H - 1; for (int k = 0; k < W; k++) { if (used[k]) { sum2 = 0; } var tmp2 = 0; for (int l = top; l <= end; l++) { if (S[l][k] == '1') tmp2++; } if (sum2 + tmp2 > K) { if (tmp2 > K) return H * W; sum2 = tmp2; if (!used[k]) { ans++; used[k] = true; } } else { sum2 += tmp2; } } return ans; } } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79]]
8
516
using System; using System.Collections.Generic; using System.Linq; static class MainClass { public struct arch {} public static void Main(string[] args) { var temp = Console.ReadLine().Split(' ').Select(long.Parse); var N = temp.ElementAt(0); var K = temp.ElementAt(1); var c = 0; while (true) { c++; if (Math.Pow(K, c) >= N) break; } var ans = c; Console.WriteLine(ans); } }
using System; using System.Collections.Generic; using System.Linq; static class MainClass { public struct arch {} public static void Main(string[] args) { var temp = Console.ReadLine().Split(' ').Select(long.Parse); var N = temp.ElementAt(0); var K = temp.ElementAt(1); var c = 0; while (true) { c++; if (Math.Pow(K, c) > N) break; } var ans = c; Console.WriteLine(ans); } }
[["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 47]]
8
121
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using static System.Math; using static Solve.Methods; using static Solve.Input; using static Solve.Output; using pii = Solve.Pair<int, int>; using pll = Solve.Pair<long, long>; using pli = Solve.Pair<long, int>; using pil = Solve.Pair<int, long>; using pss = Solve.Pair<string, string>; using psi = Solve.Pair<string, int>; using lint = System.Collections.Generic.List<int>; using llong = System.Collections.Generic.List<long>; using lstr = System.Collections.Generic.List<string>; using llint = System.Collections.Generic.List<System.Collections.Generic.List<int>>; using llstr = System.Collections.Generic.List<System.Collections.Generic.List<long>>; using lllong = System.Collections.Generic.List<System.Collections.Generic.List<string>>; using lii = System.Collections.Generic.List<Solve.Pair<int, int>>; using lll = System.Collections.Generic.List<Solve.Pair<long, long>>; using lli = System.Collections.Generic.List<Solve.Pair<long, int>>; using lil = System.Collections.Generic.List<Solve.Pair<int, long>>; using ll = System.Int64; namespace Solve { public class Solver { public void Main() { int N = ReadInt; int K = ReadInt; ll now = K; for (int i = 0; i < 100; i++) { if (now >= N) { Console.WriteLine(i+1); return; } now *= K; } } // ReSharper disable UnusedMember.Local private const int MOD = (int) 1e9 + 7, INF = 1000000010; private const long LINF = 1000000000000000100; } // ライブラリ置き場ここから // ライブラリ置き場ここまで #region Templete #if !LOCAL namespace Library { } #endif public static class Methods { public static readonly int[] dx = {-1, 0, 0, 1}; public static readonly int[] dy = {0, 1, -1, 0}; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert(bool b, string message = null) { if (!b) throw new Exception(message ?? "Assert failed."); } /* public static Comparison<T> greater<T>() where T : IComparable<T> => (a, b) => b.CompareTo(a); */ public static string JoinSpace<T>(this IEnumerable<T> source) => source.Join(" "); public static string JoinEndline<T>(this IEnumerable<T> source) => source.Join("\n"); public static string Join<T>(this IEnumerable<T> source, string s) => string.Join(s, source); public static string Join<T>(this IEnumerable<T> source, char c) => string.Join(c.ToString(), source); /// <summary> /// <see cref="Pair{T1, T2}"/> クラスのインスタンスを作成します。 /// </summary> /// <typeparam name="T1">firstの型</typeparam> /// <typeparam name="T2">secondの型</typeparam> /// <param name="first">firstの値</param> /// <param name="second">secondの値</param> /// <returns>作成した<see cref="Pair{T1, T2}"/> クラスのインスタンス</returns> public static Pair<T1, T2> make_pair<T1, T2>(T1 first, T2 second) where T1 : IComparable<T1> where T2 : IComparable<T2> => new Pair<T1, T2>(first, second); /// <summary>aとbをスワップします。</summary> public static void Swap<T>(ref T a, ref T b) where T : struct { var tmp = b; b = a; a = tmp; } /// <summary>aとbの最大公約数を求めます。</summary> /// <returns>aとbの最大公約数</returns> public static long Gcd(long a, long b) { while (true) { if (a < b) Swap(ref a, ref b); if (a % b == 0) return b; var x = a; a = b; b = x % b; } } /// <summary>aとbの最小公倍数を求めます。</summary> /// <returns>aとbの最小公倍数</returns> public static long Lcm(long a, long b) => a / Gcd(a, b) * b; /// <summary> /// 指定した数値が素数であるかを判定します。 /// </summary> /// <remarks>計算量 (sqrt(value)) </remarks> /// <param name="value">判定する数値</param> /// <returns>value が素数であるか</returns> public static bool IsPrime(long value) { if (value <= 1) return false; for (long i = 2; i * i <= value; i++) if (value % i == 0) return false; return true; } /// <summary> /// <see cref="a"/> ^ <see cref="b"/> (mod <see cref="p"/>) を求める /// </summary> /// <returns><see cref="a"/> ^ <see cref="b"/> (mod <see cref="p"/>) の値</returns> public static long PowMod(long a, long b, long p) { long res = 1; while (b > 0) { if (b % 2 != 0) res = res * a % p; a = a * a % p; b >>= 1; } return res; } /// <summary> /// mod pにおけるaの逆元を求めます。 /// </summary> /// <param name="a"></param> /// <param name="p">法</param> /// <returns></returns> public static long ModInv(long a, long p) => PowMod(a, p - 2, p); public static int DivCeil(int left, int right) => left / right + (left % right == 0 ? 0 : 1); public static long DivCeil(long left, long right) => left / right + (left % right == 0L ? 0L : 1L); /// <summary> /// src の順列を求めます。 /// </summary> /// <typeparam name="T">型</typeparam> /// <param name="src">順列を求める配列</param> /// <returns>src の順列</returns> public static IEnumerable<T[]> Permutations<T>(IEnumerable<T> src) { var ret = new List<T[]>(); Search(ret, new Stack<T>(), src.ToArray()); return ret; } private static void Search<T>(ICollection<T[]> perms, Stack<T> stack, T[] a) { int N = a.Length; if (N == 0) perms.Add(stack.Reverse().ToArray()); else { var b = new T[N - 1]; Array.Copy(a, 1, b, 0, N - 1); for (int i = 0; i < a.Length; ++i) { stack.Push(a[i]); Search(perms, stack, b); if (i < b.Length) b[i] = a[i]; stack.Pop(); } } } /// <summary> /// 指定した条件を満たす最小の数値を返します。 /// </summary> /// <param name="low">検索する数値の最小値</param> /// <param name="high">検索する数値の最大値</param> /// <param name="expression">条件</param> /// <returns>条件を満たす最小の数値</returns> public static long BinarySearch(long low, long high, Func<long, bool> expression) { while (low < high) { long middle = (high - low) / 2 + low; if (!expression(middle)) high = middle; else low = middle + 1; } return high; } /// <summary> /// 指定した値以上の先頭のインデクスを返します。 /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値以上の先頭のインデクス</returns> public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; while (low < high) { var mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) < 0) low = mid + 1; else high = mid; } return low; } /// <summary> /// 指定した値以上の先頭のインデクスを返します。 /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="value">検索する値</param> /// <returns>指定した値以上の先頭のインデクス</returns> public static int LowerBound<T>(T[] arr, T value) where T : IComparable { return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default); } /// <summary> /// 指定した値より大きい先頭のインデクスを返します。 /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値より大きい先頭のインデクス</returns> public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; while (low < high) { var mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) <= 0) low = mid + 1; else high = mid; } return low; } /// <summary> /// 指定した値より大きい先頭のインデクスを返します。 /// </summary>Z /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="value">検索する値</param> /// <returns>指定した値より大きい先頭のインデクス</returns> public static int UpperBound<T>(T[] arr, T value) { return UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default); } public static IEnumerable<TResult> SelectNotNull<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> func) => source.Where(val => val != null).Select(func); public static IEnumerable<TSource> WhereNotNull<TSource>(this IEnumerable<TSource> source) => source.Where(val => val != null); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] ArrayOf<T>(params T[] arr) => arr; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<T> ListOf<T>(params T[] arr) => new List<T>(arr); public static IEnumerable<TResult> Repeat<TResult>(TResult value) { while (true) yield return value; // ReSharper disable once IteratorNeverReturns } public static IEnumerable<TResult> Repeat<TResult>(TResult value, int count) => Enumerable.Repeat(value, count); [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] public static IEnumerable<TResult> Repeat<TResult>(this IEnumerable<TResult> source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); for (int i = 0; i < count; i++) foreach (var v in source) yield return v; } [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] public static IEnumerable<TResult> Repeat<TResult>(this IEnumerable<TResult> source) { if (source == null) throw new ArgumentNullException(nameof(source)); while (true) foreach (var v in source) yield return v; } /// <summary> /// 文字の配列を文字列に変換します。 /// </summary> /// <param name="source">文字の配列</param> /// <returns>変換した文字列</returns> public static string AsString(this IEnumerable<char> source) => new string(source.ToArray()); /// <summary> /// <see cref="source"/> の累積和を返します。 /// </summary> /// <returns><see cref="source"/> の累積和</returns> public static IEnumerable<long> CumSum(this IEnumerable<long> source) { long sum = 0; foreach (var item in source) yield return sum += item; } /// <summary> /// <see cref="source"/> の累積和を返します。 /// </summary> /// <returns><see cref="source"/> の累積和</returns> public static IEnumerable<int> CumSum(this IEnumerable<int> source) { int sum = 0; foreach (var item in source) yield return sum += item; } /// <summary> /// <see cref="value"/>が l以上 r未満の範囲に含まれているかを返します。 /// </summary> /// <typeparam name="T">要素の型</typeparam> /// <param name="value">判定する値</param> /// <param name="l">下限の値 (含まれる)</param> /// <param name="r">上限の値 (含まれない)</param> /// <returns><see cref="value"/> が指定した範囲に含まれているか</returns> public static bool IsIn<T>(this T value, T l, T r) where T : IComparable<T> { if (l.CompareTo(r) > 0) throw new ArgumentException(); return l.CompareTo(value) <= 0 && value.CompareTo(r) < 0; } /// <summary> /// <see cref="start"/> 以上 <see cref="end"/> 未満の値を <see cref="step"/> ずつ増やした結果を列挙します。 /// </summary> /// <param name="start">値の下限 (含まれる)</param> /// <param name="end">値の上限 (含まれない)</param> /// <param name="step">1要素ごとに増やす値</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> Range(int start, int end, int step = 1) { for (var i = start; i < end; i += step) yield return i; } /// <summary> /// 0 以上 <see cref="end"/> 未満の値を 1 ずつ増やした結果を列挙します。 /// </summary> /// <param name="end">値の上限 (含まれない)</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> Range(int end) => Range(0, end); /// <summary> /// <see cref="start"/> 以上 <see cref="end"/> 未満の値を <see cref="step"/> ずつ増やした結果を逆順に列挙します。 /// </summary> /// <param name="start">値の下限 (含まれる)</param> /// <param name="end">値の上限 (含まれない)</param> /// <param name="step">1要素ごとに増やす値</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> RangeReverse(int start, int end, int step = 1) { for (var i = end - 1; i >= start; i -= step) yield return i; } /// <summary> /// 0 以上 <see cref="end"/> 未満の値を 1 ずつ増やした結果を逆順に列挙します。 /// </summary> /// <param name="end">値の上限 (含まれない)</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> RangeReverse(int end) => RangeReverse(0, end); /// <summary> /// 指定した配列をコピーして昇順ソートします。(非破壊的) /// </summary> /// <typeparam name="T">ソートする配列の型</typeparam> /// <param name="arr">ソートする配列</param> /// <returns>ソートされた配列</returns> public static T[] Sort<T>(this T[] arr) { var array = new T[arr.Length]; arr.CopyTo(array, 0); Array.Sort(array); return array; } /// <summary> /// 指定した配列をコピーして降順ソートします。(非破壊的) /// </summary> /// <typeparam name="T">ソートする配列の型</typeparam> /// <param name="arr">ソートする配列</param> /// <returns>ソートされた配列</returns> public static T[] SortDescending<T>(this T[] arr) { var array = new T[arr.Length]; arr.CopyTo(array, 0); Array.Sort(array); Array.Reverse(array); return array; } public static double Log2(double x) => Log(x, 2); public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; } public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; } public static T Min<T>(params T[] col) => col.Min(); public static T Max<T>(params T[] col) => col.Max(); /// <summary> /// 要素数 (a, b) の、defaultValue で満たされたジャグ配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <returns>指定した条件で初期化された配列</returns> public static T[][] JaggedArray2D<T>(int a, int b, T defaultValue = default(T)) { var ret = new T[a][]; for (int i = 0; i < a; i++) { ret[i] = Enumerable.Repeat(defaultValue, b).ToArray(); } return ret; } /// <summary> /// 要素数 (a, b) の,defaultValue で満たされた二次元配列を作成します。 /// </summary> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <typeparam name="T">配列の型</typeparam> public static T[,] Array2D<T>(int a, int b, T defaultValue = default(T)) { var ret = new T[a, b]; for (int i = 0; i < a; i++) for (int j = 0; j < b; j++) ret[i, j] = defaultValue; return ret; } /// <summary> /// ジャグ配列を2次元配列に変換します。配列の各要素の長さがすべて同じである必要があります。 /// </summary> /// <param name="array">ジャグ配列</param> /// <typeparam name="T">二次元配列</typeparam> public static T[,] To2DArray<T>(this T[][] array) { if (!array.Any()) return new T[0, 0]; int len = array[0].Length; if (array.Any(x => x.Length != len)) throw new ArgumentException("array の各要素の長さが異なります。", nameof(array)); var ret = new T[array.Length, len]; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < len; j++) { ret[i, j] = array[i][j]; } } return ret; } // public static vector<T> ToVector<T>(this IEnumerable<T> source) => new vector<T>(source); } public static class Input { private const char _separator = ' '; private static readonly Queue<string> _input = new Queue<string>(); private static readonly StreamReader sr = #if FILE new StreamReader("in.txt"); #else new StreamReader(Console.OpenStandardInput()); #endif public static string ReadLine => sr.ReadLine(); public static string ReadStr => Read; public static string Read { get { if (_input.Count != 0) return _input.Dequeue(); // ReSharper disable once PossibleNullReferenceException var tmp = sr.ReadLine().Split(_separator); foreach (var val in tmp) { _input.Enqueue(val); } return _input.Dequeue(); } } public static int ReadInt => int.Parse(Read); public static long ReadLong => long.Parse(Read); public static double ReadDouble => double.Parse(Read); public static string[] StrArray() => ReadLine.Split(' '); public static int[] IntArray() => ReadLine.Split(' ').Select(int.Parse).ToArray(); public static long[] LongArray() => ReadLine.Split(' ').Select(long.Parse).ToArray(); public static string[] StrArray(int n) { var ret = new string[n]; for (long i = 0; i < n; ++i) ret[i] = Read; return ret; } public static int[] IntArray(int n, int offset = 0, bool sorted = false) { var ret = StrArray(n).Select(x => int.Parse(x) + offset).ToArray(); if (sorted) Array.Sort(ret); return ret; } public static long[] LongArray(int n, long offset = 0, bool sorted = false) { var ret = StrArray(n).Select(x => long.Parse(x) + offset).ToArray(); if (sorted) Array.Sort(ret); return ret; } public static string[,] Str2DArray(int n, int m) { var ret = new string[n, m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ret[i, j] = ReadStr; return ret; } public static int[,] Int2DArray(int n, int m, int offset = 0) { var ret = new int[n, m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ret[i, j] = ReadInt + offset; return ret; } public static long[,] Long2DArray(int n, int m, long offset = 0) { var ret = new long[n, m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ret[i, j] = ReadLong + offset; return ret; } public static Tuple<string[], string[]> StrArrays2(int n) { var ret1 = new string[n]; var ret2 = new string[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadStr; ret2[i] = ReadStr; } return Tuple.Create(ret1, ret2); } public static Tuple<int[], int[]> IntArrays2(int n, int offset1 = 0, int offset2 = 0) { var ret1 = new int[n]; var ret2 = new int[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadInt + offset1; ret2[i] = ReadInt + offset2; } return Tuple.Create(ret1, ret2); } public static Tuple<long[], long[]> LongArrays2(int n, long offset1 = 0, long offset2 = 0) { var ret1 = new long[n]; var ret2 = new long[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadLong + offset1; ret2[i] = ReadLong + offset2; } return Tuple.Create(ret1, ret2); } public static Tuple<string[], string[], string[]> StrArrays3(int n) { var ret1 = new string[n]; var ret2 = new string[n]; var ret3 = new string[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadStr; ret2[i] = ReadStr; } return Tuple.Create(ret1, ret2, ret3); } public static Tuple<int[], int[], int[]> IntArrays3(int n, int offset1 = 0, int offset2 = 0, int offset3 = 0) { var ret1 = new int[n]; var ret2 = new int[n]; var ret3 = new int[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadInt + offset1; ret2[i] = ReadInt + offset2; ret3[i] = ReadInt + offset3; } return Tuple.Create(ret1, ret2, ret3); } public static Tuple<long[], long[], long[]> LongArrays3(int n, long offset1 = 0, long offset2 = 0, long offset3 = 0) { var ret1 = new long[n]; var ret2 = new long[n]; var ret3 = new long[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadLong + offset1; ret2[i] = ReadLong + offset2; ret3[i] = ReadLong + offset3; } return Tuple.Create(ret1, ret2, ret3); } private static bool TypeEquals<T, U>() => typeof(T) == typeof(U); private static T ChangeType<T, U>(U a) => (T) System.Convert.ChangeType(a, typeof(T)); private static T Convert<T>(string s) => TypeEquals<T, int>() ? ChangeType<T, int>(int.Parse(s)) : TypeEquals<T, long>() ? ChangeType<T, long>(long.Parse(s)) : TypeEquals<T, double>() ? ChangeType<T, double>(double.Parse(s)) : TypeEquals<T, char>() ? ChangeType<T, char>(s[0]) : ChangeType<T, string>(s); public static bool In<T>(out T a) { try { a = Convert<T>(Read); return true; } catch { a = default(T); return false; } } public static bool In<T, U>(out T a, out U b) { try { var ar = StrArray(2); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); return true; } catch { a = default(T); b = default(U); return false; } } public static bool In<T, U, V>(out T a, out U b, out V c) { try { var ar = StrArray(3); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); c = Convert<V>(ar[2]); return true; } catch { a = default(T); b = default(U); c = default(V); return false; } } public static bool In<T, U, V, W>(out T a, out U b, out V c, out W d) { try { var ar = StrArray(4); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); c = Convert<V>(ar[2]); d = Convert<W>(ar[3]); return true; } catch { a = default(T); b = default(U); c = default(V); d = default(W); return false; } } public static bool In<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { try { var ar = StrArray(5); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); c = Convert<V>(ar[2]); d = Convert<W>(ar[3]); e = Convert<X>(ar[4]); return true; } catch { a = default(T); b = default(U); c = default(V); d = default(W); e = default(X); return false; } } } public static class Output { public static void print<T>(T t) => Console.WriteLine(t); public static void print(params object[] o) => Console.WriteLine(o.Join(" ")); public static void PrintBool(bool val, string yes = "Yes", string no = "No") => Console.WriteLine(val ? yes : no); public static void PrintYn(bool val) => PrintBool(val); public static void PrintYN(bool val) => PrintBool(val, "YES", "NO"); public static void PrintPossible(bool val) => PrintBool(val, "Possible", "Impossible"); public static void PrintYay(bool val) => PrintBool(val, "Yay!", ":("); public static void PrintDebug(params object[] args) => Console.Error.WriteLine(string.Join(" ", args)); /// <summary> /// setter で設定された値を標準出力に出力します。 /// </summary> public static object cout { set { Console.WriteLine(value); } } /// <summary> /// Local環境のみ,setter で設定された値を標準出力に出力します。 /// </summary> public static object dout { set { #if LOCAL Console.WriteLine(value); #endif } } /// <summary> /// setter で設定された値を標準エラー出力に出力します。 /// </summary> public static object cerr { set { Console.Error.WriteLine(value); } } public const string endl = "\n"; } public class Program { public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; Console.SetOut(sw); new Solver().Main(); Console.Out.Flush(); Console.Read(); } } [DebuggerDisplay("({first}, {second})")] public class Pair<T1, T2> : IComparable<Pair<T1, T2>>, IEquatable<Pair<T1, T2>> where T1 : IComparable<T1> where T2 : IComparable<T2> { public Pair(T1 first, T2 second) { this.first = first; this.second = second; } public T1 first; public T2 second; public int CompareTo(Pair<T1, T2> other) { if (ReferenceEquals(this, other)) return 0; if (ReferenceEquals(null, other)) return 1; var firstComparison = first.CompareTo(other.first); return firstComparison != 0 ? firstComparison : second.CompareTo(other.second); } public override string ToString() => $"({first}, {second})"; public bool Equals(Pair<T1, T2> other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return EqualityComparer<T1>.Default.Equals(first, other.first) && EqualityComparer<T2>.Default.Equals(second, other.second); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj.GetType() == GetType() && Equals((Pair<T1, T2>) obj); } public override int GetHashCode() { unchecked { return (EqualityComparer<T1>.Default.GetHashCode(first) * 397) ^ EqualityComparer<T2>.Default.GetHashCode(second); } } } #endregion }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using static System.Math; using static Solve.Methods; using static Solve.Input; using static Solve.Output; using pii = Solve.Pair<int, int>; using pll = Solve.Pair<long, long>; using pli = Solve.Pair<long, int>; using pil = Solve.Pair<int, long>; using pss = Solve.Pair<string, string>; using psi = Solve.Pair<string, int>; using lint = System.Collections.Generic.List<int>; using llong = System.Collections.Generic.List<long>; using lstr = System.Collections.Generic.List<string>; using llint = System.Collections.Generic.List<System.Collections.Generic.List<int>>; using llstr = System.Collections.Generic.List<System.Collections.Generic.List<long>>; using lllong = System.Collections.Generic.List<System.Collections.Generic.List<string>>; using lii = System.Collections.Generic.List<Solve.Pair<int, int>>; using lll = System.Collections.Generic.List<Solve.Pair<long, long>>; using lli = System.Collections.Generic.List<Solve.Pair<long, int>>; using lil = System.Collections.Generic.List<Solve.Pair<int, long>>; using ll = System.Int64; namespace Solve { public class Solver { public void Main() { int N = ReadInt; int K = ReadInt; ll now = K; for (int i = 0; i < 100; i++) { if (now > N) { Console.WriteLine(i+1); return; } now *= K; } } // ReSharper disable UnusedMember.Local private const int MOD = (int) 1e9 + 7, INF = 1000000010; private const long LINF = 1000000000000000100; } // ライブラリ置き場ここから // ライブラリ置き場ここまで #region Templete #if !LOCAL namespace Library { } #endif public static class Methods { public static readonly int[] dx = {-1, 0, 0, 1}; public static readonly int[] dy = {0, 1, -1, 0}; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Assert(bool b, string message = null) { if (!b) throw new Exception(message ?? "Assert failed."); } /* public static Comparison<T> greater<T>() where T : IComparable<T> => (a, b) => b.CompareTo(a); */ public static string JoinSpace<T>(this IEnumerable<T> source) => source.Join(" "); public static string JoinEndline<T>(this IEnumerable<T> source) => source.Join("\n"); public static string Join<T>(this IEnumerable<T> source, string s) => string.Join(s, source); public static string Join<T>(this IEnumerable<T> source, char c) => string.Join(c.ToString(), source); /// <summary> /// <see cref="Pair{T1, T2}"/> クラスのインスタンスを作成します。 /// </summary> /// <typeparam name="T1">firstの型</typeparam> /// <typeparam name="T2">secondの型</typeparam> /// <param name="first">firstの値</param> /// <param name="second">secondの値</param> /// <returns>作成した<see cref="Pair{T1, T2}"/> クラスのインスタンス</returns> public static Pair<T1, T2> make_pair<T1, T2>(T1 first, T2 second) where T1 : IComparable<T1> where T2 : IComparable<T2> => new Pair<T1, T2>(first, second); /// <summary>aとbをスワップします。</summary> public static void Swap<T>(ref T a, ref T b) where T : struct { var tmp = b; b = a; a = tmp; } /// <summary>aとbの最大公約数を求めます。</summary> /// <returns>aとbの最大公約数</returns> public static long Gcd(long a, long b) { while (true) { if (a < b) Swap(ref a, ref b); if (a % b == 0) return b; var x = a; a = b; b = x % b; } } /// <summary>aとbの最小公倍数を求めます。</summary> /// <returns>aとbの最小公倍数</returns> public static long Lcm(long a, long b) => a / Gcd(a, b) * b; /// <summary> /// 指定した数値が素数であるかを判定します。 /// </summary> /// <remarks>計算量 (sqrt(value)) </remarks> /// <param name="value">判定する数値</param> /// <returns>value が素数であるか</returns> public static bool IsPrime(long value) { if (value <= 1) return false; for (long i = 2; i * i <= value; i++) if (value % i == 0) return false; return true; } /// <summary> /// <see cref="a"/> ^ <see cref="b"/> (mod <see cref="p"/>) を求める /// </summary> /// <returns><see cref="a"/> ^ <see cref="b"/> (mod <see cref="p"/>) の値</returns> public static long PowMod(long a, long b, long p) { long res = 1; while (b > 0) { if (b % 2 != 0) res = res * a % p; a = a * a % p; b >>= 1; } return res; } /// <summary> /// mod pにおけるaの逆元を求めます。 /// </summary> /// <param name="a"></param> /// <param name="p">法</param> /// <returns></returns> public static long ModInv(long a, long p) => PowMod(a, p - 2, p); public static int DivCeil(int left, int right) => left / right + (left % right == 0 ? 0 : 1); public static long DivCeil(long left, long right) => left / right + (left % right == 0L ? 0L : 1L); /// <summary> /// src の順列を求めます。 /// </summary> /// <typeparam name="T">型</typeparam> /// <param name="src">順列を求める配列</param> /// <returns>src の順列</returns> public static IEnumerable<T[]> Permutations<T>(IEnumerable<T> src) { var ret = new List<T[]>(); Search(ret, new Stack<T>(), src.ToArray()); return ret; } private static void Search<T>(ICollection<T[]> perms, Stack<T> stack, T[] a) { int N = a.Length; if (N == 0) perms.Add(stack.Reverse().ToArray()); else { var b = new T[N - 1]; Array.Copy(a, 1, b, 0, N - 1); for (int i = 0; i < a.Length; ++i) { stack.Push(a[i]); Search(perms, stack, b); if (i < b.Length) b[i] = a[i]; stack.Pop(); } } } /// <summary> /// 指定した条件を満たす最小の数値を返します。 /// </summary> /// <param name="low">検索する数値の最小値</param> /// <param name="high">検索する数値の最大値</param> /// <param name="expression">条件</param> /// <returns>条件を満たす最小の数値</returns> public static long BinarySearch(long low, long high, Func<long, bool> expression) { while (low < high) { long middle = (high - low) / 2 + low; if (!expression(middle)) high = middle; else low = middle + 1; } return high; } /// <summary> /// 指定した値以上の先頭のインデクスを返します。 /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値以上の先頭のインデクス</returns> public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; while (low < high) { var mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) < 0) low = mid + 1; else high = mid; } return low; } /// <summary> /// 指定した値以上の先頭のインデクスを返します。 /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="value">検索する値</param> /// <returns>指定した値以上の先頭のインデクス</returns> public static int LowerBound<T>(T[] arr, T value) where T : IComparable { return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default); } /// <summary> /// 指定した値より大きい先頭のインデクスを返します。 /// </summary> /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="start">開始インデクス [inclusive]</param> /// <param name="end">終了インデクス [exclusive]</param> /// <param name="value">検索する値</param> /// <param name="comparer">比較関数(インターフェイス)</param> /// <returns>指定した値より大きい先頭のインデクス</returns> public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer) { int low = start; int high = end; while (low < high) { var mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) <= 0) low = mid + 1; else high = mid; } return low; } /// <summary> /// 指定した値より大きい先頭のインデクスを返します。 /// </summary>Z /// <typeparam name="T">比較する値の型</typeparam> /// <param name="arr">対象の配列(※ソート済みであること)</param> /// <param name="value">検索する値</param> /// <returns>指定した値より大きい先頭のインデクス</returns> public static int UpperBound<T>(T[] arr, T value) { return UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default); } public static IEnumerable<TResult> SelectNotNull<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> func) => source.Where(val => val != null).Select(func); public static IEnumerable<TSource> WhereNotNull<TSource>(this IEnumerable<TSource> source) => source.Where(val => val != null); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] ArrayOf<T>(params T[] arr) => arr; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static List<T> ListOf<T>(params T[] arr) => new List<T>(arr); public static IEnumerable<TResult> Repeat<TResult>(TResult value) { while (true) yield return value; // ReSharper disable once IteratorNeverReturns } public static IEnumerable<TResult> Repeat<TResult>(TResult value, int count) => Enumerable.Repeat(value, count); [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] public static IEnumerable<TResult> Repeat<TResult>(this IEnumerable<TResult> source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); for (int i = 0; i < count; i++) foreach (var v in source) yield return v; } [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] public static IEnumerable<TResult> Repeat<TResult>(this IEnumerable<TResult> source) { if (source == null) throw new ArgumentNullException(nameof(source)); while (true) foreach (var v in source) yield return v; } /// <summary> /// 文字の配列を文字列に変換します。 /// </summary> /// <param name="source">文字の配列</param> /// <returns>変換した文字列</returns> public static string AsString(this IEnumerable<char> source) => new string(source.ToArray()); /// <summary> /// <see cref="source"/> の累積和を返します。 /// </summary> /// <returns><see cref="source"/> の累積和</returns> public static IEnumerable<long> CumSum(this IEnumerable<long> source) { long sum = 0; foreach (var item in source) yield return sum += item; } /// <summary> /// <see cref="source"/> の累積和を返します。 /// </summary> /// <returns><see cref="source"/> の累積和</returns> public static IEnumerable<int> CumSum(this IEnumerable<int> source) { int sum = 0; foreach (var item in source) yield return sum += item; } /// <summary> /// <see cref="value"/>が l以上 r未満の範囲に含まれているかを返します。 /// </summary> /// <typeparam name="T">要素の型</typeparam> /// <param name="value">判定する値</param> /// <param name="l">下限の値 (含まれる)</param> /// <param name="r">上限の値 (含まれない)</param> /// <returns><see cref="value"/> が指定した範囲に含まれているか</returns> public static bool IsIn<T>(this T value, T l, T r) where T : IComparable<T> { if (l.CompareTo(r) > 0) throw new ArgumentException(); return l.CompareTo(value) <= 0 && value.CompareTo(r) < 0; } /// <summary> /// <see cref="start"/> 以上 <see cref="end"/> 未満の値を <see cref="step"/> ずつ増やした結果を列挙します。 /// </summary> /// <param name="start">値の下限 (含まれる)</param> /// <param name="end">値の上限 (含まれない)</param> /// <param name="step">1要素ごとに増やす値</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> Range(int start, int end, int step = 1) { for (var i = start; i < end; i += step) yield return i; } /// <summary> /// 0 以上 <see cref="end"/> 未満の値を 1 ずつ増やした結果を列挙します。 /// </summary> /// <param name="end">値の上限 (含まれない)</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> Range(int end) => Range(0, end); /// <summary> /// <see cref="start"/> 以上 <see cref="end"/> 未満の値を <see cref="step"/> ずつ増やした結果を逆順に列挙します。 /// </summary> /// <param name="start">値の下限 (含まれる)</param> /// <param name="end">値の上限 (含まれない)</param> /// <param name="step">1要素ごとに増やす値</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> RangeReverse(int start, int end, int step = 1) { for (var i = end - 1; i >= start; i -= step) yield return i; } /// <summary> /// 0 以上 <see cref="end"/> 未満の値を 1 ずつ増やした結果を逆順に列挙します。 /// </summary> /// <param name="end">値の上限 (含まれない)</param> /// <returns>範囲の結果</returns> public static IEnumerable<int> RangeReverse(int end) => RangeReverse(0, end); /// <summary> /// 指定した配列をコピーして昇順ソートします。(非破壊的) /// </summary> /// <typeparam name="T">ソートする配列の型</typeparam> /// <param name="arr">ソートする配列</param> /// <returns>ソートされた配列</returns> public static T[] Sort<T>(this T[] arr) { var array = new T[arr.Length]; arr.CopyTo(array, 0); Array.Sort(array); return array; } /// <summary> /// 指定した配列をコピーして降順ソートします。(非破壊的) /// </summary> /// <typeparam name="T">ソートする配列の型</typeparam> /// <param name="arr">ソートする配列</param> /// <returns>ソートされた配列</returns> public static T[] SortDescending<T>(this T[] arr) { var array = new T[arr.Length]; arr.CopyTo(array, 0); Array.Sort(array); Array.Reverse(array); return array; } public static double Log2(double x) => Log(x, 2); public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; } public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; } public static T Min<T>(params T[] col) => col.Min(); public static T Max<T>(params T[] col) => col.Max(); /// <summary> /// 要素数 (a, b) の、defaultValue で満たされたジャグ配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <returns>指定した条件で初期化された配列</returns> public static T[][] JaggedArray2D<T>(int a, int b, T defaultValue = default(T)) { var ret = new T[a][]; for (int i = 0; i < a; i++) { ret[i] = Enumerable.Repeat(defaultValue, b).ToArray(); } return ret; } /// <summary> /// 要素数 (a, b) の,defaultValue で満たされた二次元配列を作成します。 /// </summary> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <typeparam name="T">配列の型</typeparam> public static T[,] Array2D<T>(int a, int b, T defaultValue = default(T)) { var ret = new T[a, b]; for (int i = 0; i < a; i++) for (int j = 0; j < b; j++) ret[i, j] = defaultValue; return ret; } /// <summary> /// ジャグ配列を2次元配列に変換します。配列の各要素の長さがすべて同じである必要があります。 /// </summary> /// <param name="array">ジャグ配列</param> /// <typeparam name="T">二次元配列</typeparam> public static T[,] To2DArray<T>(this T[][] array) { if (!array.Any()) return new T[0, 0]; int len = array[0].Length; if (array.Any(x => x.Length != len)) throw new ArgumentException("array の各要素の長さが異なります。", nameof(array)); var ret = new T[array.Length, len]; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < len; j++) { ret[i, j] = array[i][j]; } } return ret; } // public static vector<T> ToVector<T>(this IEnumerable<T> source) => new vector<T>(source); } public static class Input { private const char _separator = ' '; private static readonly Queue<string> _input = new Queue<string>(); private static readonly StreamReader sr = #if FILE new StreamReader("in.txt"); #else new StreamReader(Console.OpenStandardInput()); #endif public static string ReadLine => sr.ReadLine(); public static string ReadStr => Read; public static string Read { get { if (_input.Count != 0) return _input.Dequeue(); // ReSharper disable once PossibleNullReferenceException var tmp = sr.ReadLine().Split(_separator); foreach (var val in tmp) { _input.Enqueue(val); } return _input.Dequeue(); } } public static int ReadInt => int.Parse(Read); public static long ReadLong => long.Parse(Read); public static double ReadDouble => double.Parse(Read); public static string[] StrArray() => ReadLine.Split(' '); public static int[] IntArray() => ReadLine.Split(' ').Select(int.Parse).ToArray(); public static long[] LongArray() => ReadLine.Split(' ').Select(long.Parse).ToArray(); public static string[] StrArray(int n) { var ret = new string[n]; for (long i = 0; i < n; ++i) ret[i] = Read; return ret; } public static int[] IntArray(int n, int offset = 0, bool sorted = false) { var ret = StrArray(n).Select(x => int.Parse(x) + offset).ToArray(); if (sorted) Array.Sort(ret); return ret; } public static long[] LongArray(int n, long offset = 0, bool sorted = false) { var ret = StrArray(n).Select(x => long.Parse(x) + offset).ToArray(); if (sorted) Array.Sort(ret); return ret; } public static string[,] Str2DArray(int n, int m) { var ret = new string[n, m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ret[i, j] = ReadStr; return ret; } public static int[,] Int2DArray(int n, int m, int offset = 0) { var ret = new int[n, m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ret[i, j] = ReadInt + offset; return ret; } public static long[,] Long2DArray(int n, int m, long offset = 0) { var ret = new long[n, m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) ret[i, j] = ReadLong + offset; return ret; } public static Tuple<string[], string[]> StrArrays2(int n) { var ret1 = new string[n]; var ret2 = new string[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadStr; ret2[i] = ReadStr; } return Tuple.Create(ret1, ret2); } public static Tuple<int[], int[]> IntArrays2(int n, int offset1 = 0, int offset2 = 0) { var ret1 = new int[n]; var ret2 = new int[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadInt + offset1; ret2[i] = ReadInt + offset2; } return Tuple.Create(ret1, ret2); } public static Tuple<long[], long[]> LongArrays2(int n, long offset1 = 0, long offset2 = 0) { var ret1 = new long[n]; var ret2 = new long[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadLong + offset1; ret2[i] = ReadLong + offset2; } return Tuple.Create(ret1, ret2); } public static Tuple<string[], string[], string[]> StrArrays3(int n) { var ret1 = new string[n]; var ret2 = new string[n]; var ret3 = new string[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadStr; ret2[i] = ReadStr; } return Tuple.Create(ret1, ret2, ret3); } public static Tuple<int[], int[], int[]> IntArrays3(int n, int offset1 = 0, int offset2 = 0, int offset3 = 0) { var ret1 = new int[n]; var ret2 = new int[n]; var ret3 = new int[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadInt + offset1; ret2[i] = ReadInt + offset2; ret3[i] = ReadInt + offset3; } return Tuple.Create(ret1, ret2, ret3); } public static Tuple<long[], long[], long[]> LongArrays3(int n, long offset1 = 0, long offset2 = 0, long offset3 = 0) { var ret1 = new long[n]; var ret2 = new long[n]; var ret3 = new long[n]; for (int i = 0; i < n; i++) { ret1[i] = ReadLong + offset1; ret2[i] = ReadLong + offset2; ret3[i] = ReadLong + offset3; } return Tuple.Create(ret1, ret2, ret3); } private static bool TypeEquals<T, U>() => typeof(T) == typeof(U); private static T ChangeType<T, U>(U a) => (T) System.Convert.ChangeType(a, typeof(T)); private static T Convert<T>(string s) => TypeEquals<T, int>() ? ChangeType<T, int>(int.Parse(s)) : TypeEquals<T, long>() ? ChangeType<T, long>(long.Parse(s)) : TypeEquals<T, double>() ? ChangeType<T, double>(double.Parse(s)) : TypeEquals<T, char>() ? ChangeType<T, char>(s[0]) : ChangeType<T, string>(s); public static bool In<T>(out T a) { try { a = Convert<T>(Read); return true; } catch { a = default(T); return false; } } public static bool In<T, U>(out T a, out U b) { try { var ar = StrArray(2); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); return true; } catch { a = default(T); b = default(U); return false; } } public static bool In<T, U, V>(out T a, out U b, out V c) { try { var ar = StrArray(3); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); c = Convert<V>(ar[2]); return true; } catch { a = default(T); b = default(U); c = default(V); return false; } } public static bool In<T, U, V, W>(out T a, out U b, out V c, out W d) { try { var ar = StrArray(4); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); c = Convert<V>(ar[2]); d = Convert<W>(ar[3]); return true; } catch { a = default(T); b = default(U); c = default(V); d = default(W); return false; } } public static bool In<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { try { var ar = StrArray(5); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); c = Convert<V>(ar[2]); d = Convert<W>(ar[3]); e = Convert<X>(ar[4]); return true; } catch { a = default(T); b = default(U); c = default(V); d = default(W); e = default(X); return false; } } } public static class Output { public static void print<T>(T t) => Console.WriteLine(t); public static void print(params object[] o) => Console.WriteLine(o.Join(" ")); public static void PrintBool(bool val, string yes = "Yes", string no = "No") => Console.WriteLine(val ? yes : no); public static void PrintYn(bool val) => PrintBool(val); public static void PrintYN(bool val) => PrintBool(val, "YES", "NO"); public static void PrintPossible(bool val) => PrintBool(val, "Possible", "Impossible"); public static void PrintYay(bool val) => PrintBool(val, "Yay!", ":("); public static void PrintDebug(params object[] args) => Console.Error.WriteLine(string.Join(" ", args)); /// <summary> /// setter で設定された値を標準出力に出力します。 /// </summary> public static object cout { set { Console.WriteLine(value); } } /// <summary> /// Local環境のみ,setter で設定された値を標準出力に出力します。 /// </summary> public static object dout { set { #if LOCAL Console.WriteLine(value); #endif } } /// <summary> /// setter で設定された値を標準エラー出力に出力します。 /// </summary> public static object cerr { set { Console.Error.WriteLine(value); } } public const string endl = "\n"; } public class Program { public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; Console.SetOut(sw); new Solver().Main(); Console.Out.Flush(); Console.Read(); } } [DebuggerDisplay("({first}, {second})")] public class Pair<T1, T2> : IComparable<Pair<T1, T2>>, IEquatable<Pair<T1, T2>> where T1 : IComparable<T1> where T2 : IComparable<T2> { public Pair(T1 first, T2 second) { this.first = first; this.second = second; } public T1 first; public T2 second; public int CompareTo(Pair<T1, T2> other) { if (ReferenceEquals(this, other)) return 0; if (ReferenceEquals(null, other)) return 1; var firstComparison = first.CompareTo(other.first); return firstComparison != 0 ? firstComparison : second.CompareTo(other.second); } public override string ToString() => $"({first}, {second})"; public bool Equals(Pair<T1, T2> other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return EqualityComparer<T1>.Default.Equals(first, other.first) && EqualityComparer<T2>.Default.Equals(second, other.second); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj.GetType() == GetType() && Equals((Pair<T1, T2>) obj); } public override int GetHashCode() { unchecked { return (EqualityComparer<T1>.Default.GetHashCode(first) * 397) ^ EqualityComparer<T2>.Default.GetHashCode(second); } } } #endregion }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47]]
8
5,463
using System; public class ABC156_B { private static void Main(string[] args) { var inputs = Console.ReadLine().Trim().Split(); var n = int.Parse(inputs[0]); var k = int.Parse(inputs[1]); var answer = Math.Ceiling(Math.Log(n, k)); Console.WriteLine(answer); } }
using System; public class ABC156_B { private static void Main(string[] args) { var inputs = Console.ReadLine().Trim().Split(); var n = int.Parse(inputs[0]); var k = int.Parse(inputs[1]); var answer = Math.Floor(Math.Log(n, k) + 1); Console.WriteLine(answer); } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
87
using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var a = Console.ReadLine(); var l = a.Split(' '); var b = int.Parse(l[0]); var c = int.Parse(l[1]); int cnt = 0; var d = b; for (int i = 0; i < b; i++) { var e = d % c; if (b == c) { Console.WriteLine(1); break; } if (e == 0 && d < c) { Console.WriteLine(cnt); break; } else { d = d / c; cnt += 1; } } } } }
using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var a = Console.ReadLine(); var l = a.Split(' '); var b = int.Parse(l[0]); var c = int.Parse(l[1]); int cnt = 0; var d = b; for (int i = 0; i < b; i++) { var e = d % c; if (b == 1) { Console.WriteLine(1); break; } if (e == 0 && d < c) { Console.WriteLine(cnt); break; } else { d = d / c; cnt += 1; } } } } }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
8
153
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var NK = ReadLongs(); long n = NK[0]; long k = NK[1]; long a = 1; long ans = 0; while (true) { ans++; a = a * k; if (a >= n) { WriteLine(ans); return; } } } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var NK = ReadLongs(); long n = NK[0]; long k = NK[1]; long a = 1; long ans = 0; while (true) { ans++; a = a * k; if (a > n) { WriteLine(ans); return; } } } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
[["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 47]]
8
291
using System; using System.Linq; class Program { static void Main(string[] args) { // 入力 long[] nr = Console.ReadLine().Split().Select(long.Parse).ToArray(); // n < rのk乗の最小値を求める long k = 0; while (nr[0] > Math.Pow(nr[1], k)) { k++; } Console.WriteLine(k); } }
using System; using System.Linq; class Program { static void Main(string[] args) { // 入力 long[] nr = Console.ReadLine().Split().Select(long.Parse).ToArray(); // n < rのk乗の最小値を求める long k = 0; while (nr[0] >= Math.Pow(nr[1], k)) { k++; } Console.WriteLine(k); } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20]]
8
87
using System; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var n = double.Parse(input[0]); var k = double.Parse(input[1]); Console.WriteLine(Math.Ceiling(Math.Log(n) / Math.Log(k))); } }
using System; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var n = double.Parse(input[0]); var k = double.Parse(input[1]); Console.WriteLine(Math.Floor(Math.Log(n) / Math.Log(k) + 1)); } }
[["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
84
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; internal static class CR { public static string Get() { return Console.ReadLine(); } public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); } public static int GetInteger() { return int.Parse(Console.ReadLine()); } public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); } } namespace AtCoder.B { public class Program { public static int N { get; private set; } public static int K { get; private set; } public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { var inputs = CR.GetIntegers().ToList(); N = inputs[0]; K = inputs[1]; var digits = 0; while (N > Math.Pow(K, digits)) { digits++; } return digits; } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; internal static class CR { public static string Get() { return Console.ReadLine(); } public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); } public static int GetInteger() { return int.Parse(Console.ReadLine()); } public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); } } namespace AtCoder.B { public class Program { public static int N { get; private set; } public static int K { get; private set; } public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { var inputs = CR.GetIntegers().ToList(); N = inputs[0]; K = inputs[1]; var digits = 0; while (N >= Math.Pow(K, digits)) { digits++; } return digits; } } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20]]
8
246
using System; public class Program { public static void Main(string[] args) { // 整数の入力 string[] input = Console.ReadLine().Split(' '); int b = int.Parse(input[0]); int c = int.Parse(input[1]); int ans = 1; while (b > c) { b = b / c; ans++; } //出力 Console.WriteLine(ans); } }
using System; public class Program { public static void Main(string[] args) { // 整数の入力 string[] input = Console.ReadLine().Split(' '); int b = int.Parse(input[0]); int c = int.Parse(input[1]); int ans = 1; while (b >= c) { b = b / c; ans++; } //出力 Console.WriteLine(ans); } }
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20]]
8
95
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Numerics; namespace AtCoder { class Program { private static void Main(string[] args) { var n = Scanner.Integer(); var x = Scanner.ArrayInt(n); var calc = Enumerable.Range(x.Min(), x.Max() - x.Min()) .Select(i => x.Select(xx => Math.Pow((xx - i), 2)).Sum()) .Min(); Console.WriteLine((int)calc); } #region Utility static readonly StreamScanner Scanner = new StreamScanner(Console.OpenStandardInput()); /// <summary> 一括出力 </summary> private static void OutAllLine(IEnumerable<dynamic> items) { var sb = new StringBuilder(); foreach (var result in items) { sb.Append(result.ToString() + "\n"); } sb = sb.Remove(sb.Length - 1, 1); Console.WriteLine(sb); } #endregion } #region Utility Class public class StreamScanner { public StreamScanner(Stream stream) { str = stream; } private readonly Stream str; private readonly byte[] buf = new byte[1024]; private int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } private byte read() { if (isEof) throw new EndOfStreamException(); if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public string ScanIncludeSpace() { var sb = new StringBuilder(); for (var b = Char(); b >= 32 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public long Long() { long ret = 0; byte b = 0; var ng = false; do b = read(); while (b != '-' && (b < '0' || '9' < b)); if (b == '-') { ng = true; b = read(); } for (; true; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; else ret = ret * 10 + b - '0'; } } public int Integer() { return (int)Long(); } public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } /// <summary> 数値読み込み </summary> public List<long> ArrayLong(int count = 0) { var scan = new List<long>(); for (int i = 0; i < count; i++) { scan.Add(Long()); } return scan; } /// <summary> 数値読み込み </summary> public List<int> ArrayInt(int count = 0) { var scan = new List<int>(); for (int i = 0; i < count; i++) { scan.Add(Integer()); } return scan; } } public class LargeCalc { public IEnumerable<long> Surplus(long baseNum, long power, int division) { long value = 1; for (int i = 1; i <= power; i++) { value = value * baseNum % division; yield return value; if (value == 0) { break; } } } } public class Primer { /// <summary> 素数判定 </summary> public bool IsPrime(int num) { if (num < 2) { return false; } if (num == 2) { return true; } 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 IEnumerable<int> GetPrimeFactors(int n) { int i = 2; int tmp = n; while (i * i <= n) //※1 { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } } public class Mod109 { public const int _7 = 1000000007; public const int _9 = 1000000009; public const int _3 = 998244353; private readonly int ModValue; public Mod109(int modValue = Mod109._7) { ModValue = modValue; } /// <summary> 和 </summary> public long Addition(IEnumerable<long> nums) { return nums.Aggregate<long, long>( 0, (current, num) => ModifyPositive((current + num) % ModValue)); } /// <summary> 差 </summary> public long Subtraction(IEnumerable<long> nums) { return nums.Aggregate<long, long>( 0, (current, num) => ModifyPositive((current - num) % ModValue)); } /// <summary> 積 </summary> public long Multiplication(IEnumerable<long> nums) { return nums.Aggregate<long, long>( 1, (current, num) => ModifyPositive((current * num) % ModValue)); } private long ModifyPositive(long value) { return value < 0 ? (value + ModValue) : value; } } public class BitArrayMaker { public List<int> Integer(int bitValue, int length) { var list = new List<int>(); for (int i = 0; i < length; i++) { if (bitValue % 2 == 1) { list.Add(i); } bitValue /= 2; } return list; } public bool[] Boolean(int bitValue, int length) { var list = new bool[length]; for (int i = 0; i < length; i++) { list[i] = bitValue % 2 == 1; bitValue /= 2; } return list; } } #endregion }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Numerics; namespace AtCoder { class Program { private static void Main(string[] args) { var n = Scanner.Integer(); var x = Scanner.ArrayInt(n); var calc = Enumerable.Range(x.Min(), x.Max() - x.Min() + 1) .Select(i => x.Select(xx => Math.Pow((xx - i), 2)).Sum()) .Min(); Console.WriteLine((int)calc); } #region Utility static readonly StreamScanner Scanner = new StreamScanner(Console.OpenStandardInput()); /// <summary> 一括出力 </summary> private static void OutAllLine(IEnumerable<dynamic> items) { var sb = new StringBuilder(); foreach (var result in items) { sb.Append(result.ToString() + "\n"); } sb = sb.Remove(sb.Length - 1, 1); Console.WriteLine(sb); } #endregion } #region Utility Class public class StreamScanner { public StreamScanner(Stream stream) { str = stream; } private readonly Stream str; private readonly byte[] buf = new byte[1024]; private int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } private byte read() { if (isEof) throw new EndOfStreamException(); if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public string ScanIncludeSpace() { var sb = new StringBuilder(); for (var b = Char(); b >= 32 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public long Long() { long ret = 0; byte b = 0; var ng = false; do b = read(); while (b != '-' && (b < '0' || '9' < b)); if (b == '-') { ng = true; b = read(); } for (; true; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; else ret = ret * 10 + b - '0'; } } public int Integer() { return (int)Long(); } public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } /// <summary> 数値読み込み </summary> public List<long> ArrayLong(int count = 0) { var scan = new List<long>(); for (int i = 0; i < count; i++) { scan.Add(Long()); } return scan; } /// <summary> 数値読み込み </summary> public List<int> ArrayInt(int count = 0) { var scan = new List<int>(); for (int i = 0; i < count; i++) { scan.Add(Integer()); } return scan; } } public class LargeCalc { public IEnumerable<long> Surplus(long baseNum, long power, int division) { long value = 1; for (int i = 1; i <= power; i++) { value = value * baseNum % division; yield return value; if (value == 0) { break; } } } } public class Primer { /// <summary> 素数判定 </summary> public bool IsPrime(int num) { if (num < 2) { return false; } if (num == 2) { return true; } 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 IEnumerable<int> GetPrimeFactors(int n) { int i = 2; int tmp = n; while (i * i <= n) //※1 { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } } public class Mod109 { public const int _7 = 1000000007; public const int _9 = 1000000009; public const int _3 = 998244353; private readonly int ModValue; public Mod109(int modValue = Mod109._7) { ModValue = modValue; } /// <summary> 和 </summary> public long Addition(IEnumerable<long> nums) { return nums.Aggregate<long, long>( 0, (current, num) => ModifyPositive((current + num) % ModValue)); } /// <summary> 差 </summary> public long Subtraction(IEnumerable<long> nums) { return nums.Aggregate<long, long>( 0, (current, num) => ModifyPositive((current - num) % ModValue)); } /// <summary> 積 </summary> public long Multiplication(IEnumerable<long> nums) { return nums.Aggregate<long, long>( 1, (current, num) => ModifyPositive((current * num) % ModValue)); } private long ModifyPositive(long value) { return value < 0 ? (value + ModValue) : value; } } public class BitArrayMaker { public List<int> Integer(int bitValue, int length) { var list = new List<int>(); for (int i = 0; i < length; i++) { if (bitValue % 2 == 1) { list.Add(i); } bitValue /= 2; } return list; } public bool[] Boolean(int bitValue, int length) { var list = new bool[length]; for (int i = 0; i < length; i++) { list[i] = bitValue % 2 == 1; bitValue /= 2; } return list; } } #endregion }
[["+", 205, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
1,325
using System; using System.Linq; class c { static void Main() { int n = int.Parse(Console.ReadLine()); var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); var ans = int.MaxValue; for (int i = x.Min(); i < x.Max(); i++) { var temp = 0; for (int j = 0; j < n; j++) { temp += (int)Math.Pow(x[j] - i, 2); } ans = Math.Min(temp, ans); } Console.WriteLine(ans); } }
using System; using System.Linq; class c { static void Main() { int n = int.Parse(Console.ReadLine()); var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); var ans = int.MaxValue; for (int i = x.Min(); i <= x.Max(); i++) { var temp = 0; for (int j = 0; j < n; j++) { temp += (int)Math.Pow(x[j] - i, 2); } ans = Math.Min(temp, ans); } Console.WriteLine(ans); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
144
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Numerics; using System.IO; using System.Runtime.InteropServices; using static System.Math; using static Math2; using static io; using static Utils; public class CompetitiveProgramming { public void Solve() { var N = Int1; var X = Ints; Array.Sort(X); int ans = INF; for (int i = X[0]; i < X[N - 1]; ++i) { int su = 0; for (int j = 0; j < N; ++j) { su += (X[j] - i) * (X[j] - i); } ans = Min(ans, su); } Write(ans); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const int MOD2 = 998244353; public static long Power(long i, long N, long MOD = 1000000007) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i % MOD; i = i * i % MOD; N >>= 1; } return res; } public static long Power2(long i, long N) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i; i = i * i; N >>= 1; } return res; } public static long GCD(long i, long N) { if (i > N) Swap(ref i, ref N); if (i == 0) return N; while (N != 0) { var r = i % N; i = N; N = r; } return i; } public static long LCM(long i, long N) => i * N / GCD(i, N); public static long Comb(long N, long R, int MOD = 1000000007) { long ret = 1; long x = 1; for (long i = N; i >= N - R + 1; --i) { ret = ret / x * i; ret %= MOD; x++; } return ret; } public static long Comb2(long N, long R) { long Nume = 1; long Deno = 1; if (R > N - R) Swap(ref N, ref R); for (long i = 1; i <= R; ++i) { Deno *= i; Nume *= N - i + 1; } return Deno / Nume; } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(int N) { string s = N.ToString(); int ret = 0; for (int i = 0; i < s.Length; ++i) ret += s[i] - '0'; return ret; } } class Program { static void Main(string[] args) { var CompetitiveProgramming = new CompetitiveProgramming(); CompetitiveProgramming.Solve(); } } public static class io { public static string Str => Console.ReadLine(); public static string[] Strs => Str.Split(' '); public static long[] Longs => Strs.Select(long.Parse).ToArray(); public static int[] Ints => Strs.Select(int.Parse).ToArray(); public static char[] Chars => Str.ToArray(); public static double[] Doubles => Strs.Select(double.Parse).ToArray(); public static long Long1 => Longs[0]; public static int Int1 => Ints[0]; public static char Char1 => Chars[0]; public static double Double1 => Doubles[0]; public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; } public static void Write(string a) => Console.WriteLine(a); public static void Write(params object[] i) => Write(string.Join(" ", i)); public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a)); public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); } public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Numerics; using System.IO; using System.Runtime.InteropServices; using static System.Math; using static Math2; using static io; using static Utils; public class CompetitiveProgramming { public void Solve() { var N = Int1; var X = Ints; Array.Sort(X); int ans = INF; for (int i = X[0]; i <= X[N - 1]; ++i) { int su = 0; for (int j = 0; j < N; ++j) { su += (X[j] - i) * (X[j] - i); } ans = Min(ans, su); } Write(ans); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const int MOD2 = 998244353; public static long Power(long i, long N, long MOD = 1000000007) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i % MOD; i = i * i % MOD; N >>= 1; } return res; } public static long Power2(long i, long N) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i; i = i * i; N >>= 1; } return res; } public static long GCD(long i, long N) { if (i > N) Swap(ref i, ref N); if (i == 0) return N; while (N != 0) { var r = i % N; i = N; N = r; } return i; } public static long LCM(long i, long N) => i * N / GCD(i, N); public static long Comb(long N, long R, int MOD = 1000000007) { long ret = 1; long x = 1; for (long i = N; i >= N - R + 1; --i) { ret = ret / x * i; ret %= MOD; x++; } return ret; } public static long Comb2(long N, long R) { long Nume = 1; long Deno = 1; if (R > N - R) Swap(ref N, ref R); for (long i = 1; i <= R; ++i) { Deno *= i; Nume *= N - i + 1; } return Deno / Nume; } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(int N) { string s = N.ToString(); int ret = 0; for (int i = 0; i < s.Length; ++i) ret += s[i] - '0'; return ret; } } class Program { static void Main(string[] args) { var CompetitiveProgramming = new CompetitiveProgramming(); CompetitiveProgramming.Solve(); } } public static class io { public static string Str => Console.ReadLine(); public static string[] Strs => Str.Split(' '); public static long[] Longs => Strs.Select(long.Parse).ToArray(); public static int[] Ints => Strs.Select(int.Parse).ToArray(); public static char[] Chars => Str.ToArray(); public static double[] Doubles => Strs.Select(double.Parse).ToArray(); public static long Long1 => Longs[0]; public static int Int1 => Ints[0]; public static char Char1 => Chars[0]; public static double Double1 => Doubles[0]; public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; } public static void Write(string a) => Console.WriteLine(a); public static void Write(params object[] i) => Write(string.Join(" ", i)); public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a)); public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); } public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
1,017
using System; using System.Collections.Generic; using System.Windows; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { public class Program { static void Main(string[] args) { var N = Console.ReadLine().ToInt(); var x = Console.ReadLine().Split(' '); var target = new List<int>(); for (int i = 0; i < x.Length; i++) { target.Add(x[i].ToInt()); } double minValue = double.MaxValue; for (int i = 0; i <= target.Max(); i++) { double calcValue = 0; for (int j = 0; j < target.Count; j++) { calcValue += Math.Pow(target[j] - i + 1, 2); } if (minValue > calcValue) { minValue = calcValue; } } Console.WriteLine(minValue); Console.ReadLine(); } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double ToDouble(this object obj) { return double.Parse(obj.ToString()); } }
using System; using System.Collections.Generic; using System.Windows; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { public class Program { static void Main(string[] args) { var N = Console.ReadLine().ToInt(); var x = Console.ReadLine().Split(' '); var target = new List<int>(); for (int i = 0; i < x.Length; i++) { target.Add(x[i].ToInt()); } double minValue = double.MaxValue; for (int i = 0; i <= 100; i++) { double calcValue = 0; for (int j = 0; j < target.Count; j++) { calcValue += Math.Pow(target[j] - i + 1, 2); } if (minValue > calcValue) { minValue = calcValue; } } Console.WriteLine(minValue); Console.ReadLine(); } } } public static class Extentions { public static int ToInt(this object obj) { return int.Parse(obj.ToString()); } public static decimal ToDecimal(this object obj) { return decimal.Parse(obj.ToString()); } public static double ToDouble(this object obj) { return double.Parse(obj.ToString()); } }
[["-", 0, 7, 15, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 7, 15, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 7, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
292
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); int N = cin.nextInt(); int[] a = cin.ArrayInt(N, 0); Array.Sort(a); int min = a[0]; int max = a[N - 1]; int Min = 9999999; for (int i = min; i < max; i++) { int sum = 0; for (int j = 0; j < N; j++) { sum += ((a[j] - i) * (a[j] - i)); } Min = Math.Min(Min, sum); } Console.WriteLine(Min); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; class Myon { public Myon() {} public static int Main() { new Myon().calc(); return 0; } Scanner cin; Func cin2; void calc() { cin = new Scanner(); cin2 = new Func(); int N = cin.nextInt(); int[] a = cin.ArrayInt(N, 0); Array.Sort(a); int min = a[0]; int max = a[N - 1]; int Min = 9999999; for (int i = min; i <= max; i++) { int sum = 0; for (int j = 0; j < N; j++) { sum += ((a[j] - i) * (a[j] - i)); } Min = Math.Min(Min, sum); } Console.WriteLine(Min); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Answer { public void Int2DArrayAns(int[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } public void Char2DArrayAns(char[,] x, char c) { for (int i = 0; i < x.GetLength(0); i++) { for (int j = 0; j < x.GetLength(1) - 1; j++) { Console.Write(x[i, j]); Console.Write(c); } Console.WriteLine(x[i, x.GetLength(1) - 1]); } } } class Func { public long GCDLong(long a, long b) { while (a != 0) { long t = a; a = b % a; b = t; } return b; } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
813
using System; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] X = new int[N]; for (var i = 0; i < N; i++) { X[i] = int.Parse(input[i]); } GetResult(N, X); } static void GetResult(int N, int[] X) { var sum = 0; int min = int.MaxValue; int zMax = 0; int zMin = int.MaxValue; foreach (var x in X) { zMax = Math.Max(x, zMax); zMin = Math.Min(x, zMin); } for (var i = zMin; i < zMax; i++) { sum = 0; for (var k = 0; k < N; k++) { sum += (int)Math.Pow(X[k] - i, 2); if (sum > min) break; } min = Math.Min(min, sum); } Console.WriteLine(min); } }
using System; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] X = new int[N]; for (var i = 0; i < N; i++) { X[i] = int.Parse(input[i]); } GetResult(N, X); } static void GetResult(int N, int[] X) { var sum = 0; int min = int.MaxValue; int zMax = 0; int zMin = int.MaxValue; foreach (var x in X) { zMax = Math.Max(x, zMax); zMin = Math.Min(x, zMin); } for (var i = zMin; i <= zMax; i++) { sum = 0; for (var k = 0; k < N; k++) { sum += (int)Math.Pow(X[k] - i, 2); if (sum > min) break; } min = Math.Min(min, sum); } Console.WriteLine(min); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
254