buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass { public const long Giri = 1000000007; public static void Main(string[] args) { var s = Console.ReadLine(); var k = Console.ReadLine().ToLong(); for (int i = 0; i < s.Length; i++) { if (s[i] - '0' != 1) { Console.WriteLine(s[i]); return; } } Console.WriteLine(1); } 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 int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); } } 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) { var r = new int[str.Length]; for (int i = 0; i < str.Length; i++) r[i] = str[i].ToInt(); return r; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass { public const long Giri = 1000000007; public static void Main(string[] args) { var s = Console.ReadLine(); var k = Console.ReadLine().ToLong(); for (int i = 0; i < Math.Min(k, s.Length); i++) { if (s[i] - '0' != 1) { Console.WriteLine(s[i]); return; } } Console.WriteLine(1); } 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 int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); } } 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) { var r = new int[str.Length]; for (int i = 0; i < str.Length; i++) r[i] = str[i].ToInt(); return r; } }
[["+", 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], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 25]]
8
343
7
using System; using System.Collections.Generic; using System.Linq; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var S = Console.ReadLine(); int K; var parseRet = int.TryParse(Console.ReadLine(), out K); if (!parseRet) { K = 100; } string store = string.Empty; foreach (var s in S) { if (string.IsNullOrEmpty(store)) { store += s.ToString(); if (s != '1') { break; } } else { if (s == '1') { store += s.ToString(); } else { store += s.ToString(); break; } } } int index = K > 100 ? 100 : K; if (store.Length < K) { Console.WriteLine(store.Last()); } else { Console.WriteLine(store[K]); } } } }
using System; using System.Collections.Generic; using System.Linq; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var S = Console.ReadLine(); int K; var parseRet = int.TryParse(Console.ReadLine(), out K); if (!parseRet) { K = int.MaxValue; } string store = string.Empty; foreach (var s in S) { if (string.IsNullOrEmpty(store)) { store += s.ToString(); if (s != '1') { break; } } else { if (s == '1') { store += s.ToString(); } else { store += s.ToString(); break; } } } if (store.Length < K) { Console.WriteLine(store.Last()); } else { Console.WriteLine(store[K - 1]); } } } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 205, 199], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 17, 47], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 12, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 75, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
207
17
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace ABC106C { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); return; } public void Solve(ConsoleInput cin) { var S = cin.ReadLine.ToCharArray(); var K = cin.ReadLong; for (long i = 0; i < K; i++) { if (S[i] == '1') { continue; } Console.WriteLine(S[i]); break; } return; } } public static class Extensions { public static string Reverse(this string sourse) { char[] chrAry = sourse.ToCharArray(); Array.Reverse(chrAry); return new string(chrAry); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace ABC106C { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); return; } public void Solve(ConsoleInput cin) { var S = cin.ReadLine.ToCharArray(); var K = cin.ReadLong; for (long i = 0; i < K; i++) { if (S[i] == '1') { continue; } Console.WriteLine(S[i]); return; } Console.WriteLine('1'); return; } } public static class Extensions { public static string Reverse(this string sourse) { char[] chrAry = sourse.ToCharArray(); Array.Reverse(chrAry); return new string(chrAry); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
[["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 7, 8, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
531
11
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace ConsoleApp1 { class Program { static void Main(string[] args) { A(); } static void A() { var S = Read().ToList(); var K = ReadLong(); if (S.Count == 1 || K == 1 || (S.Count > 1 && S[0] != '1')) { Println(S[0]); } else if (S.FindIndex(x => x != '1') + 1 > K) { Println(1); } else { Println(S[S.FindIndex(x => x != '1')]); } } static IEnumerable<int> Range(int start, int stop) { if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0)) return new List<int>(); return Enumerable.Range(start, stop - start); } static bool IsDigit(string str) { var i = 0; return int.TryParse(str, out i); } static int DigitsSum(long num) { return num.ToString().Select(x => x.ToString()).Sum(int.Parse); } static int[] ToIntArray(string str) { return str.Select(x => x.ToString()).Select(int.Parse).ToArray(); } static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b); static bool IsPrime(int x) { if (x <= 1 || (x != 2 && x % 2 == 0)) return false; if (x == 2) return true; for (int i = 3; i < x; i += 2) if (x % i == 0) return false; return true; } static string Read() => Console.ReadLine(); static int ReadInt() => int.Parse(Read()); static long ReadLong() => long.Parse(Read()); static List<string> ReadSplit() => Read().Split().ToList(); static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList(); static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList(); static void Print(object value) => Console.Write(value.ToString()); static void Println(object value) => Console.WriteLine(value.ToString()); static string Join<T>(IEnumerable<T> list) => string.Join("", list); } public static class MyExtensions { public static string Slice(this string str, int start = 0, int stop = 0) { if (start > str.Length || stop > str.Length || start < 0 || stop < 0) return ""; if (stop == 0) stop = str.Length; return str.Substring(start, stop - start); } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace ConsoleApp1 { class Program { static void Main(string[] args) { A(); } static void A() { var S = Read().ToList(); var K = ReadLong(); if (S.Count == 1 || K == 1 || (S.Count > 1 && S[0] != '1')) { Println(S[0]); } else if (S.Count(x => x != '1') == 0 || S.FindIndex(x => x != '1') + 1 > K) { Println(1); } else { Println(S[S.FindIndex(x => x != '1')]); } } static IEnumerable<int> Range(int start, int stop) { if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0)) return new List<int>(); return Enumerable.Range(start, stop - start); } static bool IsDigit(string str) { var i = 0; return int.TryParse(str, out i); } static int DigitsSum(long num) { return num.ToString().Select(x => x.ToString()).Sum(int.Parse); } static int[] ToIntArray(string str) { return str.Select(x => x.ToString()).Select(int.Parse).ToArray(); } static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b); static bool IsPrime(int x) { if (x <= 1 || (x != 2 && x % 2 == 0)) return false; if (x == 2) return true; for (int i = 3; i < x; i += 2) if (x % i == 0) return false; return true; } static string Read() => Console.ReadLine(); static int ReadInt() => int.Parse(Read()); static long ReadLong() => long.Parse(Read()); static List<string> ReadSplit() => Read().Split().ToList(); static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList(); static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList(); static void Print(object value) => Console.Write(value.ToString()); static void Println(object value) => Console.WriteLine(value.ToString()); static string Join<T>(IEnumerable<T> list) => string.Join("", list); } public static class MyExtensions { public static string Slice(this string str, int start = 0, int stop = 0) { if (start > str.Length || stop > str.Length || start < 0 || stop < 0) return ""; if (stop == 0) stop = str.Length; return str.Substring(start, stop - start); } } }
[["+", 15, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 79], ["+", 0, 28, 0, 218, 8, 16, 12, 252, 0, 104], ["+", 0, 28, 0, 218, 8, 16, 12, 252, 0, 253], ["+", 15, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 106], ["+", 12, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["+", 12, 16, 31, 16, 31, 213, 63, 214, 0, 131]]
8
664
15
using System; class Program { static void Main(string[] args) { // スペース区切りの整数の入力 string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int K = int.Parse(input[1]); // 割ればええんちゃうの int amari = N % K; //出力 Console.WriteLine(amari.ToString()); } }
using System; class Program { static void Main(string[] args) { // スペース区切りの整数の入力 string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int K = int.Parse(input[1]); // 割ればええんちゃうの int amari = N % K; //人が多いときはダメなのかぁ if (amari > 1) { amari = 1; } //出力 Console.WriteLine(amari.ToString()); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
83
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { private static string Read() { return Console.ReadLine(); } 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); } private static void print(object obj) { Console.WriteLine(obj); } static void Main(string[] args) { var a = ReadInts(); var b = a[0] % a[1]; if (b > a[1] / 2) { print(b - a[1]); } else print(b); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Program { private static string Read() { return Console.ReadLine(); } 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); } private static void print(object obj) { Console.WriteLine(obj); } static void Main(string[] args) { var a = ReadInts(); var b = a[0] % a[1]; if (b > 0) { print(1); } else print(b); } } }
[["-", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 85], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 16, 12, 204, 205, 22], ["-", 0, 28, 0, 16, 12, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 16, 12, 204, 206, 207, 0, 73]]
8
265
12
using System; using static System.Console; using static System.Math; using System.Collections.Generic; using System.Linq; using System.IO; class Program { static void Main() { var input = ReadLine().Split(); int n = int.Parse(input[0]); int k = int.Parse(input[1]); WriteLine(n % k); } }
using System; using static System.Console; using static System.Math; using System.Collections.Generic; using System.Linq; using System.IO; class Program { static void Main() { var input = ReadLine().Split(); int n = int.Parse(input[0]); int k = int.Parse(input[1]); if (n % k == 0) WriteLine(0); else WriteLine(1); } }
[["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 213, 63, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 213, 63, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
8
87
14
#pragma warning disable using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Diagnostics; using System.Collections; static class MainClass { public static void Main() { var str = Console.ReadLine().SplittedStringToInt32List(); var n = str[0]; var k = str[1]; Console.WriteLine(n - (n / k) * k); Console.ReadLine(); } #region ライブラリ #region 二分探索 public static int LowerBound<T>(this IEnumerable<T> ar, int start, int end, T value, IComparer<T> comparer) { var arr = ar.ToArray(); int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) < 0) low = mid + 1; else high = mid; } return low; } public static int LowerBound<T>(this IEnumerable<T> arr, T value) where T : IComparable { return LowerBound(arr, 0, arr.Count(), value, Comparer<T>.Default); } public static int UpperBound<T>(this IEnumerable<T> ar, int start, int end, T value, IComparer<T> comparer) { var arr = ar.ToArray(); int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) <= 0) low = mid + 1; else high = mid; } return low; } public static int UpperBound<T>(this IEnumerable<T> arr, T value) { return UpperBound(arr, 0, arr.Count(), value, Comparer<T>.Default); } #endregion #region bit全探索 /// <summary> /// Bit全探索用のライブラリ /// </summary> /// <param name="len">作る配列の長さ(lenが0以下だと(ry)</param> /// <returns>できた配列</returns> public static List<List<bool>> CreateBits(int len) { return CreateBitsPri(new List<List<bool>>(), len, 0); } private static List<List<bool>> CreateBitsPri(List<List<bool>> bits, int len, int count) { if (count == 0) { var lss = new List<bool>(); lss.Add(true); bits.Add(lss); var lx = new List<bool>(); lx.Add(false); bits.Add(lx); count++; return CreateBitsPri(bits, len, count); } if (len - count == 0) return bits; count++; var ls = new List<List<bool>>(); foreach (var item in bits) { var x = item.ToList(); x.Add(true); item.Add(false); ls.Add(item); ls.Add(x); } return CreateBitsPri(ls, len, count); } #endregion #region 文字列処理 public static int ToInt32(this string str) { return int.Parse(str); } public static List<string> SplittedStringToList(this string str) { return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .ToList(); } public static List<int> SplittedStringToInt32List(this string str) { return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => int.Parse(x)) .ToList(); } #endregion #region エラトステネスの篩 /** * MIT License Copyright (c) 2018 gushwell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **/ public class BoundedBoolArray { private BitArray _array; private int _lower; public BoundedBoolArray(int lower, int upper) { _array = new BitArray(upper - lower + 1); _lower = lower; } public bool this[int index] { get { return _array[index - _lower]; } set { _array[index - _lower] = value; } } } public static IEnumerable<int> GeneratePrimes() { var primes = new List<int>() { 2, 3 }; foreach (var p in primes) yield return p; int ix = 0; while (true) { int prime1st = primes[ix]; int prime2nd = primes[++ix]; var lower = prime1st * prime1st; var upper = prime2nd * prime2nd - 1; var sieve = new BoundedBoolArray(lower, upper); foreach (var prime in primes.Take(ix)) { var start = (int)Math.Ceiling((double)lower / prime) * prime; for (int index = start; index <= upper; index += prime) sieve[index] = true; } for (int i = lower; i <= upper; i++) { if (sieve[i] == false) { primes.Add(i); yield return i; } } } } #endregion #region DeepClone public static T DeepClone<T>(this T src) { using (var memoryStream = new MemoryStream()) { var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, src); memoryStream.Seek(0, SeekOrigin.Begin); return (T)binaryFormatter.Deserialize(memoryStream); } } #endregion #region 順列を作るやつ public static List<List<int>> GeneratePermutations(int n) { if (n > 14) throw new ArgumentOutOfRangeException(); var ls = new List<List<int>>(); ls.Add(new List<int>() { 1 }); for (int i = 0; i < n - 1; i++) { var newls = new List<List<int>>(); ls.ForEach(x => { var len = x.Count; for (int j = 0; j <= len; j++) { var item = x.DeepClone(); item.Insert(j, i + 2); newls.Add(item); } }); ls = newls; } return ls; } #endregion public static int Max(int a, int b) { return a >= b ? a : b; } public static int Min(int a, int b) { return b >= a ? a : b; } #endregion }
#pragma warning disable using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Diagnostics; using System.Collections; static class MainClass { public static void Main() { var n = Console.ReadLine().SplittedStringToInt32List(); if (n[0] % n[1] == 0) Console.WriteLine(0); else Console.WriteLine(1); Console.ReadLine(); } #region ライブラリ #region 二分探索 public static int LowerBound<T>(this IEnumerable<T> ar, int start, int end, T value, IComparer<T> comparer) { var arr = ar.ToArray(); int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) < 0) low = mid + 1; else high = mid; } return low; } public static int LowerBound<T>(this IEnumerable<T> arr, T value) where T : IComparable { return LowerBound(arr, 0, arr.Count(), value, Comparer<T>.Default); } public static int UpperBound<T>(this IEnumerable<T> ar, int start, int end, T value, IComparer<T> comparer) { var arr = ar.ToArray(); int low = start; int high = end; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (comparer.Compare(arr[mid], value) <= 0) low = mid + 1; else high = mid; } return low; } public static int UpperBound<T>(this IEnumerable<T> arr, T value) { return UpperBound(arr, 0, arr.Count(), value, Comparer<T>.Default); } #endregion #region bit全探索 /// <summary> /// Bit全探索用のライブラリ /// </summary> /// <param name="len">作る配列の長さ(lenが0以下だと(ry)</param> /// <returns>できた配列</returns> public static List<List<bool>> CreateBits(int len) { return CreateBitsPri(new List<List<bool>>(), len, 0); } private static List<List<bool>> CreateBitsPri(List<List<bool>> bits, int len, int count) { if (count == 0) { var lss = new List<bool>(); lss.Add(true); bits.Add(lss); var lx = new List<bool>(); lx.Add(false); bits.Add(lx); count++; return CreateBitsPri(bits, len, count); } if (len - count == 0) return bits; count++; var ls = new List<List<bool>>(); foreach (var item in bits) { var x = item.ToList(); x.Add(true); item.Add(false); ls.Add(item); ls.Add(x); } return CreateBitsPri(ls, len, count); } #endregion #region 文字列処理 public static int ToInt32(this string str) { return int.Parse(str); } public static List<string> SplittedStringToList(this string str) { return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .ToList(); } public static List<int> SplittedStringToInt32List(this string str) { return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => int.Parse(x)) .ToList(); } #endregion #region エラトステネスの篩 /** * MIT License Copyright (c) 2018 gushwell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **/ public class BoundedBoolArray { private BitArray _array; private int _lower; public BoundedBoolArray(int lower, int upper) { _array = new BitArray(upper - lower + 1); _lower = lower; } public bool this[int index] { get { return _array[index - _lower]; } set { _array[index - _lower] = value; } } } public static IEnumerable<int> GeneratePrimes() { var primes = new List<int>() { 2, 3 }; foreach (var p in primes) yield return p; int ix = 0; while (true) { int prime1st = primes[ix]; int prime2nd = primes[++ix]; var lower = prime1st * prime1st; var upper = prime2nd * prime2nd - 1; var sieve = new BoundedBoolArray(lower, upper); foreach (var prime in primes.Take(ix)) { var start = (int)Math.Ceiling((double)lower / prime) * prime; for (int index = start; index <= upper; index += prime) sieve[index] = true; } for (int i = lower; i <= upper; i++) { if (sieve[i] == false) { primes.Add(i); yield return i; } } } } #endregion #region DeepClone public static T DeepClone<T>(this T src) { using (var memoryStream = new MemoryStream()) { var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, src); memoryStream.Seek(0, SeekOrigin.Begin); return (T)binaryFormatter.Deserialize(memoryStream); } } #endregion #region 順列を作るやつ public static List<List<int>> GeneratePermutations(int n) { if (n > 14) throw new ArgumentOutOfRangeException(); var ls = new List<List<int>>(); ls.Add(new List<int>() { 1 }); for (int i = 0; i < n - 1; i++) { var newls = new List<List<int>>(); ls.ForEach(x => { var len = x.Count; for (int j = 0; j <= len; j++) { var item = x.DeepClone(); item.Insert(j, i + 2); newls.Add(item); } }); ls = newls; } return ls; } #endregion public static int Max(int a, int b) { return a >= b ? a : b; } public static int Min(int a, int b) { return b >= a ? a : b; } #endregion }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 17, 85], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 16, 12, 16, 17, 48], ["-", 3, 4, 0, 28, 0, 16, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
8
1,304
34
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var s = Read(); var k = Read(); var ans = ""; for (int i = 0; i < s.Length; i++) { if (s[i].ToString() != "1") { WriteLine(s[i]); return; } } WriteLine(1); } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } //最大公約数 public static int Gcd(int a, int b) { if (a < b) { return Gcd(b, a); } while (b != 0) { var reminder = a % b; a = b; b = reminder; } return a; } //最小公倍数 public static int Lcm(int a, int b) { return a * b / Gcd(a, b); } //文字数を数える public static int CountChar(string s, char c) { return s.Length - s.Replace(c.ToString(), "").Length; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtCoder { class Program { static void Main(string[] args) { var s = Read(); var k = ReadLong(); for (int i = 0; i < s.Length; i++) { if (s[i].ToString() != "1") { WriteLine(s[i]); return; } else { if (k == i + 1) { WriteLine(1); return; } } } WriteLine(1); } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } //最大公約数 public static int Gcd(int a, int b) { if (a < b) { return Gcd(b, a); } while (b != 0) { var reminder = a % b; a = b; b = reminder; } return a; } //最小公倍数 public static int Lcm(int a, int b) { return a * b / Gcd(a, b); } //文字数を数える public static int CountChar(string s, char c) { return s.Length - s.Replace(c.ToString(), "").Length; } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
8
410
28
using System; using System.Collections.Generic; using System.Linq; public static partial class Program { //テンプレここから public static int ToInt(this string str) { return int.Parse(str); } public static long ToLong(this string str) { return long.Parse(str); } public static IEnumerable<int> ToInt(this string[] strs) { return strs.Select(x => x.ToInt()); } public static IEnumerable<long> ToLong(this string[] strs) { return strs.Select(x => x.ToLong()); } public static IEnumerable<int> SplToInt(this string str, char opr = ' ') { return str.Split(opr).ToInt(); } public static IEnumerable<long> SplToLong(this string str, char opr = ' ') { return str.Split(opr).ToLong(); } public static string CRL() { return Console.ReadLine(); } public static void CWL(object obj) { Console.WriteLine(obj); } public static int Diff(int a, int b) { return Math.Abs(Math.Max(a, b) - Math.Min(a, b)); } public static long Diff(long a, long b) { return Math.Abs(Math.Max(a, b) - Math.Min(a, b)); } public static int Sign(this int i) { return Math.Sign(i); } //テンプレここまで } public static partial class Program { static void Main() { var str = CRL(); var k = CRL().ToLong(); for (int i = 0; i < k; i++) { if (str[i] != '1') { CWL(str[i]); return; } } } }
using System; using System.Collections.Generic; using System.Linq; public static partial class Program { //テンプレここから public static int ToInt(this string str) { return int.Parse(str); } public static long ToLong(this string str) { return long.Parse(str); } public static IEnumerable<int> ToInt(this string[] strs) { return strs.Select(x => x.ToInt()); } public static IEnumerable<long> ToLong(this string[] strs) { return strs.Select(x => x.ToLong()); } public static IEnumerable<int> SplToInt(this string str, char opr = ' ') { return str.Split(opr).ToInt(); } public static IEnumerable<long> SplToLong(this string str, char opr = ' ') { return str.Split(opr).ToLong(); } public static string CRL() { return Console.ReadLine(); } public static void CWL(object obj) { Console.WriteLine(obj); } public static int Diff(int a, int b) { return Math.Abs(Math.Max(a, b) - Math.Min(a, b)); } public static long Diff(long a, long b) { return Math.Abs(Math.Max(a, b) - Math.Min(a, b)); } public static int Sign(this int i) { return Math.Sign(i); } //テンプレここまで } public static partial class Program { static void Main() { var str = CRL(); var k = CRL().ToLong(); var len = Math.Min(str.Length, k); for (int i = 0; i < len; i++) { if (str[i] != '1') { CWL(str[i]); return; } } CWL(1); } }
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
384
21
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace AtCoder { // http://abc106.contest.atcoder.jp/tasks/abc106_c public class Abc106_c { #if !Development public static void Main(string[] args) { Abc106_c.Solve(args); } #endif /* S は 1 文字以上 100 文字以下の文字列. K は 1 以上 10 18 以下の整数. 5000 兆日後の文字列の長さは K 文字以上である. * */ public static void Solve(string[] args) { var s = ReadLineIntOne(); var k = ReadLineLongOne(); var 五千兆 = 5000L * 10000 * 10000 * 10000; var c = s.ToString().Select(x => int.Parse(x.ToString())); foreach (var digit in c) { if (digit > 1) { Console.WriteLine(digit); return; } k--; if (k == 0) { Console.WriteLine("1"); return; } } Console.WriteLine("1"); } public static List<string> ReadLineString() { return Console.ReadLine().Split(' ').ToList(); } public static List<int> ReadLineInt() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToList(); } public static int ReadLineIntOne() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).First(); } public static List<int> MultiReadLineInt(int lineNum) { return Enumerable.Range(0, lineNum).Select(_ => ReadLineIntOne()).ToList(); } public static long ReadLineLongOne() { return Console.ReadLine().Split(' ').Select(str => long.Parse(str)).First(); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace AtCoder { // http://abc106.contest.atcoder.jp/tasks/abc106_c public class Abc106_c { #if !Development public static void Main(string[] args) { Abc106_c.Solve(args); } #endif /* S は 1 文字以上 100 文字以下の文字列. K は 1 以上 10 18 以下の整数. 5000 兆日後の文字列の長さは K 文字以上である. * */ public static void Solve(string[] args) { var s = ReadLineStringOne(); var k = ReadLineLongOne(); var 五千兆 = 5000L * 10000 * 10000 * 10000; var c = s.Select(x => int.Parse(x.ToString())); foreach (var digit in c) { if (digit > 1) { Console.WriteLine(digit); return; } k--; if (k == 0) { Console.WriteLine("1"); return; } } } public static string ReadLineStringOne() { return Console.ReadLine(); } public static List<string> ReadLineString() { return Console.ReadLine().Split(' ').ToList(); } public static List<int> ReadLineInt() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToList(); } public static int ReadLineIntOne() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).First(); } public static List<int> MultiReadLineInt(int lineNum) { return Enumerable.Range(0, lineNum).Select(_ => ReadLineIntOne()).ToList(); } public static long ReadLineLongOne() { return Console.ReadLine().Split(' ').Select(str => long.Parse(str)).First(); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 259], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 115], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 24], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 45], ["+", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 37, 0, 213, 63, 214, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
357
20
using System; class p { static void Main() { int N = int.Parse(Console.ReadLine()); bool can = false; for (int i = 0; i < (N / 4); i++) { for (int j = 0; j < (N / 7); j++) { if (((i * 4) + (j * 7)) == N) { can = true; break; } } if (can) { break; } } Console.WriteLine(can ? "Yes" : "No"); } }
using System; class p { static void Main() { int N = int.Parse(Console.ReadLine()); bool can = false; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (((i * 4) + (j * 7)) == N) { can = true; break; } } if (can) { break; } } Console.WriteLine(can ? "Yes" : "No"); } }
[["-", 8, 196, 0, 7, 15, 16, 12, 23, 0, 24], ["-", 0, 7, 15, 16, 12, 23, 0, 16, 17, 85], ["-", 0, 7, 15, 16, 12, 23, 0, 16, 12, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 23, 0, 25]]
8
122
8
using System; namespace B { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); for (var i = 0; i < (N + 3) / 4; i++) { for (var j = 0; j < (N + 6) / 7; j++) { int sum = 4 * i + 7 * j; if (sum == N) { Console.WriteLine("Yes"); return; } } } Console.WriteLine("No"); } } }
using System; namespace B { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); for (var i = 0; i <= N / 4; i++) { for (var j = 0; j <= N / 7; j++) { int sum = 4 * i + 7 * j; if (sum == N) { Console.WriteLine("Yes"); return; } } } Console.WriteLine("No"); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 7, 15, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 15, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["-", 15, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 7, 15, 16, 12, 16, 31, 23, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
8
119
12
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; using static MyIO; public class A { public static void Main() { int n = GetInt(); while (n >= 0) { if (n % 7 == 0) { Console.WriteLine("Yes"); break; } if (n < 7) { Console.WriteLine("No"); break; } n -= 4; } } } public static class MyIO { private static string[] args = null; private static int num = -1; private static int used = -1; private static string getArg() { if (used == num) { args = Console.ReadLine().Split(' '); num = args.Length; used = 0; } return args[used++]; } public static int GetInt() { return int.Parse(getArg()); } public static long GetLong() { return long.Parse(getArg()); } public static double GetDouble() { return double.Parse(getArg()); } public static string GetString() { return getArg(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; using static MyIO; public class A { public static void Main() { int n = GetInt(); while (n >= 0) { if (n % 4 == 0) { Console.WriteLine("Yes"); return; } n -= 7; } Console.WriteLine("No"); return; } } public static class MyIO { private static string[] args = null; private static int num = -1; private static int used = -1; private static string getArg() { if (used == num) { args = Console.ReadLine().Split(' '); num = args.Length; used = 0; } return args[used++]; } public static int GetInt() { return int.Parse(getArg()); } public static long GetLong() { return long.Parse(getArg()); } public static double GetDouble() { return double.Parse(getArg()); } public static string GetString() { return getArg(); } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
8
247
20
using System; public class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); for (int i = 0; i < 100 / 7; i++) { for (int j = 0; j < 100 / 4; j++) { if (i * 7 + j * 4 == N) { Console.WriteLine("Yes"); return; } } } } }
using System; public class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); for (int i = 0; i < 100 / 7; i++) { for (int j = 0; j < 100 / 4; j++) { if (i * 7 + j * 4 == N) { Console.WriteLine("Yes"); return; } } } Console.WriteLine("No"); } }
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
91
9
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc106_c { class Program { static void Main(string[] args) { string str = Console.ReadLine(); Console.ReadLine(); if (str[0] != '1') { WriteLine(str[0]); } else { for (int i = 1; i < str.Length; i++) { if (str[i] != '1') { WriteLine(str[i]); return; } } WriteLine(1); } } } }
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc106_c { class Program { static void Main(string[] args) { string str = Console.ReadLine(); double k = double.Parse(Console.ReadLine()); if (str[0] != '1') { WriteLine(str[0]); } else { for (int i = 1; i < str.Length; i++) { if (str[i] != '1') { if (k <= i) { WriteLine(1); } else { WriteLine(str[i]); } return; } } WriteLine(1); } } } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 75, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 213, 63, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
8
156
24
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { string str = Console.ReadLine(); string str2 = Console.ReadLine(); long K = long.Parse(str2); string ans = "1"; for (var i = 0; i < str.Length; i++) { if (str.Substring(i, 1) != "1") { ans = str.Substring(i, 1); break; } } Console.WriteLine(ans); } }
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { string str = Console.ReadLine(); string str2 = Console.ReadLine(); long K = long.Parse(str2); string ans = "1"; for (var i = 0; i < str.Length; i++) { if (str.Substring(i, 1) != "1") { ans = str.Substring(i, 1); break; } if (i == K - 1) { ans = str.Substring(i, 1); break; } } Console.WriteLine(ans); } }
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
115
23
using Yorukatsu058.Questions; using Yorukatsu058.Extensions; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Yorukatsu058.Questions { public class QuestionD : AtCoderQuestionBase { public override IEnumerable<object> Solve(TextReader inputStream) { var n = inputStream.ReadInt(); if (n > 0) { for (int d = 1; d < 30; d += 2) { if ((n & (1 << d)) > 0) { n += 1 << (d + 1); } } yield return Convert.ToString(n, 2); } else if (n < 0) { n = -n; for (int d = 0; d < 30; d += 2) { if ((n & (1 << d)) > 0) { n += 1 << (d + 1); } } yield return Convert.ToString(n, 2); } else { yield return "0"; } } } } namespace Yorukatsu058 { class Program { static void Main(string[] args) { IAtCoderQuestion question = new QuestionD(); // 問題に合わせて書き換え var answers = question.Solve(Console.In); foreach (var answer in answers) { Console.WriteLine(answer); } } } } #region Base Classes namespace Yorukatsu058.Questions { public interface IAtCoderQuestion { IEnumerable<object> Solve(string input); IEnumerable<object> Solve(TextReader inputStream); } public abstract class AtCoderQuestionBase : IAtCoderQuestion { public IEnumerable<object> Solve(string input) { var stream = new MemoryStream(Encoding.Unicode.GetBytes(input)); var reader = new StreamReader(stream, Encoding.Unicode); return Solve(reader); } public abstract IEnumerable<object> Solve(TextReader inputStream); } } #endregion #region Extensions namespace Yorukatsu058.Extensions { internal static class TextReaderExtensions { internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader)); internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader)); internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader)); internal static string ReadString(this TextReader reader) => reader.ReadLine(); internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray(); internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray(); internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray(); internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator); } } #endregion
using Yorukatsu058.Questions; using Yorukatsu058.Extensions; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Yorukatsu058.Questions { public class QuestionD : AtCoderQuestionBase { public override IEnumerable<object> Solve(TextReader inputStream) { var n = inputStream.ReadLong(); if (n > 0) { for (int d = 1; d < 60; d += 2) { if ((n & (1L << d)) > 0) { n += 1L << (d + 1); } } yield return Convert.ToString(n, 2); } else if (n < 0) { n = -n; for (int d = 0; d < 60; d += 2) { if ((n & (1L << d)) > 0) { n += 1L << (d + 1); } } yield return Convert.ToString(n, 2); } else { yield return "0"; } } } } namespace Yorukatsu058 { class Program { static void Main(string[] args) { IAtCoderQuestion question = new QuestionD(); // 問題に合わせて書き換え var answers = question.Solve(Console.In); foreach (var answer in answers) { Console.WriteLine(answer); } } } } #region Base Classes namespace Yorukatsu058.Questions { public interface IAtCoderQuestion { IEnumerable<object> Solve(string input); IEnumerable<object> Solve(TextReader inputStream); } public abstract class AtCoderQuestionBase : IAtCoderQuestion { public IEnumerable<object> Solve(string input) { var stream = new MemoryStream(Encoding.Unicode.GetBytes(input)); var reader = new StreamReader(stream, Encoding.Unicode); return Solve(reader); } public abstract IEnumerable<object> Solve(TextReader inputStream); } } #endregion #region Extensions namespace Yorukatsu058.Extensions { internal static class TextReaderExtensions { internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader)); internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader)); internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader)); internal static string ReadString(this TextReader reader) => reader.ReadLine(); internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray(); internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray(); internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray(); internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator); } } #endregion
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 57, 64, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 12, 203], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 31, 203], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 31, 203], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 31, 203], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 203], ["-", 75, 57, 64, 196, 0, 7, 15, 16, 12, 203], ["+", 75, 57, 64, 196, 0, 7, 15, 16, 12, 203]]
8
602
14
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static PB10004.Algorithm.Util; namespace PB10004.Algorithm { class Template { static void Main(string[] args) { new C().Solve(); } } class A { public void Solve() {} } class B { public void Solve() {} } class C { public void Solve() { var line = ReadLine(); var K = ulong.Parse(ReadLine()); ulong i = 0; while (line[(int)i] == '1') { i++; if (i == K - 1) { WriteLine(1); return; } } WriteLine(line[(int)i]); } } class D { public void Solve() {} } public static class Util { /// <summary> /// 標準入力をint型にパースする /// </summary> /// <returns></returns> public static int ReadInt() { return int.Parse(ReadLine()); } /// <summary> /// 標準入力をint型の配列にする /// </summary> /// <returns></returns> public static int[] ReadIntArray() { return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } /// <summary> /// 標準入力をlong型にパースする /// </summary> /// <returns></returns> public static long ReadLong() { return long.Parse(ReadLine()); } /// <summary> /// 標準入力をlong型の配列にする /// </summary> /// <returns></returns> public static long[] ReadLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } /// <summary> /// 一定値の数列を生成する /// </summary> /// <param name="value"></param> /// <param name="length"></param> /// <returns></returns> public static IEnumerable<long> ConstSeq(long value, long length) { for (int i = 0; i < length; i++) { yield return value; } } /// <summary> /// int配列の累積和を求める /// </summary> /// <param name="array"></param> /// <returns></returns> public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) { int tmp = 0; foreach (var num in array) yield return tmp += num; } /// <summary> /// long配列の累積和を求める /// </summary> /// <param name="array"></param> /// <returns></returns> public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) { long tmp = 0; yield return tmp; foreach (var num in array) yield return tmp += num; } /// <summary> /// 最大公約数をユークリッドの互除法で求める /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); } /// <summary> /// 最小公倍数を求める /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long Lcm(long a, long b) { return a * b / Gcd(a, b); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static PB10004.Algorithm.Util; namespace PB10004.Algorithm { class Template { static void Main(string[] args) { new C().Solve(); } } class A { public void Solve() {} } class B { public void Solve() {} } class C { public void Solve() { var line = ReadLine(); var K = ulong.Parse(ReadLine()); int i = 0; while (line[i] == '1') { i++; if ((ulong)i == K) { WriteLine(1); return; } } WriteLine(line[i]); } } class D { public void Solve() {} } public static class Util { /// <summary> /// 標準入力をint型にパースする /// </summary> /// <returns></returns> public static int ReadInt() { return int.Parse(ReadLine()); } /// <summary> /// 標準入力をint型の配列にする /// </summary> /// <returns></returns> public static int[] ReadIntArray() { return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } /// <summary> /// 標準入力をlong型にパースする /// </summary> /// <returns></returns> public static long ReadLong() { return long.Parse(ReadLine()); } /// <summary> /// 標準入力をlong型の配列にする /// </summary> /// <returns></returns> public static long[] ReadLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } /// <summary> /// 一定値の数列を生成する /// </summary> /// <param name="value"></param> /// <param name="length"></param> /// <returns></returns> public static IEnumerable<long> ConstSeq(long value, long length) { for (int i = 0; i < length; i++) { yield return value; } } /// <summary> /// int配列の累積和を求める /// </summary> /// <param name="array"></param> /// <returns></returns> public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) { int tmp = 0; foreach (var num in array) yield return tmp += num; } /// <summary> /// long配列の累積和を求める /// </summary> /// <param name="array"></param> /// <returns></returns> public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) { long tmp = 0; yield return tmp; foreach (var num in array) yield return tmp += num; } /// <summary> /// 最大公約数をユークリッドの互除法で求める /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); } /// <summary> /// 最小公倍数を求める /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static long Lcm(long a, long b) { return a * b / Gcd(a, b); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 31, 204, 206, 207, 0, 28, 0, 74, 0, 24], ["-", 31, 204, 206, 207, 0, 28, 0, 74, 39, 199], ["-", 31, 204, 206, 207, 0, 28, 0, 74, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 39, 199], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 0, 204, 206, 207, 0, 28, 0, 74, 0, 24], ["-", 0, 204, 206, 207, 0, 28, 0, 74, 39, 199], ["-", 0, 204, 206, 207, 0, 28, 0, 74, 0, 25]]
8
498
13
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var N = sc.ReadInt(); var minus = N < 0; if (minus) N = -N; var x = new bool[32]; for (int i = 0; i < 32; i++) { var y = (N >> i) & 1; if (y == 1) { if ((i % 2 == 0 && !minus) || (i % 2 == 1 && minus)) { // + if (x[i]) { x[i + 1] = !x[i + 1]; x[i + 2] = !x[i + 2]; } x[i] = !x[i]; } else { // - if (x[i]) x[i] = !x[i]; else { x[i] = !x[i]; x[i + 1] = !x[i + 1]; } } } } long m = 0; for (int i = 0; i < x.Length; i++) { if (!x[i]) continue; m += (long)Math.Pow(-2, i); } if (minus) N = -N; if (m != N) { Console.WriteLine($"N:{N}, m:{m}"); } var ans = new string( x.Reverse().SkipWhile(f => !f).Select(f => f ? '1' : '0').ToArray()); Console.WriteLine(ans); } static Scanner sc = new Scanner(); } class Scanner { string[] S = new string[0]; int Index = 0; char[] Separators = new char[] { ' ' }; public string Next() { if (this.Index < this.S.Length) return this.S[this.Index++]; var line = ""; while (line == "") line = Console.ReadLine(); this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries); if (this.S.Length == 0) return this.Next(); this.Index = 0; return this.S[this.Index++]; } public string ReadStr() { return this.Next(); } public char ReadChar() { return this.Next()[0]; } public int ReadInt() { return int.Parse(this.Next()); } public uint ReadUInt() { return uint.Parse(this.Next()); } public long ReadLong() { return long.Parse(this.Next()); } public double ReadDouble() { return double.Parse(this.Next()); } public Tuple<int, int> ReadTup(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add); } public Tuple<long, long> ReadTupLong(int add = 0) { return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add); } public Tuple<int, int, int> ReadTup3(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public Tuple<int, int, int, int> ReadTup4(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public int[] ReadIntArray(int n) { var array = new int[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadInt(); } return array; } public long[] ReadLongArray(int n) { var array = new long[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadLong(); } return array; } public double[] ReadDoubleArray(int n) { var array = new double[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadDouble(); } return array; } public char[] ReadCharArray(int n) { var array = new char[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadChar(); } return array; } public string[] ReadStrArray(int n) { var array = new string[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadStr(); } return array; } public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) { var array = new Tuple<long, long>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTupLong(add); } return array; } public Tuple<int, int>[] ReadTupArray(int n, int add = 0) { var array = new Tuple<int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup(add); } return array; } public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) { var array = new Tuple<int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup3(add); } return array; } public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) { var array = new Tuple<int, int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup4(add); } return array; } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Program { static void Main(string[] args) { var N = sc.ReadInt(); if (N == 0) { Console.WriteLine(0); return; } var minus = N < 0; if (minus) N = -N; var x = new bool[32]; for (int i = 0; i < 32; i++) { var y = (N >> i) & 1; if (y == 1) { if ((i % 2 == 0 && !minus) || (i % 2 == 1 && minus)) { // + if (x[i]) { x[i + 1] = !x[i + 1]; x[i + 2] = !x[i + 2]; } x[i] = !x[i]; } else { // - if (x[i]) x[i] = !x[i]; else { x[i] = !x[i]; x[i + 1] = !x[i + 1]; } } } } long m = 0; for (int i = 0; i < x.Length; i++) { if (!x[i]) continue; m += (long)Math.Pow(-2, i); } if (minus) N = -N; if (m != N) { Console.WriteLine($"N:{N}, m:{m}"); } var ans = new string( x.Reverse().SkipWhile(f => !f).Select(f => f ? '1' : '0').ToArray()); 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; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
1,330
17
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { string inNum = Reader.ReadLine(); long target = long.Parse(Reader.ReadLine()); long idx = 0; long ans = 0; for (int i = 0; i < inNum.Length; i++) { long num = inNum[i] - '0'; if (num >= 2) { ans = num; break; } } Console.WriteLine(ans); } public class Reader { static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 299792458 9460730472580800 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { string inNum = Reader.ReadLine(); long target = long.Parse(Reader.ReadLine()); long idx = 0; long ans = 0; for (int i = 0; i < inNum.Length; i++) { long num = inNum[i] - '0'; if (num >= 2) { ans = num; break; } idx++; if (idx >= target) { ans = num; break; } } Console.WriteLine(ans); } public class Reader { static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 299792458 9460730472580800 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }
[["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
8
232
17
using System; using System.Text; using System.Collections.Generic; using System.Linq; using E = System.Linq.Enumerable; class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); // var A = Console.ReadLine().Split(' ').Select(x => // int.Parse(x)).ToArray(); // Console.WriteLine((long)Math.Ceiling(123456789.0/-2.0)); // Console.WriteLine(hihur(123456789,-2)); // Console.WriteLine(hihur(123456789,-2)); Console.WriteLine(BaseM2(N)); } static string BaseM2(long N) { if (N == 0) { // return (hihur(N,-2)).ToString(); return ""; } else { return BaseM2(hihu(N, -2)) + (hihur(N, -2)).ToString(); } }     static long hihu(double m, double n) { if (m < 0 && n < 0) { return (long)(Math.Ceiling(m / n)); } // Console.WriteLine(m/n); long ans = (long)(Math.Ceiling(m / n)); return ans; } static long hihur(long m, long n) { return m - hihu(m, n) * n; } }
using System; using System.Text; using System.Collections.Generic; using System.Linq; using E = System.Linq.Enumerable; class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); // var A = Console.ReadLine().Split(' ').Select(x => // int.Parse(x)).ToArray(); // Console.WriteLine((long)Math.Ceiling(123456789.0/-2.0)); // Console.WriteLine(hihur(123456789,-2)); // Console.WriteLine(hihur(123456789,-2)); if (BaseM2(N) == "") { Console.WriteLine(0); } else { Console.WriteLine(BaseM2(N)); } } static string BaseM2(long N) { if (N == 0) { // return (hihur(N,-2)).ToString(); return ""; } else { return BaseM2(hihu(N, -2)) + (hihur(N, -2)).ToString(); } }     static long hihu(double m, double n) { if (m < 0 && n < 0) { return (long)(Math.Ceiling(m / n)); } // Console.WriteLine(m/n); long ans = (long)(Math.Ceiling(m / n)); return ans; } static long hihur(long m, long n) { return m - hihu(m, n) * n; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 213, 63, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 5, 0, 62], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
209
22
using System; using static System.Console; class Program { public static void Main() { long n = long.Parse(ReadLine()); long m = 0; string ans = ""; long x = 1; // (-2)^k long y = 2; // 2^(k+1) while (n != m) { long mm = n % y; if (mm < 0) mm += y; if (mm >= y / 2) { ans = "1" + ans; n -= x; } else ans = "0" + ans; x *= -2; y *= 2; } WriteLine(ans); } }
using System; using static System.Console; class Proram { public static void Main() { long n = long.Parse(ReadLine()); if (n == 0) { WriteLine(0); return; } long m = 0; string ans = ""; long x = 1; // (-2)^k long y = 2; // 2^(k+1) while (n != m) { long mm = n % y; if (mm < 0) mm += y; if (mm >= y / 2) { ans = "1" + ans; n -= x; } else ans = "0" + ans; x *= -2; y *= 2; } WriteLine(ans); } }
[["-", 36, 36, 36, 36, 0, 208, 0, 235, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 235, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
126
17
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; static void Main() { Sc sc = new Sc(); var s = sc.Ia; Fc fc = new Fc(s[0] + 1); for (int i = 0; i < s[1]; i++) { var e = sc.Ia; fc.Ud(e[0], e[1]); } fc.Dn(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s[2]; i++) { var e = sc.Ia; sb.Append(fc.Get(e[0], e[1], e[0], e[1]) + "\n"); } Console.Write(sb); } } public class Fc { private List<int>[] dat2; private Tuple<int, int, int>[][] dat3; private int m = 1, cnt2 = 0; public Fc(int n) { while (m < n) { m <<= 1; } cnt2 = n; dat2 = new List<int>[n]; dat3 = new Tuple<int, int, int> [m - 1][]; for (int i = 0; i < n; i++) { dat2[i] = new List<int>(); } } public long Get(int x1, int x2, int y1, int y2) { int lb = -1, ub = dat3[0].Length, mid = 0; while (ub - lb > 1) { mid = (ub + lb) >> 1; if (dat3[0][mid].Item1 > y2) { ub = mid; } else { lb = mid; } } int p = ub; lb = -1; ub = dat3[0].Length; while (ub - lb > 1) { mid = (ub + lb) >> 1; if (dat3[0][mid].Item1 >= y1) { ub = mid; } else { lb = mid; } } return Fdg(x1, x2, 0, 0, m - 1, ub, p); } private long Fdg(int a, int b, int k, int l, int r, int la, int ra) { if (r < a || b < l || ra == la) { return 0; } if (a <= l && r <= b) { return ra - la; } else { return Fdg(a, b, k * 2 + 1, l, (l + r) >> 1, dat3[k][la].Item2, dat3[k][ra].Item2) + Fdg(a, b, k * 2 + 2, (l + r + 1) >> 1, r, dat3[k][la].Item3, dat3[k][ra].Item3); } } public void Ud(int x, int y) { dat2[x].Add(y); } public void Dn() { for (int i = 0; i < cnt2; i++) { dat2[i].Sort(); } for (int i = 0; i < cnt2; i += 2) { int l = (i >> 1) + (m >> 1) - 1; if (i + 1 < cnt2) { dat3[l] = new Tuple<int, int, int>[dat2[i].Count + dat2[i + 1].Count + 1]; int j = 0, k = 0; while (j < dat2[i].Count && k < dat2[i + 1].Count) { if (dat2[i][j] < dat2[i + 1][k]) { dat3[l][j + k] = Tuple.Create(dat2[i][j], j, k); j++; } else { dat3[l][j + k] = Tuple.Create(dat2[i + 1][k], j, k); k++; } } while (j < dat2[i].Count) { dat3[l][j + k] = Tuple.Create(dat2[i][j], j, k); j++; } while (k < dat2[i + 1].Count) { dat3[l][j + k] = Tuple.Create(dat2[i + 1][k], j, k); k++; } dat3[l][j + k] = Tuple.Create(int.MaxValue, j, k); } else { dat3[l] = new Tuple<int, int, int>[dat2[i].Count + 1]; for (int j = 0; j < dat2[i].Count; j++) { dat3[l][j] = Tuple.Create(dat2[i][j], j, -1); } dat3[l][dat2[i].Count] = Tuple.Create(int.MaxValue, dat2[i].Count, -1); } } for (int i = (m >> 1) - 2; i >= 0; i--) { if (dat3[(i << 1) + 2] != null) { dat3[i] = new Tuple<int, int, int>[dat3[(i << 1) + 1].Length + dat3[(i << 1) + 2].Length - 1]; int j = 0, k = 0; while (j < dat3[(i << 1) + 1].Length - 1 && k < dat3[(i << 1) + 2].Length - 1) { if (dat3[(i << 1) + 1][j].Item1 < dat3[(i << 1) + 2][k].Item1) { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 1][j].Item1, j, k); j++; } else { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 2][k].Item1, j, k); k++; } } while (j < dat3[(i << 1) + 1].Length - 1) { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 1][j].Item1, j, k); j++; } while (k < dat3[(i << 1) + 2].Length - 1) { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 2][k].Item1, j, k); k++; } dat3[i][j + k] = Tuple.Create(int.MaxValue, j, k); } else if (dat3[(i << 1) + 1] != null) { dat3[i] = new Tuple<int, int, int>[dat3[(i << 1) + 1].Length]; Array.Copy(dat3[(i << 1) + 1], dat3[i], dat3[i].Length - 1); dat3[i][dat3[i].Length - 1] = Tuple.Create(int.MaxValue, 1, 0); } else { dat3[i] = new Tuple<int, int, int>[1]; dat3[i][0] = Tuple.Create(int.MaxValue, 0, 0); } } } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; static void Main() { Sc sc = new Sc(); var s = sc.Ia; Fc fc = new Fc(s[0] + 1); for (int i = 0; i < s[1]; i++) { var e = sc.Ia; fc.Ud(e[0], e[1]); } fc.Dn(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s[2]; i++) { var e = sc.Ia; sb.Append(fc.Get(e[0], e[1], e[0], e[1]) + "\n"); } Console.Write(sb); } } public class Fc { private List<int>[] dat2; private Tuple<int, int, int>[][] dat3; private int m = 1, cnt2 = 0; public Fc(int n) { while (m < n) { m <<= 1; } cnt2 = n; dat2 = new List<int>[n]; dat3 = new Tuple<int, int, int> [m - 1][]; for (int i = 0; i < n; i++) { dat2[i] = new List<int>(); } } public long Get(int x1, int x2, int y1, int y2) { int lb = -1, ub = dat3[0].Length, mid = 0; while (ub - lb > 1) { mid = (ub + lb) >> 1; if (dat3[0][mid].Item1 > y2) { ub = mid; } else { lb = mid; } } int p = ub; lb = -1; ub = dat3[0].Length; while (ub - lb > 1) { mid = (ub + lb) >> 1; if (dat3[0][mid].Item1 >= y1) { ub = mid; } else { lb = mid; } } return Fdg(x1, x2, 0, 0, m - 1, ub, p); } private long Fdg(int a, int b, int k, int l, int r, int la, int ra) { if (r < a || b < l || ra == la) { return 0; } if (a <= l && r <= b) { return ra - la; } else { return Fdg(a, b, k * 2 + 1, l, (l + r) >> 1, dat3[k][la].Item2, dat3[k][ra].Item2) + Fdg(a, b, k * 2 + 2, (l + r + 1) >> 1, r, dat3[k][la].Item3, dat3[k][ra].Item3); } } public void Ud(int x, int y) { dat2[x].Add(y); } public void Dn() { for (int i = 0; i < cnt2; i++) { dat2[i].Sort(); } for (int i = 0; i < cnt2; i += 2) { int l = (i >> 1) + (m >> 1) - 1; if (i + 1 < cnt2) { dat3[l] = new Tuple<int, int, int>[dat2[i].Count + dat2[i + 1].Count + 1]; int j = 0, k = 0; while (j < dat2[i].Count && k < dat2[i + 1].Count) { if (dat2[i][j] < dat2[i + 1][k]) { dat3[l][j + k] = Tuple.Create(dat2[i][j], j, k); j++; } else { dat3[l][j + k] = Tuple.Create(dat2[i + 1][k], j, k); k++; } } while (j < dat2[i].Count) { dat3[l][j + k] = Tuple.Create(dat2[i][j], j, k); j++; } while (k < dat2[i + 1].Count) { dat3[l][j + k] = Tuple.Create(dat2[i + 1][k], j, k); k++; } dat3[l][j + k] = Tuple.Create(int.MaxValue, j, k); } else { dat3[l] = new Tuple<int, int, int>[dat2[i].Count + 1]; for (int j = 0; j < dat2[i].Count; j++) { dat3[l][j] = Tuple.Create(dat2[i][j], j, -1); } dat3[l][dat2[i].Count] = Tuple.Create(int.MaxValue, dat2[i].Count, -1); } } for (int i = (m >> 1) - 2; i >= 0; i--) { if (dat3[(i << 1) + 2] != null) { dat3[i] = new Tuple<int, int, int>[dat3[(i << 1) + 1].Length + dat3[(i << 1) + 2].Length - 1]; int j = 0, k = 0; while (j < dat3[(i << 1) + 1].Length - 1 && k < dat3[(i << 1) + 2].Length - 1) { if (dat3[(i << 1) + 1][j].Item1 < dat3[(i << 1) + 2][k].Item1) { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 1][j].Item1, j, k); j++; } else { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 2][k].Item1, j, k); k++; } } while (j < dat3[(i << 1) + 1].Length - 1) { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 1][j].Item1, j, k); j++; } while (k < dat3[(i << 1) + 2].Length - 1) { dat3[i][j + k] = Tuple.Create(dat3[(i << 1) + 2][k].Item1, j, k); k++; } dat3[i][j + k] = Tuple.Create(int.MaxValue, j, k); } else if (dat3[(i << 1) + 1] != null) { dat3[i] = new Tuple<int, int, int>[dat3[(i << 1) + 1].Length]; Array.Copy(dat3[(i << 1) + 1], dat3[i], dat3[i].Length - 1); dat3[i][dat3[i].Length - 1] = Tuple.Create(int.MaxValue, dat3[i].Length - 1, 0); } else { dat3[i] = new Tuple<int, int, int>[1]; dat3[i][0] = Tuple.Create(int.MaxValue, 0, 0); } } } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
[["+", 0, 28, 0, 16, 31, 214, 205, 204, 205, 22], ["+", 0, 16, 31, 214, 205, 204, 206, 207, 0, 70], ["+", 31, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 31, 214, 205, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33]]
8
2,470
7
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Ccs { class Program { static void Main(string[] args) { // Console.WriteLine(-10 % 3); var n = Int64.Parse(Console.ReadLine()); // Console.WriteLine(n); var log = new ArrayList(); var i = 0; while (n != 0) { var r = n % (Int64)Math.Pow(2, i + 1); log.Add(r != 0 ? 1 : 0); n += r * (i % 2 == 0 ? -1 : 1) * (n < 0 ? -1 : 1); Console.WriteLine(i + " " + r + " " + n); ++i; } if (log.Count == 0) Console.Write(0); else for (int j = 0; j < log.Count; ++j) Console.Write(log[log.Count - j - 1]); Console.WriteLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Ccs { class Program { static void Main(string[] args) { // Console.WriteLine(-10 % 3); var n = Int64.Parse(Console.ReadLine()); // Console.WriteLine(n); var log = new ArrayList(); var i = 0; while (n != 0) { var r = n % (Int64)Math.Pow(2, i + 1); log.Add(r != 0 ? 1 : 0); n += r * (i % 2 == 0 ? -1 : 1) * (n < 0 ? -1 : 1); // Console.WriteLine(i + " " + r + " " + n); ++i; } if (log.Count == 0) Console.Write(0); else for (int j = 0; j < log.Count; ++j) Console.Write(log[log.Count - j - 1]); Console.WriteLine(); } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 222], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 17, 72], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["-", 0, 28, 0, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
8
224
19
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0035 { class Program { static void Main(string[] args) { var s = Console.ReadLine(); int A = int.Parse(s.Split(' ')[0]); int B = int.Parse(s.Split(' ')[1]); if (A % B == 0) { Console.WriteLine("0"); return; } var md = A % B; var result = Math.Abs(A / B - md); Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0035 { class Program { static void Main(string[] args) { var s = Console.ReadLine(); int A = int.Parse(s.Split(' ')[0]); int B = int.Parse(s.Split(' ')[1]); if (A % B == 0) { Console.WriteLine("0"); return; } Console.WriteLine("1"); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
144
25
using System; using System.Collections.Generic; class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); Stack<int> d = new Stack<int>(); while (N != 0) { if (N % 2 != 0) { d.Push(1); N--; } else d.Push(0); N /= 2; N = -N; } while (d.Count != 0) Console.Write(d.Pop()); Console.WriteLine(); } }
using System; using System.Collections.Generic; class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); Stack<int> d = new Stack<int>(); while (N != 0) { if (N % 2 != 0) { d.Push(1); N--; } else d.Push(0); N /= 2; N = -N; } if (d.Count == 0) Console.WriteLine(0); else { while (d.Count != 0) Console.Write(d.Pop()); Console.WriteLine(); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
120
18
using System; using System.Collections.Generic; using System.Linq; 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 Int() { 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] = Int() + add; } return Array; } public long Long() { 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] = Long() + add; } return Array; } } class Program { static Scanner cin = new Scanner(); static void Main() { long N = cin.Long(); string ans = ""; while (N != 0) { if (N % 2 == 0) { ans = "0" + ans; N /= -2; } else { ans = "1" + ans; N = (N - 1) / (-2); } } Console.WriteLine(ans); Console.ReadLine(); } }
using System; using System.Collections.Generic; using System.Linq; 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 Int() { 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] = Int() + add; } return Array; } public long Long() { 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] = Long() + add; } return Array; } } class Program { static Scanner cin = new Scanner(); static void Main() { long N = cin.Long(); if (N == 0) Console.WriteLine(0); else { string ans = ""; while (N != 0) { if (N % 2 == 0) { ans = "0" + ans; N /= -2; } else { ans = "1" + ans; N = (N - 1) / (-2); } } Console.WriteLine(ans); } Console.ReadLine(); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
394
16
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Convert; using static System.Console; using static System.Math; class MainClass { static void Main(string[] args) { Answer(); } public static void Answer() { var cin = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var N = cin[0]; var K = cin[1]; var amari = N % K; if (amari < 0) Console.WriteLine("1"); else Console.WriteLine("0"); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Convert; using static System.Console; using static System.Math; class MainClass { static void Main(string[] args) { Answer(); } public static void Answer() { var cin = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var N = cin[0]; var K = cin[1]; var amari = N % K; if (amari == 0) Console.WriteLine("0"); else Console.WriteLine("1"); } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
140
6
using System; using System.Linq; class p { static void Main() { int N = int.Parse(Console.ReadLine()); string ans = ""; while (N != 0) { if (N % 2 != 0) { ans = "1" + ans; N = (N - 1) / -2; } else { ans = "0" + ans; N /= -2; } } Console.WriteLine(ans); } }
using System; using System.Linq; class p { static void Main() { int N = int.Parse(Console.ReadLine()); string ans = ""; while (N != 0) { if (N % 2 != 0) { ans = "1" + ans; N = (N - 1) / -2; } else { ans = "0" + ans; N /= -2; } } Console.WriteLine(ans == "" ? "0" : ans); } }
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 0, 28, 0, 41, 15, 16, 12, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22]]
8
99
9
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace ConsoleApp1 { class Program { static void Main(string[] args) { A(); } static void A() { var NK = ReadSplitInt(); if (NK[0] % NK[1] == 0) { Println(0); } else { Println((NK[0] / NK[1]) - (NK[0] % NK[1])); } } static List<long> ReadLines(long n) { var l = new List<long>(); for (long i = 0; i < n; i++) { l.Add(ReadLong()); } return l; } static IEnumerable<int> Range(int start, int stop) { if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0)) return new List<int>(); return Enumerable.Range(start, stop - start); } static bool IsDigit(string str) { var i = 0; return int.TryParse(str, out i); } static int SumDigits(long num) { return num.ToString().Select(x => x.ToString()).Sum(int.Parse); } static int[] ToIntArray(string str) { return str.Select(x => x.ToString()).Select(int.Parse).ToArray(); } static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b); static long Lcm(long a, long b) => a / Gcd(a, b) * b; static bool IsPrime(int x) { if (x <= 1 || (x != 2 && x % 2 == 0)) return false; if (x == 2) return true; for (int i = 3; i < x; i += 2) if (x % i == 0) return false; return true; } static string Read() => Console.ReadLine(); static int ReadInt() => int.Parse(Read()); static long ReadLong() => long.Parse(Read()); static List<string> ReadSplit() => Read().Split().ToList(); static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList(); static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList(); static void Print(object value) => Console.Write(value.ToString()); static void Println(object value) => Console.WriteLine(value.ToString()); static string Join<T>(IEnumerable<T> list) => string.Join("", list); } public static class MyExtensions { public static string Slice(this string str, int start = 0, int stop = 0) { if (start > str.Length || stop > str.Length || start < 0 || stop < 0) return ""; if (stop == 0) stop = str.Length; return str.Substring(start, stop - start); } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; namespace ConsoleApp1 { class Program { static void Main(string[] args) { A(); } static void A() { var NK = ReadSplitInt(); if (NK[0] % NK[1] == 0) { Println(0); } else { Println(1); } } static List<long> ReadLines(long n) { var l = new List<long>(); for (long i = 0; i < n; i++) { l.Add(ReadLong()); } return l; } static IEnumerable<int> Range(int start, int stop) { if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0)) return new List<int>(); return Enumerable.Range(start, stop - start); } static bool IsDigit(string str) { var i = 0; return int.TryParse(str, out i); } static int SumDigits(long num) { return num.ToString().Select(x => x.ToString()).Sum(int.Parse); } static int[] ToIntArray(string str) { return str.Select(x => x.ToString()).Select(int.Parse).ToArray(); } static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b); static long Lcm(long a, long b) => a / Gcd(a, b) * b; static bool IsPrime(int x) { if (x <= 1 || (x != 2 && x % 2 == 0)) return false; if (x == 2) return true; for (int i = 3; i < x; i += 2) if (x % i == 0) return false; return true; } static string Read() => Console.ReadLine(); static int ReadInt() => int.Parse(Read()); static long ReadLong() => long.Parse(Read()); static List<string> ReadSplit() => Read().Split().ToList(); static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList(); static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList(); static void Print(object value) => Console.Write(value.ToString()); static void Println(object value) => Console.WriteLine(value.ToString()); static string Join<T>(IEnumerable<T> list) => string.Join("", list); } public static class MyExtensions { public static string Slice(this string str, int start = 0, int stop = 0) { if (start > str.Length || stop > str.Length || start < 0 || stop < 0) return ""; if (stop == 0) stop = str.Length; return str.Substring(start, stop - start); } } }
[["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 85], ["-", 0, 16, 31, 23, 0, 16, 12, 204, 205, 22], ["-", 31, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 31, 204, 205, 22], ["-", 12, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 17, 109], ["-", 0, 16, 12, 23, 0, 16, 12, 204, 205, 22], ["-", 12, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["-", 12, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
8
689
22
using System; using System.Linq; using System.Collections.Generic; namespace program { class Program { static void Main() { int[] a = Input.ScanIntArray(); if (a[0] < a[1]) Console.WriteLine(1); else Console.WriteLine(a[0] - (a[0] / a[1]) * a[1]); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(' '); } } static class MyMath { public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong GCD(ulong a, ulong b) { Func<ulong, ulong, ulong> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); } } }
using System; using System.Linq; using System.Collections.Generic; namespace program { class Program { static void Main() { int[] a = Input.ScanIntArray(); Console.WriteLine(a[0] % a[1] == 0 ? 0 : 1); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(' '); } } static class MyMath { public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong GCD(ulong a, ulong b) { Func<ulong, ulong, ulong> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["-", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["-", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["-", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 28, 0, 16, 12, 16, 31, 23, 0, 24], ["-", 12, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109], ["-", 0, 28, 0, 16, 12, 16, 31, 23, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 12, 16, 17, 48], ["-", 0, 28, 0, 16, 12, 16, 12, 204, 205, 22], ["-", 0, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["-", 0, 16, 12, 16, 12, 204, 206, 207, 0, 73]]
8
619
38
using System; using System.Collections.Generic; using System.Linq; namespace ABC105C { static class MainClass { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); if (N == 0) { Console.WriteLine("0"); return; } int diff = N; var anslist = new List<int>(); int anstmp = 0; while (diff != 0) { anstmp = GetInitial(diff); anslist.Add(anstmp); diff = diff - (int)Math.Pow(-2, anstmp); } string ans = ""; int tmp = anslist.First(); foreach (int item in anslist) { for (int i = 0; i < tmp - item - 1; i++) { ans += "0"; } ans += "1"; tmp = item; } Console.WriteLine(ans); } public static int GetInitial(int a) { long tmp = 0; if (a < 0) { for (int i = 0; i < -a; i++) { tmp = tmp + (int)Math.Pow(-2, 2 * i + 1); if (a >= tmp) { return 2 * i + 1; } } } else { for (int i = 0; i < a; i++) { tmp = tmp + (int)Math.Pow(-2, 2 * i); if (a <= tmp) { return 2 * i; } } } return 0; } public static long Gcd(long a, long b) { long tmp; // a<bにする if (a >= b) { tmp = a; a = b; b = tmp; } if (a == 0) { return b; } tmp = a; a = b % a; b = tmp; return Gcd(a, b); } public static IEnumerable<long> PF(long n) { long i = 2; long tmp = n; while (i * i <= n) //※1 { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; //最後の素数も返す } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC105C { static class MainClass { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); if (N == 0) { Console.WriteLine("0"); return; } int diff = N; var anslist = new List<int>(); int anstmp = 0; while (diff != 0) { anstmp = GetInitial(diff); anslist.Add(anstmp); diff = diff - (int)Math.Pow(-2, anstmp); // Console.WriteLine("diff: " + diff.ToString() + "anstmp: " + // anstmp.ToString()); } string ans = ""; int tmp = anslist.First(); foreach (int item in anslist) { for (int i = 0; i < tmp - item - 1; i++) { ans += "0"; } ans += "1"; tmp = item; } if (tmp > 0) { for (int i = 0; i < tmp; i++) { ans += "0"; } } Console.WriteLine(ans); } public static int GetInitial(int a) { long tmp = 0; if (a < 0) { for (int i = 0; i < -a; i++) { tmp = tmp + (int)Math.Pow(-2, 2 * i + 1); if (a >= tmp) { return 2 * i + 1; } } } else { for (int i = 0; i < a; i++) { tmp = tmp + (int)Math.Pow(-2, 2 * i); if (a <= tmp) { return 2 * i; } } } return 0; } public static long Gcd(long a, long b) { long tmp; // a<bにする if (a >= b) { tmp = a; a = b; b = tmp; } if (a == 0) { return b; } tmp = a; a = b % a; b = tmp; return Gcd(a, b); } public static IEnumerable<long> PF(long n) { long i = 2; long tmp = n; while (i * i <= n) //※1 { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; //最後の素数も返す } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 88], ["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 24], ["+", 0, 57, 64, 196, 0, 7, 10, 198, 39, 199], ["+", 64, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 35], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 25], ["+", 0, 57, 64, 196, 0, 7, 8, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 8, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 7, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
465
30
using System; using System.Collections.Generic; using System.Linq; class Procon { public Procon() {} static void Main(string[] agrs) { new Procon().Do(); } Scanner cin; public void Do() { cin = new Scanner(); int N = cin.nextInt(); int K = cin.nextInt(); Console.WriteLine((N / K - N % K) % K); } } class Scanner { string[] s; int i; int max_i; public Scanner() { s = new string[0]; max_i = 0; i = 0; } public string nextString() { if (i >= s.Length) { s = Console.ReadLine().Split(' '); max_i = s.Length; i = 0; if (max_i == 0) { return ""; } return s[i++]; } else { return s[i++]; } } public int nextInt() { return int.Parse(nextString()); } public long nextLong() { return long.Parse(nextString()); } public double nextDouble() { return double.Parse(nextString()); } public string[] arrayString() { return Console.ReadLine().Split(' '); } public int[] arrayInt() { string[] str = Console.ReadLine().Split(' '); int[] array = new int[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = int.Parse(str[i]); } return array; } public long[] arrayLong() { string[] str = Console.ReadLine().Split(' '); long[] array = new long[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = long.Parse(str[i]); } return array; } public double[] arrayDouble() { string[] str = Console.ReadLine().Split(' '); double[] array = new double[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = double.Parse(str[i]); } return array; } }
using System; using System.Collections.Generic; using System.Linq; class Procon { public Procon() {} static void Main(string[] agrs) { new Procon().Do(); } Scanner cin; public void Do() { cin = new Scanner(); int N = cin.nextInt(); int K = cin.nextInt(); if (N % K == 0) { Console.WriteLine(0); return; } Console.WriteLine(1); } } class Scanner { string[] s; int i; int max_i; public Scanner() { s = new string[0]; max_i = 0; i = 0; } public string nextString() { if (i >= s.Length) { s = Console.ReadLine().Split(' '); max_i = s.Length; i = 0; if (max_i == 0) { return ""; } return s[i++]; } else { return s[i++]; } } public int nextInt() { return int.Parse(nextString()); } public long nextLong() { return long.Parse(nextString()); } public double nextDouble() { return double.Parse(nextString()); } public string[] arrayString() { return Console.ReadLine().Split(' '); } public int[] arrayInt() { string[] str = Console.ReadLine().Split(' '); int[] array = new int[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = int.Parse(str[i]); } return array; } public long[] arrayLong() { string[] str = Console.ReadLine().Split(' '); long[] array = new long[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = long.Parse(str[i]); } return array; } public double[] arrayDouble() { string[] str = Console.ReadLine().Split(' '); double[] array = new double[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = double.Parse(str[i]); } return array; } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 85], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
8
507
29
using System; namespace ABC105 { class TaskC { public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string ans = ""; while (n != 0) { if (n % 2 != 0) { ans = "1" + ans; n = n - 1; } else { ans = "0" + ans; } n /= -2; } Console.WriteLine(ans); } } }
using System; namespace ABC105 { class TaskC { public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string ans = ""; if (n == 0) { Console.WriteLine("0"); return; } while (n != 0) { if (n % 2 != 0) { ans = "1" + ans; n = n - 1; } else { ans = "0" + ans; } n /= -2; } Console.WriteLine(ans); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
98
19
using System; using System.Collections.Generic; using System.Text; namespace AtCoder { public class Program { // ABC105-C static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int posi = 0, nega = 0, diff = N; int[] pattern = new int[32]; int m = 1; for (int i = 0; i < pattern.Length; i++) { pattern[i] = m; m = (m << 1) | i % 2; } while (true) { if (diff == 0) { // 終了 Console.WriteLine(Convert.ToString(posi + nega, 2)); return; } else if (diff > 0) { // 正 int i = 0; while (pattern[i] < diff) { i += 2; } posi += 1 << i; } else { // 負 int i = 1; while (-1 * pattern[i] > diff) { i += 2; } nega += 1 << i; } diff = N - (posi + (-1 * nega)); } } } }
using System; using System.Collections.Generic; using System.Text; namespace AtCoder { public class Program { // ABC105-C static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long posi = 0, nega = 0, diff = N; long[] pattern = new long[64]; long m = 1; for (long i = 0; i < pattern.Length; i++) { pattern[i] = m; m = (m << 1) | i % 2; } while (true) { if (diff == 0) { // 終了 Console.WriteLine(Convert.ToString(posi + nega, 2)); return; } else if (diff > 0) { // 正 int i = 0; while (pattern[i] < diff) { i += 2; } posi += 1L << i; } else { // 負 int i = 1; while (-1 * pattern[i] > diff) { i += 2; } nega += 1L << i; } diff = N - (posi + (-1 * nega)); } } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 31, 203], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 203], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 31, 203], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 31, 203]]
8
233
16
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace At { class Program { static void Main(string[] args) { var nk = ReadInts(); WriteLine(nk[0] % nk[1]); } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace At { class Program { static void Main(string[] args) { var r = ReadInts(); if (r[0] % r[1] == 0) { WriteLine(0); } else { WriteLine(1); } } private static string Read() { return ReadLine(); } private static string[] Reads() { return (Read().Split()); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 3, 4, 0, 28, 0, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 213, 63, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
243
24
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp { class Program { static void Main(string[] args) { var strs = Console.ReadLine().Split(); var N = int.Parse(strs[0]); var K = int.Parse(strs[1]); Console.WriteLine(N % K); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp { class Program { static void Main(string[] args) { var strs = Console.ReadLine().Split(); var N = int.Parse(strs[0]); var K = int.Parse(strs[1]); Console.WriteLine(N % K == 0 ? "0" : "1"); } } }
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
8
82
10
using System; using System.Collections.Generic; using System.Linq; namespace ABC104A { class ABC104A { static void Main(string[] args) { var n = double.Parse(Console.ReadLine()); foreach (var v in Solve(n).Reverse()) { Console.Write(v); } Console.WriteLine(); } static string Solve(double n) { const double dec = -2; if (n == 0) { return "0"; } var s = ""; double k = n < 0 ? -1 : 1; while (n != 0) { if (n % dec == 0) { s += "0"; } else { s += "1"; --n; } n /= dec; Console.WriteLine(n); } return s; } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC104A { class ABC104A { static void Main(string[] args) { var n = double.Parse(Console.ReadLine()); foreach (var v in Solve(n).Reverse()) { Console.Write(v); } Console.WriteLine(); } static string Solve(double n) { const double dec = -2; if (n == 0) { return "0"; } var s = ""; double k = n < 0 ? -1 : 1; while (n != 0) { if (n % dec == 0) { s += "0"; } else { s += "1"; --n; } n /= dec; } return s; } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
8
174
7
using System; using System.Collections.Generic; using System.Text; namespace AtTest.ABC_105 { class C { static void Main(string[] args) { Method(args); Console.ReadLine(); } static void Method(string[] args) { int n = int.Parse(Console.ReadLine()); if (n == 0) { Console.WriteLine(0); } //指数が小さいほうからスタートするのがポイント var haveIndexList = new List<bool>(); int checkIndex = 1; while (n != 0) { if (Math.Abs(n) % (1 << checkIndex) != 0) { haveIndexList.Add(true); int val = (1 << (checkIndex - 1)); if ((checkIndex - 1) % 2 == 1) val *= -1; n -= val; } else { haveIndexList.Add(false); } checkIndex++; } string result = ""; for (int i = haveIndexList.Count - 1; i >= 0; i--) { result += haveIndexList[i] ? '1' : '0'; } Console.WriteLine(result); } } }
using System; using System.Collections.Generic; namespace AtTest.ABC_105 { class C { static void Main(string[] args) { Method(args); Console.ReadLine(); } static void Method(string[] args) { long n = long.Parse(Console.ReadLine()); if (n == 0) { Console.WriteLine(0); } //指数が小さいほうからスタートするのがポイント var haveIndexList = new List<bool>(); long checkIndex = 1; while (n != 0) { if (Math.Abs(n) % Math.Pow(2, checkIndex) != 0) { haveIndexList.Add(true); long val = (long)Math.Pow(2, checkIndex - 1); if ((checkIndex - 1) % 2 == 1) val *= -1; n -= val; } else { haveIndexList.Add(false); } checkIndex++; } string result = ""; for (int i = haveIndexList.Count - 1; i >= 0; i--) { result += haveIndexList[i] ? '1' : '0'; } Console.WriteLine(result); } } }
[["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["-", 15, 16, 31, 16, 12, 23, 0, 16, 31, 203], ["-", 15, 16, 31, 16, 12, 23, 0, 16, 17, 151], ["+", 31, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 21], ["-", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 23, 0, 16, 31, 203], ["-", 0, 200, 0, 212, 0, 23, 0, 16, 17, 151], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 74, 51, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 212, 0, 74, 51, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 23, 0, 16, 12, 23, 0, 25]]
8
233
30
using System; using System.Linq; public class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); string res = ""; while (N != 0) { if (N % 2 == 1) { res += "1"; N--; } else { res += "0"; } N /= -2; } if (N == 0) res = "0"; res = string.Join("", res.ToArray().Reverse()); Console.WriteLine(res); } }
using System; using System.Linq; public class Program { public static void Main() { int N = int.Parse(Console.ReadLine()); string res = ""; while (N != 0) { if (N % 2 != 0) { res += "1"; N--; } else { res += "0"; } N /= -2; } if (res == "") res = "0"; res = string.Join("", res.ToArray().Reverse().ToArray()); Console.WriteLine(res); } }
[["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 5, 0, 62], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22]]
8
121
13
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; using static System.Console; using static System.Math; class Z { static void Main() => new K(); } class K { int F => int.Parse(Str); long FL => long.Parse(Str); int[] G => Strs.Select(int.Parse).ToArray(); long[] GL => Strs.Select(long.Parse).ToArray(); string Str => ReadLine(); string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); const int MOD = 1000000007; public K() { SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); Out.Flush(); } void Solve() { var N = FL; var l = new List<long>(); while (N != 0) { int r = N % 2 == 0 ? 0 : 1; WriteLine($"{N} {r}"); N = (N - r) / (-2); l.Add(r); } l.Reverse(); if (l.Count == 0) l.Add(0); WriteLine(string.Join("", l)); } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; using static System.Console; using static System.Math; class Z { static void Main() => new K(); } class K { int F => int.Parse(Str); long FL => long.Parse(Str); int[] G => Strs.Select(int.Parse).ToArray(); long[] GL => Strs.Select(long.Parse).ToArray(); string Str => ReadLine(); string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); const int MOD = 1000000007; public K() { SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); Out.Flush(); } void Solve() { var N = FL; var l = new List<long>(); while (N != 0) { int r = N % 2 == 0 ? 0 : 1; N = (N - r) / (-2); l.Add(r); } l.Reverse(); if (l.Count == 0) l.Add(0); WriteLine(string.Join("", l)); } }
[["-", 0, 52, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22]]
8
312
13
using System; class Program { static void Main(string[] args) { // 整数の入力 string input = Console.ReadLine(); int N = int.Parse(input); // atcoderってこんな数学な感じなんですか・・・ // なんとなく普通の二進数にしたあと奇数番と偶数番でうなるのがいい気がしてきた int[] Splus = new int[34]; int[] Shonmono = new int[34]; //// そっかプラスだけじゃないんかぁ // int pn = 0; // if (N >= 0) { // pn = 1; //} // else //{ // pn = 0; // N = -N; //} //普通に二進数 for (int i = 0; i < 34; i++) { if (i % 2 == 0) { if (N % 2 != 0) { Shonmono[i] = 1; N = N - 1; } } else { if (N % 2 != 0) { Shonmono[i] = 1; N = N + 1; } } N = N / 2; } ////偶数番の2倍の分だけ低くなるのかな?・・・・・・ // for (int i = 0; i < 16; i++) //{ // if (Splus[i] == 1) // { // Shonmono[i + 1]++; // } //} ////めっちゃ考えた末、桁をあげるには上二つを1増やせばいいと思った。 // for (int i = 0; i < 32; i++) //{ // if (Shonmono[i] > 1) // { // Shonmono[i + 1] += 1; // Shonmono[i + 2] += 1; // Shonmono[i] -= 2; // } //} int max = 0; for (int i = 33; i > 0; i--) { if (Shonmono[i] == 0) { max = i; } else { break; } } String result = ""; for (int i = 0; i < max; i++) { result += Shonmono[i]; } //出力 Console.WriteLine(result); // System.Threading.Thread.Sleep(30000); } }
using System; class Program { static void Main(string[] args) { // 整数の入力 string input = Console.ReadLine(); int N = int.Parse(input); // atcoderってこんな数学な感じなんですか・・・ // なんとなく普通の二進数にしたあと奇数番と偶数番でうなるのがいい気がしてきた int[] Splus = new int[34]; int[] Shonmono = new int[34]; //// そっかプラスだけじゃないんかぁ // int pn = 0; // if (N >= 0) { // pn = 1; //} // else //{ // pn = 0; // N = -N; //} //普通に二進数 for (int i = 0; i < 34; i++) { if (i % 2 == 0) { if (N % 2 != 0) { Shonmono[i] = 1; N = N - 1; } } else { if (N % 2 != 0) { Shonmono[i] = 1; N = N + 1; } } N = N / 2; } ////偶数番の2倍の分だけ低くなるのかな?・・・・・・ // for (int i = 0; i < 16; i++) //{ // if (Splus[i] == 1) // { // Shonmono[i + 1]++; // } //} ////めっちゃ考えた末、桁をあげるには上二つを1増やせばいいと思った。 // for (int i = 0; i < 32; i++) //{ // if (Shonmono[i] > 1) // { // Shonmono[i + 1] += 1; // Shonmono[i + 2] += 1; // Shonmono[i] -= 2; // } //} int max = 0; for (int i = 33; i > 0; i--) { if (Shonmono[i] == 0) { max = i; } else { break; } } String result = ""; for (int i = max - 1; i >= 0; i--) { result += Shonmono[i]; } //出力 Console.WriteLine(result); // System.Threading.Thread.Sleep(30000); } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68]]
8
251
10
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int n = int.Parse(str[0]); string output = ""; int baseNum = -2; List<int> nums = new List<int>(); while (n != 0) { nums.Add(seizyoyo(n, baseNum)); n = (n - seizyoyo(n, baseNum)) / baseNum; // Console.WriteLine(n); } for (int i = 0; i < nums.Count; i++) { output += nums[nums.Count - 1 - i].ToString(); } //出力 Console.WriteLine(output); } static int seizyoyo(int n, int m) { int amari = 0; if (n >= 0) { amari = n % m; } else { amari = (-n) % m; } return amari; } }
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int n = int.Parse(str[0]); string output = ""; int baseNum = -2; List<int> nums = new List<int>(); while (n != 0) { nums.Add(seizyoyo(n, baseNum)); n = (n - seizyoyo(n, baseNum)) / baseNum; // Console.WriteLine(n); } if (nums.Count == 0) { output = "0"; } else { for (int i = 0; i < nums.Count; i++) { output += nums[nums.Count - 1 - i].ToString(); } } //出力 Console.WriteLine(output); } static int seizyoyo(int n, int m) { int amari = 0; if (n >= 0) { amari = n % m; } else { amari = (-n) % m; } return amari; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 7, 8, 196, 0, 46]]
8
207
19
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using static System.Console; using static AtCoder.Util; using static AtCoder.Cin; using static System.Math; namespace AtCoder { class Program { static void Main() => ReadLong().Call(ToNegabinary).WriteLine(); static string ToNegabinary(long value) { string result = string.Empty; while (value != 0) { long remainder = value % -2; value = value / -2; if (remainder < 0) { remainder += 2; value += 1; } result = remainder.ToString() + result; } return result; } } } /* ***************** Following Contents are my common library ******** */ namespace AtCoder { static class Util { public static IEnumerable<int> Factors(this int n) { for (int i = 1; i <= n; i++) if (n % i == 0) yield return i; } public static IEnumerable<int> Natural() { for (int i = 0;; i++) yield return i; } public static int Pow(int i, int exp) => (exp == 0) ? 1 : i * Pow(i, exp - 1); public static HashSet<T> ToHashSet<T>(this IEnumerable<T> source) => new HashSet<T>(source); public static MultiSet<T> ToMultiSet<T>(this IEnumerable<T> t) => new MultiSet<T>(t); public static int Plus(this int i, int j) => i + j; public static int Max(this int i, int j) => i > j? i : j; public static bool IsPalindrome(string s) { for (int i = 0; i < s.Length / 2; i++) { if (s[i] != s[s.Length - 1 - i]) return false; } return true; } public readonly static VectorInt2[] Dir8 = { new VectorInt2(-1, -1), new VectorInt2(-1, 0), new VectorInt2(-1, 1), new VectorInt2(0, -1), new VectorInt2(0, 1), new VectorInt2(1, -1), new VectorInt2(1, 0), new VectorInt2(1, 1) }; public const long MODCONST = 1000000007; public static T debug<T>(this T value) { Console.Error.WriteLine($"debug:{value}"); return value; } public static T Id<T>(T t) => t; public static long ToLong(this String s) => long.Parse(s); public static long ToLong(this char c) => c - '0'; public static int ToInt(this String s) => int.Parse(s); public static int ToInt(this char c) => c - '0'; public static void Times(this int n, Action action) { for (int i = 0; i < n; i++) action(); } public static void Times(this long n, Action action) { for (long i = 0; i < n; i++) action(); } public static IEnumerable<T> Times<T>(this int n, Func<T> func) { for (long i = 0; i < n; i++) yield return func(); } public static IEnumerable<T> Times<T>(this long n, Func<T> func) { for (long i = 0; i < n; i++) yield return func(); } public static void Call<T>(this T t, Action<T> action) => action(t); public static bool In<T>(this T t, IEnumerable<T> range) => range.Contains(t); public static void WriteLine<T>(this T t) => Console.WriteLine(t); public static T Call<S, T>(this S s, Func<S, T> func) => func(s); public static void Each<T>(this IEnumerable<T> e, Action<T> action) { foreach (var v in e) action(v); } public static IEnumerable<int> FromTo(int a, int b) => Range(a, Max(b - a + 1, 0)); public static IEnumerable<T> Repeat<T>(T t) { while (true) yield return t; } public static IEnumerable<T> Replicate<T>(int n, T t) => Repeat(t).Take(n); public static IEnumerable<T> Cycle<T>(IEnumerable<T> e) { while (true) foreach (var v in e) yield return v; } public static VectorInt2 ReadVectorInt2() => new VectorInt2(ReadInt(), ReadInt()); public static string ReplaceX(this string input, string pattern, string replace) => Regex.Replace(input, pattern, replace); public static IEnumerable<int> Range(int i, int j) => Enumerable.Range(i, j); public static IEnumerable<long> Range(long i, long j) { for (long k = i; k < i + j; k++) yield return k; } public static void Swap<T>(this IList<T> enumerable, int i, int j) { var buf = enumerable[i]; enumerable[i] = enumerable[j]; enumerable[j] = buf; } public static void ReverseRange<T>(this IList<T> enumerable, int i, int j) { int half = (j - i) / 2; for (int k = 0; k <= half; k++) enumerable.Swap(i + k, j - k); } public static bool isEmpty<T>(this IEnumerable<T> enumerable) => !enumerable.Any(); } static class Cin { private static Queue<string> tokens; static Cin() { string line; tokens = new Queue<string>(); while ((line = Console.ReadLine()) != null) { foreach (var token in line.Split(' ')) { tokens.Enqueue(token); } } } static public int ReadInt() => int.Parse(tokens.Dequeue()); static public IList<int> ReadInt(long n) { var list = new List<int>(); n.Times(() => list.Add(ReadInt())); return list; } static public long ReadLong() => long.Parse(tokens.Dequeue()); static public IList<long> ReadLong(long n) { var list = new List<long>(); n.Times(() => list.Add(ReadLong())); return list; } static public string ReadString() => tokens.Dequeue(); static public IList<string> ReadString(long n) { var list = new List<string>(); n.Times(() => list.Add(ReadString())); return list; } } struct VectorInt2 { public int X { get; set; } public int Y { get; set; } public VectorInt2(int x, int y) { X = x; Y = y; } static public VectorInt2 operator +(VectorInt2 v1, VectorInt2 v2) => new VectorInt2(v1.X + v2.X, v1.Y + v2.Y); static public VectorInt2 operator -(VectorInt2 v1, VectorInt2 v2) => new VectorInt2(v1.X - v2.X, v1.Y - v2.Y); static public VectorInt2 operator *(VectorInt2 v1, VectorInt2 v2) => new VectorInt2(v1.X * v2.X, v1.Y *v2.Y); static public VectorInt2 operator *(VectorInt2 v1, int i) => new VectorInt2(v1.X * i, v1.Y *i); static public VectorInt2 operator *(int i, VectorInt2 v2) => new VectorInt2(i * v2.X, i *v2.Y); static public VectorInt2 operator /(VectorInt2 v1, int i) => new VectorInt2(v1.X / i, v1.Y / i); } class Maxer<T> where T : IComparable<T> { public T Value; public Maxer(T t) { Value = t; } public void Max(T other) { if (Value.CompareTo(other) < 0) Value = other; } } class MultiSet<T> : IEnumerable<KeyValuePair<T, int>> { Dictionary<T, int> dictionary = new Dictionary<T, int>(); public MultiSet(IEnumerable<T> data) { foreach (var datum in data) { if (dictionary.ContainsKey(datum)) { dictionary[datum]++; } else { dictionary[datum] = 1; } } } public int this[T key] { get { return dictionary.ContainsKey(key) ? dictionary[key] : 0; } } public MultiSet() {} public Dictionary<T, int> AsDict() => dictionary; public IEnumerator<KeyValuePair<T, int>> GetEnumerator() => dictionary.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using static System.Console; using static AtCoder.Util; using static AtCoder.Cin; using static System.Math; namespace AtCoder { class Program { static void Main() => ReadLong().Call(ToNegabinary).WriteLine(); static string ToNegabinary(long value) { if (value == 0) return "0"; string result = string.Empty; while (value != 0) { long remainder = value % -2; value = value / -2; if (remainder < 0) { remainder += 2; value += 1; } result = remainder.ToString() + result; } return result; } } } /* ***************** Following Contents are my common library ******** */ namespace AtCoder { static class Util { public static IEnumerable<int> Factors(this int n) { for (int i = 1; i <= n; i++) if (n % i == 0) yield return i; } public static IEnumerable<int> Natural() { for (int i = 0;; i++) yield return i; } public static int Pow(int i, int exp) => (exp == 0) ? 1 : i * Pow(i, exp - 1); public static HashSet<T> ToHashSet<T>(this IEnumerable<T> source) => new HashSet<T>(source); public static MultiSet<T> ToMultiSet<T>(this IEnumerable<T> t) => new MultiSet<T>(t); public static int Plus(this int i, int j) => i + j; public static int Max(this int i, int j) => i > j? i : j; public static bool IsPalindrome(string s) { for (int i = 0; i < s.Length / 2; i++) { if (s[i] != s[s.Length - 1 - i]) return false; } return true; } public readonly static VectorInt2[] Dir8 = { new VectorInt2(-1, -1), new VectorInt2(-1, 0), new VectorInt2(-1, 1), new VectorInt2(0, -1), new VectorInt2(0, 1), new VectorInt2(1, -1), new VectorInt2(1, 0), new VectorInt2(1, 1) }; public const long MODCONST = 1000000007; public static T debug<T>(this T value) { Console.Error.WriteLine($"debug:{value}"); return value; } public static T Id<T>(T t) => t; public static long ToLong(this String s) => long.Parse(s); public static long ToLong(this char c) => c - '0'; public static int ToInt(this String s) => int.Parse(s); public static int ToInt(this char c) => c - '0'; public static void Times(this int n, Action action) { for (int i = 0; i < n; i++) action(); } public static void Times(this long n, Action action) { for (long i = 0; i < n; i++) action(); } public static IEnumerable<T> Times<T>(this int n, Func<T> func) { for (long i = 0; i < n; i++) yield return func(); } public static IEnumerable<T> Times<T>(this long n, Func<T> func) { for (long i = 0; i < n; i++) yield return func(); } public static void Call<T>(this T t, Action<T> action) => action(t); public static bool In<T>(this T t, IEnumerable<T> range) => range.Contains(t); public static void WriteLine<T>(this T t) => Console.WriteLine(t); public static T Call<S, T>(this S s, Func<S, T> func) => func(s); public static void Each<T>(this IEnumerable<T> e, Action<T> action) { foreach (var v in e) action(v); } public static IEnumerable<int> FromTo(int a, int b) => Range(a, Max(b - a + 1, 0)); public static IEnumerable<T> Repeat<T>(T t) { while (true) yield return t; } public static IEnumerable<T> Replicate<T>(int n, T t) => Repeat(t).Take(n); public static IEnumerable<T> Cycle<T>(IEnumerable<T> e) { while (true) foreach (var v in e) yield return v; } public static VectorInt2 ReadVectorInt2() => new VectorInt2(ReadInt(), ReadInt()); public static string ReplaceX(this string input, string pattern, string replace) => Regex.Replace(input, pattern, replace); public static IEnumerable<int> Range(int i, int j) => Enumerable.Range(i, j); public static IEnumerable<long> Range(long i, long j) { for (long k = i; k < i + j; k++) yield return k; } public static void Swap<T>(this IList<T> enumerable, int i, int j) { var buf = enumerable[i]; enumerable[i] = enumerable[j]; enumerable[j] = buf; } public static void ReverseRange<T>(this IList<T> enumerable, int i, int j) { int half = (j - i) / 2; for (int k = 0; k <= half; k++) enumerable.Swap(i + k, j - k); } public static bool isEmpty<T>(this IEnumerable<T> enumerable) => !enumerable.Any(); } static class Cin { private static Queue<string> tokens; static Cin() { string line; tokens = new Queue<string>(); while ((line = Console.ReadLine()) != null) { foreach (var token in line.Split(' ')) { tokens.Enqueue(token); } } } static public int ReadInt() => int.Parse(tokens.Dequeue()); static public IList<int> ReadInt(long n) { var list = new List<int>(); n.Times(() => list.Add(ReadInt())); return list; } static public long ReadLong() => long.Parse(tokens.Dequeue()); static public IList<long> ReadLong(long n) { var list = new List<long>(); n.Times(() => list.Add(ReadLong())); return list; } static public string ReadString() => tokens.Dequeue(); static public IList<string> ReadString(long n) { var list = new List<string>(); n.Times(() => list.Add(ReadString())); return list; } } struct VectorInt2 { public int X { get; set; } public int Y { get; set; } public VectorInt2(int x, int y) { X = x; Y = y; } static public VectorInt2 operator +(VectorInt2 v1, VectorInt2 v2) => new VectorInt2(v1.X + v2.X, v1.Y + v2.Y); static public VectorInt2 operator -(VectorInt2 v1, VectorInt2 v2) => new VectorInt2(v1.X - v2.X, v1.Y - v2.Y); static public VectorInt2 operator *(VectorInt2 v1, VectorInt2 v2) => new VectorInt2(v1.X * v2.X, v1.Y *v2.Y); static public VectorInt2 operator *(VectorInt2 v1, int i) => new VectorInt2(v1.X * i, v1.Y *i); static public VectorInt2 operator *(int i, VectorInt2 v2) => new VectorInt2(i * v2.X, i *v2.Y); static public VectorInt2 operator /(VectorInt2 v1, int i) => new VectorInt2(v1.X / i, v1.Y / i); } class Maxer<T> where T : IComparable<T> { public T Value; public Maxer(T t) { Value = t; } public void Max(T other) { if (Value.CompareTo(other) < 0) Value = other; } } class MultiSet<T> : IEnumerable<KeyValuePair<T, int>> { Dictionary<T, int> dictionary = new Dictionary<T, int>(); public MultiSet(IEnumerable<T> data) { foreach (var datum in data) { if (dictionary.ContainsKey(datum)) { dictionary[datum]++; } else { dictionary[datum] = 1; } } } public int this[T key] { get { return dictionary.ContainsKey(key) ? dictionary[key] : 0; } } public MultiSet() {} public Dictionary<T, int> AsDict() => dictionary; public IEnumerator<KeyValuePair<T, int>> GetEnumerator() => dictionary.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 37, 0, 5, 0, 62], ["+", 8, 196, 0, 57, 64, 37, 0, 5, 0, 222], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35]]
8
1,931
11
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Dcs { class Program { static void Main(string[] args) { var nm = Console.ReadLine() .Split(' ') .ToList() .Select(x => Int32.Parse(x)) .ToArray(); var n = nm[0]; var m = nm[1]; var An = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray(); // Console.WriteLine(n+" "+m); var dict = new Dictionary<Int32, Int64>(); dict.Add(0, 1); var accum = 0; foreach (var e in An) { accum += e; var r = accum %= m; if (dict.ContainsKey(r)) dict[r] += 1; else dict.Add(r, 1); } /* foreach (var e in dict) Console.WriteLine(e); */ var ans = dict.Select(x => x.Value) .Where(x => x > 1) .Select(x => x * (x - 1) / 2) .Aggregate((a0, an) => a0 + an); /* foreach (var e in arr) Console.WriteLine(e); */ Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Dcs { class Program { static void Main(string[] args) { var nm = Console.ReadLine() .Split(' ') .ToList() .Select(x => Int32.Parse(x)) .ToArray(); var n = nm[0]; var m = nm[1]; var An = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray(); // Console.WriteLine(n+" "+m); var dict = new Dictionary<Int32, Int64>(); dict.Add(0, 1); var accum = 0; foreach (var e in An) { accum += e; var r = accum %= m; if (dict.ContainsKey(r)) dict[r] += 1; else dict.Add(r, 1); } /* foreach (var e in dict) Console.WriteLine(e); */ var ans = dict.Select(x => x.Value) .Where(x => x > 1) .Select(x => x * (x - 1) / 2) .Sum(); // .Aggregate((a0, an) => a0+an ); /* foreach (var e in arr) Console.WriteLine(e); */ Console.WriteLine(ans); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 24], ["-", 0, 28, 0, 218, 54, 55, 0, 220, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 21], ["-", 3, 4, 0, 28, 0, 218, 54, 55, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 12, 22]]
8
264
11
using System; using System.Collections.Generic; using System.Linq; namespace CandyDistribution { /// <summary> /// /// </summary> public class Program2 { /// <summary> /// /// </summary> /// <param name="args"></param> public static void Main(string[] args) { // 標準入力を受け取るところは同じ var n_m = Console.ReadLine().Split(' '); var n = long.Parse(n_m[0]); var m = long.Parse(n_m[1]); var boxes = Console.ReadLine().Split(' ').Select(s => long.Parse(s)); /* N箱の内連続したi箱に入っている、お菓子の合計がMの倍数であることを確認するには、 * とある箱までの合計お菓子数のMの剰余が、2回以上(剰余0は1回)発生した場合、 * 前回まで割り切れた回数 +1回、割り切れる組み合わせが存在することになる。 * ※剰余0は初回も割り切れる回数としてカウントする。 * 例: * お菓子6箱(4, 1, 5, 4, 1, 5) 子供2人の場合 * * お菓子の箱番: 1, 2, 3, 4, 5, 6 * お菓子の入数: 4, 1, 5, 4, 1, 5 * お菓子の合計: 4, 5, 10, 14, 15, 20 * お菓子の剰余: 0, 1, 0, 0, 1, 0 * 割り切り(0) : 1, -, 2, 3, -, 4 = 10回 * 割り切り(1) : -, 0, -, -, 1, - = 1回 * 割り切り合計: 11回 * * 割り切り(1)の5箱目で1回としている意味。 * ⇒割り切り(1)の2箱目で 5 % 2 = 1となり割り切れていない状態から *  割り切り(1)の5箱目で 15 % 2 = 1としている。 *  これは3箱目~5箱目の合計が10(5, 4, 1)であるため、 *  10 % 2 = 0で割り切れる状態が発生したことを表し、 *  割り切り回数 1回としてカウントされているため。 * */ // お菓子の合計を取得する。 var sumBoxes = getSumBoxes(boxes); // お菓子の剰余の割り切りを取得する。 var modNums = getModNums(sumBoxes, m); // 割り切り合計を取得する。 var ans = getDivSum(modNums); // 標準出力を返すところも同じ Console.WriteLine(ans); } /// <summary> /// お菓子の合計を取得する。 /// </summary> /// <param name="boxes">お菓子の入数</param> /// <returns></returns> public static IEnumerable<long> getSumBoxes(IEnumerable<long> boxes) { var sumBoxes = new List<long>(); var sum = 0L; boxes.ToList().ForEach(num => { sum += num; sumBoxes.Add(sum); }); return sumBoxes; } /// <summary> /// お菓子の剰余を取得する。 /// </summary> /// <param name="sum">お菓子の合計</param> /// <returns></returns> public static IEnumerable<long> getModNums(IEnumerable<long> sum, long m) { var modNums = new List<long>(); sum.ToList().ForEach(num => { modNums.Add(num % m); }); return modNums; } /// <summary> /// 割り切り合計を取得する。 /// </summary> /// <param name="modNums">お菓子の剰余</param> /// <returns></returns> public static long getDivSum(IEnumerable<long> modNums) { var divSum = 0L; var modCountDict = new Dictionary<long, long>(); // modNums.ToList().ForEach(modNum => { // 剰余の発生回数の取得 if (modCountDict.ContainsKey(modNum)) { modCountDict[modNum]++; } else { if (divSum == 0L) { // 剰余0は発生時に割り切りとなるため、1開始 modCountDict.Add(modNum, 1L); } else { modCountDict.Add(modNum, 0L); } } // 割り切り合計への加算 divSum += modCountDict[modNum]; }); return divSum; } } }
using System; using System.Collections.Generic; using System.Linq; namespace CandyDistribution { /// <summary> /// /// </summary> public class Program2 { /// <summary> /// /// </summary> /// <param name="args"></param> public static void Main(string[] args) { // 標準入力を受け取る var n_m = Console.ReadLine().Split(' '); var n = long.Parse(n_m[0]); var m = long.Parse(n_m[1]); var boxes = Console.ReadLine().Split(' ').Select(s => long.Parse(s)); /* N箱の内連続したi箱に入っている、お菓子の合計がMの倍数であることを確認するには、 * とある箱までの合計お菓子数のMの剰余が、2回以上(剰余0は1回)発生した場合、 * 前回まで割り切れた回数 +1回、割り切れる組み合わせが存在することになる。 * ※剰余0は初回も割り切れる回数としてカウントする。 * 例: * お菓子6箱(4, 1, 5, 4, 1, 5) 子供2人の場合 * * お菓子の箱番: 1, 2, 3, 4, 5, 6 * お菓子の入数: 4, 1, 5, 4, 1, 5 * お菓子の合計: 4, 5, 10, 14, 15, 20 * お菓子の剰余: 0, 1, 0, 0, 1, 0 * 割り切り(0) : 1, -, 2, 3, -, 4 = 10回 * 割り切り(1) : -, 0, -, -, 1, - = 1回 * 割り切り合計: 11回 * * 割り切り(1)の5箱目で1回としている意味。 * ⇒割り切り(1)の2箱目で 5 % 2 = 1となり割り切れていない状態から *  割り切り(1)の5箱目で 15 % 2 = 1としている。 *  これは3箱目~5箱目の合計が10(5, 4, 1)であるため、 *  10 % 2 = 0で割り切れる状態が発生したことを表し、 *  割り切り回数 1回としてカウントされているため。 * * 補足:標準入力の値が異常値の場合の考慮は省略しているため、 *    入力値Nは使用していない。 */ // お菓子の合計を取得する。 var sumBoxes = GetSumBoxes(boxes); // お菓子の剰余の割り切りを取得する。 var modNums = GetModNums(sumBoxes, m); // 割り切り合計を取得する。 var ans = GetDivSum(modNums); // 標準出力を返す Console.WriteLine(ans); } /// <summary> /// お菓子の合計を取得する。 /// </summary> /// <param name="boxes">お菓子の入数</param> /// <returns></returns> public static IEnumerable<long> GetSumBoxes(IEnumerable<long> boxes) { var sumBoxes = new List<long>(); var sum = 0L; boxes.ToList().ForEach(num => { sum += num; sumBoxes.Add(sum); }); return sumBoxes; } /// <summary> /// お菓子の剰余を取得する。 /// </summary> /// <param name="sum">お菓子の合計</param> /// <returns></returns> public static IEnumerable<long> GetModNums(IEnumerable<long> sum, long m) { var modNums = sum.Select(num => num % m); return modNums; } /// <summary> /// 割り切り合計を取得する。 /// </summary> /// <param name="modNums">お菓子の剰余</param> /// <returns></returns> public static long GetDivSum(IEnumerable<long> modNums) { var divSum = 0L; var modCountDict = new Dictionary<long, long>(); // modNums.ToList().ForEach(modNum => { // 剰余の発生回数の取得 if (modCountDict.ContainsKey(modNum)) { modCountDict[modNum]++; } else { if (modNum == 0L) { // 剰余0は発生時に割り切りとなるため、1開始 modCountDict.Add(modNum, 1L); } else { modCountDict.Add(modNum, 0L); } } // 割り切り合計への加算 divSum += modCountDict[modNum]; }); return divSum; } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 196, 0, 45], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 28, 0, 218, 8, 196, 0, 1, 0, 35], ["-", 3, 4, 0, 28, 0, 218, 8, 196, 0, 46], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22]]
8
391
36
using System; using static System.Console; using static System.Math; using System.Collections.Generic; using System.Linq; using System.IO; class Program { static void Main() { var input = ReadLine().Split(); int n = int.Parse(input[0]); int m = int.Parse(input[1]); int[] a = Array.ConvertAll(ReadLine().Split(), int.Parse); Dictionary<long, long> dic = new Dictionary<long, long>(); dic.Add(0, 0); long[] sum = new long[n + 1]; foreach (int i in EnumerableCommon.Range(n)) { sum[i + 1] = (sum[i] + a[i]) % m; } long ans = 0; foreach (int i in EnumerableCommon.Range(sum.Length)) { if (dic.ContainsKey(sum[i])) { ans += dic[sum[i]]; } else dic.Add(sum[i], 0); } WriteLine(ans); } public static partial class EnumerableCommon { public static IEnumerable<int> Range(int count) { return Enumerable.Range(0, count); } } }
using System; using static System.Console; using static System.Math; using System.Collections.Generic; using System.Linq; using System.IO; class Program { static void Main() { var input = ReadLine().Split(); int n = int.Parse(input[0]); int m = int.Parse(input[1]); int[] a = Array.ConvertAll(ReadLine().Split(), int.Parse); Dictionary<long, long> dic = new Dictionary<long, long>(); long[] sum = new long[n + 1]; foreach (int i in EnumerableCommon.Range(n)) { sum[i + 1] = (sum[i] + a[i]) % m; } long ans = 0; foreach (int i in EnumerableCommon.Range(sum.Length)) { if (dic.ContainsKey(sum[i])) { ans += dic[sum[i]]; } else dic.Add(sum[i], 0); dic[sum[i]]++; } WriteLine(ans); } public static partial class EnumerableCommon { public static IEnumerable<int> Range(int count) { return Enumerable.Range(0, count); } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 210, 8, 196, 0, 57, 75, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 223, 0, 204, 205, 22], ["+", 0, 1, 0, 223, 0, 204, 206, 207, 0, 70], ["+", 0, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 1, 0, 223, 0, 204, 206, 207, 0, 73], ["+", 0, 210, 8, 196, 0, 1, 0, 223, 0, 29]]
8
270
18
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AABC { class Program { static void Main(string[] args) { string s = Console.ReadLine(); int k = int.Parse(s); if (k < 1200) { Console.WriteLine("ABC"); } else if (k > 1200 && k < 2800) { Console.WriteLine("ARC"); } else { Console.WriteLine("AGC"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AABC { class Program { static void Main(string[] args) { string s = Console.ReadLine(); int k = int.Parse(s); if (k < 1200) { Console.WriteLine("ABC"); } else if (k >= 1200 && k < 2800) { Console.WriteLine("ARC"); } else if (k >= 2800) { Console.WriteLine("AGC"); } } } }
[["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 47], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 20], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 17, 20], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 25]]
8
116
8
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var S = ReadLine(); var N = S.Length; if (S[0] != 'A') { WriteLine("WA"); return; } else if (1 != S.Substring(2, N - 3).Count(s => s == 'C')) { WriteLine("WA"); return; } else if ('z' < S[1] || 'z' < S[N - 1]) { WriteLine("WA"); return; } else { for (var i = 2; i < N - 1; ++i) { if (S[i] != 'C' && 'z' < S[i]) { WriteLine("WA"); return; } } } WriteLine("AC"); } static long Mod = 998244353; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var S = ReadLine(); var N = S.Length; if (S[0] != 'A') { WriteLine("WA"); return; } else if (1 != S.Substring(2, N - 3).Count(s => s == 'C')) { WriteLine("WA"); return; } else if (S[1] < 'a' || S[N - 1] < 'a') { WriteLine("WA"); return; } else { for (var i = 2; i < N - 1; ++i) { if (S[i] != 'C' && S[i] < 'a') { WriteLine("WA"); return; } } } WriteLine("AC"); } static long Mod = 998244353; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
[["-", 75, 57, 15, 16, 31, 16, 31, 252, 0, 104], ["-", 75, 57, 15, 16, 31, 16, 31, 252, 0, 253], ["-", 75, 57, 75, 57, 15, 16, 31, 16, 17, 18], ["-", 0, 57, 75, 57, 75, 57, 15, 16, 17, 106], ["+", 75, 57, 75, 57, 15, 16, 31, 16, 17, 18], ["-", 75, 57, 15, 16, 12, 16, 31, 252, 0, 253], ["+", 75, 57, 15, 16, 31, 16, 12, 252, 0, 253], ["-", 75, 57, 75, 57, 15, 16, 12, 16, 17, 18], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 17, 106], ["+", 75, 57, 75, 57, 15, 16, 12, 16, 17, 18], ["+", 75, 57, 15, 16, 12, 16, 12, 252, 0, 104], ["+", 75, 57, 15, 16, 12, 16, 12, 252, 0, 253], ["-", 0, 57, 15, 16, 12, 16, 31, 252, 0, 104], ["-", 0, 57, 15, 16, 12, 16, 31, 252, 0, 253], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 104], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 253]]
8
538
22
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace FertiLib.Contest.B { static class Program { public static void Solve(Scanner cin) { string s = cin.ReadString(); bool ok = true; if (s[0] != 'A') ok = false; if (s.Count(x => x == 'C') != 1) ok = false; if (s[1] == 'C') ok = false; if (s.Count(x => char.IsUpper(x)) != 2) ok = false; Console.WriteLine(ok ? "AC" : "WA"); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO"); public static void YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No"); public static void yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no"); public static bool Chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) >= 0) return false; a = b; return true; } public static bool Chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) <= 0) return false; a = b; return true; } } static class Util { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace FertiLib.Contest.B { static class Program { public static void Solve(Scanner cin) { string s = cin.ReadString(); bool ok = true; if (s[0] != 'A') ok = false; if (s.Count(x => x == 'C') != 1) ok = false; if (s[1] == 'C' || s[s.Length - 1] == 'C') ok = false; if (s.Count(x => char.IsUpper(x)) != 2) ok = false; Console.WriteLine(ok ? "AC" : "WA"); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO"); public static void YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No"); public static void yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no"); public static bool Chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) >= 0) return false; a = b; return true; } public static bool Chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) <= 0) return false; a = b; return true; } } static class Util { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 104], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 253]]
8
2,720
13
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace B { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var s = Console.ReadLine(); var answer = s[0] == 'A'; if (answer) { var countC = 0; for (var i = 2; i < s.Length - 1; i++) { if (s[i] == 'C') countC++; else if ((s[i] - 'a') < 0) answer = false; } if (answer) answer = countC == 1; } Console.WriteLine(answer ? "AC" : "WA"); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace B { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var s = Console.ReadLine(); var answer = s[0] == 'A'; if (answer) { var countC = 0; for (var i = 1; i < s.Length; i++) { if (i > 1 && i < s.Length - 1 && s[i] == 'C') countC++; else if ((s[i] - 'a') < 0) answer = false; } if (answer) answer = countC == 1; } Console.WriteLine(answer ? "AC" : "WA"); } } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 64, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 64, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 18], ["+", 31, 16, 12, 16, 12, 16, 31, 214, 205, 22], ["+", 31, 16, 12, 16, 12, 16, 31, 214, 0, 131], ["+", 31, 16, 12, 16, 12, 16, 31, 214, 141, 22], ["+", 15, 16, 31, 16, 12, 16, 12, 16, 17, 33], ["+", 15, 16, 31, 16, 12, 16, 12, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98]]
8
201
16
using System; namespace b { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var r = true; r = s[0] != 'A' ? false : r; var count = 0; for (var i = 1; i < s.Length; i++) { if (char.IsUpper(s[i])) { if (s[i] == 'C') { if ((i >= 2 && i <= s.Length - 2)) { count++; } else { r = false; } } else { r = false; } } } if (count != 0) { r = count != 1 ? false : r; } Console.WriteLine(r ? "AC" : "WA"); } } }
using System; namespace b { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var r = true; if (s[0] != 'A') { r = false; } var count = 0; for (var i = 1; i < s.Length; i++) { if (char.IsUpper(s[i])) { if (s[i] == 'C') { if ((i >= 2 && i <= s.Length - 2)) { count++; } else { r = false; } } else { r = false; } } } r = count != 1 ? false : r; Console.WriteLine(r ? "AC" : "WA"); } } }
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["-", 0, 1, 0, 11, 12, 41, 64, 211, 0, 147], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
169
20
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using static Ha2ne2Util.Cin; using static Ha2ne2Util.Util; using static System.Console; using static System.Math; using System.Collections; using Pair = System.Tuple<long, long>; /// <summary> /// https://atcoder.jp/contests/abc104 /// 2020/02/02 /// </summary> namespace ABC104 { public class Program { public static void Main(string[] args) { // A(); 4m B(); // C(); // C(); // D(); } public static void D() {} public static void C() {} public static void B() { // ^A、3~-2までにCが1個、ほかは小文字 string S = ReadString(); string komoji = "abcdefghijklmnopqrstuvwxyz"; HashSet<Char> komojiSet = new HashSet<char>(); foreach (var c in komoji) { komojiSet.Add(c); } if (S[0] != 'A') { Console.WriteLine("WA"); return; } if (!komojiSet.Contains(S[1])) { Console.WriteLine("WA"); return; } bool foundC = false; for (int i = 2; i <= S.Length - 2; i++) { if (S[i] == 'C' && foundC == false) { foundC = true; } else if (komojiSet.Contains(S[i])) { // nop } else { Console.WriteLine("WA"); return; } } if (!foundC) { Console.WriteLine("WA"); return; } for (int i = S.Length - 2; i < S.Length; i++) { if (!komojiSet.Contains(S[i])) { Console.WriteLine("WA"); return; } } Console.WriteLine("AC"); } public static void A() { long R = rl; if (R < 1200) { Console.WriteLine("ABC"); } else if (R < 2800) { Console.WriteLine("ARC"); } else { Console.WriteLine("AGC"); } } } } namespace Ha2ne2Util { public static class Cin { private static string[] Tokens { get; set; } private static int Pointer { get; set; } public static string Next() { if (Tokens == null || Tokens.Length <= Pointer) { Tokens = Console.ReadLine().Split(' '); Pointer = 0; } return Tokens[Pointer++]; } public static int ReadInt() { return int.Parse(Next()); } public static long rl => ReadLong(); public static long[] rla => ReadLongArray(); public static double rd => ReadDouble(); public static double[] rda => ReadDoubleArray(); public static long ReadLong() { return long.Parse(Next()); } public static double ReadDouble() { return double.Parse(Next()); } public static int[] ReadIntArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } public static long[] ReadLongArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } public static double[] ReadDoubleArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); } public static void ReadArrays(out long[] a, out long[] b, long N) { a = new long[N]; b = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); } } public static void ReadArrays(out long[] a, out long[] b, out long[] c, long N) { a = new long[N]; b = new long[N]; c = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); c[i] = ReadLong(); } } public static int[][] ReadIntTable(int n) { Tokens = null; int[][] ret = new int [n][]; for (int i = 0; i < n; i++) { ret[i] = ReadIntArray(); } return ret; } public static long[][] ReadLongTable(long n) { Tokens = null; long[][] ret = new long [n][]; for (long i = 0; i < n; i++) { ret[i] = ReadLongArray(); } return ret; } public static string ReadString() { return Next(); } /// <summary> /// "00101001010"という様な入力をintの配列にして返す /// </summary> /// <returns></returns> public static int[] ReadIntArrayFromBinaryString() { Tokens = null; return Array.ConvertAll(Console.ReadLine().ToArray(), c => int.Parse(c.ToString())); } /// <summary> /// "00101001010"という様な入力をboolの配列にして返す /// </summary> /// <returns></returns> public static bool[] ReadBoolArrayFromBinaryString() { Tokens = null; return Console.ReadLine().Select(c => c == '1').ToArray(); } } /// <summary> /// ユーティリティー /// </summary> public static class Util { // 10^17 public static readonly long INF = (long)1e17; public static IEnumerable<int> Range(int end) { for (int i = 0; i < end; i++) { yield return i; } } public static IEnumerable<int> Range(int from, int end) { for (int i = from; i < end; i++) { yield return i; } } public static IEnumerable<int> Range(int from, int end, int step) { for (int i = from; i < end; i += step) { yield return i; } } /// <summary> /// ソートをして結果を返します。 /// 破壊的関数です。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="array"></param> /// <returns></returns> public static T[] Sort<T>(T[] array) { Array.Sort<T>(array); return array; } /// <summary> /// 降順ソートをして結果を返します。 /// 破壊的関数です。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="array"></param> /// <returns></returns> public static T[] SortDecend<T>(T[] array) { Array.Sort<T>(array); Array.Reverse(array); return array; } /// <summary> /// Rubyにあるようなやつ /// ex) 5.Times(i => Console.WriteLine(i)); /// </summary> /// <param name="times"></param> /// <param name="action"></param> public static void Times(this int times, Action<int> action) { for (int i = 0; i < times; i++) { action(i); } } /// <summary> /// 引数aと引数bの値を入れ替えます /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="b"></param> public static void Swap<T>(ref T a, ref T b) { T _a = a; a = b; b = _a; } /// <summary> /// Console.WriteLineの自動フラッシュをしないようにする /// </summary> public static void DontAutoFlush() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } public static void Flush() { Console.Out.Flush(); } /// <summary> /// 先頭と末尾に要素を増やした新しい配列を返します。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="array"></param> /// <returns></returns> public static T[] AddHeadAndTail<T>(T[] array) { int len = array.Length; T[] res = new T[len + 2]; Array.Copy(array, 0, res, 1, len); return res; } /// <summary> /// 昇順ソート済みの配列を2分探索します。 /// 要素が見つからなかった場合はnより大きい数値の中で最小の数値のインデックスを返す。 /// </summary> /// <param name="array"></param> /// <param name="n"></param> /// <returns></returns> public static int BinarySearch(long[] array, long n) { int left = 0; int right = array.Length - 1; while (left <= right) { int mid = (right - left) / 2 + left; if (array[mid] == n) { return mid; } else if (n < array[mid]) { right = mid - 1; } else { left = mid + 1; } } return left; } public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); } public static int[] GetDivisor(int n) { double sqrt = Math.Sqrt(n); List<int> divisor = new List<int>(); for (int i = 1; i <= sqrt; i++) { if (n % i == 0) { divisor.Add(i); int tmp = n / i; if (tmp != i) { divisor.Add(tmp); } } } return Sort(divisor.ToArray()); } public static int[] LongToBinaryArray(long n) { List<int> lst = new List<int>(); while (n > 0) { int amari = (int)(n % 2); lst.Add(amari); n /= 2; } return lst.ToArray(); } public static long BinaryArrayToLong(int[] binaryArray) { long result = 0; long b = 1; int len = binaryArray.Length; for (int i = 0; i < len; i++) { result += binaryArray[i] * b; b *= 2; } return result; } public static void Deconstruct<T>(this T[] items, out T t0) { t0 = items.Length > 0 ? items[0] : default(T); } public static void Deconstruct<T>(this T[] items, out T t0, out T t1) { if (items.Length < 2) throw new ArgumentException(); t0 = items[0]; t1 = items[1]; } public static void Deconstruct<T>(this T[] items, out T t0, out T t1, out T t2) { if (items.Length < 3) throw new ArgumentException(); t0 = items[0]; t1 = items[1]; t2 = items[2]; } public static void Deconstruct<T>(this T[] items, out T t0, out T t1, out T t2, out T t3) { if (items.Length < 4) throw new ArgumentException(); t0 = items[0]; t1 = items[1]; t2 = items[2]; t3 = items[3]; } public static void ArrayInitialize<T>(T[,] array, T value) { int len0 = array.GetLength(0); int len1 = array.GetLength(1); for (int i = 0; i < len0; i++) { for (int j = 0; j < len1; j++) { array[i, j] = value; } } } public static void ChMax(ref long a, long b) { if (a < b) a = b; } public static void ChMin(ref long a, long b) { if (a > b) a = b; } public readonly static int MOD = 1000000007; public static long ModAdd(long a, long b) { long res = a + b; if (res >= MOD) return res % MOD; return res; } public static long ModMul(long a, long b) { long res = a * b; if (res >= MOD) return res % MOD; return res; } public static void ModAddEqual(ref long a, long b) { a += b; if (a >= MOD) a %= MOD; } public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) { T min = source.First(); long minValue = conv(min); foreach (T x in source.Skip(1)) { long n = conv(x); if (n < minValue) { min = x; } } return min; } public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) { T min = source.First(); long maxValue = conv(min); foreach (T x in source.Skip(1)) { long n = conv(x); if (maxValue < n) { min = x; } } return min; } public static void FillArray<T>(T[] array, T value) { int max = array.Length; for (int i = 0; i < max; i++) { array[i] = value; } } public static void FillArray<T>(T[,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { array[i, j] = value; } } } public static void FillArray<T>(T[,,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); int max2 = array.GetLength(2); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { for (int k = 0; k < max2; k++) { array[i, j, k] = value; } } } } } /// <summary> /// HashSetにTupleを入れた時の、等値性判定方法の指定に使います。 /// HashSetのコンストラクタに渡して使います。 /// EqualsとGetHashCodeを提供します。 /// </summary> /// <typeparam name="T"></typeparam> public class EqualityComparer<T> : IEqualityComparer<T> { private Func<T, T, bool> _equals; private Func<T, int> _getHashCode; public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) { _equals = equals; _getHashCode = getHashCode; } public bool Equals(T x, T y) { return _equals(x, y); } public int GetHashCode(T obj) { return _getHashCode(obj); } } /// <summary> /// UnionFindTree /// </summary> public class UnionFindTree { public int[] Node; public UnionFindTree(int N) { Node = new int[N]; for (int i = 0; i < N; i++) { Node[i] = -1; } } public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); } public bool Merge(int x, int y) { int xr = GetRoot(x); int yr = GetRoot(y); if (xr == yr) return false; // xが、大きなグループを示すようにSwapする(値が小さい方が大きなグループ) if (Node[xr] > Node[yr]) Swap(ref xr, ref yr); // グループの数を合算する Node[xr] += Node[yr]; // 根を張り替える Node[yr] = xr; return true; } public int Size(int x) { return -Node[GetRoot(x)]; } public int GetRoot(int n) { if (Node[n] < 0) { return n; } else { // 根を張りなおす。 Node[n] = GetRoot(Node[n]); return Node[n]; } } } /// <summary> /// PriorityQueue /// </summary> /// <typeparam name="T"></typeparam> public class PriorityQueue<T> { private Comparison<T> _comparison = null; private int _type = 0; private T[] _heap; private int _sz = 0; private int _count = 0; /// <summary> /// Priority queue /// </summary> /// <param name="maxSize">max size</param> /// <param name="type">0: asc, 1:desc</param> public PriorityQueue(int maxSize, int type = 0) { _heap = new T[maxSize]; _type = type; } public PriorityQueue(int maxSize, Comparison<T> comparison) { _heap = new T[maxSize]; _comparison = comparison; } private int Compare(T x, T y) { return _comparison(x, y); // if (_comparison != null) return _comparison(x, y); // return _type == 0 ? x.CompareTo(y) : y.CompareTo(x); } public void Push(T x) { _count++; // node number var i = _sz++; while (i > 0) { // parent node number var p = (i - 1) / 2; if (Compare(_heap[p], x) <= 0) break; _heap[i] = _heap[p]; i = p; } _heap[i] = x; } public T Pop() { _count--; T ret = _heap[0]; T x = _heap[--_sz]; int i = 0; while (i * 2 + 1 < _sz) { // children int a = i * 2 + 1; int b = i * 2 + 2; if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b; if (Compare(_heap[a], x) >= 0) break; _heap[i] = _heap[a]; i = a; } _heap[i] = x; return ret; } public int Count() { return _count; } public T Peek() { return _heap[0]; } public bool Contains(T x) { for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true; return false; } public void Clear() { while (this.Count() > 0) this.Pop(); } public IEnumerator<T> GetEnumerator() { var ret = new List<T>(); while (this.Count() > 0) { ret.Add(this.Pop()); } foreach (var r in ret) { this.Push(r); yield return r; } } public T[] ToArray() { T[] array = new T[_sz]; int i = 0; foreach (var r in this) { array[i++] = r; } return array; } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using static Ha2ne2Util.Cin; using static Ha2ne2Util.Util; using static System.Console; using static System.Math; using System.Collections; using Pair = System.Tuple<long, long>; /// <summary> /// https://atcoder.jp/contests/abc104 /// 2020/02/02 3完 R1457 /// </summary> namespace ABC104 { public class Program { public static void Main(string[] args) { // A(); 4m // B(); 29m // C(); 70m // D(); 降参 // 2回目 // A(); 1m B(); // C(); // D(); } public static void D() {} public static void C() {} public static void B() { string S = ReadString(); string komoji = "abcdefghijklmnopqrstuvwxyz"; HashSet<char> komojiSet = new HashSet<char>(); foreach (var c in komoji) { komojiSet.Add(c); } if (S[0] != 'A') { Console.WriteLine("WA"); return; } if (!komojiSet.Contains(S[1])) { Console.WriteLine("WA"); return; } bool foundC = false; for (int i = 2; i < S.Length - 1; i++) { if (S[i] == 'C' && foundC == false) { foundC = true; } else if (komojiSet.Contains(S[i])) { // nop } else { Console.WriteLine("WA"); return; } } if (!foundC) { Console.WriteLine("WA"); return; } if (!komojiSet.Contains(S[S.Length - 1])) { Console.WriteLine("WA"); return; } Console.WriteLine("AC"); } public static void A() { long R = rl; if (R < 1200) { Console.WriteLine("ABC"); } else if (R < 2800) { Console.WriteLine("ARC"); } else { Console.WriteLine("AGC"); } } // public static void D() //{ // string S = ReadString(); // long[,] dp = new long[S.Length + 1, 4]; // dp[0, 0] = 1; // for (int i = 0; i < S.Length; i++) // { // for (int j = 0; j < 4; j++) // { // if (S[i] == '?') // { // dp[i + 1, j] = ModMul(dp[i, j], 3); // } // else // { // dp[i + 1, j] = dp[i, j]; // } // } // if (S[i] == 'A' || S[i] == '?') // dp[i + 1, 1] = ModAdd(dp[i + 1, 1], dp[i, 0]); // if (S[i] == 'B' || S[i] == '?') // dp[i + 1, 2] = ModAdd(dp[i + 1, 2], dp[i, 1]); // if (S[i] == 'C' || S[i] == '?') // dp[i + 1, 3] = ModAdd(dp[i + 1, 3], dp[i, 2]); // } // Console.WriteLine(dp[S.Length, 3]); //} // public static void C() //{ // int D = ReadInt(); // long G = rl; // long[] P, C; // ReadArrays(out P, out C, D); // long ans = INF; // int n = (1 << D) - 1; // for (int i = n; i >= 0; i--) // { // long count = 0; // long score = 0; // for (int j = 0; j < D; j++) // { // if ((i & (1 << j)) == (1 << j)) // { // count += P[j]; // score += (j + 1) * 100 * P[j] + C[j]; // } // } // if (score >= G) // { // ChMin(ref ans, count); // continue; // } // long nokori = G - score; // for (int j = D-1; j >= 0; j--) // { // if ((i & (1 << j)) == (1 << j)) // continue; // var problemScore = (j + 1) * 100; // var max = problemScore * P[j]; // if (nokori > max) // { // nokori -= max; // count += P[j]; // continue; // } // count += nokori / problemScore; // if (nokori % problemScore != 0) // count++; // break; // } // ChMin(ref ans, count); // } // Console.WriteLine(ans); //} // public static void B() //{ // // ^A、3~-2までにCが1個、ほかは小文字 // string S = ReadString(); // string komoji = "abcdefghijklmnopqrstuvwxyz"; // HashSet<Char> komojiSet = new HashSet<char>(); // foreach(var c in komoji) // { // komojiSet.Add(c); // } // if (S[0] != 'A') // { // Console.WriteLine("WA"); // return; // } // if (!komojiSet.Contains(S[1])) // { // Console.WriteLine("WA"); // return; // } // bool foundC = false; // for (int i = 2; i <= S.Length - 2; i++) // { // if (S[i] == 'C' && foundC == false) // { // foundC = true; // } // else if (komojiSet.Contains(S[i])) // { // // nop // } // else // { // Console.WriteLine("WA"); // return; // } // } // if (!foundC) // { // Console.WriteLine("WA"); // return; // } // if (!komojiSet.Contains(S[S.Length-1])) // { // Console.WriteLine("WA"); // return; // } // Console.WriteLine("AC"); //} // public static void A() //{ // long R = rl; // if (R < 1200) // { // Console.WriteLine("ABC"); // } // else if (R < 2800) // { // Console.WriteLine("ARC"); // } // else // { // Console.WriteLine("AGC"); // } //} } } namespace Ha2ne2Util { public static class Cin { private static string[] Tokens { get; set; } private static int Pointer { get; set; } public static string Next() { if (Tokens == null || Tokens.Length <= Pointer) { Tokens = Console.ReadLine().Split(' '); Pointer = 0; } return Tokens[Pointer++]; } public static int ReadInt() { return int.Parse(Next()); } public static long rl => ReadLong(); public static long[] rla => ReadLongArray(); public static double rd => ReadDouble(); public static double[] rda => ReadDoubleArray(); public static long ReadLong() { return long.Parse(Next()); } public static double ReadDouble() { return double.Parse(Next()); } public static int[] ReadIntArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } public static long[] ReadLongArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } public static double[] ReadDoubleArray() { Tokens = null; return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse); } public static void ReadArrays(out long[] a, out long[] b, long N) { a = new long[N]; b = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); } } public static void ReadArrays(out long[] a, out long[] b, out long[] c, long N) { a = new long[N]; b = new long[N]; c = new long[N]; for (int i = 0; i < N; i++) { a[i] = ReadLong(); b[i] = ReadLong(); c[i] = ReadLong(); } } public static int[][] ReadIntTable(int n) { Tokens = null; int[][] ret = new int [n][]; for (int i = 0; i < n; i++) { ret[i] = ReadIntArray(); } return ret; } public static long[][] ReadLongTable(long n) { Tokens = null; long[][] ret = new long [n][]; for (long i = 0; i < n; i++) { ret[i] = ReadLongArray(); } return ret; } public static string ReadString() { return Next(); } /// <summary> /// "00101001010"という様な入力をintの配列にして返す /// </summary> /// <returns></returns> public static int[] ReadIntArrayFromBinaryString() { Tokens = null; return Array.ConvertAll(Console.ReadLine().ToArray(), c => int.Parse(c.ToString())); } /// <summary> /// "00101001010"という様な入力をboolの配列にして返す /// </summary> /// <returns></returns> public static bool[] ReadBoolArrayFromBinaryString() { Tokens = null; return Console.ReadLine().Select(c => c == '1').ToArray(); } } /// <summary> /// ユーティリティー /// </summary> public static class Util { // 10^17 public static readonly long INF = (long)1e17; public static IEnumerable<int> Range(int end) { for (int i = 0; i < end; i++) { yield return i; } } public static IEnumerable<int> Range(int from, int end) { for (int i = from; i < end; i++) { yield return i; } } public static IEnumerable<int> Range(int from, int end, int step) { for (int i = from; i < end; i += step) { yield return i; } } /// <summary> /// ソートをして結果を返します。 /// 破壊的関数です。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="array"></param> /// <returns></returns> public static T[] Sort<T>(T[] array) { Array.Sort<T>(array); return array; } /// <summary> /// 降順ソートをして結果を返します。 /// 破壊的関数です。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="array"></param> /// <returns></returns> public static T[] SortDecend<T>(T[] array) { Array.Sort<T>(array); Array.Reverse(array); return array; } /// <summary> /// Rubyにあるようなやつ /// ex) 5.Times(i => Console.WriteLine(i)); /// </summary> /// <param name="times"></param> /// <param name="action"></param> public static void Times(this int times, Action<int> action) { for (int i = 0; i < times; i++) { action(i); } } /// <summary> /// 引数aと引数bの値を入れ替えます /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="b"></param> public static void Swap<T>(ref T a, ref T b) { T _a = a; a = b; b = _a; } /// <summary> /// Console.WriteLineの自動フラッシュをしないようにする /// </summary> public static void DontAutoFlush() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } public static void Flush() { Console.Out.Flush(); } /// <summary> /// 先頭と末尾に要素を増やした新しい配列を返します。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="array"></param> /// <returns></returns> public static T[] AddHeadAndTail<T>(T[] array) { int len = array.Length; T[] res = new T[len + 2]; Array.Copy(array, 0, res, 1, len); return res; } /// <summary> /// 昇順ソート済みの配列を2分探索します。 /// 要素が見つからなかった場合はnより大きい数値の中で最小の数値のインデックスを返す。 /// </summary> /// <param name="array"></param> /// <param name="n"></param> /// <returns></returns> public static int BinarySearch(long[] array, long n) { int left = 0; int right = array.Length - 1; while (left <= right) { int mid = (right - left) / 2 + left; if (array[mid] == n) { return mid; } else if (n < array[mid]) { right = mid - 1; } else { left = mid + 1; } } return left; } public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); } public static int[] GetDivisor(int n) { double sqrt = Math.Sqrt(n); List<int> divisor = new List<int>(); for (int i = 1; i <= sqrt; i++) { if (n % i == 0) { divisor.Add(i); int tmp = n / i; if (tmp != i) { divisor.Add(tmp); } } } return Sort(divisor.ToArray()); } public static int[] LongToBinaryArray(long n) { List<int> lst = new List<int>(); while (n > 0) { int amari = (int)(n % 2); lst.Add(amari); n /= 2; } return lst.ToArray(); } public static long BinaryArrayToLong(int[] binaryArray) { long result = 0; long b = 1; int len = binaryArray.Length; for (int i = 0; i < len; i++) { result += binaryArray[i] * b; b *= 2; } return result; } public static void Deconstruct<T>(this T[] items, out T t0) { t0 = items.Length > 0 ? items[0] : default(T); } public static void Deconstruct<T>(this T[] items, out T t0, out T t1) { if (items.Length < 2) throw new ArgumentException(); t0 = items[0]; t1 = items[1]; } public static void Deconstruct<T>(this T[] items, out T t0, out T t1, out T t2) { if (items.Length < 3) throw new ArgumentException(); t0 = items[0]; t1 = items[1]; t2 = items[2]; } public static void Deconstruct<T>(this T[] items, out T t0, out T t1, out T t2, out T t3) { if (items.Length < 4) throw new ArgumentException(); t0 = items[0]; t1 = items[1]; t2 = items[2]; t3 = items[3]; } public static void ArrayInitialize<T>(T[,] array, T value) { int len0 = array.GetLength(0); int len1 = array.GetLength(1); for (int i = 0; i < len0; i++) { for (int j = 0; j < len1; j++) { array[i, j] = value; } } } public static void ChMax(ref long a, long b) { if (a < b) a = b; } public static void ChMin(ref long a, long b) { if (a > b) a = b; } public readonly static int MOD = 1000000007; public static long ModAdd(long a, long b) { long res = a + b; if (res >= MOD) return res % MOD; return res; } public static long ModMul(long a, long b) { long res = a * b; if (res >= MOD) return res % MOD; return res; } public static void ModAddEqual(ref long a, long b) { a += b; if (a >= MOD) a %= MOD; } public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) { T min = source.First(); long minValue = conv(min); foreach (T x in source.Skip(1)) { long n = conv(x); if (n < minValue) { min = x; } } return min; } public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) { T min = source.First(); long maxValue = conv(min); foreach (T x in source.Skip(1)) { long n = conv(x); if (maxValue < n) { min = x; } } return min; } public static void FillArray<T>(T[] array, T value) { int max = array.Length; for (int i = 0; i < max; i++) { array[i] = value; } } public static void FillArray<T>(T[,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { array[i, j] = value; } } } public static void FillArray<T>(T[,,] array, T value) { int max0 = array.GetLength(0); int max1 = array.GetLength(1); int max2 = array.GetLength(2); for (int i = 0; i < max0; i++) { for (int j = 0; j < max1; j++) { for (int k = 0; k < max2; k++) { array[i, j, k] = value; } } } } } /// <summary> /// HashSetにTupleを入れた時の、等値性判定方法の指定に使います。 /// HashSetのコンストラクタに渡して使います。 /// EqualsとGetHashCodeを提供します。 /// </summary> /// <typeparam name="T"></typeparam> public class EqualityComparer<T> : IEqualityComparer<T> { private Func<T, T, bool> _equals; private Func<T, int> _getHashCode; public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) { _equals = equals; _getHashCode = getHashCode; } public bool Equals(T x, T y) { return _equals(x, y); } public int GetHashCode(T obj) { return _getHashCode(obj); } } /// <summary> /// UnionFindTree /// </summary> public class UnionFindTree { public int[] Node; public UnionFindTree(int N) { Node = new int[N]; for (int i = 0; i < N; i++) { Node[i] = -1; } } public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); } public bool Merge(int x, int y) { int xr = GetRoot(x); int yr = GetRoot(y); if (xr == yr) return false; // xが、大きなグループを示すようにSwapする(値が小さい方が大きなグループ) if (Node[xr] > Node[yr]) Swap(ref xr, ref yr); // グループの数を合算する Node[xr] += Node[yr]; // 根を張り替える Node[yr] = xr; return true; } public int Size(int x) { return -Node[GetRoot(x)]; } public int GetRoot(int n) { if (Node[n] < 0) { return n; } else { // 根を張りなおす。 Node[n] = GetRoot(Node[n]); return Node[n]; } } } /// <summary> /// PriorityQueue /// </summary> /// <typeparam name="T"></typeparam> public class PriorityQueue<T> { private Comparison<T> _comparison = null; private int _type = 0; private T[] _heap; private int _sz = 0; private int _count = 0; /// <summary> /// Priority queue /// </summary> /// <param name="maxSize">max size</param> /// <param name="type">0: asc, 1:desc</param> public PriorityQueue(int maxSize, int type = 0) { _heap = new T[maxSize]; _type = type; } public PriorityQueue(int maxSize, Comparison<T> comparison) { _heap = new T[maxSize]; _comparison = comparison; } private int Compare(T x, T y) { return _comparison(x, y); // if (_comparison != null) return _comparison(x, y); // return _type == 0 ? x.CompareTo(y) : y.CompareTo(x); } public void Push(T x) { _count++; // node number var i = _sz++; while (i > 0) { // parent node number var p = (i - 1) / 2; if (Compare(_heap[p], x) <= 0) break; _heap[i] = _heap[p]; i = p; } _heap[i] = x; } public T Pop() { _count--; T ret = _heap[0]; T x = _heap[--_sz]; int i = 0; while (i * 2 + 1 < _sz) { // children int a = i * 2 + 1; int b = i * 2 + 2; if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b; if (Compare(_heap[a], x) >= 0) break; _heap[i] = _heap[a]; i = a; } _heap[i] = x; return ret; } public int Count() { return _count; } public T Peek() { return _heap[0]; } public bool Contains(T x) { for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true; return false; } public void Clear() { while (this.Count() > 0) this.Pop(); } public IEnumerator<T> GetEnumerator() { var ret = new List<T>(); while (this.Count() > 0) { ret.Add(this.Pop()); } foreach (var r in ret) { this.Push(r); yield return r; } } public T[] ToArray() { T[] array = new T[_sz]; int i = 0; foreach (var r in this) { array[i++] = r; } return array; } } }
[["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 141, 22], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
3,578
34
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Practice { class Program { static void Main(string[] args) { Solve(); } private const long MOD = 1000000007; private static Dictionary<string, int> dic = new Dictionary<string, int>(); static void Solve() { var o = ReadAndParseIntArr(); int n = o[0]; int k = o[1]; int ans = 0; if (n > k) { if (n % k == 0) { ans = 0; } else { ans = 1; } } else { ans = 1; } Console.WriteLine(ans); } #region よく使う便利関数 private static bool isPrime(long x) { if (x == 2) { return true; } if (x < 2 || x % 2 == 0) { return false; } long i = 3; while (i * i <= x) { if (x % i == 0) { return false; } i = i + 2; } return true; } private static long lcm(long x, long y) { return x / gcd(x, y) * y; } private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; } private static long pow(long x, long n) { if (n == 0) { return 1; } long res = pow(x * x % MOD, n / 2); if (n % 2 == 1) { res = res * x % MOD; } return res; } private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); } private static int[] ReadAndParseIntArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } private static long ReadAndParseLong() { return long.Parse(Console.ReadLine()); } private static long[] ReadAndParseLongArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } #endregion } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Practice { class Program { static void Main(string[] args) { Solve(); } private const long MOD = 1000000007; private static Dictionary<string, int> dic = new Dictionary<string, int>(); static void Solve() { var o = ReadAndParseIntArr(); int n = o[0]; int k = o[1]; int ans = 0; if (n % k == 0) { ans = 0; } else { ans = 1; } Console.WriteLine(ans); } #region よく使う便利関数 private static bool isPrime(long x) { if (x == 2) { return true; } if (x < 2 || x % 2 == 0) { return false; } long i = 3; while (i * i <= x) { if (x % i == 0) { return false; } i = i + 2; } return true; } private static long lcm(long x, long y) { return x / gcd(x, y) * y; } private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; } private static long pow(long x, long n) { if (n == 0) { return 1; } long res = pow(x * x % MOD, n / 2); if (n % 2 == 1) { res = res * x % MOD; } return res; } private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); } private static int[] ReadAndParseIntArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } private static long ReadAndParseLong() { return long.Parse(Console.ReadLine()); } private static long[] ReadAndParseLongArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } #endregion } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["-", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["-", 64, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
8
449
15
using System; namespace ABC105_A_AtCoder_Crackers { internal class Program { public static void Main(string[] args) { string[] instr = Console.ReadLine().Split(' '); int n = int.Parse(instr[0]); int k = int.Parse(instr[1]); int waru = n / k; int amari = n % k; if (amari != 0) { Console.WriteLine(1); } Console.WriteLine(0); } } }
using System; namespace ABC105_A_AtCoder_Crackers { internal class Program { public static void Main(string[] args) { string[] instr = Console.ReadLine().Split(' '); int n = int.Parse(instr[0]); int k = int.Parse(instr[1]); int amari = n % k; if (amari != 0) { Console.WriteLine(1); } else { Console.WriteLine(0); } } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
104
10
using System; using System.Linq; using System.Collections.Generic; using static System.Math; using static System.Console; namespace AtCoder { class AtCoderrrrrr { static void Main(string[] args) { string s = ReadLine(); int w = int.Parse(ReadLine()); string ans = ""; int tmp = 0; for (int i = 0; i < s.Length; i++) { tmp++; if (tmp == w) { tmp = 0; ans += s[i].ToString(); } } WriteLine(ans); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Math; using static System.Console; namespace AtCoder { class AtCoderrrrrr { static void Main(string[] args) { string s = ReadLine(); int w = int.Parse(ReadLine()); string ans = ""; for (int i = 0; i < s.Length; i++) { if (i % w == 0) { ans += s[i].ToString(); } } WriteLine(ans); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
125
18
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtcoderTemplateForCSharp { public class Program { public static void Main(string[] args) { var s = Console.ReadLine(); var w = Console.ReadLine().Select(x => int.Parse(x.ToString())).First(); for (int i = 0; i < s.Length; i++) { if (i % w == 0) { Console.Write(s[i]); } } Console.WriteLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtcoderTemplateForCSharp { public class Program { public static void Main(string[] args) { var s = Console.ReadLine(); var w = int.Parse(Console.ReadLine()); for (int i = 0; i < s.Length; i++) { if (i % w == 0) { Console.Write(s[i]); } } Console.WriteLine(); } } }
[["-", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24]]
8
130
19
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtcoderTemplateForCSharp { public class Program { public static void Main(string[] args) { var s = Console.ReadLine(); var w = Console.ReadLine().Select(x => int.Parse(x.ToString())).First(); var ansList = new List<char>(); for (int i = 0; i < s.Length; i++) { if ((i + w) % w == 0) { Console.Write(s[i]); } } Console.WriteLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtcoderTemplateForCSharp { public class Program { public static void Main(string[] args) { var s = Console.ReadLine(); var w = int.Parse(Console.ReadLine()); var ansList = new List<char>(); for (int i = 0; i < s.Length; i++) { if (i % w == 0) { Console.Write(s[i]); } } Console.WriteLine(); } } }
[["-", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25]]
8
145
23
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtcoderTemplateForCSharp { public class Program { public static void Main(string[] args) { var s = Console.ReadLine(); var w = Console.ReadLine().Select(x => int.Parse(x.ToString())).First(); var ans = ""; for (int i = 0; i < s.Length; i++) { if (i % w == 0) { ans += s.Substring(i, 1); } } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtcoderTemplateForCSharp { public class Program { public static void Main(string[] args) { var s = Console.ReadLine(); var w = int.Parse(Console.ReadLine()); var ans = ""; for (int i = 0; i < s.Length; i++) { if (i % w == 0) { ans += s.Substring(i, 1); } } Console.WriteLine(ans); } } }
[["-", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24]]
8
138
19
using System; using System.Collections.Generic; using static Assistant.Input; using static Assistant.Debug; using System.Linq; using Assistant; namespace SoundHound2018C { class Program { static void Main(string[] args) { var n = RInt; var m = RInt; var d = RInt; decimal ans = 0; ans = (decimal)2 * (n - d) * (m - 1); ans /= (decimal)n * n; Console.WriteLine(ans); } } } namespace Assistant { static class Input { static List<string> line = new List<string>(); static int index = 0; static String RNext() { if (line.Count <= index) line.AddRange(Console.ReadLine().Split()); return line[index++]; } public static int RInt => int.Parse(RNext()); public static long RLong => long.Parse(RNext()); public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray(); public static string RString => RNext(); //以下未テスト public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray(); public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray(); public static char[][] RMap(int h) => Enumerable.Repeat(0, h) .Select(x => Console.ReadLine().ToCharArray()) .ToArray(); } public struct Mlong { long _v; const long mod = 1000000007; public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; } public static implicit operator Mlong(long _x) => new Mlong(_x); public static implicit operator long(Mlong _x) => _x._v; public static Mlong operator +(Mlong m1, Mlong m2) { long m = m1._v + m2._v; return m >= mod ? m - mod : m; } public static Mlong operator -(Mlong m1, Mlong m2) { long m = m1._v - m2._v; return m >= 0 ? m : m + mod; } public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod; public static Mlong operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod; public static long ModPow(long a, long n) { if (n == 0) return 1; else if (n % 2 == 1) return a * ModPow(a, n - 1) % mod; else return ModPow(a * a % mod, n / 2); } static Mlong[] fac, finv, inv; public static void nCkInit(int max) { fac = new Mlong[max]; finv = new Mlong[max]; inv = new Mlong[max]; fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < max; i++) { fac[i] = fac[i - 1] * i; inv[i] = mod - inv[mod % i] * (mod / i); finv[i] = finv[i - 1] * inv[i]; } } public static Mlong nCk(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[k] * finv[n - k]; } } static class Debug { static public void Draw2D<T>(T[,] map, int mode = 1) { #if DEBUG int W = map.GetLength(0); int H = map.GetLength(1); string[,] map2 = new string[W + 1, H + 1]; for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (i == 0 && j == 0) map2[i, j] = 0.ToString(); else if (i == 0) map2[i, j] = (j - 1).ToString(); else if (j == 0) map2[i, j] = (i - 1).ToString(); else map2[i, j] = map[i - 1, j - 1].ToString(); } } for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (mode == 0) Console.Write(map2[i, j].Last()); if (mode == 1) Console.Write(map2[i, j] + " "); } Console.WriteLine(); } Console.WriteLine(); #endif } public static void Draw1D<T>(T[] array, int mode = 0) { #if DEBUG Console.WriteLine(string.Join(" ", array)); #endif } } }
using System; using System.Collections.Generic; using static Assistant.Input; using static Assistant.Debug; using System.Linq; using Assistant; namespace SoundHound2018C { class Program { static void Main(string[] args) { var n = RInt; var m = RInt; var d = RInt; decimal ans = d == 0 ? 1 : 2; ans *= (decimal)(n - d) * (m - 1); ans /= (decimal)n * n; Console.WriteLine(ans); } } } namespace Assistant { static class Input { static List<string> line = new List<string>(); static int index = 0; static String RNext() { if (line.Count <= index) line.AddRange(Console.ReadLine().Split()); return line[index++]; } public static int RInt => int.Parse(RNext()); public static long RLong => long.Parse(RNext()); public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray(); public static string RString => RNext(); //以下未テスト public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray(); public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray(); public static char[][] RMap(int h) => Enumerable.Repeat(0, h) .Select(x => Console.ReadLine().ToCharArray()) .ToArray(); } public struct Mlong { long _v; const long mod = 1000000007; public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; } public static implicit operator Mlong(long _x) => new Mlong(_x); public static implicit operator long(Mlong _x) => _x._v; public static Mlong operator +(Mlong m1, Mlong m2) { long m = m1._v + m2._v; return m >= mod ? m - mod : m; } public static Mlong operator -(Mlong m1, Mlong m2) { long m = m1._v - m2._v; return m >= 0 ? m : m + mod; } public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod; public static Mlong operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod; public static long ModPow(long a, long n) { if (n == 0) return 1; else if (n % 2 == 1) return a * ModPow(a, n - 1) % mod; else return ModPow(a * a % mod, n / 2); } static Mlong[] fac, finv, inv; public static void nCkInit(int max) { fac = new Mlong[max]; finv = new Mlong[max]; inv = new Mlong[max]; fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < max; i++) { fac[i] = fac[i - 1] * i; inv[i] = mod - inv[mod % i] * (mod / i); finv[i] = finv[i - 1] * inv[i]; } } public static Mlong nCk(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[k] * finv[n - k]; } } static class Debug { static public void Draw2D<T>(T[,] map, int mode = 1) { #if DEBUG int W = map.GetLength(0); int H = map.GetLength(1); string[,] map2 = new string[W + 1, H + 1]; for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (i == 0 && j == 0) map2[i, j] = 0.ToString(); else if (i == 0) map2[i, j] = (j - 1).ToString(); else if (j == 0) map2[i, j] = (i - 1).ToString(); else map2[i, j] = map[i - 1, j - 1].ToString(); } } for (int i = 0; i < W + 1; i++) { for (int j = 0; j < H + 1; j++) { if (mode == 0) Console.Write(map2[i, j].Last()); if (mode == 1) Console.Write(map2[i, j] + " "); } Console.WriteLine(); } Console.WriteLine(); #endif } public static void Draw1D<T>(T[] array, int mode = 0) { #if DEBUG Console.WriteLine(string.Join(" ", array)); #endif } } }
[["+", 0, 200, 0, 212, 0, 41, 15, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 75, 203], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["-", 0, 11, 12, 16, 31, 16, 31, 74, 51, 203], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48]]
8
1,164
10
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Math; using static System.Array; using static AtCoder.Tool; namespace AtCoder { class AC { const int MOD = 1000000007; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dx = { 0, 1, 0, -1 }; static readonly int[] dy = { 1, 0, -1, 0 }; // static List<List<int>> G = new List<List<int>>(); // static List<List<Edge>>G = new List<List<Edge>>(); // static List<Edge> E = new List<Edge>(); static void Main(string[] args) { // var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = // false }; Console.SetOut(sw); var cin = new Scanner(); var input = cin.SplitReadL(); long n = input[0]; long m = input[1]; long d = input[2]; Console.WriteLine((double)(m - 1) / n); // Console.Out.Flush(); } struct Edge { public int from; public int to; public long dist; public Edge(int t, long c) { from = -1; to = t; dist = c; } public Edge(int f, int t, long c) { from = f; to = t; dist = c; } } struct Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T first; public U second; private readonly bool CompWithFirst; public Pair(T f, U s, int comp) { first = f; second = s; CompWithFirst = comp == 1; } public Pair(T f, U s) { first = f; second = s; CompWithFirst = true; } public int CompareTo(Pair<T, U> other) { return CompWithFirst ? first.CompareTo(other.first) : second.CompareTo(other.second); } } } public class PriorityQueue<T> where T : IComparable<T> { private List<T> Q; private readonly int r; public PriorityQueue(bool ascending) { if (ascending) { r = 1; } else { r = -1; } Q = new List<T>(); } private void PushHeap(List<T> list, T item) { int n = list.Count(); list.Add(item); while (n != 0) { int pIndex = (n - 1) / 2; if (list[n].CompareTo(list[pIndex]) * r > 0) { Swap(Q, n, pIndex); } else { break; } n = pIndex; } } private void PopHeap(List<T> list) { int n = list.Count() - 1; list[0] = list[n]; list.RemoveAt(n); int cur = 0; int comp; while (2 * cur + 1 <= n - 1) { int c1 = 2 * cur + 1; int c2 = 2 * (cur + 1); if (c1 == n - 1) { comp = c1; } else { comp = list[c1].CompareTo(list[c2]) * r > 0 ? c1 : c2; } if (list[cur].CompareTo(list[comp]) * r < 0) { Swap(Q, cur, comp); } else { break; } cur = comp; } } private void Swap(List<T> list, int a, int b) { T keep = list[a]; list[a] = list[b]; list[b] = keep; } public void Enqueue(T value) { PushHeap(Q, value); } public T Dequeue() { T ret = Q[0]; PopHeap(Q); return ret; } public T Peek() { return Q[0]; } public int CountItem() { return Q.Count(); } } public class Scanner { public int[] SplitRead() { int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray(); return array; } public long[] SplitReadL() { long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray(); return array; } } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { for (var i = 0; i < array.Length; i++) { array[i] = initialvalue; } } static public T MaxLot<T>(params T[] val) where T : IComparable<T> { T ret = val[0]; for (var i = 1; i < val.Count(); i++) { if (ret.CompareTo(val[i]) < 0) { ret = val[i]; } } return ret; } static public T MinLot<T>(params T[] val) where T : IComparable<T> { T ret = val[0]; for (var i = 1; i < val.Count(); i++) { if (ret.CompareTo(val[i]) > 0) { ret = val[i]; } } return ret; } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Math; using static System.Array; using static AtCoder.Tool; namespace AtCoder { class AC { const int MOD = 1000000007; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dx = { 0, 1, 0, -1 }; static readonly int[] dy = { 1, 0, -1, 0 }; // static List<List<int>> G = new List<List<int>>(); // static List<List<Edge>>G = new List<List<Edge>>(); // static List<Edge> E = new List<Edge>(); static void Main(string[] args) { // var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = // false }; Console.SetOut(sw); var cin = new Scanner(); var input = cin.SplitReadL(); long n = input[0]; long m = input[1]; long d = input[2]; double a = (double)(m - 1) / n; double b = (double)(n - d) / n; if (d != 0) { a *= 2; } Console.WriteLine(a * b); // Console.Out.Flush(); } struct Edge { public int from; public int to; public long dist; public Edge(int t, long c) { from = -1; to = t; dist = c; } public Edge(int f, int t, long c) { from = f; to = t; dist = c; } } struct Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T first; public U second; private readonly bool CompWithFirst; public Pair(T f, U s, int comp) { first = f; second = s; CompWithFirst = comp == 1; } public Pair(T f, U s) { first = f; second = s; CompWithFirst = true; } public int CompareTo(Pair<T, U> other) { return CompWithFirst ? first.CompareTo(other.first) : second.CompareTo(other.second); } } } public class PriorityQueue<T> where T : IComparable<T> { private List<T> Q; private readonly int r; public PriorityQueue(bool ascending) { if (ascending) { r = 1; } else { r = -1; } Q = new List<T>(); } private void PushHeap(List<T> list, T item) { int n = list.Count(); list.Add(item); while (n != 0) { int pIndex = (n - 1) / 2; if (list[n].CompareTo(list[pIndex]) * r > 0) { Swap(Q, n, pIndex); } else { break; } n = pIndex; } } private void PopHeap(List<T> list) { int n = list.Count() - 1; list[0] = list[n]; list.RemoveAt(n); int cur = 0; int comp; while (2 * cur + 1 <= n - 1) { int c1 = 2 * cur + 1; int c2 = 2 * (cur + 1); if (c1 == n - 1) { comp = c1; } else { comp = list[c1].CompareTo(list[c2]) * r > 0 ? c1 : c2; } if (list[cur].CompareTo(list[comp]) * r < 0) { Swap(Q, cur, comp); } else { break; } cur = comp; } } private void Swap(List<T> list, int a, int b) { T keep = list[a]; list[a] = list[b]; list[b] = keep; } public void Enqueue(T value) { PushHeap(Q, value); } public T Dequeue() { T ret = Q[0]; PopHeap(Q); return ret; } public T Peek() { return Q[0]; } public int CountItem() { return Q.Count(); } } public class Scanner { public int[] SplitRead() { int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray(); return array; } public long[] SplitReadL() { long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray(); return array; } } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { for (var i = 0; i < array.Length; i++) { array[i] = initialvalue; } } static public T MaxLot<T>(params T[] val) where T : IComparable<T> { T ret = val[0]; for (var i = 1; i < val.Count(); i++) { if (ret.CompareTo(val[i]) < 0) { ret = val[i]; } } return ret; } static public T MinLot<T>(params T[] val) where T : IComparable<T> { T ret = val[0]; for (var i = 1; i < val.Count(); i++) { if (ret.CompareTo(val[i]) > 0) { ret = val[i]; } } return ret; } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 212, 0, 16, 31, 74, 51, 23, 0, 24], ["+", 0, 16, 31, 74, 51, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 74, 51, 23, 0, 16, 12, 22], ["+", 0, 212, 0, 16, 31, 74, 51, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
8
1,098
41
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace AtCoder.SoundHound2018.B { class Program { static void Main() { var sc = new Scanner(); var n = sc.Nextint(); var m = sc.Nextint(); var d = sc.Nextint(); var cnt = (2d + (n - 2d)) * (m - 1); var result = cnt / n / n; Console.WriteLine(result); } } class Scanner { string[] s; long 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 (long i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(long N, double add = 0) { double[] Array = new double[N]; for (long i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } public decimal NextDecimal() { return decimal.Parse(Next()); } public decimal[] ArrayDecimal(long N, decimal add = 0) { decimal[] Array = new decimal[N]; for (long i = 0; i < N; i++) { Array[i] = NextDecimal(); } return Array; } } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace AtCoder.SoundHound2018.C { class Program { static void Main() { var sc = new Scanner(); var n = sc.Nextint(); var m = sc.Nextint(); var d = sc.Nextint(); var cnt = 0d; if (d == 0) cnt = n; else cnt = 2d * (n - d); var result = cnt * (m - 1d) / n / n; Console.WriteLine(result); } } class Scanner { string[] s; long 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 (long i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(long N, double add = 0) { double[] Array = new double[N]; for (long i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } public decimal NextDecimal() { return decimal.Parse(Next()); } public decimal[] ArrayDecimal(long N, decimal add = 0) { decimal[] Array = new decimal[N]; for (long i = 0; i < N; i++) { Array[i] = NextDecimal(); } return Array; } } }
[["-", 36, 36, 0, 208, 0, 209, 141, 232, 141, 22], ["+", 36, 36, 0, 208, 0, 209, 141, 232, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 250], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 31, 250], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 212, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 12, 250], ["+", 0, 16, 31, 16, 31, 16, 12, 23, 0, 25]]
8
553
31
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var array = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); decimal n = array[0]; decimal m = array[1]; decimal d = array[2]; // double res = 1.0 * (m - 1) * Math.Pow(n, m-1) / Math.Pow(n, m); decimal res; res = (m - 1.0m) * (n - d) / n / n; Console.WriteLine(string.Format("{0:f10}", res)); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var array = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); decimal n = array[0]; decimal m = array[1]; decimal d = array[2]; // double res = 1.0 * (m - 1) * Math.Pow(n, m-1) / Math.Pow(n, m); decimal res; if (d == 0) { res = (m - 1.0m) / n; } else { res = (m - 1.0m) * 2 * (n - d) / n / n; } Console.WriteLine(string.Format("{0:f10}", res)); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 31, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 12, 250], ["+", 31, 16, 31, 16, 31, 16, 31, 23, 0, 25], ["+", 12, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
124
23
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Practice { class Program { public struct Card { public char c; public int d; } static void Main(string[] args) { // SolveA(args); // SolveB(args); SolveC(args); // SolveD(args); } static void SolveA(string[] args) { // int n =int.Parse(Console.ReadLine()); int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int a = arr[0]; int b = arr[1]; string result = null; if (a + b == 15) { result = "+"; } else if (a * b == 15) { result = "*"; } else { result = "x"; } Console.WriteLine(result); } static void SolveB(string[] args) { string sz = Console.ReadLine(); int w = int.Parse(Console.ReadLine()); string result = ""; for (int i = 0; i < sz.Length; i += w) { result += sz[i]; } Console.WriteLine(result); } static void SolveC(string[] args) { int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); long n = arr[0]; long m = arr[1]; long d = arr[2]; double result = 0.0; if (n == 1) { result = 1.0; } else if (n == 2) { result = (double)(m - 1) / 2; } else { if (d == 0) { result = (double)(m - 1) / n; } else { } } Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Practice { class Program { public struct Card { public char c; public int d; } static void Main(string[] args) { // SolveA(args); // SolveB(args); SolveC(args); // SolveD(args); } static void SolveA(string[] args) { // int n =int.Parse(Console.ReadLine()); int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int a = arr[0]; int b = arr[1]; string result = null; if (a + b == 15) { result = "+"; } else if (a * b == 15) { result = "*"; } else { result = "x"; } Console.WriteLine(result); } static void SolveB(string[] args) { string sz = Console.ReadLine(); int w = int.Parse(Console.ReadLine()); string result = ""; for (int i = 0; i < sz.Length; i += w) { result += sz[i]; } Console.WriteLine(result); } static void SolveC(string[] args) { int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); long n = arr[0]; long m = arr[1]; long d = arr[2]; double result = 0.0; if (n == 1) { result = 1.0; } else if (n == 2) { result = (double)(m - 1) / 2; } else { if (d == 0) { result = (double)(m - 1) / n; } else { result = (double)(n - d) * 2 * (m - 1) / n / n; } } Console.WriteLine(result); } } }
[["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 31, 16, 31, 16, 31, 16, 31, 74, 0, 24], ["+", 31, 16, 31, 16, 31, 16, 31, 74, 39, 199], ["+", 31, 16, 31, 16, 31, 16, 31, 74, 0, 25], ["+", 31, 16, 31, 16, 31, 74, 51, 23, 0, 24], ["+", 31, 16, 31, 74, 51, 23, 0, 16, 31, 22], ["+", 31, 16, 31, 74, 51, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 74, 51, 23, 0, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 74, 51, 23, 0, 25], ["+", 12, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 12, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 48], ["+", 12, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["+", 12, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 75, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
8
377
23
using System; using System.Collections.Generic; using System.Linq; class Solution { static void Main() { var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); var n = vals[0]; var m = vals[1]; var d = vals[2]; var ones = d == 0 ? n : Math.Min(d * 2, n); var twos = n - ones; var probability = (1 * ones + 2 * twos) / (double)n / n; Console.WriteLine(probability); var ave = (m - 1) * probability; Console.WriteLine(ave); } }
using System; using System.Collections.Generic; using System.Linq; class Solution { static void Main() { var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); var n = vals[0]; var m = vals[1]; var d = vals[2]; var ones = d == 0 ? n : Math.Min(d * 2, n); var twos = n - ones; var probability = (1 * ones + 2 * twos) / (double)n / n; var ave = (m - 1) * probability; Console.WriteLine(ave); } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
149
7
using System; using System.Collections.Generic; class Program { static void Main() { int[] s = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); List<long[]>[] li = new List<long[]>[s[0] + 1]; long[] hy = new long[s[0] + 1]; long[] hs = new long[s[0] + 1]; long[] ans = new long[s[0]]; for (int i = 1; i <= s[0]; i++) { li[i] = new List<long[]>(); hy[i] = -1; hs[i] = -1; } for (int i = 0; i < s[1]; i++) { long[] q = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); li[q[0]].Add(new long[] { q[1], q[2], q[3] }); li[q[1]].Add(new long[] { q[0], q[2], q[3] }); } int m = 1; heap uy = new heap(); for (int i = 0; i < li[s[2]].Count; i++) { uy.ha(li[s[2]][i][1], li[s[2]][i][0]); } hy[s[2]] = 0; while (m < s[0]) { if (hs[uy.he[0][1]] == -1) { hy[uy.he[0][1]] = uy.he[0][0]; for (int i = 0; i < li[uy.he[0][1]].Count; i++) { if (hy[li[uy.he[0][1]][i][0]] == -1) { uy.ha(li[uy.he[0][1]][i][1] + uy.he[0][0], li[uy.he[0][1]][i][0]); } } m++; } uy.hr(); } m = 1; heap us = new heap(); for (int i = 0; i < li[s[3]].Count; i++) { us.ha(li[s[3]][i][2], li[s[3]][i][0]); } hs[s[3]] = 0; while (m < s[0]) { if (hs[us.he[0][1]] == -1) { hs[us.he[0][1]] = us.he[0][0]; for (int i = 0; i < li[us.he[0][1]].Count; i++) { if (hs[li[us.he[0][1]][i][0]] == -1) { us.ha(li[us.he[0][1]][i][2] + us.he[0][0], li[us.he[0][1]][i][0]); } } m++; } us.hr(); } ans[s[0] - 1] = 1000000000000000 - hy[s[0]] - hs[s[0]]; for (int i = s[0] - 1; i > 0; i--) { ans[i - 1] = Math.Max(1000000000000000 - hy[i] - hs[i], ans[i]); } Console.WriteLine(String.Join("\n", ans)); } } public class heap { public List<long[]> he = new List<long[]>(); public void ha(long a, long b) { he.Add(new long[] { a, b }); int j = he.Count - 1; while (he[j][0] < he[(j - 1) / 2][0]) { long v = he[j][0]; he[j][0] = he[(j - 1) / 2][0]; he[(j - 1) / 2][0] = v; v = he[j][1]; he[j][1] = he[(j - 1) / 2][1]; he[(j - 1) / 2][1] = v; j = (j - 1) / 2; } } public void hr() { he[0][0] = he[he.Count - 1][0]; he[0][1] = he[he.Count - 1][1]; he.RemoveAt(he.Count - 1); int j = 0; while (true) { if (j * 2 + 2 < he.Count) { if (he[j * 2 + 1][0] < he[j * 2 + 2][0]) { j = j * 2 + 1; } else { j = j * 2 + 2; } } else if (j * 2 + 1 < he.Count) { j = j * 2 + 1; } else { break; } if (he[j][0] >= he[(j - 1) / 2][0]) { break; } long v = he[j][0]; he[j][0] = he[(j - 1) / 2][0]; he[(j - 1) / 2][0] = v; v = he[j][1]; he[j][1] = he[(j - 1) / 2][1]; he[(j - 1) / 2][1] = v; } } }
using System; using System.Collections.Generic; class Program { static void Main() { int[] s = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); List<long[]>[] li = new List<long[]>[s[0] + 1]; long[] hy = new long[s[0] + 1], hs = new long[s[0] + 1], ans = new long[s[0]]; for (int i = 1; i <= s[0]; i++) { li[i] = new List<long[]>(); hy[i] = -1; hs[i] = -1; } for (int i = 0; i < s[1]; i++) { long[] q = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); li[q[0]].Add(new long[] { q[1], q[2], q[3] }); li[q[1]].Add(new long[] { q[0], q[2], q[3] }); } int m = 1; heap uy = new heap(); for (int i = 0; i < li[s[2]].Count; i++) { uy.ha(li[s[2]][i][1], li[s[2]][i][0]); } hy[s[2]] = 0; while (m < s[0]) { if (hy[uy.he[0][1]] == -1) { hy[uy.he[0][1]] = uy.he[0][0]; for (int i = 0; i < li[uy.he[0][1]].Count; i++) { if (hy[li[uy.he[0][1]][i][0]] == -1) { uy.ha(li[uy.he[0][1]][i][1] + uy.he[0][0], li[uy.he[0][1]][i][0]); } } m++; } uy.hr(); } m = 1; heap us = new heap(); for (int i = 0; i < li[s[3]].Count; i++) { us.ha(li[s[3]][i][2], li[s[3]][i][0]); } hs[s[3]] = 0; while (m < s[0]) { if (hs[us.he[0][1]] == -1) { hs[us.he[0][1]] = us.he[0][0]; for (int i = 0; i < li[us.he[0][1]].Count; i++) { if (hs[li[us.he[0][1]][i][0]] == -1) { us.ha(li[us.he[0][1]][i][2] + us.he[0][0], li[us.he[0][1]][i][0]); } } m++; } us.hr(); } ans[s[0] - 1] = 1000000000000000 - hy[s[0]] - hs[s[0]]; for (int i = s[0] - 1; i > 0; i--) { ans[i - 1] = Math.Max(1000000000000000 - hy[i] - hs[i], ans[i]); } Console.WriteLine(String.Join("\n", ans)); } } public class heap { public List<long[]> he = new List<long[]>(); public void ha(long a, long b) { he.Add(new long[] { a, b }); int j = he.Count - 1; while (he[j][0] < he[(j - 1) / 2][0]) { long v = he[j][0]; he[j][0] = he[(j - 1) / 2][0]; he[(j - 1) / 2][0] = v; v = he[j][1]; he[j][1] = he[(j - 1) / 2][1]; he[(j - 1) / 2][1] = v; j = (j - 1) / 2; } } public void hr() { he[0][0] = he[he.Count - 1][0]; he[0][1] = he[he.Count - 1][1]; he.RemoveAt(he.Count - 1); int j = 0; while (true) { if (j * 2 + 2 < he.Count) { if (he[j * 2 + 1][0] < he[j * 2 + 2][0]) { j = j * 2 + 1; } else { j = j * 2 + 2; } } else if (j * 2 + 1 < he.Count) { j = j * 2 + 1; } else { break; } if (he[j][0] >= he[(j - 1) / 2][0]) { break; } long v = he[j][0]; he[j][0] = he[(j - 1) / 2][0]; he[(j - 1) / 2][0] = v; v = he[j][1]; he[j][1] = he[(j - 1) / 2][1]; he[(j - 1) / 2][1] = v; } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22]]
8
1,351
12
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; static List<Tuple<int, int>>[] li; static int[] b; static int z = 0; static long u = 0; static long[] h, d; static bool bo = false; static void Main() { Sc sc = new Sc(); var s = sc.Ia; int n = s[0], m = s[1]; li = new List<Tuple<int, int>>[n + 1]; b = new int[n + 1]; h = new long[n + 1]; d = new long[] { long.MaxValue, 1 }; var c = new long[n + 1]; for (int i = 1; i <= n; i++) { li[i] = new List<Tuple<int, int>>(); c[i] = long.MaxValue; } for (int i = 0; i < m; i++) { var e = sc.Ia; li[e[0]].Add(Tuple.Create(e[1], e[2])); li[e[1]].Add(Tuple.Create(e[0], e[2])); } h[1] = 1; Fu(1, 1); long ans = 0; if (z != 0) { h[z] = u >> 1; b = new int[n + 1]; Fu2(z); h[0] = 1; ans = (h.Min() > 0 && z != -1) ? 1 : 0; } else { if (d[0] + d[1] > 0) { ans = 1 + d[0] - 1 + d[1] - 1; } } Console.WriteLine("{0}", ans); } static void Fu2(int a) { b[a] = 1; for (int i = 0; i < li[a].Count && z != -1; i++) { if (b[li[a][i].Item1] == 0) { h[li[a][i].Item1] = li[a][i].Item2 - h[a]; Fu2(li[a][i].Item1); } else if (li[a][i].Item2 - h[li[a][i].Item1] != h[a]) { z = -1; } } } static void Fu(int a, int g) { b[a] = g; for (int i = 0; i < li[a].Count; i++) { if (b[li[a][i].Item1] == 0) { h[li[a][i].Item1] = li[a][i].Item2 - h[a]; d[(g ^ 1) & 1] = Min(d[(g ^ 1) & 1], h[li[a][i].Item1]); Fu(li[a][i].Item1, g + 1); if (z != 0) { if (!bo) { u += li[a][i].Item2 * (b[z] % 2 == b[a] % 2 ? 1 : -1); if (z == a) { bo = true; } } break; } } else if (b[li[a][i].Item1] != g - 1) { if ((g - b[li[a][i].Item1]) % 2 == 0) { u += li[a][i].Item2; z = li[a][i].Item1; break; } } } } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program { const int mod = (int)1e9 + 7; static List<Tuple<int, int>>[] li; static int[] b; static int z = 0; static long u = 0; static long[] h, d; static bool bo = false; static void Main() { Sc sc = new Sc(); var s = sc.Ia; int n = s[0], m = s[1]; li = new List<Tuple<int, int>>[n + 1]; b = new int[n + 1]; h = new long[n + 1]; d = new long[] { long.MaxValue, 1 }; var c = new long[n + 1]; for (int i = 1; i <= n; i++) { li[i] = new List<Tuple<int, int>>(); c[i] = long.MaxValue; } for (int i = 0; i < m; i++) { var e = sc.Ia; li[e[0]].Add(Tuple.Create(e[1], e[2])); li[e[1]].Add(Tuple.Create(e[0], e[2])); } h[1] = 1; Fu(1, 1); long ans = 0; if (z != 0) { h[z] = u >> 1; b = new int[n + 1]; Fu2(z); h[0] = 1; ans = (h.Min() > 0 && z != -1) ? 1 : 0; } else { b = new int[n + 1]; Fu2(1); if (d[0] + d[1] > 0 && z != -1) { ans = 1 + d[0] - 1 + d[1] - 1; } } Console.WriteLine("{0}", ans); } static void Fu2(int a) { b[a] = 1; for (int i = 0; i < li[a].Count && z != -1; i++) { if (b[li[a][i].Item1] == 0) { h[li[a][i].Item1] = li[a][i].Item2 - h[a]; Fu2(li[a][i].Item1); } else if (li[a][i].Item2 - h[li[a][i].Item1] != h[a]) { z = -1; } } } static void Fu(int a, int g) { b[a] = g; for (int i = 0; i < li[a].Count; i++) { if (b[li[a][i].Item1] == 0) { h[li[a][i].Item1] = li[a][i].Item2 - h[a]; d[(g ^ 1) & 1] = Min(d[(g ^ 1) & 1], h[li[a][i].Item1]); Fu(li[a][i].Item1, g + 1); if (z != 0) { if (!bo) { u += li[a][i].Item2 * (b[z] % 2 == b[a] % 2 ? 1 : -1); if (z == a) { bo = true; } } break; } } else if (b[li[a][i].Item1] != g - 1) { if ((g - b[li[a][i].Item1]) % 2 == 0) { u += li[a][i].Item2; z = li[a][i].Item1; break; } } } } } public class Sc { public int I { get { return int.Parse(Console.ReadLine()); } } public long L { get { return long.Parse(Console.ReadLine()); } } public double D { get { return double.Parse(Console.ReadLine()); } } public string S { get { return Console.ReadLine(); } } public int[] Ia { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } public object[] Oa { get { return Console.ReadLine().Split(); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public int[] Ia3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), int.Parse); } public int[] Ia3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), int.Parse); } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), long.Parse); } } public long[] La3(int a) { return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(), long.Parse); } public long[] La3(bool a, int b, bool c, int d) { return Array.ConvertAll(((a ? b.ToString() + " " : "") + Console.ReadLine() + (c ? " " + d.ToString() : "")) .Split(), long.Parse); } public T[] Arr<T>(int n, Func<T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(); } return a; } public T[] Arr<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i); } return a; } public T[] Arr<T>(int n, Func<string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(Console.ReadLine().Split()); } return a; } public T[] Arr<T>(int n, Func<int, string[], T> f) { var a = new T[n]; for (int i = 0; i < n; i++) { a[i] = f(i, Console.ReadLine().Split()); } return a; } }
[["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 227, 0, 228], ["+", 0, 1, 0, 11, 12, 227, 39, 224, 39, 199], ["+", 0, 11, 12, 227, 39, 224, 225, 226, 0, 70], ["+", 12, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["+", 12, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["+", 12, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 0, 11, 12, 227, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 213, 63, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 98], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 16, 12, 16, 12, 241, 0, 33], ["+", 0, 57, 15, 16, 12, 16, 12, 241, 0, 203]]
8
1,668
20
using System; using System.Linq; namespace AtCorder { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); var a = "1 1 1 1 1".Split(' ').Select(s => long.Parse(s)).Distinct(); var min = a.Min(); var max = a.Max(); Console.WriteLine(max - min); } } }
using System; using System.Linq; namespace AtCorder { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).Distinct(); var min = a.Min(); var max = a.Max(); Console.WriteLine(max - min); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 63, 214, 205, 213, 63, 214, 205, 5, 0, 62], ["-", 63, 214, 205, 213, 63, 214, 205, 5, 0, 222], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
8
98
12
using System; class Program { static void Main() { int N = int.Parse(Console.ReadLine()); int L, kL; string[] str = Console.ReadLine().Split(' '); L = 0; kL = 0; for (int i = 0; i < N - 1; i++) { L = System.Math.Abs(int.Parse(str[i]) - int.Parse(str[i + 1])); if (L > kL) { kL = L; } } Console.WriteLine("{0}", kL); } }
using System; class Program { static void Main() { int N = int.Parse(Console.ReadLine()); int L, kL; string[] str = Console.ReadLine().Split(' '); L = 0; kL = 0; for (int i = 0; i < N - 1; i++) { for (int j = 1; j < N; j++) { L = System.Math.Abs(int.Parse(str[i]) - int.Parse(str[j])); if (L > kL) { kL = L; } } } Console.WriteLine("{0}", kL); } }
[["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
131
20
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); int N = int.Parse(input); string[] s_array = Console.ReadLine().Split(' '); int[] A_array = new int[N + 1]; for (int i = 0; i < N; i++) { A_array[i] = int.Parse(s_array[i]); } int max = A_array.Max(); int min = A_array.Min(); Console.WriteLine(max - min); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); int N = int.Parse(input); string[] s_array = Console.ReadLine().Split(' '); var A_array = new List<int>(); for (int i = 0; i < N; i++) { A_array.Add(int.Parse(s_array[i])); } int max = A_array.Max(); int min = A_array.Min(); Console.WriteLine(max - min); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
154
22
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace C { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var n = int.Parse(Console.ReadLine()); var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); var bi = ai.Select((x, i) => x - (i + 1)).ToArray(); Array.Sort(bi); var b = bi.Length % 2 == 0 ? bi[(n + 1) / 2 - 1] : bi[n / 2 - 1]; var answer = ai.Select((x, i) => Math.Abs(x - (b + i + 1))).Sum(); Console.WriteLine(answer); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace C { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var n = int.Parse(Console.ReadLine()); var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); var bi = ai.Select((x, i) => x - (i + 1)).ToArray(); Array.Sort(bi); var b = n % 2 == 0 ? bi[n / 2 - 1] : bi[n / 2]; var answer = ai.Select((x, i) => Math.Abs(x - (b + i + 1))).Sum(); Console.WriteLine(answer); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 41, 15, 16, 31, 16, 31, 214, 205, 22], ["-", 0, 41, 15, 16, 31, 16, 31, 214, 0, 131], ["-", 0, 41, 15, 16, 31, 16, 31, 214, 141, 22], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 31, 22], ["-", 0, 28, 0, 16, 31, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 75, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 75, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
241
12
using System; using System.Diagnostics; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; class Program { const string Yes = "Yes"; const string No = "No"; const long Mod = 1000000007; static void Main(string[] args) { #if DEBUG MyDebugger.Test(process, "../TextFile1.txt"); #else object ret = process(new StreamReader(Console.OpenStandardInput())); Console.WriteLine(ret); #endif } static object process(TextReader input) { var n = int.Parse(input.ReadLine()); var aa = ToIntArray(input.ReadLine(), n); Func<long, long> f = (x) => { return aa.Sum(a => Math.Abs(a - x)); }; for (int i = 0; i < n; i++) { aa[i] -= (i + 1); } Array.Sort(aa); var ce = aa.Length / 2; long min = long.MaxValue; min = Math.Min(min, f(aa[ce])); min = Math.Min(min, f(aa[ce + 1])); return min; } static long[] ToIntArray(string strs, int n) { var ret = new long[n]; var spl = strs.Split(' '); for (int i = 0; i < n; i++) ret[i] = long.Parse(spl[i]); return ret; } }
using System; using System.Diagnostics; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; class Program { const string Yes = "Yes"; const string No = "No"; const long Mod = 1000000007; static void Main(string[] args) { #if DEBUG MyDebugger.Test(process, "../TextFile1.txt"); #else object ret = process(new StreamReader(Console.OpenStandardInput())); Console.WriteLine(ret); #endif } static object process(TextReader input) { var n = int.Parse(input.ReadLine()); var aa = ToIntArray(input.ReadLine(), n); Func<long, long> f = (x) => { return aa.Sum(a => Math.Abs(a - x)); }; for (int i = 0; i < n; i++) { aa[i] -= (i + 1); } Array.Sort(aa); var ce = aa.Length / 2; long min = long.MaxValue; min = Math.Min(min, f(aa[ce])); // min = Math.Min(min, f(aa[ce +1])); return min; } static long[] ToIntArray(string strs, int n) { var ret = new long[n]; var spl = strs.Split(' '); for (int i = 0; i < n; i++) ret[i] = long.Parse(spl[i]); return ret; } }
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 12, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
340
19
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; namespace ABC102C { class Program { static void Solve(Input input) { var n = input.NextInt(); var a = input.NextInt(n); var b = a.Select((x, i) => x - (i + 1)).OrderBy(x => x).ToArray(); int c1 = b[(int)Math.Floor(b.Length / 2.0)]; int c2 = b[(int)Math.Ceiling(b.Length / 2.0)]; long sum1 = 0; long sum2 = 0; for (int i = 0; i < n; i++) { sum1 += Math.Abs(a[i] - (c1 + i + 1)); sum2 += Math.Abs(a[i] - (c2 + i + 1)); } Console.WriteLine(Math.Min(sum1, sum2)); } #region Competitive Template static readonly int MOD = (int)1e9 + 7; public static void Main(string[] args) { // 出力が少ないときはこれをセットする方が時間かかるけれど // その場合は出力がボトルネックになっていないので、まあ良しとする var needsFlushOutput = true; if (needsFlushOutput) { // 細かく出力しないようにする var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } // 通常は引数無しで、ファイルから読み出したい場合はpath指定する var input = new Input(); // 仮想的に標準入力をセットする // input.SetText(""); Solve(input); Console.Out.Flush(); } class Input { // 変な改行コードがたまに混じっているので、一応セパレート指定する // スペース単独指定の方がもちろん早い static readonly char[] separator = { ' ', '\r', '\n' }; Queue<string> q { get; set; } StreamReader sr; /// <summary> /// 特定のファイルから読み出したい場合はpath指定する /// </summary> /// <param name="path"></param> public Input(string path = "") { q = new Queue<string>(); if (string.IsNullOrEmpty(path)) { sr = new StreamReader(Console.OpenStandardInput()); } else { sr = new StreamReader(path); } } /// <summary> /// 入力予約 /// </summary> /// <param name="items"></param> public void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } /// <summary> /// 入力予約 /// </summary> /// <param name="s"></param> /// <returns></returns> public bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } return true; } /// <summary> /// 内部queueに入力からの値をsplitして格納する /// </summary> /// <returns></returns> bool read() { var s = sr.ReadLine(); if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } if (!q.Any()) return read(); return true; } /// <summary> /// 次のstringを一つ読み込む /// </summary> /// <returns></returns> public string Next() { if (!q.Any()) { if (!read()) { return ""; } } return q.Dequeue(); } /// <summary> /// 指定個数queueにたまるまでenqueueし続ける /// </summary> /// <param name="n"></param> /// <returns></returns> bool accumulate(int n) { while (q.Count() < n) { if (!read()) return false; } return true; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); /// <summary> /// n個の要素をparseして、それぞれにoffsetをaddした配列を返す /// </summary> /// <typeparam name="T"></typeparam> /// <param name="n"></param> /// <param name="offset"></param> /// <param name="parse"></param> /// <param name="add"></param> /// <returns></returns> T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) { if (!accumulate(n)) return null; var a = new T[n]; for (int i = 0; i < n; i++) a[i] = add(parse(q.Dequeue()), offset); return a; } public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x); public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse, (x, y) => x + y); public long[] NextLong(int n, long offset = 0) => NextT(n, offset, long.Parse, (x, y) => x + y); public double[] NextDouble(int n, double offset = 0.0) => NextT(n, offset, double.Parse, (x, y) => x + y); } static class Utils { public static void Print<T>(IEnumerable<T> ie, string sep = " ") => Console.WriteLine(string.Join(sep, ie)); public static void Print<T>(params T[] objs) => Print(objs); public static T Max<T>(params T[] objs) => objs.Max(); public static T Min<T>(params T[] objs) => objs.Min(); public static void Swap<T>(ref T x, ref T y) where T : struct { var t = x; x = y; y = t; } public static void Swap<T>(IList<T> list, int i, int j) where T : struct { var t = list[i]; list[i] = list[j]; list[j] = t; } /// <summary> /// vでfillされたT[d1][d2]配列を作成する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="d1"></param> /// <param name="d2"></param> /// <param name="v"></param> /// <returns></returns> public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) { return Enumerable.Repeat(0, d1) .Select(_ => Enumerable.Repeat(v, d2).ToArray()) .ToArray(); } /// <summary> /// vでfillされたT[d1][d2][d3]配列を作成する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="d1"></param> /// <param name="d2"></param> /// <param name="d3"></param> /// <param name="v"></param> /// <returns></returns> public static T[][][] Create3DArray<T>(int d1, int d2, int d3, T v = default(T)) { return Enumerable.Repeat(0, d1) .Select(_ => Enumerable.Repeat(0, d2) .Select(__ => Enumerable.Repeat(v, d3).ToArray()) .ToArray()) .ToArray(); } } #endregion } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; namespace ABC102C { class Program { static void Solve(Input input) { var n = input.NextInt(); var a = input.NextInt(n); if (n == 1) { Console.WriteLine(0); return; } var b = a.Select((x, i) => x - (i + 1)).OrderBy(x => x).ToArray(); int c1 = b[(int)Math.Floor(b.Length / 2.0)]; int c2 = b[(int)Math.Ceiling(b.Length / 2.0)]; long sum1 = 0; long sum2 = 0; for (int i = 0; i < n; i++) { sum1 += Math.Abs(a[i] - (c1 + i + 1)); sum2 += Math.Abs(a[i] - (c2 + i + 1)); } Console.WriteLine(Math.Min(sum1, sum2)); } #region Competitive Template static readonly int MOD = (int)1e9 + 7; public static void Main(string[] args) { // 出力が少ないときはこれをセットする方が時間かかるけれど // その場合は出力がボトルネックになっていないので、まあ良しとする var needsFlushOutput = true; if (needsFlushOutput) { // 細かく出力しないようにする var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } // 通常は引数無しで、ファイルから読み出したい場合はpath指定する var input = new Input(); // 仮想的に標準入力をセットする // input.SetText(""); Solve(input); Console.Out.Flush(); } class Input { // 変な改行コードがたまに混じっているので、一応セパレート指定する // スペース単独指定の方がもちろん早い static readonly char[] separator = { ' ', '\r', '\n' }; Queue<string> q { get; set; } StreamReader sr; /// <summary> /// 特定のファイルから読み出したい場合はpath指定する /// </summary> /// <param name="path"></param> public Input(string path = "") { q = new Queue<string>(); if (string.IsNullOrEmpty(path)) { sr = new StreamReader(Console.OpenStandardInput()); } else { sr = new StreamReader(path); } } /// <summary> /// 入力予約 /// </summary> /// <param name="items"></param> public void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } /// <summary> /// 入力予約 /// </summary> /// <param name="s"></param> /// <returns></returns> public bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } return true; } /// <summary> /// 内部queueに入力からの値をsplitして格納する /// </summary> /// <returns></returns> bool read() { var s = sr.ReadLine(); if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } if (!q.Any()) return read(); return true; } /// <summary> /// 次のstringを一つ読み込む /// </summary> /// <returns></returns> public string Next() { if (!q.Any()) { if (!read()) { return ""; } } return q.Dequeue(); } /// <summary> /// 指定個数queueにたまるまでenqueueし続ける /// </summary> /// <param name="n"></param> /// <returns></returns> bool accumulate(int n) { while (q.Count() < n) { if (!read()) return false; } return true; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); /// <summary> /// n個の要素をparseして、それぞれにoffsetをaddした配列を返す /// </summary> /// <typeparam name="T"></typeparam> /// <param name="n"></param> /// <param name="offset"></param> /// <param name="parse"></param> /// <param name="add"></param> /// <returns></returns> T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) { if (!accumulate(n)) return null; var a = new T[n]; for (int i = 0; i < n; i++) a[i] = add(parse(q.Dequeue()), offset); return a; } public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x); public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse, (x, y) => x + y); public long[] NextLong(int n, long offset = 0) => NextT(n, offset, long.Parse, (x, y) => x + y); public double[] NextDouble(int n, double offset = 0.0) => NextT(n, offset, double.Parse, (x, y) => x + y); } static class Utils { public static void Print<T>(IEnumerable<T> ie, string sep = " ") => Console.WriteLine(string.Join(sep, ie)); public static void Print<T>(params T[] objs) => Print(objs); public static T Max<T>(params T[] objs) => objs.Max(); public static T Min<T>(params T[] objs) => objs.Min(); public static void Swap<T>(ref T x, ref T y) where T : struct { var t = x; x = y; y = t; } public static void Swap<T>(IList<T> list, int i, int j) where T : struct { var t = list[i]; list[i] = list[j]; list[j] = t; } /// <summary> /// vでfillされたT[d1][d2]配列を作成する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="d1"></param> /// <param name="d2"></param> /// <param name="v"></param> /// <returns></returns> public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) { return Enumerable.Repeat(0, d1) .Select(_ => Enumerable.Repeat(v, d2).ToArray()) .ToArray(); } /// <summary> /// vでfillされたT[d1][d2][d3]配列を作成する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="d1"></param> /// <param name="d2"></param> /// <param name="d3"></param> /// <param name="v"></param> /// <returns></returns> public static T[][][] Create3DArray<T>(int d1, int d2, int d3, T v = default(T)) { return Enumerable.Repeat(0, d1) .Select(_ => Enumerable.Repeat(0, d2) .Select(__ => Enumerable.Repeat(v, d3).ToArray()) .ToArray()) .ToArray(); } } #endregion } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
1,286
17
using System; using System.Collections.Generic; using System.Linq; class Procon { public Procon() {} static void Main(string[] agrs) { new Procon().Do(); } Scanner cin; public void Do() { cin = new Scanner(); int N = cin.nextInt(); long[] a = cin.arrayLong(); long[] b = new long[N]; for (int i = 1; i <= N; i++) { b[i - 1] = a[i - 1] - i; } Array.Sort(b); long m = (b[N / 2 - 1] + b[N / 2]) / 2; long ret = 0; for (int i = 0; i < N; i++) { ret += Math.Abs(b[i] - m); } Console.WriteLine(ret); } } class Scanner { string[] s; int i; int max_i; public Scanner() { s = new string[0]; max_i = 0; i = 0; } public string nextString() { if (i >= s.Length) { s = Console.ReadLine().Split(' '); max_i = s.Length; i = 0; if (max_i == 0) { return ""; } return s[i++]; } else { return s[i++]; } } public int nextInt() { return int.Parse(nextString()); } public long nextLong() { return long.Parse(nextString()); } public double nextDouble() { return double.Parse(nextString()); } public string[] arrayString() { return Console.ReadLine().Split(' '); } public int[] arrayInt() { string[] str = Console.ReadLine().Split(' '); int[] array = new int[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = int.Parse(str[i]); } return array; } public long[] arrayLong() { string[] str = Console.ReadLine().Split(' '); long[] array = new long[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = long.Parse(str[i]); } return array; } public double[] arrayDouble() { string[] str = Console.ReadLine().Split(' '); double[] array = new double[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = double.Parse(str[i]); } return array; } }
using System; using System.Collections.Generic; using System.Linq; class Procon { public Procon() {} static void Main(string[] agrs) { new Procon().Do(); } Scanner cin; public void Do() { cin = new Scanner(); int N = cin.nextInt(); long[] a = cin.arrayLong(); long[] b = new long[N]; for (int i = 1; i <= N; i++) { b[i - 1] = a[i - 1] - i; } Array.Sort(b); long m = 0; if (N % 2 == 0) { m = (b[N / 2 - 1] + b[N / 2]) / 2; } else { m = b[N / 2]; } long ret = 0; for (int i = 0; i < N; i++) { ret += Math.Abs(b[i] - m); } Console.WriteLine(ret); } } class Scanner { string[] s; int i; int max_i; public Scanner() { s = new string[0]; max_i = 0; i = 0; } public string nextString() { if (i >= s.Length) { s = Console.ReadLine().Split(' '); max_i = s.Length; i = 0; if (max_i == 0) { return ""; } return s[i++]; } else { return s[i++]; } } public int nextInt() { return int.Parse(nextString()); } public long nextLong() { return long.Parse(nextString()); } public double nextDouble() { return double.Parse(nextString()); } public string[] arrayString() { return Console.ReadLine().Split(' '); } public int[] arrayInt() { string[] str = Console.ReadLine().Split(' '); int[] array = new int[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = int.Parse(str[i]); } return array; } public long[] arrayLong() { string[] str = Console.ReadLine().Split(' '); long[] array = new long[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = long.Parse(str[i]); } return array; } public double[] arrayDouble() { string[] str = Console.ReadLine().Split(' '); double[] array = new double[str.Length]; for (int i = 0; i < str.Length; i++) { array[i] = double.Parse(str[i]); } return array; } }
[["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
607
26
using System; using System.Linq; using System.Collections.Generic; class Cmondai { static void Main() { var N = Int64.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray(); var array = new long[N]; for (long i = 0; i < N; ++i) { array[i] = A[i] - (i + 1); } array = array.OrderBy(x => x).ToArray(); var num = (N + 1) / 2; var ans = 0L; if (N % 2 == 0) { num = (array[num - 1] + array[num]) / 2; Math.Min(GetAns(N, A, num - 1), Math.Min(GetAns(N, A, num), GetAns(N, A, num + 1))); } else ans = GetAns(N, A, num); Console.WriteLine(ans); } static long GetAns(long N, long[] A, long num) { var ans = 0L; for (long i = 0; i < N; ++i) { ans += Math.Abs(A[i] - (i + 1 + num)); } return ans; } }
using System; using System.Linq; using System.Collections.Generic; class Cmondai { static void Main() { var N = Int64.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray(); var array = new long[N]; for (long i = 0; i < N; ++i) { array[i] = A[i] - (i + 1); } array = array.OrderBy(x => x).ToArray(); var num = (N + 1) / 2; var ans = 0L; if (N % 2 == 0) { num = (array[num - 1] + array[num]) / 2; ans = Math.Min(GetAns(N, A, num - 1), Math.Min(GetAns(N, A, num), GetAns(N, A, num + 1))); } else { num = array[num - 1]; ans = GetAns(N, A, num); } Console.WriteLine(ans); } static long GetAns(long N, long[] A, long num) { var ans = 0L; for (long i = 0; i < N; ++i) { ans += Math.Abs(A[i] - (i + 1 + num)); } return ans; } }
[["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
293
13
using System; using System.Linq; using System.Collections.Generic; class Cmondai { static void Main() { var N = Int64.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray(); var array = new long[N]; for (long i = 0; i < N; ++i) { array[i] = A[i] - (i + 1); } array = array.OrderBy(x => x).ToArray(); var num = (N + 1) / 2; var ans = 0L; if (N % 2 == 0) num = (array[num - 1] + array[num]) / 2; ans = GetAns(N, A, num); Console.WriteLine(ans); } static long GetAns(long N, long[] A, long num) { var ans = 0L; for (long i = 0; i < N; ++i) { ans += Math.Abs(A[i] - (i + 1 + num)); } return ans; } }
using System; using System.Linq; using System.Collections.Generic; class Cmondai { static void Main() { var N = Int64.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray(); var array = new long[N]; for (long i = 0; i < N; ++i) { array[i] = A[i] - (i + 1); } array = array.OrderBy(x => x).ToArray(); var num = (N + 1) / 2; var ans = 0L; if (N % 2 == 0) num = (array[num - 1] + array[num]) / 2; else num = array[num - 1]; ans = GetAns(N, A, num); Console.WriteLine(ans); } static long GetAns(long N, long[] A, long num) { var ans = 0L; for (long i = 0; i < N; ++i) { ans += Math.Abs(A[i] - (i + 1 + num)); } return ans; } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 1, 0, 11, 12, 204, 205, 22], ["+", 75, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 75, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 75, 1, 0, 35]]
8
249
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC102C_cs { class Program { static void Main(string[] args) { int givenN = int.Parse(Console.ReadLine()); if (givenN == 1) { Console.WriteLine("0"); return; } var givenA = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var changedA = LinearApproximation.ChangedArray(givenA); var center = LinearApproximation.Center(givenN); var median1 = changedA[center]; var median2 = changedA[center + 1]; var result1 = LinearApproximation.Sadness(givenA, median1); var result2 = LinearApproximation.Sadness(givenA, median2); Console.WriteLine(Math.Min(result1, result2)); } } public static class LinearApproximation { public static int[] ChangedArray(int[] a) { var result = a.Select((x, i) => x - i - 1).ToArray(); return result; } public static int Center(int n) { return (n - 1) / 2; } public static int Sadness(int[] a, int b) { return a.Select((n, i) => Math.Abs(n - (b + i + 1))).Sum(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC102C_cs { class Program { static void Main(string[] args) { int givenN = int.Parse(Console.ReadLine()); if (givenN == 1) { Console.WriteLine("0"); return; } var givenA = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var changedA = LinearApproximation.ChangedArray(givenA); var center = LinearApproximation.Center(givenN); double median1 = changedA[center]; double median2 = (changedA[center + 1] + median1) / 2; var result1 = LinearApproximation.Sadness(givenA, median1); var result2 = LinearApproximation.Sadness(givenA, median2); Console.WriteLine(Math.Min(result1, result2)); } } public static class LinearApproximation { public static int[] ChangedArray(int[] a) { var result = a.Select((x, i) => x - i - 1).OrderBy(x => x).ToArray(); return result; } public static int Center(int n) { return (n - 1) / 2; } public static double Sadness(int[] a, double b) { return a.Select((n, i) => Math.Abs(n - (b + i + 1))).Sum(); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199]]
8
294
21
using System; using System.Collections; using System.Collections.Generic; using System.Dynamic; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection.Emit; using System.Runtime.Remoting.Proxies; using System.Text; using static System.Console; using static System.Math; using static Ex; class Simple { private int N; private int[] A; void Solve() { io.i(out N); io.ini(out A, N); var a = new int[N]; REP(N, i => a[i] = A[i] - (i + 1)); var b = (int)a.MEDIAN(); var ans = 0; REP(N, i => ans += Abs(a[i] - b)); io.o(ans); } void Test() { // } public static void Main(string[] args) => new Simple().Stream(); IO io = new IO(); private void Stream() { // var exStdIn = new System.IO.StreamReader("stdin.txt"); // SetIn(exStdIn); Solve(); // Test(); io.Flush(); } } class IO { #region INPUT private const int Size = 1 << 12; private readonly Stream _stream = Console.OpenStandardInput(); private readonly byte[] _buffer = new byte[Size]; private int _ptr = 0, _buffLen = 0; private bool HasNextByte() { if (_ptr < _buffLen) return true; _ptr = 0; _buffLen = _stream.Read(_buffer, 0, Size); return _buffLen > 0; } private byte ReadByte() { if (HasNextByte()) return _buffer[_ptr++]; else throw new EndOfStreamException(); } private bool IsAscii(int c) => '!' <= c && c <= '~'; private void SkipNonAscii() { while (HasNextByte() && !IsAscii(_buffer[_ptr])) _ptr++; } private bool HasNext() { SkipNonAscii(); return HasNextByte(); } private char NextChar() { byte b = 0; do b = ReadByte(); while (!IsAscii(b)); return (char)b; } private string Next() { var sb = new StringBuilder(); for (var b = NextChar(); IsAscii(b); b = (char)ReadByte()) sb.Append(b); return sb.ToString(); } private void Read<T>(out T v) => v = SuitType<T>(Next()); private T ConvertType<T, TU>(TU v) => (T)Convert.ChangeType(v, typeof(T)); private bool TypeEqual<T, TU>() => typeof(T) == typeof(TU); private T SuitType<T>(string s) { if (TypeEqual<T, int>()) ConvertType<T, int>(int.Parse(s)); if (TypeEqual<T, long>()) ConvertType<T, long>(long.Parse(s)); if (TypeEqual<T, double>()) ConvertType<T, double>(double.Parse(s)); if (TypeEqual<T, char>()) ConvertType<T, char>(char.Parse(s)); return ConvertType<T, string>(s); } private T i<T>() => SuitType<T>(String); public string String => Next(); public char Char => NextChar(); public int Int => int.Parse(Next()); public long Long => long.Parse(Next()); public double Double => double.Parse(Next()); public void i<T>(out T v) => Read(out v); public void i<T, TU>(out T t, out TU u) { i(out t); i(out u); } public void i<T, TU, TV>(out T t, out TU u, out TV v) { i(out t, out u); i(out v); } public void i<T, TU, TV, TW>(out T t, out TU u, out TV v, out TW w) { i(out t, out u, out v); i(out w); } public void i<T, TU, TV, TW, TX>(out T t, out TU u, out TV v, out TW w, out TX x) { i(out t, out u, out v, out w); i(out x); } public void ini<T>(out T[] a, int n) { a = new T[n]; for (int i = 0; i < n; ++i) a[i] = i<T>(); } public void ini<T, TU>(out T[] a, out TU[] b, int n) { a = new T[n]; b = new TU[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<TU>(); } } public void ini<T, TU, TV>(out T[] a, out TU[] b, out TV[] c, int n) { a = new T[n]; b = new TU[n]; c = new TV[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<TU>(); c[i] = i<TV>(); } } public void ini<T>(out T[,] a, int h, int w) { a = new T[h, w]; for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) a[i, j] = i<T>(); } #endregion #region OUTPUT private readonly StreamWriter _sw = new StreamWriter(Console.OpenStandardOutput()) { #if DEBUG AutoFlush = true #else AutoFlush = false #endif }; public void Flush() => Console.Out.Flush(); private void Out<T>(T v) => Console.Write(v); private void OutLine<T>(T v) => Console.WriteLine(v); public void o() => OutLine(""); public void o<T>(T v) => OutLine(v); public void o<T>(params T[] a) => Array.ForEach(a, OutLine); public void o<T>(T[,] a) { int a0 = a.GetLength(0), a1 = a.GetLength(1); for (int i = 0; i < a0; ++i) { for (int j = 0; j < a1 - 1; ++j) Out(a[i, j] + " "); OutLine(a[i, a1 - 1]); } } public void ol<T>(params T[] a) => OutLine(string.Join(" ", a)); public void YN(bool f) => OutLine(f ? "YES" : "NO"); public void Yn(bool f) => OutLine(f ? "Yes" : "No"); public void yn(bool f) => OutLine(f ? "yes" : "no"); #endregion public IO() { Console.SetOut(_sw); } } static class Ex { public static void REP(int a, Action<int> act) => FOR(0, a, act); public static void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); } public static void REPEQ(int a, Action<int> act) => FOR(0, a + 1, act); public static void FOREQ(int a, int b, Action<int> act) => FOR(a, b + 1, act); public static T MIN<T>(params T[] a) => a.Min(); public static T MAX<T>(params T[] a) => a.Max(); } static class NumEx { public static string toString(this double d) => d.ToString("R"); public static string Pad0<T>(this T s, int n) => s.ToString().PadLeft(n, '0'); public static int RoundOff(this double v, int n) => (int)Math.Round(v, n - 1, MidpointRounding.AwayFromZero); public static int RoundUp(this double v) => (int)Math.Ceiling(v); public static int RoundDown(this double v) => (int)Math.Floor(v); public static bool Odd(this int v) => (v & 1) != 0; public static bool Odd(this long v) => (v & 1) != 0; } static class ArrayEx { public static int MEAN(this int[] a) => (int)a.Aggregate(0L, (acc, x) => acc + x) / a.Length; public static long MEAN(this long[] a) => a.Sum() / a.Length; public static double MEAN(this double[] a) => a.Sum() / a.Length; public static double MEDIAN(this int[] a) { var arr = a.OrderBy(x => x).ToArray(); if (a.Length % 2 != 0) return a[a.Length / 2]; else return (a[a.Length / 2 - 1] + a[a.Length / 2]) / 2.0; } }
using System; using System.Collections; using System.Collections.Generic; using System.Dynamic; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection.Emit; using System.Runtime.Remoting.Proxies; using System.Text; using static System.Console; using static System.Math; using static Ex; class Simple { private int N; private int[] A; void Solve() { io.i(out N); io.ini(out A, N); var a = new int[N]; REP(N, i => a[i] = A[i] - (i + 1)); var b = a.OrderBy(x => x).ToArray()[a.Length / 2]; var ans = 0L; REP(N, i => ans += Abs(a[i] - b)); io.o(ans); } void Test() { // } public static void Main(string[] args) => new Simple().Stream(); IO io = new IO(); private void Stream() { // var exStdIn = new System.IO.StreamReader("stdin.txt"); // SetIn(exStdIn); Solve(); // Test(); io.Flush(); } } class IO { #region INPUT private const int Size = 1 << 12; private readonly Stream _stream = Console.OpenStandardInput(); private readonly byte[] _buffer = new byte[Size]; private int _ptr = 0, _buffLen = 0; private bool HasNextByte() { if (_ptr < _buffLen) return true; _ptr = 0; _buffLen = _stream.Read(_buffer, 0, Size); return _buffLen > 0; } private byte ReadByte() { if (HasNextByte()) return _buffer[_ptr++]; else throw new EndOfStreamException(); } private bool IsAscii(int c) => '!' <= c && c <= '~'; private void SkipNonAscii() { while (HasNextByte() && !IsAscii(_buffer[_ptr])) _ptr++; } private bool HasNext() { SkipNonAscii(); return HasNextByte(); } private char NextChar() { byte b = 0; do b = ReadByte(); while (!IsAscii(b)); return (char)b; } private string Next() { var sb = new StringBuilder(); for (var b = NextChar(); IsAscii(b); b = (char)ReadByte()) sb.Append(b); return sb.ToString(); } private void Read<T>(out T v) => v = SuitType<T>(Next()); private T ConvertType<T, TU>(TU v) => (T)Convert.ChangeType(v, typeof(T)); private bool TypeEqual<T, TU>() => typeof(T) == typeof(TU); private T SuitType<T>(string s) { if (TypeEqual<T, int>()) ConvertType<T, int>(int.Parse(s)); if (TypeEqual<T, long>()) ConvertType<T, long>(long.Parse(s)); if (TypeEqual<T, double>()) ConvertType<T, double>(double.Parse(s)); if (TypeEqual<T, char>()) ConvertType<T, char>(char.Parse(s)); return ConvertType<T, string>(s); } private T i<T>() => SuitType<T>(String); public string String => Next(); public char Char => NextChar(); public int Int => int.Parse(Next()); public long Long => long.Parse(Next()); public double Double => double.Parse(Next()); public void i<T>(out T v) => Read(out v); public void i<T, TU>(out T t, out TU u) { i(out t); i(out u); } public void i<T, TU, TV>(out T t, out TU u, out TV v) { i(out t, out u); i(out v); } public void i<T, TU, TV, TW>(out T t, out TU u, out TV v, out TW w) { i(out t, out u, out v); i(out w); } public void i<T, TU, TV, TW, TX>(out T t, out TU u, out TV v, out TW w, out TX x) { i(out t, out u, out v, out w); i(out x); } public void ini<T>(out T[] a, int n) { a = new T[n]; for (int i = 0; i < n; ++i) a[i] = i<T>(); } public void ini<T, TU>(out T[] a, out TU[] b, int n) { a = new T[n]; b = new TU[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<TU>(); } } public void ini<T, TU, TV>(out T[] a, out TU[] b, out TV[] c, int n) { a = new T[n]; b = new TU[n]; c = new TV[n]; for (int i = 0; i < n; ++i) { a[i] = i<T>(); b[i] = i<TU>(); c[i] = i<TV>(); } } public void ini<T>(out T[,] a, int h, int w) { a = new T[h, w]; for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) a[i, j] = i<T>(); } #endregion #region OUTPUT private readonly StreamWriter _sw = new StreamWriter(Console.OpenStandardOutput()) { #if DEBUG AutoFlush = true #else AutoFlush = false #endif }; public void Flush() => Console.Out.Flush(); private void Out<T>(T v) => Console.Write(v); private void OutLine<T>(T v) => Console.WriteLine(v); public void o() => OutLine(""); public void o<T>(T v) => OutLine(v); public void o<T>(params T[] a) => Array.ForEach(a, OutLine); public void o<T>(T[,] a) { int a0 = a.GetLength(0), a1 = a.GetLength(1); for (int i = 0; i < a0; ++i) { for (int j = 0; j < a1 - 1; ++j) Out(a[i, j] + " "); OutLine(a[i, a1 - 1]); } } public void ol<T>(params T[] a) => OutLine(string.Join(" ", a)); public void YN(bool f) => OutLine(f ? "YES" : "NO"); public void Yn(bool f) => OutLine(f ? "Yes" : "No"); public void yn(bool f) => OutLine(f ? "yes" : "no"); #endregion public IO() { Console.SetOut(_sw); } } static class Ex { public static void REP(int a, Action<int> act) => FOR(0, a, act); public static void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); } public static void REPEQ(int a, Action<int> act) => FOR(0, a + 1, act); public static void FOREQ(int a, int b, Action<int> act) => FOR(a, b + 1, act); public static T MIN<T>(params T[] a) => a.Min(); public static T MAX<T>(params T[] a) => a.Max(); } static class NumEx { public static string toString(this double d) => d.ToString("R"); public static string Pad0<T>(this T s, int n) => s.ToString().PadLeft(n, '0'); public static int RoundOff(this double v, int n) => (int)Math.Round(v, n - 1, MidpointRounding.AwayFromZero); public static int RoundUp(this double v) => (int)Math.Ceiling(v); public static int RoundDown(this double v) => (int)Math.Floor(v); public static bool Odd(this int v) => (v & 1) != 0; public static bool Odd(this long v) => (v & 1) != 0; } static class ArrayEx { public static int MEAN(this int[] a) => (int)a.Aggregate(0L, (acc, x) => acc + x) / a.Length; public static long MEAN(this long[] a) => a.Sum() / a.Length; public static double MEAN(this double[] a) => a.Sum() / a.Length; public static double MEDIAN(this int[] a) { var arr = a.OrderBy(x => x).ToArray(); if (a.Length % 2 != 0) return a[a.Length / 2]; else return (a[a.Length / 2 - 1] + a[a.Length / 2]) / 2.0; } }
[["+", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 204, 205, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 85], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
2,110
19
using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); var b = new int[n]; for (int i = 0; i < n; i++) b[i] = a[i] - (i + 1); var med = b[n / 2]; Console.WriteLine(getSum(a, med)); } public static long getSum(int[] a, int b) { var n = a.Length; var ret = 0L; for (int i = 0; i < n; i++) ret += Math.Abs(a[i] - (b + i + 1)); return ret; } }
using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); var b = new int[n]; for (int i = 0; i < n; i++) b[i] = a[i] - (i + 1); Array.Sort(b); var med = b[n / 2]; Console.WriteLine(getSum(a, med)); } public static long getSum(int[] a, int b) { var n = a.Length; var ret = 0L; for (int i = 0; i < n; i++) ret += Math.Abs(a[i] - b - i - 1); return ret; } }
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
8
195
13
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCorder { class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var ls = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); for (int i = 0; i < ls.Count(); i++) { ls[i] -= i + 1; } ls.Sort(); var ans = ls.Select(x => Math.Abs(x - ls[int.Parse((N / 2).ToString())])).Sum(); var ansMax = ls.Select(x => Math.Abs(x - ls[int.Parse(((N / 2) + 1).ToString())])) .Sum(); var ansMin = ls.Select(x => Math.Abs(x - ls[int.Parse(((N / 2) - 1).ToString())])) .Sum(); Console.WriteLine((Math.Min(ans, Math.Min(ansMax, ansMin))).ToString()); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCorder { class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var ls = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); if (N == 1) { Console.WriteLine("0"); return; } for (int i = 0; i < ls.Count(); i++) { ls[i] -= i + 1; } ls.Sort(); var ans = ls.Select(x => Math.Abs(x - ls[int.Parse((N / 2).ToString())])).Sum(); var ansMax = ls.Select(x => Math.Abs(x - ls[int.Parse(((N / 2) + 1).ToString())])) .Sum(); var ansMin = ls.Select(x => Math.Abs(x - ls[int.Parse(((N / 2) - 1).ToString())])) .Sum(); Console.WriteLine((Math.Min(ans, Math.Min(ansMax, ansMin))).ToString()); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
279
19
using System; using System.Collections.Generic; using System.Linq; namespace Practice { class Program { static void Main(string[] args) { // SolveA(args); // SolveB(args); SolveC(args); // SolveD(args); } static void SolveA(string[] args) { string sz = (Console.ReadLine()); long n = long.Parse(sz); if (n % 2 == 0) { Console.WriteLine(n); } else { Console.WriteLine(n * 2); } } static void SolveB(string[] args) { string sz = (Console.ReadLine()); long n = long.Parse(sz); long[] a = new long[n]; string[] szArr = Console.ReadLine().Split(' '); long max = long.MinValue; long min = long.MaxValue; for (int i = 0; i < szArr.Length; ++i) { long tmp = long.Parse(szArr[i]); a[i] = tmp; max = Math.Max(tmp, max); min = Math.Min(tmp, min); } long val = Math.Abs(max - min); Console.WriteLine(val); } static void SolveC(string[] args) { string sz = (Console.ReadLine()); long n = long.Parse(sz); long[] a = new long[n]; string[] szArr = Console.ReadLine().Split(' '); for (int i = 0; i < szArr.Length; ++i) { long tmp = long.Parse(szArr[i]); a[i] = tmp - (i + 1); } long[] a2 = a.OrderByDescending(p => p).ToArray(); long b_candidate = 0; long b_candidate2 = 0; if (n % 2 == 1) { long idx = (n - 1) / 2 + 1; if (n == 1) idx = 0; b_candidate = a2[idx]; } else { long k = n / 2; b_candidate2 = (a2[k] + a[k + 1]) / 2; } var sad_list = new List<long>(); sad_list.Add(SadValue(a, b_candidate)); sad_list.Add(SadValue(a, b_candidate2)); long sad = sad_list.Min(); Console.WriteLine(sad); } private static double Average(long[] a) { // オーバーフローしそう double ave = 0.0; long total = 0; for (int i = 0; i < a.Length; ++i) { ave += (a[i] - ave) / (total + 1); total++; } return ave; } private static long SadValue(long[] a, long b) { long val = 0; for (int i = 0; i < a.Length; ++i) { val += Math.Abs(a[i] - b); } return val; } } }
using System; using System.Collections.Generic; using System.Linq; namespace Practice { class Program { static void Main(string[] args) { // SolveA(args); // SolveB(args); SolveC(args); // SolveD(args); } static void SolveA(string[] args) { string sz = (Console.ReadLine()); long n = long.Parse(sz); if (n % 2 == 0) { Console.WriteLine(n); } else { Console.WriteLine(n * 2); } } static void SolveB(string[] args) { string sz = (Console.ReadLine()); long n = long.Parse(sz); long[] a = new long[n]; string[] szArr = Console.ReadLine().Split(' '); long max = long.MinValue; long min = long.MaxValue; for (int i = 0; i < szArr.Length; ++i) { long tmp = long.Parse(szArr[i]); a[i] = tmp; max = Math.Max(tmp, max); min = Math.Min(tmp, min); } long val = Math.Abs(max - min); Console.WriteLine(val); } static void SolveC(string[] args) { string sz = (Console.ReadLine()); long n = long.Parse(sz); long[] a = new long[n]; string[] szArr = Console.ReadLine().Split(' '); for (int i = 0; i < szArr.Length; ++i) { long tmp = long.Parse(szArr[i]); a[i] = tmp - (i + 1); } long[] a2 = a.OrderByDescending(p => p).ToArray(); long b_candidate = 0; long b_candidate2 = 0; if (n % 2 == 1) { long idx = (n - 1) / 2; b_candidate = a2[idx]; } else { long k = (n - 1) / 2; b_candidate = a2[k]; b_candidate2 = a[k + 1]; } var sad_list = new List<long>(); sad_list.Add(SadValue(a, b_candidate)); sad_list.Add(SadValue(a, b_candidate2)); long sad = sad_list.Min(); Console.WriteLine(sad); } private static double Average(long[] a) { // オーバーフローしそう double ave = 0.0; long total = 0; for (int i = 0; i < a.Length; ++i) { ave += (a[i] - ave) / (total + 1); total++; } return ave; } private static long SadValue(long[] a, long b) { long val = 0; for (int i = 0; i < a.Length; ++i) { val += Math.Abs(a[i] - b); } return val; } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 64, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
8
628
26
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var array = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); for (int i = 0; i < array.Length; i++) { array[i] -= i + 1; } var sorted = array.OrderBy(x => x).ToArray(); var minL = sorted[N / 2]; var minH = N == 1 ? sorted[(N / 2) + 1] : sorted[0]; Console.WriteLine(Math.Min(abs(minL, N, sorted), abs(minH, N, sorted))); } static long abs(long b, long N, long[] array) { long res = 0; for (long i = 0; i < N; i++) { res += Math.Abs(array[i] - b); } return res; } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var array = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); for (int i = 0; i < array.Length; i++) { array[i] -= i + 1; } var sorted = array.OrderBy(x => x).ToArray(); var minL = sorted[N / 2]; var minH = N == 1 ? sorted[0] : sorted[(N / 2) + 1]; Console.WriteLine(Math.Min(abs(minL, N, sorted), abs(minH, N, sorted))); } static long abs(long b, long N, long[] array) { long res = 0; for (long i = 0; i < N; i++) { res += Math.Abs(array[i] - b); } return res; } }
[["+", 0, 41, 64, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 41, 64, 204, 206, 207, 0, 73], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 0, 200, 0, 212, 0, 41, 75, 204, 205, 22], ["+", 0, 212, 0, 41, 75, 204, 206, 207, 0, 70], ["-", 0, 212, 0, 41, 64, 204, 206, 207, 0, 73], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["-", 0, 200, 0, 212, 0, 41, 75, 204, 205, 22], ["-", 0, 212, 0, 41, 75, 204, 206, 207, 0, 70], ["-", 0, 41, 75, 204, 206, 207, 0, 28, 0, 203]]
8
235
10
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc102_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] arr = ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 0; i < arr.Length; i++) { arr[i] -= i + 1; } double sum = 0; foreach (var item in arr) { sum += item; } double mean = sum / arr.Length; int x = (int)Floor(mean); int y = (int)Ceiling(mean); double sum1 = 0; double sum2 = 0; for (int i = 0; i < arr.Length; i++) { sum1 += Abs(arr[i] - x); sum2 += Abs(arr[i] - y); } WriteLine(Min(sum1, sum2)); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc102_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] arr = ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 0; i < arr.Length; i++) { arr[i] -= i + 1; } double sum = 0; foreach (var item in arr) { sum += item; } double mean = arr.Length / 2; int x = (int)Floor(mean); int y = (int)Ceiling(mean); double sum1 = 0; double sum2 = 0; var tmp = arr; Array.Sort(tmp); for (int i = 0; i < arr.Length; i++) { sum1 += Abs(arr[i] - tmp[x]); sum2 += Abs(arr[i] - tmp[y]); } WriteLine(Min(sum1, sum2)); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 204, 205, 22], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 73]]
8
247
22
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { int inputCount = int.Parse(Reader.ReadLine()); this.Items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray(); long minItem = Items.Min(); long maxItem = Items.Max(); long minB = 1 - maxItem; long maxB = Items.Length - minItem; long b = GetAns(minB, maxB); long ans = GetCalc(b); Console.WriteLine(ans); } private long GetAns(long min, long max) { if (max - min <= 2) { long tmp1 = GetCalc(min); long tmp2 = GetCalc((max + min) / 2); long tmp3 = GetCalc(max); long tmp4 = new long[] { tmp1, tmp2, tmp3 }.Min(); if (tmp1 == tmp4) { return min; } else if (tmp2 == tmp4) { return (max + min) / 2; } else { return max; } } long mid1 = min + ((max - min) / 3); long mid2 = max - ((max - min) / 3); long valMin = GetCalc(min); long valMid1 = GetCalc(mid1); long valMid2 = GetCalc(mid2); long valMax = GetCalc(max); long minVal = new long[] { valMin, valMid1, valMid2, valMax }.Min(); if (valMin == minVal) { return GetAns(min, mid1); } else if (valMid1 == minVal) { return GetAns(min, mid2); } else if (valMid2 == minVal) { return GetAns(mid1, max); } else { return GetAns(mid2, max); } } private long GetCalc(long target) { if (dic.ContainsKey(target)) { return dic[target]; } long num = 0; for (int i = 1; i <= Items.Length; i++) { num += Math.Abs(Items[i - 1] - (i + target)); } dic[target] = num; return num; } private Dictionary<long, long> dic = new Dictionary<long, long>(); private long[] Items; public class Reader { static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 6 6 5 4 3 2 1 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { int inputCount = int.Parse(Reader.ReadLine()); this.Items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray(); long minItem = Items.Min(); long maxItem = Items.Max(); long minB = 1000000000 * -2; long maxB = 1000000000 * 2; long b = GetAns(minB, maxB); long ans = GetCalc(b); Console.WriteLine(ans); } private long GetAns(long min, long max) { if (max - min <= 2) { long tmp1 = GetCalc(min); long tmp2 = GetCalc((max + min) / 2); long tmp3 = GetCalc(max); long tmp4 = new long[] { tmp1, tmp2, tmp3 }.Min(); if (tmp1 == tmp4) { return min; } else if (tmp2 == tmp4) { return (max + min) / 2; } else { return max; } } long mid1 = min + ((max - min) / 3); long mid2 = max - ((max - min) / 3); long valMin = GetCalc(min); long valMid1 = GetCalc(mid1); long valMid2 = GetCalc(mid2); long valMax = GetCalc(max); long minVal = new long[] { valMin, valMid1, valMid2, valMax }.Min(); if (valMin == minVal) { return GetAns(min, mid1); } else if (valMid1 == minVal) { return GetAns(min, mid2); } else if (valMid2 == minVal) { return GetAns(mid1, max); } else { return GetAns(mid2, max); } } private long GetCalc(long target) { if (dic.ContainsKey(target)) { return dic[target]; } long num = 0; for (int i = 1; i <= Items.Length; i++) { num += Math.Abs(Items[i - 1] - (i + target)); } dic[target] = num; return num; } private Dictionary<long, long> dic = new Dictionary<long, long>(); private long[] Items; public class Reader { static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 1 10 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 241, 0, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 16, 31, 214, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258]]
8
608
15
using System; using System.Linq; class Program { static long[] a; static int[] d; static long[] s; static void Main() { Console.ReadLine(); a = Console.ReadLine().Split().Select(long.Parse).ToArray(); var gap0 = Init(); var gapMin = Enumerable.Range(3, a.Length - 4).Min(_ => NextGap()); Console.WriteLine(Math.Min(gap0, gapMin)); } static long Init() { d = new[] { 1, 2, 3, a.Length }; s = new[] { a[0], a[1], a[2], a.Skip(3).Sum() }; Flatten(2); return s.Max() - s.Min(); } static long NextGap() { Slide(1); Flatten(0); Flatten(2); return s.Max() - s.Min(); } static void Flatten(int di) { var di2 = di + 1; if (s[di] >= s[di2]) return; while (d[di] + 1 < d[di2]) { var s1 = s[di] + a[d[di]]; var s2 = s[di2] - a[d[di]]; if (s1 <= s2) Slide(di); else { if (s1 - s2 < s[di2] - s[di]) Slide(di); break; } } } static void Slide(int di) { s[di] += a[d[di]]; s[di + 1] -= a[d[di]++]; } }
using System; using System.Linq; using static System.Console; class Program { static long[] a; static int[] d; static long[] s; static void Main() { ReadLine(); a = ReadLine().Split().Select(long.Parse).ToArray(); var gap0 = Init(); if (d[3] == 4) { WriteLine(gap0); return; } var gapMin = Enumerable.Range(3, d[3] - 4).Min(_ => NextGap()); WriteLine(Math.Min(gap0, gapMin)); } static long Init() { d = new[] { 1, 2, 3, a.Length }; s = new[] { a[0], a[1], a[2], a.Skip(3).Sum() }; Flatten(2); return s.Max() - s.Min(); } static long NextGap() { Slide(1); Flatten(0); Flatten(2); return s.Max() - s.Min(); } static void Flatten(int di) { var di2 = di + 1; if (s[di] >= s[di2]) return; while (d[di] + 1 < d[di2]) { var s1 = s[di] + a[d[di]]; var s2 = s[di2] - a[d[di]]; if (s1 <= s2) Slide(di); else { if (s1 - s2 < s[di2] - s[di]) Slide(di); break; } } } static void Slide(int di) { s[di] += a[d[di]]; s[di + 1] -= a[d[di]++]; } }
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 115], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 3, 4, 0, 28, 0, 16, 31, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 204, 205, 22], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73]]
8
375
37
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; namespace ConsoleApplication1 { internal static class Program { public static void Main(string[] args) { var scanner = new StreamScanner(Console.OpenStandardInput()); var n = scanner.Integer(); var dist = new SortedDictionary<int, int>(); var bMin = int.MaxValue; var bMax = int.MinValue; for (var i = 0; i < n; i++) { var v = scanner.Integer(); var d = v - (i + 1); if (!dist.ContainsKey(d)) { dist[d] = 1; } else { dist[d] = +1; } if (d < bMin) bMin = d; if (d > bMax) bMax = d; } var sorrow = 0; foreach (var k in dist.Keys) { sorrow += (k - bMin) * dist[k]; } var minSorrow = sorrow; var last = dist.Keys.First(); var lower = dist[last]; foreach (var k in dist.Keys.Skip(1)) { sorrow += (lower - (n - lower)) * (k - last); if (sorrow < minSorrow) { minSorrow = sorrow; } lower += dist[k]; last = k; } Console.WriteLine(minSorrow); } } // https://qiita.com/Camypaper/items/de6d576fe5513743a50e public class StreamScanner { private readonly Stream stream; private readonly byte[] buf = new byte[1024]; private int len, pos; private bool isEof = false; public bool IsEndOfStream => isEof; public StreamScanner(Stream stream) { this.stream = stream; } private byte Read() { if (isEof) throw new EndOfStreamException(); if (pos >= len) { pos = 0; if ((len = stream.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[pos++]; } 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 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); } } }
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; namespace ConsoleApplication1 { internal static class Program { public static void Main(string[] args) { var scanner = new StreamScanner(Console.OpenStandardInput()); var n = scanner.Integer(); var dist = new SortedDictionary<long, long>(); var bMin = long.MaxValue; for (var i = 0; i < n; i++) { var v = scanner.Long(); var d = v - (i + 1); if (!dist.ContainsKey(d)) { dist[d] = 1; } else { dist[d] = dist[d] + 1; } if (d < bMin) bMin = d; } var sorrow = 0L; foreach (var k in dist.Keys.Skip(1)) { sorrow += (k - bMin) * dist[k]; } var minSorrow = sorrow; var last = dist.Keys.First(); var lower = dist[last]; foreach (var k in dist.Keys.Skip(1)) { sorrow += (lower - (n - lower)) * (k - last); if (sorrow < minSorrow) { minSorrow = sorrow; } lower += dist[k]; last = k; } Console.WriteLine(minSorrow); } } // https://qiita.com/Camypaper/items/de6d576fe5513743a50e public class StreamScanner { private readonly Stream stream; private readonly byte[] buf = new byte[1024]; private int len, pos; private bool isEof = false; public bool IsEndOfStream => isEof; public StreamScanner(Stream stream) { this.stream = stream; } private byte Read() { if (isEof) throw new EndOfStreamException(); if (pos >= len) { pos = 0; if ((len = stream.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[pos++]; } 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 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); } } }
[["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["+", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 24], ["+", 0, 210, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 25]]
8
671
36
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Contest.cs { class Program { static void Main(string[] args) { int[] input = ReadInt(); int D = input[0]; int N = input[1]; int ans; if (D == 0) { ans = N; } else if (D == 1) { if (N == 100) { ans = N * 101; } else { ans = N * 100; } } else { if (N == 100) { ans = N * 10100; } else { ans = N * 10000; } } Console.WriteLine(ans); Console.ReadKey(); } static string[] ReadStr() { return Console.ReadLine().Split(' ').ToArray(); } static int[] ReadInt() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Contest.cs { class Program { static void Main(string[] args) { int[] input = ReadInt(); int D = input[0]; int N = input[1]; int ans; if (D == 0) { if (N == 100) { ans = N + 1; } else { ans = N; } } else if (D == 1) { if (N == 100) { ans = N * 101; } else { ans = N * 100; } } else { if (N == 100) { ans = N * 10100; } else { ans = N * 10000; } } Console.WriteLine(ans); Console.ReadKey(); } static string[] ReadStr() { return Console.ReadLine().Split(' ').ToArray(); } static int[] ReadInt() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); } } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 22], ["+", 64, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
8
225
17
using System; using System.Collections.Generic; using System.Linq; using System.IO; // using System.Text; // using System.Text.RegularExpressions; // using System.Globalization; // using System.Diagnostics; using static System.Console; // using System.Numerics; // using static System.Math; // using pair = Pair<int, int>; class Program { static void Main() { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; } void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; } void solve() { int D = cin.nextint; int N = cin.nextint; Write(N.ToString()); for (int i = 0; i < D; i++) { Write("00"); } WriteLine(); // WriteLine((long)N * (long)Math.Pow(100, D)); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; // using System.Text; // using System.Text.RegularExpressions; // using System.Globalization; // using System.Diagnostics; using static System.Console; // using System.Numerics; // using static System.Math; // using pair = Pair<int, int>; class Program { static void Main() { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; } void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; } void solve() { int D = cin.nextint; int N = cin.nextint; if (N == 100) N += 1; Write(N); for (int i = 0; i < D; i++) { Write("00"); } WriteLine(); // WriteLine((long)N * (long)Math.Pow(100, D)); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }
[["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
466
14
using System; namespace AtCorder100_B { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int D = int.Parse(input[0]); int N = int.Parse(input[1]); Console.WriteLine(Math.Pow(100, D) * N); } } }
using System; namespace AtCorder100_B { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int D = int.Parse(input[0]); int N = int.Parse(input[1]); if (N == 100) N++; Console.WriteLine(Math.Pow(100, D) * N); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
82
9
using System; using System.Text; using System.Collections.Generic; using System.Linq; using E = System.Linq.Enumerable; class Program { static void Main(string[] args) { //入力を受け取る var S = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var ans = 0; for (int i = 0; i < S.Length; i++) { if (S[i] == '+') { ans++; } else { ans--; } } Console.WriteLine(ans); } }
using System; using System.Text; using System.Collections.Generic; using System.Linq; using E = System.Linq.Enumerable; class Program { static void Main(string[] args) { //入力を受け取る var S = Console.ReadLine(); var ans = 0; for (int i = 0; i < S.Length; i++) { if (S[i] == '+') { ans++; } else { ans--; } } Console.WriteLine(ans); } }
[["-", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 205, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["-", 205, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 24], ["-", 0, 218, 8, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
8
129
23
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ACprac { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int d = int.Parse(str[0]); int n = int.Parse(str[1]); int kai = n * (int)(Math.Pow(100, d)); Console.WriteLine(kai); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ACprac { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int d = int.Parse(str[0]); int n = int.Parse(str[1]); if (n == 100) n++; int kai = n * (int)(Math.Pow(100, d)); Console.WriteLine(kai); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
116
9
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static program.Input; using static program.MyMath; using static System.Console; namespace program { class Program { static string alp = "abcdefghijklmnopqrstuvwxyz"; static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static long MOD = 1000000007; static void Main() { var n = ScanStr(); var a = n.ToCharArray().Select(_ => int.Parse($"{_}")).Sum(); WriteLine(a % (n.Length) == 0 ? "Yes" : "No"); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } static public string RegaxReplace(this string arg1, string pattern, string replacement) { return Regex.Replace(arg1, pattern, replacement); } static public string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } } static class MyMath { static public long[] CumSum(this long[] a) { var res = new long[a.Length]; long s = 0; for (int i = 0; i < a.Length; i++) res[i] = (s += a[i]); return res; } static public IEnumerable<int> PrimeFactors(this int n) { int tmp = n; for (int i = 2; i * i <= n; i++) { while (tmp % i == 0) { tmp /= i; yield return i; } } if (tmp != 1) yield return tmp; } static public IEnumerable<long> PrimeFactors(this long n) { var tmp = n; for (long i = 2; i * i <= n; i++) { while (tmp % i == 0) { tmp /= i; yield return i; } } if (tmp != 1) yield return tmp; } static public int Digit(this int n, int d) { if (d < 0) return 0; return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d); } static public int Length(this int n) { if (n < 0) return 0; return (int)Math.Log10(n) + 1; } static public int Top(this int n) { return n.Digit(n.Length() - 1); } public static bool isPrime(this int p) { if (p <= 1) return false; for (int i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static bool isPrime(this long p) { if (p <= 1) return false; for (long i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static long GCD(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) { if (b == 0) { x = 1; y = 0; return a; } var d = extGCD(b, a % b, ref y, ref x); y -= a / b * x; return d; } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static long LCM(long a, long b) { return a * b / GCD(a, b); } public static long Inv(this long a, long m = 1000000007) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; swap(ref a, ref b); u -= t * v; swap(ref u, ref v); } u %= m; if (u < 0) u += m; return u; } private static void swap(ref long a, ref long b) { var t = a; a = b; b = t; } } }
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static program.Input; using static program.MyMath; using static System.Console; namespace program { class Program { static string alp = "abcdefghijklmnopqrstuvwxyz"; static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static long MOD = 1000000007; static void Main() { var n = ScanStr(); var a = n.ToCharArray().Select(_ => int.Parse($"{_}")).Sum(); WriteLine(int.Parse(n) % a == 0 ? "Yes" : "No"); } } static class Input { static public int ScanInt() { return int.Parse(Console.ReadLine()); } static public uint ScanUint() { return uint.Parse(Console.ReadLine()); } static public double ScanDouble() { return double.Parse(Console.ReadLine()); } static public long ScanLong() { return long.Parse(Console.ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); } static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return Console.ReadLine(); } static public string[] ScanStrArray() { return ScanStr().Split(); } static public string RegaxReplace(this string arg1, string pattern, string replacement) { return Regex.Replace(arg1, pattern, replacement); } static public string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } } static class MyMath { static public long[] CumSum(this long[] a) { var res = new long[a.Length]; long s = 0; for (int i = 0; i < a.Length; i++) res[i] = (s += a[i]); return res; } static public IEnumerable<int> PrimeFactors(this int n) { int tmp = n; for (int i = 2; i * i <= n; i++) { while (tmp % i == 0) { tmp /= i; yield return i; } } if (tmp != 1) yield return tmp; } static public IEnumerable<long> PrimeFactors(this long n) { var tmp = n; for (long i = 2; i * i <= n; i++) { while (tmp % i == 0) { tmp /= i; yield return i; } } if (tmp != 1) yield return tmp; } static public int Digit(this int n, int d) { if (d < 0) return 0; return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d); } static public int Length(this int n) { if (n < 0) return 0; return (int)Math.Log10(n) + 1; } static public int Top(this int n) { return n.Digit(n.Length() - 1); } public static bool isPrime(this int p) { if (p <= 1) return false; for (int i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static bool isPrime(this long p) { if (p <= 1) return false; for (long i = 2; i * i <= p; i++) if (p % i == 0) return false; return true; } public static int GCD(int a, int b) { Func<int, int, int> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static long GCD(long a, long b) { Func<long, long, long> gcd = null; gcd = (x, y) => y == 0 ? x : gcd(y, x % y); return a > b ? gcd(a, b) : gcd(b, a); } public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) { if (b == 0) { x = 1; y = 0; return a; } var d = extGCD(b, a % b, ref y, ref x); y -= a / b * x; return d; } public static int LCM(int a, int b) { return a * b / GCD(a, b); } public static long LCM(long a, long b) { return a * b / GCD(a, b); } public static long Inv(this long a, long m = 1000000007) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; swap(ref a, ref b); u -= t * v; swap(ref u, ref v); } u %= m; if (u < 0) u += m; return u; } private static void swap(ref long a, ref long b) { var t = a; a = b; b = t; } } }
[["-", 0, 28, 0, 41, 15, 16, 31, 16, 31, 22], ["-", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 205, 199], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["-", 15, 16, 31, 16, 12, 23, 0, 214, 0, 131], ["-", 15, 16, 31, 16, 12, 23, 0, 214, 141, 22], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 12, 22]]
8
1,300
9
using System; using System.Collections.Generic; using System.Linq; namespace ABC { class Program { public static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var sum = 0; int dig = 1; for (int i = n; i >= 10; i /= 10) { dig++; } for (var i = 0; i < dig; i++) { dig = n % 10; sum = sum + dig; n = n / 10; } if (n % sum == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC { class Program { public static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var nn = n; var sum = 0; var len = 1; var dig = 0; for (int i = n; i >= 10; i /= 10) { len++; } for (var i = 0; i < len; i++) { dig = n % 10; sum = sum + dig; n = n / 10; } if (nn % sum == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22]]
8
144
20
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); int A = int.Parse(input); int div_num = 0; while (true) { int ch = Console.Read(); char c = (char)ch; if (ch == -1) { break; } div_num += int.Parse(c.ToString()); } if (A % div_num == 0) { Console.WriteLine("Yes"); } if (A % div_num != 0) { Console.WriteLine("No"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); int A = int.Parse(input); int div_num = 0; foreach (char c in input) { div_num += int.Parse(c.ToString()); } if (A % div_num == 0) { Console.WriteLine("Yes"); } if (A % div_num != 0) { Console.WriteLine("No"); } } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["-", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["-", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["-", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 45], ["-", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 52, 8, 196, 0, 197, 0, 35], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 51, 22], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["-", 8, 196, 0, 57, 15, 16, 12, 241, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
8
155
31
using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string ss = Console.ReadLine(); string[] s = ss.Split(); int a = int.Parse(ss); int b = 0; for (int i = 0; i < s.Length; i++) { b += int.Parse(s[i]); } string buf = ""; if (a % b == 0) { buf = "Yes"; } else { buf = "No"; } Console.Write(buf); } } }
using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string ss = Console.ReadLine(); int a = int.Parse(ss); int b = 0; for (int i = 0; i < ss.Length; i++) { b += int.Parse(ss[i].ToString()); } string buf = ""; if (a % b == 0) { buf = "Yes"; } else { buf = "No"; } Console.Write(buf); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 28, 0, 213, 63, 214, 205, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
125
19
using System; using System.Collections.Generic; using System.Linq; class Program { static int n; static int sum = 0; static string ans; static int Main() { string nyu = Console.ReadLine(); n = int.Parse(nyu); char[] s = nyu.ToCharArray(); for (int i = 0; i < s.Length; i++) { sum += (int)char.GetNumericValue(s[i]); Console.WriteLine("s[i] = {0}, sum = {1}", s[i], sum); } Console.WriteLine("{0}", sum); if (n % sum == 0) { ans = "Yes"; } else { ans = "No"; } Console.WriteLine("{0}", ans); return 0; } }
using System; using System.Collections.Generic; using System.Linq; class Program { static int n; static int sum = 0; static string ans; static int Main() { string nyu = Console.ReadLine(); n = int.Parse(nyu); char[] s = nyu.ToCharArray(); for (int i = 0; i < s.Length; i++) { sum += (int)char.GetNumericValue(s[i]); } if (n % sum == 0) { ans = "Yes"; } else { ans = "No"; } Console.WriteLine("{0}", ans); return 0; } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
168
27
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 = Console.ReadLine().Split(); int d = int.Parse(input[0]); int n = int.Parse(input[1]); double num = 1; switch (d) { case 0: if (n == 100) num = 101; else num = n; break; case 1: num = 100 * n; break; case 2: num = 10000 * n; break; } Console.WriteLine(num); } } }
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 = Console.ReadLine().Split(); int d = int.Parse(input[0]); int n = int.Parse(input[1]); double num = 1; switch (d) { case 0: if (n == 100) num = 101; else num = n; break; case 1: if (n == 100) num = 10100; else num = 100 * n; break; case 2: if (n == 100) num = 1010000; else num = 10000 * n; break; } Console.WriteLine(num); } } }
[["+", 0, 99, 8, 254, 0, 239, 0, 57, 0, 121], ["+", 0, 99, 8, 254, 0, 239, 0, 57, 0, 24], ["+", 8, 254, 0, 239, 0, 57, 15, 16, 31, 22], ["+", 8, 254, 0, 239, 0, 57, 15, 16, 17, 60], ["+", 8, 254, 0, 239, 0, 57, 15, 16, 12, 203], ["+", 0, 99, 8, 254, 0, 239, 0, 57, 0, 25], ["+", 0, 239, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 239, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 8, 254, 0, 239, 0, 57, 64, 1, 0, 35], ["+", 0, 99, 8, 254, 0, 239, 0, 57, 0, 95]]
8
147
22
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { try { SetOut(sw); Solve.Answer(); Out.Flush(); } catch (Exception ex) { WriteLine(ex.ToString()); Out.Flush(); } } } public class Solve { public static void Answer() { var NK = IO.RSInt; var a = IO.RSInt; WriteLine(NK[0] / (NK[1] - 1)); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; static void Main(string[] args) { try { SetOut(sw); Solve.Answer(); Out.Flush(); } catch (Exception ex) { WriteLine(ex.ToString()); Out.Flush(); } } } public class Solve { public static void Answer() { var NK = IO.RSInt; var a = IO.RSInt; NK[0] -= NK[1]; int g = 1; while (NK[0] > 0) { g++; NK[0] -= NK[1] - 1; } WriteLine(g); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
[["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 8, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 52, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["+", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
501
37
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp4 { class Program { static void Main(string[] args) { var s = Console.ReadLine().Split(' '); long a, b, c, d = 1; a = long.Parse(s[0]); b = long.Parse(s[1]); if (a == 0) { c = b; } else { for (int i = 0; i < a; i++) { d *= 100; } if (b != 100) { c = d * b; } else { c = d * (b + 1); } } Console.WriteLine(c); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp4 { class Program { static void Main(string[] args) { var s = Console.ReadLine().Split(' '); long a, b, c, d = 1; a = long.Parse(s[0]); b = long.Parse(s[1]); if (a == 0) { c = b; if (b == 100) { c++; } } else { for (int i = 0; i < a; i++) { d *= 100; } if (b != 100) { c = d * b; } else { c = d * (b + 1); } } Console.WriteLine(c); } } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
8
166
11