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.Linq; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int[] inp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); Console.WriteLine(inp.Sum() > 22 ? "bust" : "win"); } } }
using System; using System.Linq; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int[] inp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); Console.WriteLine(inp.Sum() > 21 ? "bust" : "win"); } } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203]]
8
75
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC147A { class Program { static void Main(string[] args) { int A, B, C, D; var word = Console.ReadLine().Split(' '); A = int.Parse(word[0]); B = int.Parse(word[0]); C = int.Parse(word[0]); D = 0; D = A + B + C; if (D >= 22) { Console.Write("bust"); } else if (D <= 21) { Console.Write("win"); } Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC147A { class Program { static void Main(string[] args) { int A, B, C, D; var word = Console.ReadLine().Split(' '); A = int.Parse(word[0]); B = int.Parse(word[1]); C = int.Parse(word[2]); D = 0; D = A + B + C; if (D >= 22) { Console.Write("bust"); } else if (D <= 21) { Console.Write("win"); } Console.ReadKey(); } } }
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
8
160
4
using System; public class Program { public static void Main(string[] args) { var input = Console.ReadLine().Split(); var a1 = int.Parse(input[0]); var a2 = int.Parse(input[1]); var a3 = int.Parse(input[2]); if (a1 + a2 + a2 >= 22) { Console.WriteLine("bust"); } else { Console.WriteLine("win"); } } }
using System; public class Program { public static void Main(string[] args) { var input = Console.ReadLine().Split(); var a1 = int.Parse(input[0]); var a2 = int.Parse(input[1]); var a3 = int.Parse(input[2]); if (a1 + a2 + a3 >= 22) { Console.WriteLine("bust"); } else { Console.WriteLine("win"); } } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22]]
8
105
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC147A { class Program { static void Main(string[] args) { int A1, A2, A3; var word = Console.ReadLine().Split(' '); A1 = int.Parse(word[0]); A2 = int.Parse(word[1]); A3 = int.Parse(word[2]); if (A1 + A2 + A3 >= 22) Console.WriteLine("dust"); if (A1 + A2 + A3 <= 21) Console.WriteLine("win"); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC147A { class Program { static void Main(string[] args) { int A1, A2, A3; var word = Console.ReadLine().Split(' '); A1 = int.Parse(word[0]); A2 = int.Parse(word[1]); A3 = int.Parse(word[2]); if (A1 + A2 + A3 >= 22) Console.WriteLine("bust"); if (A1 + A2 + A3 <= 21) Console.WriteLine("win"); Console.ReadKey(); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
149
2
using System; public class test { public static void Main() { var input = Console.ReadLine().Split(' '); var result = int.Parse(input[0]) + int.Parse(input[1]) + int.Parse(input[2]); if (result >= 22) { Console.WriteLine("burst"); } else if (result <= 21) { Console.WriteLine("win"); } } }
using System; public class test { public static void Main() { var input = Console.ReadLine().Split(' '); var result = int.Parse(input[0]) + int.Parse(input[1]) + int.Parse(input[2]); if (result >= 22) { Console.WriteLine("bust"); } else if (result <= 21) { Console.WriteLine("win"); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
100
2
using System; using static System.Console; namespace brackjack { class Program { static void Main(string[] args) { string[] ss = ReadLine().Split(' '); if (int.Parse(ss[0]) + int.Parse(ss[1]) + int.Parse(ss[2]) <= 21) { WriteLine("Win"); return; } else { WriteLine("bust"); return; } } } }
using System; using static System.Console; namespace brackjack { class Program { static void Main(string[] args) { string[] ss = ReadLine().Split(' '); if (int.Parse(ss[0]) + int.Parse(ss[1]) + int.Parse(ss[2]) <= 21) { WriteLine("win"); return; } else { WriteLine("bust"); return; } } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
101
2
using System; class ACBC1208_A { public static void Main() { var ss = Console.ReadLine().Split(' '); int i = 0; foreach (var s in ss) i += int.Parse(s); if (i > 21) Console.WriteLine("win"); else Console.WriteLine("bust"); } }
using System; class ACBC1208_A { public static void Main() { var ss = Console.ReadLine().Split(' '); int i = 0; foreach (var s in ss) i += int.Parse(s); if (i < 22) Console.WriteLine("win"); else Console.WriteLine("bust"); } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
8
77
4
using System; using System.Collections.Generic; using System.Linq; using System.Diagnostics; class Program { static void Main(string[] args) { var sc = new Scanner(); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if (a + b + c <= 21) Console.WriteLine("Win"); else Console.WriteLine("bust"); } } // chokudai's Scanner class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } }
using System; using System.Collections.Generic; using System.Linq; using System.Diagnostics; class Program { static void Main(string[] args) { var sc = new Scanner(); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if (a + b + c <= 21) Console.WriteLine("win"); else Console.WriteLine("bust"); } } // chokudai's Scanner class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
450
2
using System; using System.Linq; class Atcoder { static void Main(string[] args) { int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int b = a[0] + a[1] + a[2]; if (b >= 21) { Console.WriteLine("bust"); } else { Console.WriteLine("win"); } } }
using System; using System.Linq; class Atcoder { static void Main(string[] args) { int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int b = a[0] + a[1] + a[2]; if (b >= 22) { Console.WriteLine("bust"); } else { Console.WriteLine("win"); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
8
96
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc147_b { class Program { static void Main(string[] args) { string S = Console.ReadLine(); string N = string.Concat(S.Reverse()); int H = 0; for (int i = 0; i < S.Length; i++) { if (S[i] == N[i]) { ; } else { H++; } } Console.WriteLine(H); Console.Read(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc147_b { class Program { static void Main(string[] args) { string S = Console.ReadLine(); string N = string.Concat(S.Reverse()); int H = 0; for (int i = 0; i < S.Length / 2; i++) { if (S[i] == N[i]) { ; } else { H++; } } Console.WriteLine(H); Console.Read(); } } }
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 85], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
126
2
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static System.Console; using static Program.Input; using static Program.MyMath; using static Program.Const; namespace Program { static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public const long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } public class Program { public static void Main() { var s = ReadLine(); var t = s.Reverse().ToArray(); var res = 0; for (int i = 0; i < s.Length; i++) if (s[i] != t[i]) res++; WriteLine(res); } } static class Input { public static void InputLine(out int a, out int b) { var input = ScanIntArray(); a = input[0]; b = input[1]; } public static void InputLine(out int a, out int b, out int c) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out int a, out int b, out int c, out int d) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out long a, out long b) { var input = ScanLongArray(); a = input[0]; b = input[1]; } public static void InputLine(out long a, out long b, out long c) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out long a, out long b, out long c, out long d) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out string a, out string b) { var input = ScanStrArray(); a = input[0]; b = input[1]; } public static int ScanInt() { return int.Parse(ReadLine()); } static public uint ScanUint() { return uint.Parse(ReadLine()); } static public double ScanDouble() { return double.Parse(ReadLine()); } static public long ScanLong() { return long.Parse(ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(ReadLine()); } static public int[] ScanIntArray() { return ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return 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 class MyMath { static public int CountBit(this long a) { if (a == 0) return 0; int c = 1; for (; a > 1; a /= 2) if (a % 2 == 1) c++; return c; } static public int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } 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 = MOD) { 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; } public static long ModPow(long a, long n, long m = MOD) { long res = 1; while (n > 0) { if (n % 2 == 1) res = (res * a) % m; a = (a * a) % m; n >>= 1; } return res; } } static class MyLinq { public static void Sort(this string[] array) { Array.Sort(array, StringComparer.OrdinalIgnoreCase); } public static void StringSort(this List<string> list) { list.Sort(StringComparer.OrdinalIgnoreCase); } public static string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } public static IEnumerable<TItem> Distinct<TItem, TKey>(this IEnumerable<TItem> source, Func<TItem, TKey> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); var set = new HashSet<TKey>(); foreach (var item in source) if (set.Add(keySelector(item))) yield return item; } } }
using System; using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using static System.Console; using static Program.Input; using static Program.MyMath; using static Program.Const; namespace Program { static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public const long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } public class Program { public static void Main() { var s = ReadLine(); var t = s.Reverse().ToArray(); var res = 0; for (int i = 0; i < s.Length; i++) if (s[i] != t[i]) res++; WriteLine(res / 2); } } static class Input { public static void InputLine(out int a, out int b) { var input = ScanIntArray(); a = input[0]; b = input[1]; } public static void InputLine(out int a, out int b, out int c) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out int a, out int b, out int c, out int d) { var input = ScanIntArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out long a, out long b) { var input = ScanLongArray(); a = input[0]; b = input[1]; } public static void InputLine(out long a, out long b, out long c) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; } public static void InputLine(out long a, out long b, out long c, out long d) { var input = ScanLongArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void InputLine(out string a, out string b) { var input = ScanStrArray(); a = input[0]; b = input[1]; } public static int ScanInt() { return int.Parse(ReadLine()); } static public uint ScanUint() { return uint.Parse(ReadLine()); } static public double ScanDouble() { return double.Parse(ReadLine()); } static public long ScanLong() { return long.Parse(ReadLine()); } static public ulong ScanUlong() { return ulong.Parse(ReadLine()); } static public int[] ScanIntArray() { return ReadLine().Split().Select(x => int.Parse(x)).ToArray(); } static public uint[] ScanUintArray() { return ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); } static public double[] ScanDoubleArray() { return ReadLine().Split().Select(x => double.Parse(x)).ToArray(); } static public long[] ScanLongArray() { return ReadLine().Split().Select(x => long.Parse(x)).ToArray(); } static public ulong[] ScanUlongArray() { return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); } static public string ScanStr() { return 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 class MyMath { static public int CountBit(this long a) { if (a == 0) return 0; int c = 1; for (; a > 1; a /= 2) if (a % 2 == 1) c++; return c; } static public int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } 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 = MOD) { 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; } public static long ModPow(long a, long n, long m = MOD) { long res = 1; while (n > 0) { if (n % 2 == 1) res = (res * a) % m; a = (a * a) % m; n >>= 1; } return res; } } static class MyLinq { public static void Sort(this string[] array) { Array.Sort(array, StringComparer.OrdinalIgnoreCase); } public static void StringSort(this List<string> list) { list.Sort(StringComparer.OrdinalIgnoreCase); } public static string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); } public static IEnumerable<TItem> Distinct<TItem, TKey>(this IEnumerable<TItem> source, Func<TItem, TKey> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); var set = new HashSet<TKey>(); foreach (var item in source) if (set.Add(keySelector(item))) yield return item; } } }
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
2,014
2
using System; class Program { static void Main(string[] args) { // スペース区切りの整数の入力 string[] input = Console.ReadLine().Split(' '); string msg = input[0]; int replaceCount = 0; for (int i = 0; i < msg.Length / 2; i++) if (msg[i] != msg[msg.Length - 1]) replaceCount++; Console.WriteLine(replaceCount); } }
using System; class Program { static void Main(string[] args) { // スペース区切りの整数の入力 string[] input = Console.ReadLine().Split(' '); string msg = input[0]; int replaceCount = 0; for (int i = 0; i < msg.Length / 2; i++) if (msg[i] != msg[msg.Length - 1 - i]) replaceCount++; Console.WriteLine(replaceCount); } }
[["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 22]]
8
94
2
using System; class Program { static void Main() { var line = Console.ReadLine(); byte cnt = 0; var len = line.Length; if (len == 1) { Console.WriteLine("0"); return; } var half = len / 2; len -= 1; for (byte i = 0; i <= half; i++) { var a = line[i]; var b = line[len - i]; if (a != b) { cnt++; } } Console.WriteLine(cnt); } }
using System; class Program { static void Main() { var line = Console.ReadLine(); byte cnt = 0; var len = line.Length; if (len == 1) { Console.WriteLine("0"); return; } var half = len / 2; len -= 1; for (byte i = 0; i < half; i++) { var a = line[i]; var b = line[len - i]; if (a != b) { cnt++; } } Console.WriteLine(cnt); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18]]
8
117
2
using System; class Program { static void Main() { int L, l, count = 0; string s = Console.ReadLine(); L = s.Length; l = L - 1; for (int i = 0; i < L; i++) { if (s[i] != s[l - i]) count++; } Console.WriteLine(count); } }
using System; class Program { static void Main() { int L, l, count = 0; string s = Console.ReadLine(); L = s.Length; l = L - 1; for (int i = 0; i < L / 2; i++) { if (s[i] != s[l - i]) count++; } Console.WriteLine(count); } }
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 85], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
84
2
using System; class Program { static void Main(string[] args) { string str1 = Console.ReadLine(); decimal hug = 0; decimal num = Math.Floor((decimal)str1.Length / 2) + 1; for (int i = 0; i < num; i++) { if (str1[i] != str1[str1.Length - 1 - i]) { hug++; } } Console.WriteLine(hug.ToString()); } }
using System; class Program { static void Main(string[] args) { string str1 = Console.ReadLine(); decimal hug = 0; decimal num = Math.Floor((decimal)str1.Length / 2); for (int i = 0; i < num; i++) { if (str1[i] != str1[str1.Length - 1 - i]) { hug++; } } Console.WriteLine(hug.ToString()); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
8
101
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { static class CHonestOrUnkind2 { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var list = new List<List<Tuple<int, int>>>(); for (int i = 0; i < n; i++) { var a = int.Parse(Console.ReadLine()); list.Add(new List<Tuple<int, int>>()); for (int j = 0; j < a; j++) { var xy = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList(); list[i].Add(Tuple.Create(xy[0] - 1, xy[1])); } } int honestCount = 0; int maxHonestCount = 0; for (int bit = 0; bit < (1 << n); bit++) { honestCount = 0; if (!IsHonest(bit, list)) { continue; } for (int i = 0; i < bit; i++) { if ((bit & (1 << i)) > 0) { honestCount++; } } maxHonestCount = Math.Max(maxHonestCount, honestCount); } Console.WriteLine(maxHonestCount); Console.ReadLine(); } static bool IsHonest(int bit, List<List<Tuple<int, int>>> list) { for (int i = 0; i < list.Count; i++) { // Number"i" is honest? Unkind is skip. if ((bit & (1 << i)) == 0) { continue; } foreach (var item in list[i]) { // Evidence is honest, but temp is unkind. if (item.Item2 == 1 && (bit & (1 << item.Item1)) == 0) { // Exists unkind in bit. return false; } // Evidence is unkind, but temp is honest. if (item.Item2 == 0 && (bit & (1 << item.Item1)) > 0) { // Exists unkind in bit. return false; } } } // Not exists unkind in bit. return true; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { static class CHonestOrUnkind2 { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var list = new List<List<Tuple<int, int>>>(); for (int i = 0; i < n; i++) { var a = int.Parse(Console.ReadLine()); list.Add(new List<Tuple<int, int>>()); for (int j = 0; j < a; j++) { var xy = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList(); list[i].Add(Tuple.Create(xy[0] - 1, xy[1])); } } int honestCount = 0; int maxHonestCount = 0; for (int bit = 0; bit < (1 << n); bit++) { honestCount = 0; if (!IsHonest(bit, list)) { continue; } for (int i = 0; i < n; i++) { if ((bit & (1 << i)) > 0) { honestCount++; } } maxHonestCount = Math.Max(maxHonestCount, honestCount); } Console.WriteLine(maxHonestCount); Console.ReadLine(); } static bool IsHonest(int bit, List<List<Tuple<int, int>>> list) { for (int i = 0; i < list.Count; i++) { // Number"i" is honest? Unkind is skip. if ((bit & (1 << i)) == 0) { continue; } foreach (var item in list[i]) { // Evidence is honest, but temp is unkind. if (item.Item2 == 1 && (bit & (1 << item.Item1)) == 0) { // Exists unkind in bit. return false; } // Evidence is unkind, but temp is honest. if (item.Item2 == 0 && (bit & (1 << item.Item1)) > 0) { // Exists unkind in bit. return false; } } } // Not exists unkind in bit. return true; } } }
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22]]
8
442
2
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; namespace c { class Program { public static readonly long INF = 999999999999; public static readonly long MOD = 1000000007; static void Main(string[] args) { var n = Scanner.IntScan()[0]; var xy = new List<List<int[]>>(); for (var i = 0; i < n; i++) { var a = Scanner.IntScan()[0]; var z = new List<int[]>(); for (var j = 0; j < a; j++) { z.Add(Scanner.IntScan()); } xy.Add(z); } var res = 0; for (var bit = 0; bit < (1 << n); bit++) { var sum = 0; var ok = true; for (var i = 0; i < n; i++) { if (((bit >> i) & 1) == 1) { foreach (var a in xy[i]) { if (((bit >> (a[0] - 1)) & 1) == a[1]) { sum++; } else { ok = false; } } } } if (ok) { if (res < sum) res = sum; } } Console.WriteLine(res); } } public class Scanner { public static string[] Scan() => Console.ReadLine().Split(' '); public static int[] IntScan() => Array.ConvertAll(Scan(), int.Parse); public static long[] LongScan() => Array.ConvertAll(Scan(), long.Parse); public static string[][] Scan(int n) => Enumerable.Repeat(0, n).Select(_ => Scan()).ToArray(); public static int[][] IntScan(int n) => Enumerable.Repeat(0, n).Select(_ => IntScan()).ToArray(); public static long[][] LongScan(int n) => Enumerable.Repeat(0, n).Select(_ => LongScan()).ToArray(); } public class Ex { public static bool Chmin(ref int a, int b) { if (a > b) { a = b; return true; } return false; } public static bool Chmin(ref long a, long b) { if (a > b) { a = b; return true; } return false; } public static bool Chmax(ref int a, int b) { if (a < b) { a = b; return true; } return false; } public static bool Chmax(ref long a, long b) { if (a < b) { a = b; return true; } return false; } public static int[] SubArr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; } } }
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; namespace c { class Program { public static readonly long INF = 999999999999; public static readonly long MOD = 1000000007; static void Main(string[] args) { var n = Scanner.IntScan()[0]; var xy = new List<List<int[]>>(); for (var i = 0; i < n; i++) { var a = Scanner.IntScan()[0]; var z = new List<int[]>(); for (var j = 0; j < a; j++) { z.Add(Scanner.IntScan()); } xy.Add(z); } var res = 0; for (var bit = 0; bit < (1 << n); bit++) { var sum = 0; var ok = true; for (var i = 0; i < n; i++) { if (((bit >> i) & 1) == 1) { sum++; foreach (var a in xy[i]) { if (((bit >> (a[0] - 1)) & 1) == a[1]) { } else { ok = false; } } } } if (ok) { if (res < sum) res = sum; } } Console.WriteLine(res); } } public class Scanner { public static string[] Scan() => Console.ReadLine().Split(' '); public static int[] IntScan() => Array.ConvertAll(Scan(), int.Parse); public static long[] LongScan() => Array.ConvertAll(Scan(), long.Parse); public static string[][] Scan(int n) => Enumerable.Repeat(0, n).Select(_ => Scan()).ToArray(); public static int[][] IntScan(int n) => Enumerable.Repeat(0, n).Select(_ => IntScan()).ToArray(); public static long[][] LongScan(int n) => Enumerable.Repeat(0, n).Select(_ => LongScan()).ToArray(); } public class Ex { public static bool Chmin(ref int a, int b) { if (a > b) { a = b; return true; } return false; } public static bool Chmin(ref long a, long b) { if (a > b) { a = b; return true; } return false; } public static bool Chmax(ref int a, int b) { if (a < b) { a = b; return true; } return false; } public static bool Chmax(ref long a, long b) { if (a < b) { a = b; return true; } return false; } public static int[] SubArr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; } } }
[["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
656
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var waaaa = new waaaa(); waaaa.Solve(); } } public class waaaa { const int MOD = 1000000007; const int INF = 1 << 20; const long INFL = 1 << 62; const int MOD2 = 998244353; myinout IO = new myinout(); Math2 mmath = new Math2(); public void Solve() { //ここから var N = IO.Int1; int[,] x = new int[N, N]; int[,] y = new int[N, N]; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { x[i, j] = -1; y[i, j] = -1; } } for (int i = 0; i < N; ++i) { int A = IO.Int1; for (int j = 0; j < A; ++j) { var o = IO.IntM; x[i, j] = o[0] - 1; y[i, j] = o[1]; } } int ans = 0; for (int i = 0; i < (1 << N); ++i) { int count = 0; bool f = true; for (int j = 0; j < N; ++j) { if (((i >> j) & 1) == 1) { count++; bool f2 = true; for (int k = 0; k < N; ++k) { // jのk番目の証言 var sss = x[j, k]; if ((((i >> sss) & 1) == 1 && y[j, k] == 0)) { f = false; } } for (int k = 0; k < N; ++k) // k番目の証人 { for (int l = 0; l < N; ++l) // l番目の証言 { if (((i >> k) & 1) == 1 && x[k, l] == j && y[k, l] == 0) f2 = false; } } if (!f2) { f = false; break; } } } // IO.wri(f); if (f) ans = Math.Max(ans, count); } IO.wri(ans); } } // b-aで降順 public class Math2 { public long[] Fact; // Nまでの階乗 public long[] invFact; //階乗の逆元 // Nまでの階乗をセットしておく public void FactoricalModSet(long N, long MOD = 1000000007) { Fact = new long[N + 1]; invFact = new long[N + 1]; Fact[0] = 1; for (long i = 1; i <= N; ++i) { Fact[i] = Fact[i - 1] * i % MOD; } invFact[N] = pow(Fact[N], MOD - 2); for (long i = N; i > 0; --i) { invFact[i - 1] = invFact[i] * i % MOD; } } // nCr 引数:n r (mod) public long nCr(long n, long r, long MOD = 1000000007) { return (Fact[n] * invFact[r] % MOD * invFact[n - r] % MOD); } //階乗(O(logN)) 引数:底x n乗 (MOD) public long pow(long x, long n, long MOD = 1000000007) { long res = 1; while (n > 0) { if ((n & 1) != 0) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } //最大公約数 引数:整数x,y public long GCD(long x, long y) { while (y != 0) { var r = x % y; x = y; y = r; } return x; } //最小公倍数 引数:整数x,y public long LCM(long x, long y) { return x * y / GCD(x, y); } //素因数分解 引数:整数N public Dictionary<long, int> PrimeFactorization(long N) { var ret = new Dictionary<long, int>(); for (long i = 2; i * i <= N; ++i) { int cnt = 0; while (N % i == 0) { cnt++; N /= i; } if (cnt != 0) ret[i] = cnt; } if (N >= 2) ret[N] = 1; return ret; } //約数列挙 public List<long> divisorenumrate(long N) { var ret = new List<long>(); for (long i = 1; i * i <= N; ++i) { if (N % i == 0) { ret.Add(i); ret.Add(N / i); } } return ret; } public void Swap<T>(ref T a, ref T b) { var x = a; a = b; b = x; } } class myinout { // in public string Str => Console.ReadLine(); public string[] StrM => Str.Split(' '); public long[] LongM => StrM.Select(long.Parse).ToArray(); public int[] IntM => StrM.Select(int.Parse).ToArray(); public char[] CharM => Str.ToArray(); public long Long1 => LongM[0]; public int Int1 => IntM[0]; // out public void wri<T>(T x) { Console.WriteLine(x); } public void yn(bool x) { if (x) wri("Yes"); else wri("No"); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var waaaa = new waaaa(); waaaa.Solve(); } } public class waaaa { const int MOD = 1000000007; const int INF = 1 << 20; const long INFL = 1 << 62; const int MOD2 = 998244353; myinout IO = new myinout(); Math2 mmath = new Math2(); public void Solve() { //ここから var N = IO.Int1; int[,] x = new int[N, N]; int[,] y = new int[N, N]; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { x[i, j] = -1; y[i, j] = -1; } } for (int i = 0; i < N; ++i) { int A = IO.Int1; for (int j = 0; j < A; ++j) { var o = IO.IntM; x[i, j] = o[0] - 1; y[i, j] = o[1]; } } int ans = 0; for (int i = 0; i < (1 << N); ++i) { int count = 0; bool f = true; for (int j = 0; j < N; ++j) { if (((i >> j) & 1) == 1) { count++; bool f2 = true; for (int k = 0; k < N; ++k) { // jのk番目の証言 var sss = x[j, k]; if ((((i >> sss) & 1) != 1 && y[j, k] == 1)) { f = false; } } for (int k = 0; k < N; ++k) // k番目の証人 { for (int l = 0; l < N; ++l) // l番目の証言 { if (((i >> k) & 1) == 1 && x[k, l] == j && y[k, l] == 0) f2 = false; } } if (!f2) { f = false; break; } } } // IO.wri(f); if (f) ans = Math.Max(ans, count); } IO.wri(ans); } } // b-aで降順 public class Math2 { public long[] Fact; // Nまでの階乗 public long[] invFact; //階乗の逆元 // Nまでの階乗をセットしておく public void FactoricalModSet(long N, long MOD = 1000000007) { Fact = new long[N + 1]; invFact = new long[N + 1]; Fact[0] = 1; for (long i = 1; i <= N; ++i) { Fact[i] = Fact[i - 1] * i % MOD; } invFact[N] = pow(Fact[N], MOD - 2); for (long i = N; i > 0; --i) { invFact[i - 1] = invFact[i] * i % MOD; } } // nCr 引数:n r (mod) public long nCr(long n, long r, long MOD = 1000000007) { return (Fact[n] * invFact[r] % MOD * invFact[n - r] % MOD); } //階乗(O(logN)) 引数:底x n乗 (MOD) public long pow(long x, long n, long MOD = 1000000007) { long res = 1; while (n > 0) { if ((n & 1) != 0) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } //最大公約数 引数:整数x,y public long GCD(long x, long y) { while (y != 0) { var r = x % y; x = y; y = r; } return x; } //最小公倍数 引数:整数x,y public long LCM(long x, long y) { return x * y / GCD(x, y); } //素因数分解 引数:整数N public Dictionary<long, int> PrimeFactorization(long N) { var ret = new Dictionary<long, int>(); for (long i = 2; i * i <= N; ++i) { int cnt = 0; while (N % i == 0) { cnt++; N /= i; } if (cnt != 0) ret[i] = cnt; } if (N >= 2) ret[N] = 1; return ret; } //約数列挙 public List<long> divisorenumrate(long N) { var ret = new List<long>(); for (long i = 1; i * i <= N; ++i) { if (N % i == 0) { ret.Add(i); ret.Add(N / i); } } return ret; } public void Swap<T>(ref T a, ref T b) { var x = a; a = b; b = x; } } class myinout { // in public string Str => Console.ReadLine(); public string[] StrM => Str.Split(' '); public long[] LongM => StrM.Select(long.Parse).ToArray(); public int[] IntM => StrM.Select(int.Parse).ToArray(); public char[] CharM => Str.ToArray(); public long Long1 => LongM[0]; public int Int1 => IntM[0]; // out public void wri<T>(T x) { Console.WriteLine(x); } public void yn(bool x) { if (x) wri("Yes"); else wri("No"); } }
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 79], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 203], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 203]]
8
1,168
4
using System; using System.Collections.Generic; using System.Linq; public static class Bits { public static int PopCount(int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } } public struct Person { public int Honests; public int Unkinds; public Person(int honests, int unkinds) { Honests = honests; Unkinds = unkinds; } } public class Solution { public static void Main() { var N = int.Parse(Console.ReadLine()); var persons = new Person[N]; for (int i = 0; i < N; i++) { var A = int.Parse(Console.ReadLine()); var honests = 0; var unkinds = 0; for (int j = 0; j < A; j++) { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var x = vals[0]; var y = vals[1]; if (y == 1) { honests |= 1 << (x - 1); } else { unkinds |= 1 << (x - 1); } } persons[i] = new Person(honests, unkinds); } var max = 0; var mask = (1 << N) - 1; for (int pattern = 0; pattern < (1 << (N - 1)); pattern++) { bool ok = true; for (int i = 0; i < N; i++) { if (((1 << i) & pattern) == 0) { continue; } var person = persons[i]; if ((person.Honests & pattern) != person.Honests) { ok = false; break; } if ((person.Unkinds & (mask ^ pattern)) != person.Unkinds) { ok = false; break; } } if (ok) { max = Math.Max(Bits.PopCount(pattern), max); } } Console.WriteLine(max); } }
using System; using System.Collections.Generic; using System.Linq; public static class Bits { public static int PopCount(int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } } public struct Person { public int Honests; public int Unkinds; public Person(int honests, int unkinds) { Honests = honests; Unkinds = unkinds; } } public class Solution { public static void Main() { var N = int.Parse(Console.ReadLine()); var persons = new Person[N]; for (int i = 0; i < N; i++) { var A = int.Parse(Console.ReadLine()); var honests = 0; var unkinds = 0; for (int j = 0; j < A; j++) { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var x = vals[0]; var y = vals[1]; if (y == 1) { honests |= 1 << (x - 1); } else { unkinds |= 1 << (x - 1); } } persons[i] = new Person(honests, unkinds); } var max = 0; var mask = (1 << N) - 1; for (int pattern = 0; pattern < (1 << N); pattern++) { bool ok = true; for (int i = 0; i < N; i++) { if (((1 << i) & pattern) == 0) { continue; } var person = persons[i]; if ((person.Honests & pattern) != person.Honests) { ok = false; break; } if ((person.Unkinds & (mask ^ pattern)) != person.Unkinds) { ok = false; break; } } if (ok) { max = Math.Max(Bits.PopCount(pattern), max); } } Console.WriteLine(max); } }
[["-", 15, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 203], ["-", 15, 16, 12, 23, 0, 16, 12, 23, 0, 25]]
8
485
4
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Numerics; using static System.Math; using static System.Array; using static AtCoder.IO_ShortCut; using static AtCoder.Tool; namespace AtCoder { class AC { const int MOD = 1000000007; // const int MOD = 998244353; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dI = { 0, 1, 0, -1, 1, -1, -1, 1 }; static readonly int[] dJ = { 1, 0, -1, 0, 1, 1, -1, -1 }; 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); int N = Int; var A = _ReadSplitLong; long ans = 0; for (var b = 0; b <= 61; b++) { long cur = (1L << b); long cnt = 0; for (var i = 0; i < N; i++) { if (Bit(A[i], b)) { cnt++; } } ans += (((cnt * (N - cnt)) % MOD) * cur) % MOD; ans %= MOD; } OutL(ans); // Console.Out.Flush(); } public static int[] Z_algorithm(string S) { int L = S.Length; var ret = new int[L]; int i = 1, j = 0; ret[0] = L; while (i < L) { while (i + j < L && (S[i + j] == S[j])) j++; ret[i] = j; if (j == 0) { i++; continue; } int k = 1; while (i + k < L && (k + ret[k] < j)) { ret[i + k] = ret[k]; k++; } i += k; j -= k; } return ret; } 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; } } } 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 Count() { return Q.Count(); } public bool Contains(T obj) { return Q.Contains(obj); } } static class IO_ShortCut { public static string[] _ReadSplit => Console.ReadLine().Split(); public static int[] _ReadSplitInt => ConvertAll(Console.ReadLine().Split(), int.Parse); public static long[] _ReadSplitLong => ConvertAll(Console.ReadLine().Split(), long.Parse); public static double[] _ReadSplit_Double => ConvertAll(Console.ReadLine().Split(), double.Parse); public static string Str => Console.ReadLine(); public static int Int => int.Parse(Console.ReadLine()); public static long Long => long.Parse(Console.ReadLine()); public static double Double => double.Parse(Console.ReadLine()); public static T Conv<T>(string input) => (T)Convert.ChangeType(input, typeof(T)); public static void Input<T>(out T a) => a = Conv<T>(Console.ReadLine()); public static void Input<T, U>(out T a, out U b) { var q = _ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); } public static void Input<T, U, V>(out T a, out U b, out V c) { var q = _ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); } public static void Input<T, U, V, W>(out T a, out U b, out V c, out W d) { var q = _ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); d = Conv<W>(q[3]); } public static void OutL(object s) => Console.WriteLine(s); public static void Out_Sep<T>(IEnumerable<T> s) => Console.WriteLine(string.Join(" ", s)); public static void Out_Sep<T>(IEnumerable<T> s, string sep) => Console.WriteLine(string.Join($"{sep}", s)); public static void Out_Sep(params object[] s) => Console.WriteLine(string.Join(" ", s)); public static void Out_One(object s) => Console.Write($"{s} "); public static void Out_One(object s, string sep) => Console.Write($"{s}{sep}"); public static void Endl() => Console.WriteLine(); } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { array = ConvertAll(array, x => initialvalue); } static public void Swap<T>(ref T a, ref T b) { T keep = a; a = b; b = keep; } static public void Display<T>(T[,] array2d, int n, int m) { for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { Console.Write($"{array2d[i, j]} "); } Console.WriteLine(); } } static public long LPow(int a, int b) => (long)Pow(a, b); static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0; } class Modulo { private int M; private readonly long[] m_facs; public long Mul(long a, long b) { return ((a * b) % M); } public Modulo(long n, int m) { M = m; m_facs = new long[n + 1]; m_facs[0] = 1; for (long i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public long Fac(long n) { return m_facs[n]; } public long Pow(long a, long m) { switch (m) { case 0: return 1L; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public long Div(long a, long b) { return Mul(a, Pow(b, M - 2)); } public long Ncr(long n, long r) { if (n < r) { return 0; } if (n == r) { return 1; } long res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Numerics; using static System.Math; using static System.Array; using static AtCoder.IO_ShortCut; using static AtCoder.Tool; namespace AtCoder { class AC { const int MOD = 1000000007; // const int MOD = 998244353; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dI = { 0, 1, 0, -1, 1, -1, -1, 1 }; static readonly int[] dJ = { 1, 0, -1, 0, 1, 1, -1, -1 }; 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); int N = Int; var A = _ReadSplitLong; long ans = 0; for (var b = 0; b <= 61; b++) { long cur = (1L << b) % MOD; long cnt = 0; for (var i = 0; i < N; i++) { if (Bit(A[i], b)) { cnt++; } } ans += (((cnt * (N - cnt)) % MOD) * cur % MOD) % MOD; ans %= MOD; } OutL(ans); // Console.Out.Flush(); } public static int[] Z_algorithm(string S) { int L = S.Length; var ret = new int[L]; int i = 1, j = 0; ret[0] = L; while (i < L) { while (i + j < L && (S[i + j] == S[j])) j++; ret[i] = j; if (j == 0) { i++; continue; } int k = 1; while (i + k < L && (k + ret[k] < j)) { ret[i + k] = ret[k]; k++; } i += k; j -= k; } return ret; } 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; } } } 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 Count() { return Q.Count(); } public bool Contains(T obj) { return Q.Contains(obj); } } static class IO_ShortCut { public static string[] _ReadSplit => Console.ReadLine().Split(); public static int[] _ReadSplitInt => ConvertAll(Console.ReadLine().Split(), int.Parse); public static long[] _ReadSplitLong => ConvertAll(Console.ReadLine().Split(), long.Parse); public static double[] _ReadSplit_Double => ConvertAll(Console.ReadLine().Split(), double.Parse); public static string Str => Console.ReadLine(); public static int Int => int.Parse(Console.ReadLine()); public static long Long => long.Parse(Console.ReadLine()); public static double Double => double.Parse(Console.ReadLine()); public static T Conv<T>(string input) => (T)Convert.ChangeType(input, typeof(T)); public static void Input<T>(out T a) => a = Conv<T>(Console.ReadLine()); public static void Input<T, U>(out T a, out U b) { var q = _ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); } public static void Input<T, U, V>(out T a, out U b, out V c) { var q = _ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); } public static void Input<T, U, V, W>(out T a, out U b, out V c, out W d) { var q = _ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); d = Conv<W>(q[3]); } public static void OutL(object s) => Console.WriteLine(s); public static void Out_Sep<T>(IEnumerable<T> s) => Console.WriteLine(string.Join(" ", s)); public static void Out_Sep<T>(IEnumerable<T> s, string sep) => Console.WriteLine(string.Join($"{sep}", s)); public static void Out_Sep(params object[] s) => Console.WriteLine(string.Join(" ", s)); public static void Out_One(object s) => Console.Write($"{s} "); public static void Out_One(object s, string sep) => Console.Write($"{s}{sep}"); public static void Endl() => Console.WriteLine(); } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { array = ConvertAll(array, x => initialvalue); } static public void Swap<T>(ref T a, ref T b) { T keep = a; a = b; b = keep; } static public void Display<T>(T[,] array2d, int n, int m) { for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { Console.Write($"{array2d[i, j]} "); } Console.WriteLine(); } } static public long LPow(int a, int b) => (long)Pow(a, b); static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0; } class Modulo { private int M; private readonly long[] m_facs; public long Mul(long a, long b) { return ((a * b) % M); } public Modulo(long n, int m) { M = m; m_facs = new long[n + 1]; m_facs[0] = 1; for (long i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public long Fac(long n) { return m_facs[n]; } public long Pow(long a, long m) { switch (m) { case 0: return 1L; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public long Div(long a, long b) { return Mul(a, Pow(b, M - 2)); } public long Ncr(long n, long r) { if (n < r) { return 0; } if (n == r) { return 1; } long res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } }
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
8
2,019
4
using System; using System.Text; using System.Collections.Generic; using System.Collections; 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 => long.Parse(x)).ToArray(); var len = Convert.ToString(A.Max(), 2).Length; var sum1 = new long[len]; var sum0 = new long[len]; var til1 = new long[len]; for (long i = N - 1; i >= 0; i--) { var S = Convert.ToString(A[i], 2); for (int j = 0; j < len; j++) { if (j < S.Length && S[S.Length - j - 1] == '1') { til1[j] += sum0[j]; sum1[j]++; } else { til1[j] += sum1[j]; sum0[j]++; } } } long ans = 0; long mo = 1000000007; for (int i = 0; i < len; i++) { // Console.WriteLine(til1[i]); ans += til1[i] * ((long)Math.Pow(2, i)) % mo; ans %= mo; } Console.WriteLine(ans); } }
using System; using System.Text; using System.Collections.Generic; using System.Collections; 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 => long.Parse(x)).ToArray(); var len = Convert.ToString(A.Max(), 2).Length; var sum1 = new long[len]; var sum0 = new long[len]; var til1 = new long[len]; for (long i = N - 1; i >= 0; i--) { var S = Convert.ToString(A[i], 2); for (int j = 0; j < len; j++) { if (j < S.Length && S[S.Length - j - 1] == '1') { til1[j] += sum0[j]; sum1[j]++; } else { til1[j] += sum1[j]; sum0[j]++; } } } long ans = 0; long mo = 1000000007; for (int i = 0; i < len; i++) { // Console.WriteLine(til1[i]); ans += (til1[i] % mo) * ((long)Math.Pow(2, i) % mo); ans %= mo; } Console.WriteLine(ans); } }
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 12, 23, 0, 74, 51, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
8
310
6
using System; using System.Collections.Generic; using System.ComponentModel.Design; using System.Diagnostics; using System.Linq; using System.Runtime; using System.Text; using Microsoft.Win32; using static System.Console; public static class Program { private static readonly long INF = long.MaxValue / 2; private static readonly int MOD = 1000000007; struct Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T first; public U second; private bool CompWithFirst; public Pair(T f, U s, int comp) { first = f; second = s; CompWithFirst = comp == 1; } 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 bool IsEmpty() { return !Q.Any(); } } static long ModInv(long a, long m) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; long tmp = a; a = b; b = tmp; u -= t * v; tmp = u; u = v; v = tmp; } u %= m; if (u < 0) u += m; return u; } public static long CalcComb(long n, long m) { //条件チェック if (n < m) return 0; if (n < 0 || m < 0) return 0; // nCm = nCm-1 ×(n-m+1)/ m // return CalcFact(n) / (CalcFact(m) * CalcFact(n - m)); // MODで割ってbの逆元を求める return CalcFact(n) * ModInv((CalcFact(m) * CalcFact(n - m)) % MOD, MOD) % MOD; } /// <summary> /// 階乗を計算する。 /// </summary> /// <param name="n">n</param> /// <returns>nの階乗(n!)</returns> public static long CalcFact(long n) { if (n <= 0) { return 1; } return n * CalcFact(n - 1) % MOD; } struct Pos { public int x; public int y; public Pos(int x, int y) { this.x = x; this.y = y; } public static Pos operator +(Pos p1, Pos p2) { var result = new Pos(); result.x = p2.x + p1.x; result.y = p2.y + p1.y; return result; } public static Pos operator -(Pos p1, Pos p2) { var result = new Pos(); result.x = p2.x - p1.x; result.y = p2.y - p1.y; return result; } } class Modular { private const int M = 1000000007; private long value; public Modular(long value) { this.value = value; } public static implicit operator Modular(long a) { var m = a % M; return new Modular((m < 0) ? m + M : m); } public static Modular operator +(Modular a, Modular b) { return a.value + b.value; } public static Modular operator -(Modular a, Modular b) { return a.value - b.value; } public static Modular operator *(Modular a, Modular b) { return a.value * b.value; } private static Modular Pow(Modular a, int n) { switch (n) { case 0: return 1; case 1: return a; default: var p = Pow(a, n / 2); return p * p * Pow(a, n % 2); } } public static Modular operator /(Modular a, Modular b) { return a * Pow(b, M - 2); } private static readonly List<int> facs = new List<int> { 1 }; private static Modular Fac(int n) { for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % M)); } return facs[n]; } public static Modular Ncr(int n, int r) { return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r)); } public static explicit operator int(Modular a) { return (int)a.value; } } static class Permutation<T> { private static void Search(List<T[]> perms, Stack<T> stack, T[] a) { int N = a.Length; if (N == 0) { perms.Add(stack.Reverse().ToArray()); } else { var b = new T[N - 1]; Array.Copy(a, 1, b, 0, N - 1); for (int i = 0; i < a.Length; ++i) { stack.Push(a[i]); Search(perms, stack, b); if (i < b.Length) { b[i] = a[i]; } stack.Pop(); } } } public static IEnumerable<T[]> All(IEnumerable<T> src) { var perms = new List<T[]>(); Search(perms, new Stack<T>(), src.ToArray()); return perms; } } public static int ReadLineToInt() { return int.Parse(ReadLine()); } public static long ReadLineToLong() { return long.Parse(ReadLine()); } public static int[] ReadLineToInts() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] ReadLineToLongs() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } static int nibunn(int[] array, int target) { int L = 0; int R = array.Length; while (R - L > 1) { int mid = (R + L) / 2; if (array[mid] > target) L = mid; else R = mid; } return L; } struct Testmony { public int To; public int IsHonest; public Testmony(int to, int isHonest) { To = to; IsHonest = isHonest; } } public static void Main(string[] args) { int n = ReadLineToInt(); long[] v = ReadLineToLongs(); long sum = 0; for (int i = 0; i < 60; i++) { long x = 0; foreach (var a in v) { if ((a >> i & 1) == 1) x++; } long xy = x * (n - x) % MOD; for (int j = 0; j < i; j++) { xy = xy * 2 % MOD; } sum += xy; } WriteLine(sum); } }
using System; using System.Collections.Generic; using System.ComponentModel.Design; using System.Diagnostics; using System.Linq; using System.Runtime; using System.Text; using Microsoft.Win32; using static System.Console; public static class Program { private static readonly long INF = long.MaxValue / 2; private static readonly int MOD = 1000000007; struct Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T first; public U second; private bool CompWithFirst; public Pair(T f, U s, int comp) { first = f; second = s; CompWithFirst = comp == 1; } 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 bool IsEmpty() { return !Q.Any(); } } static long ModInv(long a, long m) { long b = m, u = 1, v = 0; while (b != 0) { long t = a / b; a -= t * b; long tmp = a; a = b; b = tmp; u -= t * v; tmp = u; u = v; v = tmp; } u %= m; if (u < 0) u += m; return u; } public static long CalcComb(long n, long m) { //条件チェック if (n < m) return 0; if (n < 0 || m < 0) return 0; // nCm = nCm-1 ×(n-m+1)/ m // return CalcFact(n) / (CalcFact(m) * CalcFact(n - m)); // MODで割ってbの逆元を求める return CalcFact(n) * ModInv((CalcFact(m) * CalcFact(n - m)) % MOD, MOD) % MOD; } /// <summary> /// 階乗を計算する。 /// </summary> /// <param name="n">n</param> /// <returns>nの階乗(n!)</returns> public static long CalcFact(long n) { if (n <= 0) { return 1; } return n * CalcFact(n - 1) % MOD; } struct Pos { public int x; public int y; public Pos(int x, int y) { this.x = x; this.y = y; } public static Pos operator +(Pos p1, Pos p2) { var result = new Pos(); result.x = p2.x + p1.x; result.y = p2.y + p1.y; return result; } public static Pos operator -(Pos p1, Pos p2) { var result = new Pos(); result.x = p2.x - p1.x; result.y = p2.y - p1.y; return result; } } class Modular { private const int M = 1000000007; private long value; public Modular(long value) { this.value = value; } public static implicit operator Modular(long a) { var m = a % M; return new Modular((m < 0) ? m + M : m); } public static Modular operator +(Modular a, Modular b) { return a.value + b.value; } public static Modular operator -(Modular a, Modular b) { return a.value - b.value; } public static Modular operator *(Modular a, Modular b) { return a.value * b.value; } private static Modular Pow(Modular a, int n) { switch (n) { case 0: return 1; case 1: return a; default: var p = Pow(a, n / 2); return p * p * Pow(a, n % 2); } } public static Modular operator /(Modular a, Modular b) { return a * Pow(b, M - 2); } private static readonly List<int> facs = new List<int> { 1 }; private static Modular Fac(int n) { for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % M)); } return facs[n]; } public static Modular Ncr(int n, int r) { return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r)); } public static explicit operator int(Modular a) { return (int)a.value; } } static class Permutation<T> { private static void Search(List<T[]> perms, Stack<T> stack, T[] a) { int N = a.Length; if (N == 0) { perms.Add(stack.Reverse().ToArray()); } else { var b = new T[N - 1]; Array.Copy(a, 1, b, 0, N - 1); for (int i = 0; i < a.Length; ++i) { stack.Push(a[i]); Search(perms, stack, b); if (i < b.Length) { b[i] = a[i]; } stack.Pop(); } } } public static IEnumerable<T[]> All(IEnumerable<T> src) { var perms = new List<T[]>(); Search(perms, new Stack<T>(), src.ToArray()); return perms; } } public static int ReadLineToInt() { return int.Parse(ReadLine()); } public static long ReadLineToLong() { return long.Parse(ReadLine()); } public static int[] ReadLineToInts() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] ReadLineToLongs() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } static int nibunn(int[] array, int target) { int L = 0; int R = array.Length; while (R - L > 1) { int mid = (R + L) / 2; if (array[mid] > target) L = mid; else R = mid; } return L; } struct Testmony { public int To; public int IsHonest; public Testmony(int to, int isHonest) { To = to; IsHonest = isHonest; } } public static void Main(string[] args) { int n = ReadLineToInt(); long[] v = ReadLineToLongs(); long sum = 0; for (int i = 0; i < 60; i++) { long x = 0; foreach (var a in v) { if ((a >> i & 1) == 1) x++; } long xy = x * (n - x) % MOD; for (int j = 0; j < i; j++) { xy = xy * 2 % MOD; } sum += xy; sum %= MOD; } WriteLine(sum); } }
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
8
1,851
4
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { // modをかける場所がわからない int N = int.Parse(Console.ReadLine()); long[] A = new long[N]; string[] str = Console.ReadLine().Split(); for (var i = 0; i < N; i++) { A[i] = long.Parse(str[i]); } long ans = 0; int mod = (int)1e9 + 7; // bit列60桁分をすべて走査する for (int k = 0; k < 60; k++) { long x0 = 0; long x1 = 0; for (int i = 0; i < N; i++) { // k桁目をビット演算で取り出す var x = (A[i] >> k) & 1; // k桁目が 0, 1 のどちらかを数えておく if (x == 0) x0 += 1; else x1 += 1; } long p = 1; for (int i = 0; i < k; i++) { p *= 2; // p %= mod; } // x0 * x1 が 0, 1 の組み合わせ数 var count = (x0 * x1); ans += count * p; ans %= mod; } Console.WriteLine(ans); } }
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { // modをかける場所がわからない int N = int.Parse(Console.ReadLine()); long[] A = new long[N]; string[] str = Console.ReadLine().Split(); for (var i = 0; i < N; i++) { A[i] = long.Parse(str[i]); } long ans = 0; int mod = (int)1e9 + 7; // bit列60桁分をすべて走査する for (int k = 0; k < 60; k++) { long x0 = 0; long x1 = 0; for (int i = 0; i < N; i++) { // k桁目をビット演算で取り出す var x = (A[i] >> k) & 1; // k桁目が 0, 1 のどちらかを数えておく if (x == 0) x0 += 1; else x1 += 1; } long p = 1; for (int i = 0; i < k; i++) { p *= 2; p %= mod; } // x0 * x1 が 0, 1 の組み合わせ数 var count = (x0 * x1) % mod; //ここでmodしているのは2の0乗分を計算している ans += count * p; // modは2の1乗分から ans %= mod; } Console.WriteLine(ans); } }
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
8
239
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.ABC_147 { class D { static void Main(string[] args) { var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false }; SetOut(sw); Method(args); Out.Flush(); } static void Method(string[] args) { long n = ReadInt(); long[] array = ReadLongs(); long[] cnts = new long[61]; for (int i = 0; i < n; i++) { long tmp = array[i]; long div = 1; for (int j = 0; j < cnts.Length; j++) { if ((tmp & div) > 0) cnts[j]++; div *= 2; } } long res = 0; long digValue = 1; long mask = 1000000000 + 7; for (int i = 0; i < cnts.Length; i++) { long tmp = n - cnts[i]; tmp *= digValue; tmp %= mask; tmp *= cnts[i]; tmp %= mask; res += tmp; res %= mask; digValue *= 2; digValue %= 2; } WriteLine(res); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.ABC_147 { class D { static void Main(string[] args) { var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false }; SetOut(sw); Method(args); Out.Flush(); } static void Method(string[] args) { long n = ReadInt(); long[] array = ReadLongs(); long[] cnts = new long[60]; for (int i = 0; i < n; i++) { long tmp = array[i]; long div = 1; for (int j = 0; j < cnts.Length; j++) { if ((tmp & div) > 0) cnts[j]++; div *= 2; } } long res = 0; long digValue = 1; long mask = 1000000000 + 7; for (int i = 0; i < cnts.Length; i++) { long tmp = n - cnts[i]; tmp *= digValue; tmp %= mask; tmp *= cnts[i]; tmp %= mask; res += tmp; res %= mask; digValue *= 2; digValue %= mask; } WriteLine(res); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
[["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22]]
8
461
4
// ReSharper disable ArrangeTypeMemberModifiers // ReSharper disable ConvertIfStatementToSwitchStatement // ReSharper disable FunctionRecursiveOnAllPaths // ReSharper disable InconsistentNaming // ReSharper disable InlineOutVariableDeclaration // ReSharper disable InvertIf // ReSharper disable JoinDeclarationAndInitializer // ReSharper disable MemberCanBeMadeStatic.Global // ReSharper disable MemberCanBeMadeStatic.Local // ReSharper disable NonReadonlyMemberInGetHashCode // ReSharper disable PossibleNullReferenceException // ReSharper disable RedundantUsingDirective // ReSharper disable SuggestVarOrType_BuiltInTypes // ReSharper disable SuggestVarOrType_Elsewhere // ReSharper disable TailRecursiveCall // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Local // ReSharper disable UseObjectOrCollectionInitializert #if true && UTAKA_LOCAL //#if false #define UTAKA_DEBUG #endif //#define TOPCODER using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Numerics; using System.Runtime.InteropServices; using System.Security.Cryptography; namespace UtakaApp { public partial class Program { public const string SiteName = "AtCoder"; public const string ContestName = "abc147"; public const string ProblemName = "D"; public const long Mod = 1000000007L; public void Solve() { int N = cin.ReadInt; long[] A = cin.ReadLongArray(N); long ans = 0; long b = 1; for (int j = 0; j < 60; j++) { int oneCount = 0; for (int i = 0; i < N; i++) { if ((A[i] & (1L << j)) != 0) { oneCount++; } } ans += (b * oneCount % Mod * (N - oneCount) % Mod); ans %= Mod; b *= 2; } cou.WriteLine(ans); } } //========================================================================================= // Debug IO //========================================================================================= public partial class Program { //========================================================================================= // Main //========================================================================================= private readonly ConsoleInput cin; private readonly IConsole cou; public Program(ConsoleInput cin, IConsole cou) { this.cin = cin; this.cou = cou; } #if !TOPCODER public static void Main(string[] args) { #if UTAKA_LOCAL //#if false new TestCaseCheckerForAtCoder().TestProblems(); #else var cin = new ConsoleInput(System.Console.In); var console = new MyConsole(); new Program(cin, console).Solve(); console.Flush(); #endif } #endif //========================================================================================= // Library //========================================================================================= public static T[] Array1D<T>(int a, T defaultValue) where T : struct { var ret = new T[a]; for (int i = 0; i < a; i++) { ret[i] = defaultValue; } return ret; } public static T[] Array1D<T>(int a) where T : struct { var ret = new T[a]; return ret; } /// <summary> /// 要素数 (a, b) の、defaultValue で満たされた配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <returns>指定した条件で初期化された配列</returns> public static T[,] Array2D<T>(int a, int b, T defaultValue) where T : struct { var ret = new T[a, b]; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { ret[i, j] = defaultValue; } } return ret; } public static T[,,] Array3D<T>(int a, int b, int c, T defaultValue) where T : struct { T[,,] ret = new T[a, b, c]; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { for (int k = 0; k < c; k++) { ret[i, j, k] = defaultValue; } } } return ret; } /// <summary> /// 要素数 (a, b) の、defaultValue で満たされたJag配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <returns>指定した条件で初期化された配列</returns> public static T[][] JagArray2D<T>(int a, int b, T defaultValue) where T : struct { var ret = new T[a][]; for (int i = 0; i < a; i++) { var row = new T[b]; ret[i] = row; for (int j = 0; j < b; j++) { row[j] = defaultValue; } } return ret; } /// <summary> /// 要素数 (a, b) のdefault値で満たされたJag配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <returns>初期化された配列</returns> public static T[][] JagArray2D<T>(int a, int b) where T : struct { var ret = new T[a][]; for (int i = 0; i < a; i++) { ret[i] = new T[b]; } return ret; } public static T[][][] JagArray3D<T>(int a, int b, int c, T defaultValue) where T : struct { var ret = new T[a][][]; for (int i = 0; i < a; i++) { T[][] aRow = new T[b][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[] bRow = new T[c]; aRow[j] = bRow; for (int k = 0; k < c; k++) { bRow[k] = defaultValue; } } } return ret; } public static T[][][] JagArray3D<T>(int a, int b, int c) where T : struct { var ret = new T[a][][]; for (int i = 0; i < a; i++) { T[][] aRow = new T[b][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[] bRow = new T[c]; aRow[j] = bRow; } } return ret; } public static T[][][][] JagArray4D<T>(int a, int b, int c, int d, T defaultValue) where T : struct { var ret = new T[a][][][]; for (int i = 0; i < a; i++) { T[][][] aRow = new T[b][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][] bRow = new T[c][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[] cRow = new T[d]; bRow[k] = cRow; for (int l = 0; l < d; l++) { cRow[l] = defaultValue; } } } } return ret; } public static T[][][][] JagArray4D<T>(int a, int b, int c, int d) where T : struct { var ret = new T[a][][][]; for (int i = 0; i < a; i++) { T[][][] aRow = new T[b][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][] bRow = new T[c][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[] cRow = new T[d]; bRow[k] = cRow; } } } return ret; } public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e, T defaultValue) where T : struct { var ret = new T[a][][][][]; for (int i = 0; i < a; i++) { T[][][][] aRow = new T[b][][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][][] bRow = new T[c][][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[][] cRow = new T[d][]; bRow[k] = cRow; for (int l = 0; l < d; l++) { T[] dRow = new T[e]; cRow[l] = dRow; for (int m = 0; m < e; m++) { dRow[m] = defaultValue; } } } } } return ret; } public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e) where T : struct { var ret = new T[a][][][][]; for (int i = 0; i < a; i++) { T[][][][] aRow = new T[b][][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][][] bRow = new T[c][][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[][] cRow = new T[d][]; bRow[k] = cRow; for (int l = 0; l < d; l++) { T[] dRow = new T[e]; cRow[l] = dRow; } } } } return ret; } /// <summary> /// ジャグ配列をコピーして返す。 /// </summary> public static T[][] CopyJagArray2D<T>(T[][] source) where T : struct { int len = source.Length; T[][] dest = new T[len][]; for (int i = 0; i < len; i++) { T[] inner = source[i]; int innerLength = inner.Length; T[] newer = new T[innerLength]; Array.Copy(inner, newer, innerLength); dest[i] = newer; } return dest; } } public class IntLargeComparer : IComparer<int> { public static IntLargeComparer Instance = new IntLargeComparer(); public int Compare(int x, int y) { return y - x; } } public class LongLargeComparer : IComparer<long> { public static LongLargeComparer Instance = new LongLargeComparer(); public int Compare(long x, long y) { if (x > y) return -1; if (x < y) return 1; return 0; } } public static class UtakaExtentions { /// <summary> /// 配列をコピーします /// </summary> public static T[] Copy<T>(this IList<T> a) { T[] ret = new T[a.Count]; for (int i = 0; i < a.Count; i++) ret[i] = a[i]; return ret; } } public class ConsoleInput { private readonly char _separator = ' '; private readonly TextReader _stream; private readonly Queue<string> inputStream; public ConsoleInput(TextReader stream, char separator = ' ') { _separator = separator; _stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) { return inputStream.Dequeue(); } var tmp = _stream.ReadLine().Split(_separator); for (var i = 0; i < tmp.Length; ++i) { inputStream.Enqueue(tmp[i]); } return inputStream.Dequeue(); } } public string ReadLine => _stream.ReadLine(); public int ReadInt => int.Parse(Read); public long ReadLong => long.Parse(Read); public double ReadDouble => double.Parse(Read); public 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; } } public interface IConsole { void Flush(); void Write(object obj); void Write(string str); void WriteLine(object obj); void WriteLine(string str); void WriteLine(); } public class MyConsole : IConsole { public MyConsole() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } public void Flush() { Console.Out.Flush(); } public void Write(object obj) { Write(obj.ToString()); } public void Write(string str) { Console.Write(str); } public void WriteLine(object obj) { WriteLine(obj.ToString()); } public void WriteLine(string str) { Console.WriteLine(str); } public void WriteLine() { Console.WriteLine(); } } #if UTAKA_LOCAL public class DebugConsole : IConsole { private readonly StringBuilder mSb; public DebugConsole() { mSb = new StringBuilder(); } public void Flush() { // 何もしない } public void Write(object obj) { Write(obj.ToString()); } public void Write(string str) { mSb.Append(str); } public void WriteLine(object obj) { WriteLine(obj.ToString()); } public void WriteLine(string str) { mSb.AppendLine(str); } public void WriteLine() { mSb.AppendLine(); } public string GetAllOutput() { return mSb.ToString(); } } #endif #if UTAKA_LOCAL public class TestCaseCheckerForAtCoder { private string GetDirectoryPath() { var problemPart = string.IsNullOrEmpty(Program.ProblemName) ? "" : $"/{Program.ProblemName}"; return $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/AlgorithmPrac/{Program.SiteName}/{Program.ContestName}{problemPart}"; } private string GetInputFilePath(int testCaseNumber) { return $"{GetDirectoryPath()}/sample-{testCaseNumber}.in"; } private string GetOutputFilePath(int testCaseNumber) { return $"{GetDirectoryPath()}/sample-{testCaseNumber}.out"; } public bool TestProblem(int testCaseNumber) { var inputFilePath = GetInputFilePath(testCaseNumber); var outputFilePath = GetOutputFilePath(testCaseNumber); TextReader inputStream = new StreamReader(inputFilePath); var cin = new ConsoleInput(inputStream); var debugConsoleWriter = new DebugConsole(); new Program(cin, debugConsoleWriter).Solve(); var output = debugConsoleWriter.GetAllOutput(); TextReader outputStream = new StreamReader(outputFilePath); var outputAnswer = outputStream.ReadToEnd(); Dbg.WriteLine(output); Dbg.WriteLine(outputAnswer); var isCorrect = output == outputAnswer; return isCorrect; } public void TestProblems(int targetTestCaseNumber = -1) { if (targetTestCaseNumber >= 0) { Console.WriteLine( $"!!!!!!!!!!!! Check TestCase {targetTestCaseNumber} !!!!!!!!!!"); } bool isSuccessAll = true; int testCaseNumber = 0; while (true) { testCaseNumber++; bool foundTargetTest = targetTestCaseNumber == testCaseNumber; if (targetTestCaseNumber >= 0 && !foundTargetTest) { continue; } var inputFileName = GetInputFilePath(testCaseNumber); if (!File.Exists(inputFileName)) { break; } Console.WriteLine( $"TestCase {testCaseNumber} ====================================================="); var result = TestProblem(testCaseNumber); if (result) { Console.WriteLine("Success"); } else { isSuccessAll = false; Console.WriteLine("Failure *****"); } if (foundTargetTest) { break; } } if (isSuccessAll) { Console.WriteLine("!!!!!!!!! All Success !!!!!!!!!"); } } } #endif public static class Dbg { [Conditional("UTAKA_DEBUG")] public static void WriteLine(string str) { Console.WriteLine(str); } [Conditional("UTAKA_DEBUG")] public static void WriteLine() { Console.WriteLine(); } [Conditional("UTAKA_DEBUG")] public static void Write(string str) { Console.Write(str); } } }
// ReSharper disable ArrangeTypeMemberModifiers // ReSharper disable ConvertIfStatementToSwitchStatement // ReSharper disable FunctionRecursiveOnAllPaths // ReSharper disable InconsistentNaming // ReSharper disable InlineOutVariableDeclaration // ReSharper disable InvertIf // ReSharper disable JoinDeclarationAndInitializer // ReSharper disable MemberCanBeMadeStatic.Global // ReSharper disable MemberCanBeMadeStatic.Local // ReSharper disable NonReadonlyMemberInGetHashCode // ReSharper disable PossibleNullReferenceException // ReSharper disable RedundantUsingDirective // ReSharper disable SuggestVarOrType_BuiltInTypes // ReSharper disable SuggestVarOrType_Elsewhere // ReSharper disable TailRecursiveCall // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Local // ReSharper disable UseObjectOrCollectionInitializert #if true && UTAKA_LOCAL //#if false #define UTAKA_DEBUG #endif //#define TOPCODER using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Numerics; using System.Runtime.InteropServices; using System.Security.Cryptography; namespace UtakaApp { public partial class Program { public const string SiteName = "AtCoder"; public const string ContestName = "abc147"; public const string ProblemName = "D"; public const long Mod = 1000000007L; public void Solve() { int N = cin.ReadInt; long[] A = cin.ReadLongArray(N); long ans = 0; long b = 1; for (int j = 0; j < 62; j++) { int oneCount = 0; for (int i = 0; i < N; i++) { if ((A[i] & (1L << j)) != 0) { oneCount++; } } ans += (b * oneCount % Mod * (N - oneCount) % Mod); ans %= Mod; b *= 2; b %= Mod; } cou.WriteLine(ans); } } //========================================================================================= // Debug IO //========================================================================================= public partial class Program { //========================================================================================= // Main //========================================================================================= private readonly ConsoleInput cin; private readonly IConsole cou; public Program(ConsoleInput cin, IConsole cou) { this.cin = cin; this.cou = cou; } #if !TOPCODER public static void Main(string[] args) { #if UTAKA_LOCAL //#if false new TestCaseCheckerForAtCoder().TestProblems(); #else var cin = new ConsoleInput(System.Console.In); var console = new MyConsole(); new Program(cin, console).Solve(); console.Flush(); #endif } #endif //========================================================================================= // Library //========================================================================================= public static T[] Array1D<T>(int a, T defaultValue) where T : struct { var ret = new T[a]; for (int i = 0; i < a; i++) { ret[i] = defaultValue; } return ret; } public static T[] Array1D<T>(int a) where T : struct { var ret = new T[a]; return ret; } /// <summary> /// 要素数 (a, b) の、defaultValue で満たされた配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <returns>指定した条件で初期化された配列</returns> public static T[,] Array2D<T>(int a, int b, T defaultValue) where T : struct { var ret = new T[a, b]; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { ret[i, j] = defaultValue; } } return ret; } public static T[,,] Array3D<T>(int a, int b, int c, T defaultValue) where T : struct { T[,,] ret = new T[a, b, c]; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { for (int k = 0; k < c; k++) { ret[i, j, k] = defaultValue; } } } return ret; } /// <summary> /// 要素数 (a, b) の、defaultValue で満たされたJag配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <param name="defaultValue">デフォルト値</param> /// <returns>指定した条件で初期化された配列</returns> public static T[][] JagArray2D<T>(int a, int b, T defaultValue) where T : struct { var ret = new T[a][]; for (int i = 0; i < a; i++) { var row = new T[b]; ret[i] = row; for (int j = 0; j < b; j++) { row[j] = defaultValue; } } return ret; } /// <summary> /// 要素数 (a, b) のdefault値で満たされたJag配列を作成します。 /// </summary> /// <typeparam name="T">配列の型</typeparam> /// <param name="a">1次元の要素数</param> /// <param name="b">2次元の要素数</param> /// <returns>初期化された配列</returns> public static T[][] JagArray2D<T>(int a, int b) where T : struct { var ret = new T[a][]; for (int i = 0; i < a; i++) { ret[i] = new T[b]; } return ret; } public static T[][][] JagArray3D<T>(int a, int b, int c, T defaultValue) where T : struct { var ret = new T[a][][]; for (int i = 0; i < a; i++) { T[][] aRow = new T[b][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[] bRow = new T[c]; aRow[j] = bRow; for (int k = 0; k < c; k++) { bRow[k] = defaultValue; } } } return ret; } public static T[][][] JagArray3D<T>(int a, int b, int c) where T : struct { var ret = new T[a][][]; for (int i = 0; i < a; i++) { T[][] aRow = new T[b][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[] bRow = new T[c]; aRow[j] = bRow; } } return ret; } public static T[][][][] JagArray4D<T>(int a, int b, int c, int d, T defaultValue) where T : struct { var ret = new T[a][][][]; for (int i = 0; i < a; i++) { T[][][] aRow = new T[b][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][] bRow = new T[c][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[] cRow = new T[d]; bRow[k] = cRow; for (int l = 0; l < d; l++) { cRow[l] = defaultValue; } } } } return ret; } public static T[][][][] JagArray4D<T>(int a, int b, int c, int d) where T : struct { var ret = new T[a][][][]; for (int i = 0; i < a; i++) { T[][][] aRow = new T[b][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][] bRow = new T[c][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[] cRow = new T[d]; bRow[k] = cRow; } } } return ret; } public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e, T defaultValue) where T : struct { var ret = new T[a][][][][]; for (int i = 0; i < a; i++) { T[][][][] aRow = new T[b][][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][][] bRow = new T[c][][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[][] cRow = new T[d][]; bRow[k] = cRow; for (int l = 0; l < d; l++) { T[] dRow = new T[e]; cRow[l] = dRow; for (int m = 0; m < e; m++) { dRow[m] = defaultValue; } } } } } return ret; } public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e) where T : struct { var ret = new T[a][][][][]; for (int i = 0; i < a; i++) { T[][][][] aRow = new T[b][][][]; ret[i] = aRow; for (int j = 0; j < b; j++) { T[][][] bRow = new T[c][][]; aRow[j] = bRow; for (int k = 0; k < c; k++) { T[][] cRow = new T[d][]; bRow[k] = cRow; for (int l = 0; l < d; l++) { T[] dRow = new T[e]; cRow[l] = dRow; } } } } return ret; } /// <summary> /// ジャグ配列をコピーして返す。 /// </summary> public static T[][] CopyJagArray2D<T>(T[][] source) where T : struct { int len = source.Length; T[][] dest = new T[len][]; for (int i = 0; i < len; i++) { T[] inner = source[i]; int innerLength = inner.Length; T[] newer = new T[innerLength]; Array.Copy(inner, newer, innerLength); dest[i] = newer; } return dest; } } public class IntLargeComparer : IComparer<int> { public static IntLargeComparer Instance = new IntLargeComparer(); public int Compare(int x, int y) { return y - x; } } public class LongLargeComparer : IComparer<long> { public static LongLargeComparer Instance = new LongLargeComparer(); public int Compare(long x, long y) { if (x > y) return -1; if (x < y) return 1; return 0; } } public static class UtakaExtentions { /// <summary> /// 配列をコピーします /// </summary> public static T[] Copy<T>(this IList<T> a) { T[] ret = new T[a.Count]; for (int i = 0; i < a.Count; i++) ret[i] = a[i]; return ret; } } public class ConsoleInput { private readonly char _separator = ' '; private readonly TextReader _stream; private readonly Queue<string> inputStream; public ConsoleInput(TextReader stream, char separator = ' ') { _separator = separator; _stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) { return inputStream.Dequeue(); } var tmp = _stream.ReadLine().Split(_separator); for (var i = 0; i < tmp.Length; ++i) { inputStream.Enqueue(tmp[i]); } return inputStream.Dequeue(); } } public string ReadLine => _stream.ReadLine(); public int ReadInt => int.Parse(Read); public long ReadLong => long.Parse(Read); public double ReadDouble => double.Parse(Read); public 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; } } public interface IConsole { void Flush(); void Write(object obj); void Write(string str); void WriteLine(object obj); void WriteLine(string str); void WriteLine(); } public class MyConsole : IConsole { public MyConsole() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } public void Flush() { Console.Out.Flush(); } public void Write(object obj) { Write(obj.ToString()); } public void Write(string str) { Console.Write(str); } public void WriteLine(object obj) { WriteLine(obj.ToString()); } public void WriteLine(string str) { Console.WriteLine(str); } public void WriteLine() { Console.WriteLine(); } } #if UTAKA_LOCAL public class DebugConsole : IConsole { private readonly StringBuilder mSb; public DebugConsole() { mSb = new StringBuilder(); } public void Flush() { // 何もしない } public void Write(object obj) { Write(obj.ToString()); } public void Write(string str) { mSb.Append(str); } public void WriteLine(object obj) { WriteLine(obj.ToString()); } public void WriteLine(string str) { mSb.AppendLine(str); } public void WriteLine() { mSb.AppendLine(); } public string GetAllOutput() { return mSb.ToString(); } } #endif #if UTAKA_LOCAL public class TestCaseCheckerForAtCoder { private string GetDirectoryPath() { var problemPart = string.IsNullOrEmpty(Program.ProblemName) ? "" : $"/{Program.ProblemName}"; return $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/AlgorithmPrac/{Program.SiteName}/{Program.ContestName}{problemPart}"; } private string GetInputFilePath(int testCaseNumber) { return $"{GetDirectoryPath()}/sample-{testCaseNumber}.in"; } private string GetOutputFilePath(int testCaseNumber) { return $"{GetDirectoryPath()}/sample-{testCaseNumber}.out"; } public bool TestProblem(int testCaseNumber) { var inputFilePath = GetInputFilePath(testCaseNumber); var outputFilePath = GetOutputFilePath(testCaseNumber); TextReader inputStream = new StreamReader(inputFilePath); var cin = new ConsoleInput(inputStream); var debugConsoleWriter = new DebugConsole(); new Program(cin, debugConsoleWriter).Solve(); var output = debugConsoleWriter.GetAllOutput(); TextReader outputStream = new StreamReader(outputFilePath); var outputAnswer = outputStream.ReadToEnd(); Dbg.WriteLine(output); Dbg.WriteLine(outputAnswer); var isCorrect = output == outputAnswer; return isCorrect; } public void TestProblems(int targetTestCaseNumber = -1) { if (targetTestCaseNumber >= 0) { Console.WriteLine( $"!!!!!!!!!!!! Check TestCase {targetTestCaseNumber} !!!!!!!!!!"); } bool isSuccessAll = true; int testCaseNumber = 0; while (true) { testCaseNumber++; bool foundTargetTest = targetTestCaseNumber == testCaseNumber; if (targetTestCaseNumber >= 0 && !foundTargetTest) { continue; } var inputFileName = GetInputFilePath(testCaseNumber); if (!File.Exists(inputFileName)) { break; } Console.WriteLine( $"TestCase {testCaseNumber} ====================================================="); var result = TestProblem(testCaseNumber); if (result) { Console.WriteLine("Success"); } else { isSuccessAll = false; Console.WriteLine("Failure *****"); } if (foundTargetTest) { break; } } if (isSuccessAll) { Console.WriteLine("!!!!!!!!! All Success !!!!!!!!!"); } } } #endif public static class Dbg { [Conditional("UTAKA_DEBUG")] public static void WriteLine(string str) { Console.WriteLine(str); } [Conditional("UTAKA_DEBUG")] public static void WriteLine() { Console.WriteLine(); } [Conditional("UTAKA_DEBUG")] public static void Write(string str) { Console.Write(str); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22]]
8
3,316
6
using System; namespace E { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); long MOD = 1000000007; long result = 1; var colorCount = new int[3]; for (int i = 0; i < N; i++) { if (A[i] == colorCount[0] && A[i] == colorCount[1] && A[i] == colorCount[2]) { result *= 3; result %= MOD; colorCount[0]++; } else if (A[i] == colorCount[0] && A[i] == colorCount[1]) { result *= 2; result %= MOD; colorCount[0]++; } else if (A[i] == colorCount[1] && A[i] == colorCount[2]) { result *= 2; result %= MOD; colorCount[1]++; } else if (A[i] == colorCount[0]) { colorCount[0]++; } else if (A[i] == colorCount[1]) { colorCount[1]++; } else if (A[i] == colorCount[2]) { colorCount[2]++; } } Console.WriteLine(result); } } }
using System; namespace E { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); long MOD = 1000000007; long result = 1; var colorCount = new int[3]; for (int i = 0; i < N; i++) { if (A[i] == colorCount[0] && A[i] == colorCount[1] && A[i] == colorCount[2]) { result *= 3; result %= MOD; colorCount[0]++; } else if (A[i] == colorCount[0] && A[i] == colorCount[1]) { result *= 2; result %= MOD; colorCount[0]++; } else if (A[i] == colorCount[1] && A[i] == colorCount[2]) { result *= 2; result %= MOD; colorCount[1]++; } else if (A[i] == colorCount[0]) { colorCount[0]++; } else if (A[i] == colorCount[1]) { colorCount[1]++; } else if (A[i] == colorCount[2]) { colorCount[2]++; } else result = 0; } Console.WriteLine(result); } } }
[["+", 75, 57, 75, 57, 75, 57, 75, 57, 0, 95], ["+", 75, 57, 75, 57, 75, 1, 0, 11, 31, 22], ["+", 75, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 57, 75, 57, 75, 1, 0, 11, 12, 203], ["+", 75, 57, 75, 57, 75, 57, 75, 1, 0, 35]]
8
292
5
using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using E = System.Linq.Enumerable; internal partial class Solver { public void Run() { var t1 = ni(); var t2 = ni(); var a1 = nl(); var a2 = nl(); var b1 = nl(); var b2 = nl(); var c1 = (a1 - b1) * t1; var c2 = (a2 - b2) * t2; if (c1 < 0) { c1 *= -1; c2 *= -1; } // c1 >= 0 bool isInfinity = false; long ans = 0; if (c1 + c2 > 0) { ans = 0; } else if (c1 + c2 == 0) { isInfinity = true; } else { // c1 + c2 < 0 ans = -1; long down = -(c1 + c2); // new { c1, c2, down }.Dump(); ans = DivUpper(c1, down); ans = ans * 2 - 1; if (c1 % down == 0) ans++; if (ans < 0) ans = 0; } if (isInfinity) cout.WriteLine("Infinity"); else cout.WriteLine(ans); } public static long DivUpper(long x, long y) { if (y < 0) { return DivUpper(-x, -y); } if (x <= 0) { return x / y; } return x / y + (x % y == 0 ? 0 : 1); } } // PREWRITEN CODE BEGINS FROM HERE internal partial class Solver : Scanner { public static void Main(string[] args) { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver(Console.In, Console.Out).Run(); Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } internal static class LinqPadExtension { public static T Dump<T>(this T obj) { #if LOCAL return LINQPad.Extensions.Dump(obj); #else return obj; #endif } } public class Scanner { private readonly TextReader Reader; private readonly Queue<string> TokenQueue = new Queue<string>(); private readonly CultureInfo ci = CultureInfo.InvariantCulture; public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return int.Parse(Next(), ci); } public long NextLong() { return long.Parse(Next(), ci); } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (TokenQueue.Count == 0) { if (!StockTokens()) { throw new InvalidOperationException(); } } return TokenQueue.Dequeue(); } public bool HasNext() { if (TokenQueue.Count > 0) { return true; } return StockTokens(); } private static readonly char[] _separator = new[] { ' ', '\t' }; private bool StockTokens() { while (true) { string line = Reader.ReadLine(); if (line == null) { return false; } string[] tokens = line.Split(_separator, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length == 0) { continue; } foreach (string token in tokens) { TokenQueue.Enqueue(token); } return true; } } }
using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using E = System.Linq.Enumerable; internal partial class Solver { public void Run() { var t1 = ni(); var t2 = ni(); var a1 = nl(); var a2 = nl(); var b1 = nl(); var b2 = nl(); var c1 = (a1 - b1) * t1; var c2 = (a2 - b2) * t2; if (c1 < 0) { c1 *= -1; c2 *= -1; } // c1 >= 0 bool isInfinity = false; long ans = 0; if (c1 + c2 > 0) { ans = 0; } else if (c1 + c2 == 0) { isInfinity = true; } else { // c1 + c2 < 0 ans = -1; long down = -(c1 + c2); // new { c1, c2, down }.Dump(); ans = DivUpper(c1, down); ans = ans * 2 - 1; if (c1 % down == 0) ans++; if (ans < 0) ans = 0; } if (isInfinity) cout.WriteLine("infinity"); else cout.WriteLine(ans); } public static long DivUpper(long x, long y) { if (y < 0) { return DivUpper(-x, -y); } if (x <= 0) { return x / y; } return x / y + (x % y == 0 ? 0 : 1); } } // PREWRITEN CODE BEGINS FROM HERE internal partial class Solver : Scanner { public static void Main(string[] args) { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Solver(Console.In, Console.Out).Run(); Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } internal static class LinqPadExtension { public static T Dump<T>(this T obj) { #if LOCAL return LINQPad.Extensions.Dump(obj); #else return obj; #endif } } public class Scanner { private readonly TextReader Reader; private readonly Queue<string> TokenQueue = new Queue<string>(); private readonly CultureInfo ci = CultureInfo.InvariantCulture; public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return int.Parse(Next(), ci); } public long NextLong() { return long.Parse(Next(), ci); } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (TokenQueue.Count == 0) { if (!StockTokens()) { throw new InvalidOperationException(); } } return TokenQueue.Dequeue(); } public bool HasNext() { if (TokenQueue.Count > 0) { return true; } return StockTokens(); } private static readonly char[] _separator = new[] { ' ', '\t' }; private bool StockTokens() { while (true) { string line = Reader.ReadLine(); if (line == null) { return false; } string[] tokens = line.Split(_separator, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length == 0) { continue; } foreach (string token in tokens) { TokenQueue.Enqueue(token); } return true; } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
1,179
2
using System; class Program { static void Main(string[] args) { string input = Console.ReadLine(); int ans = 0; switch (input) { case "SUN": ans = 7; break; case "MON": ans = 6; break; case "THE": ans = 5; break; case "WED": ans = 4; break; case "THU": ans = 3; break; case "FRI": ans = 2; break; case "SAT": ans = 1; break; } Console.Write(ans); } }
using System; class Program { static void Main(string[] args) { string input = Console.ReadLine(); int ans = 0; switch (input) { case "SUN": ans = 7; break; case "MON": ans = 6; break; case "TUE": ans = 5; break; case "WED": ans = 4; break; case "THU": ans = 3; break; case "FRI": ans = 2; break; case "SAT": ans = 1; break; } Console.Write(ans); } }
[["-", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222]]
8
122
2
using System; using System.Collections.Generic; class Prog { static void Main(string[] args) { var a = Console.ReadLine(); var list = new List<string>(); list.Add("SUN"); list.Add("MON"); list.Add("TUE"); list.Add("WED"); list.Add("THU"); list.Add("FRI"); list.Add("SUT"); for (int i = 0; i < 7; i++) { if (list[i] == a) { Console.WriteLine(7 - i); } } } }
using System; using System.Collections.Generic; class Prog { static void Main(string[] args) { var a = Console.ReadLine(); var list = new List<string>(); list.Add("SUN"); list.Add("MON"); list.Add("TUE"); list.Add("WED"); list.Add("THU"); list.Add("FRI"); list.Add("SAT"); for (int i = 0; i < 7; i++) { if (list[i] == a) { Console.WriteLine(7 - i); } } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
145
2
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; public class Hello { public static void Main() { string read = rstr(); string[] list = new string[] { "SUN", "SAT", "FRI", "THU", "WED", "TUE", "MON" }; for (int i = 0; i < 7; i++) { if (read == list[i]) { WriteLine(i); break; } } } //各種読取 static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static int[,] inta2(int num_array, int in_array) { int[,] int_array2 = new int[num_array, in_array]; for (int i = 0; i < num_array; i++) { int[] temp_array = inta(); for (int j = 0; j < in_array; j++) { int_array2[i, j] = temp_array[j]; } } return int_array2; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; } // A/B小数点以下切上 static long divideup(long divided, long divid) { long temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } } //知見 // (string) hogestr -> (char[]) hoge // char hoge = hogestr.ToCharArray(); // (char[]) hoge -> (string) hogestr // string hoge = new string(hoge); // Hashtable × Dictionary ○ // Dictionary hoge<string,int> // hoge.ContainsKey(string) -> return boolean // hoge[string] -> return int // hoge[int] -> CE // Dictionary hoge<int1,int2> // hoge<int1,int2>: hoge[int1] -> return int2 // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2 // SortedDictionary() > SortedList() ??? // キュー -> 幅優先 ??? // スタック -> 深さ優先 ???
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; public class Hello { public static void Main() { string read = rstr(); string[] list = new string[] { "", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN" }; for (int i = 0; i < 8; i++) { if (read == list[i]) { WriteLine(i); break; } } } //各種読取 static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static int[,] inta2(int num_array, int in_array) { int[,] int_array2 = new int[num_array, in_array]; for (int i = 0; i < num_array; i++) { int[] temp_array = inta(); for (int j = 0; j < in_array; j++) { int_array2[i, j] = temp_array[j]; } } return int_array2; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; } // A/B小数点以下切上 static long divideup(long divided, long divid) { long temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } } //知見 // (string) hogestr -> (char[]) hoge // char hoge = hogestr.ToCharArray(); // (char[]) hoge -> (string) hogestr // string hoge = new string(hoge); // Hashtable × Dictionary ○ // Dictionary hoge<string,int> // hoge.ContainsKey(string) -> return boolean // hoge[string] -> return int // hoge[int] -> CE // Dictionary hoge<int1,int2> // hoge<int1,int2>: hoge[int1] -> return int2 // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2 // SortedDictionary() > SortedList() ??? // キュー -> 幅優先 ??? // スタック -> 深さ優先 ???
[["-", 0, 212, 0, 227, 0, 229, 0, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 227, 0, 229, 0, 21], ["+", 0, 212, 0, 227, 0, 229, 0, 5, 0, 62], ["+", 0, 212, 0, 227, 0, 229, 0, 5, 0, 222], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
8
648
7
using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { string[] weekdays = { "SUN", "SAT", "FRI", "THU", "WED", "TUE", "MON" }; string s = Console.ReadLine(); for (int i = 0; i < weekdays.Length; i++) { if (weekdays[i] == s) { Console.WriteLine(i.ToString()); } } Console.ReadLine(); } } }
using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { string[] weekdays = { "", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN" }; string s = Console.ReadLine(); for (int i = 0; i < weekdays.Length; i++) { if (weekdays[i] == s) { Console.WriteLine(i.ToString()); } } Console.ReadLine(); } } }
[["-", 0, 200, 0, 212, 0, 229, 0, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 229, 0, 5, 0, 62], ["+", 0, 198, 0, 200, 0, 212, 0, 229, 0, 21], ["+", 0, 200, 0, 212, 0, 229, 0, 5, 0, 222]]
8
112
5
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProCon { class Program { static void Main(string[] args) { string inStr = args[0]; string ret = string.Empty; switch (inStr) { case "SUN": ret = "7"; break; case "MON": ret = "6"; break; case "TUE": ret = "5"; break; case "WED": ret = "4"; break; case "THU": ret = "3"; break; case "FRI": ret = "2"; break; case "SAT": ret = "1"; break; } Console.WriteLine(ret); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProCon { class Program { static void Main(string[] args) { string inStr = Console.ReadLine(); string ret = string.Empty; switch (inStr) { case "SUN": ret = "7"; break; case "MON": ret = "6"; break; case "TUE": ret = "5"; break; case "WED": ret = "4"; break; case "THU": ret = "3"; break; case "FRI": ret = "2"; break; case "SAT": ret = "1"; break; } Console.WriteLine(ret); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 0, 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
165
9
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // https://atcoder.jp/contests/abc141/tasks/abc141_a public class QuestionA { public static void Main(string[] args) { // 文字列の入力 string s = Console.ReadLine(); List<string> days = new List<string> { "SAT", "FRI", "THU", "WEB", "TUE", "MON", "SUN" }; var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Console.WriteLine(days.IndexOf(s) + 1); Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Abc { // https://atcoder.jp/contests/abc141/tasks/abc141_a public class QuestionA { public static void Main(string[] args) { // 文字列の入力 string s = Console.ReadLine(); List<string> days = new List<string> { "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN" }; var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Console.WriteLine(days.IndexOf(s) + 1); Console.Out.Flush(); } } }
[["-", 0, 212, 0, 230, 10, 229, 0, 5, 0, 222], ["+", 0, 212, 0, 230, 10, 229, 0, 5, 0, 222]]
8
153
2
using System; using System.Linq; using System.Collections.Generic; namespace A { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var ans = 0; if (s == "SUN") ans = 0; else if (s == "MON") ans = 6; else if (s == "TUE") ans = 5; else if (s == "WED") ans = 4; else if (s == "THU") ans = 3; else if (s == "FRI") ans = 2; else if (s == "SAT") ans = 1; Console.WriteLine(ans); } } }
using System; using System.Linq; using System.Collections.Generic; namespace A { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var ans = 0; if (s == "SUN") ans = 7; else if (s == "MON") ans = 6; else if (s == "TUE") ans = 5; else if (s == "WED") ans = 4; else if (s == "THU") ans = 3; else if (s == "FRI") ans = 2; else if (s == "SAT") ans = 1; Console.WriteLine(ans); } } }
[["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203]]
8
145
2
using System; public class WaitingHoliday { public static void Main(string[] argc) { string input = Console.ReadLine(); int remainDays = HowManyDaysToNextHoliday(input); Console.WriteLine(remainDays); } public static int HowManyDaysToNextHoliday(string inputStr) { switch (inputStr) { case "SUN": return 7; break; case "MON": return 6; break; case "TUE": return 5; break; case "WED": return 4; break; case "THU": return 3; break; case "FRI": return 2; break; case "SUT": return 1; break; default: return 0; } } }
using System; public class WaitingHoliday { public static void Main(string[] argc) { string input = Console.ReadLine(); int remainDays = HowManyDaysToNextHoliday(input); Console.WriteLine(remainDays); } public static int HowManyDaysToNextHoliday(string inputStr) { switch (inputStr) { case "SUN": return 7; break; case "MON": return 6; break; case "TUE": return 5; break; case "WED": return 4; break; case "THU": return 3; break; case "FRI": return 2; break; case "SAT": return 1; break; default: return 0; } } }
[["-", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222]]
8
135
2
using System; using System.Text; class AtCoder { static void Main() { string s = Console.ReadLine(); int cnt = 0; if (s == "SUN") { Console.WriteLine("7"); } else if (s == "MON") { Console.WriteLine("6"); } else if (s == "TUE") { Console.WriteLine("5"); } else if (s == "WED") { Console.WriteLine("4"); } else if (s == "THU") { Console.WriteLine("3"); } else if (s == "FIR") { Console.WriteLine("2"); } else if (s == "SAT") { Console.WriteLine("1"); } } }
using System; using System.Text; class AtCoder { static void Main() { string s = Console.ReadLine(); int cnt = 0; if (s == "SUN") { Console.WriteLine("7"); } else if (s == "MON") { Console.WriteLine("6"); } else if (s == "TUE") { Console.WriteLine("5"); } else if (s == "WED") { Console.WriteLine("4"); } else if (s == "THU") { Console.WriteLine("3"); } else if (s == "FRI") { Console.WriteLine("2"); } else if (s == "SAT") { Console.WriteLine("1"); } } }
[["-", 75, 57, 75, 57, 15, 16, 12, 5, 0, 222], ["+", 75, 57, 75, 57, 15, 16, 12, 5, 0, 222]]
8
172
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { //入力 string youbi; youbi = Console.ReadLine(); //計算 string cntDay = ""; switch (youbi) { case "SUN": cntDay = "7"; break; case "MON": cntDay = "6"; break; case "TUE": cntDay = "5"; break; case "WED": cntDay = "4"; break; case "THU": cntDay = "3"; break; case "FRI": cntDay = "2"; break; case "STA": cntDay = "1"; break; default: break; } //出力 Console.WriteLine(cntDay); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { //入力 string youbi; youbi = Console.ReadLine(); //計算 string cntDay = ""; switch (youbi) { case "SUN": cntDay = "7"; break; case "MON": cntDay = "6"; break; case "TUE": cntDay = "5"; break; case "WED": cntDay = "4"; break; case "THU": cntDay = "3"; break; case "FRI": cntDay = "2"; break; case "SAT": cntDay = "1"; break; default: break; } //出力 Console.WriteLine(cntDay); } } }
[["-", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222]]
8
174
2
using System; using System.Collections.Generic; namespace practice_csharp { class Program { private static Dictionary<string, int> Day = new Dictionary<string, int>() { { "SUN", 0 }, { "SAT", 1 }, { "FRI", 2 }, { "THU", 3 }, { "WED", 4 }, { "TUE", 5 }, { "MON", 6 } }; static void Main(string[] args) { var after = Day[Console.ReadLine()]; Console.WriteLine(after); } } }
using System; using System.Collections.Generic; namespace practice_csharp { class Program { private static Dictionary<string, int> Day = new Dictionary<string, int>() { { "SUN", 7 }, { "SAT", 1 }, { "FRI", 2 }, { "THU", 3 }, { "WED", 4 }, { "TUE", 5 }, { "MON", 6 } }; static void Main(string[] args) { var after = Day[Console.ReadLine()]; Console.WriteLine(after); } } }
[["-", 0, 212, 0, 230, 10, 229, 0, 229, 0, 203], ["+", 0, 212, 0, 230, 10, 229, 0, 229, 0, 203]]
8
125
2
using System; namespace AtCoder { class Program { static void Main(string[] args) { string str = Console.ReadLine(); int ans = 0; if (str == "SUN") ans = 7; else if (str == "MON") ans = 6; else if (str == "THE") ans = 5; else if (str == "WED") ans = 4; else if (str == "THU") ans = 3; else if (str == "FRI") ans = 2; else ans = 1; Console.WriteLine(ans); } } } /* long a, b, c; a = long.Parse(Console.ReadLine()); //標準入力 string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得 b = long.Parse(str[0]); //数値で受け取りたい場合は変換する c = long.Parse(str[1]); string S = Console.ReadLine(); char[] C = new char[N]; C = S.ToCharArray(); Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力 Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力 Member = ReadLine().Split(' ').Select(long.Parse).ToArray(); string[] str = Console.ReadLine().Split(' '); long[] a = new long[N]; for(long i = 0; i < N; i++) a[i] = long.Parse(str[i]); */
using System; namespace AtCoder { class Program { static void Main(string[] args) { string str = Console.ReadLine(); int ans = 0; if (str == "SUN") ans = 7; else if (str == "MON") ans = 6; else if (str == "TUE") ans = 5; else if (str == "WED") ans = 4; else if (str == "THU") ans = 3; else if (str == "FRI") ans = 2; else ans = 1; Console.WriteLine(ans); } } } /* long a, b, c; a = long.Parse(Console.ReadLine()); //標準入力 string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得 b = long.Parse(str[0]); //数値で受け取りたい場合は変換する c = long.Parse(str[1]); string S = Console.ReadLine(); char[] C = new char[N]; C = S.ToCharArray(); Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力 Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力 Member = ReadLine().Split(' ').Select(long.Parse).ToArray(); string[] str = Console.ReadLine().Split(' '); long[] a = new long[N]; for(long i = 0; i < N; i++) a[i] = long.Parse(str[i]); */
[["-", 75, 57, 75, 57, 15, 16, 12, 5, 0, 222], ["+", 75, 57, 75, 57, 15, 16, 12, 5, 0, 222]]
8
126
2
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; namespace MyProject { class Program { static void Main(string[] args) { #if Local var sw = new Stopwatch(); sw.Start(); Console.SetIn(new StreamReader("input.in")); #endif var solver = new Solver(); solver.Solve(); #if Local Console.WriteLine($"{sw.ElapsedMilliseconds}ms"); #endif } } class Solver { public void Solve() { var table = new Dictionary<string, int>() { { "SUN", 7 }, { "MON", 6 }, { "TUE", 5 }, { "WEB", 4 }, { "THU", 3 }, { "FRI", 2 }, { "SAT", 1 }, }; var S = Console.ReadLine(); var answer = table[S]; Console.WriteLine(answer); } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; namespace MyProject { class Program { static void Main(string[] args) { #if Local var sw = new Stopwatch(); sw.Start(); Console.SetIn(new StreamReader("input.in")); #endif var solver = new Solver(); solver.Solve(); #if Local Console.WriteLine($"{sw.ElapsedMilliseconds}ms"); #endif } } class Solver { public void Solve() { var table = new Dictionary<string, int>() { { "SUN", 7 }, { "MON", 6 }, { "TUE", 5 }, { "WED", 4 }, { "THU", 3 }, { "FRI", 2 }, { "SAT", 1 }, }; var S = Console.ReadLine(); var answer = table[S]; Console.WriteLine(answer); } } }
[["-", 0, 230, 10, 229, 0, 229, 0, 5, 0, 222], ["+", 0, 230, 10, 229, 0, 229, 0, 5, 0, 222]]
8
215
2
using System; using System.Collections.Generic; using System.Linq; public class Solution { public static void Main() { var s = Console.ReadLine(); int result = 0; switch (s) { case "SUN": result = 7; break; case "MON": result = 6; break; case "TUE": result = 7; break; case "WED": result = 8; break; case "THU": result = 3; break; case "FRI": result = 2; break; case "SAT": result = 1; break; } Console.WriteLine(result); } }
using System; using System.Collections.Generic; using System.Linq; public class Solution { public static void Main() { var s = Console.ReadLine(); int result = 0; switch (s) { case "SUN": result = 7; break; case "MON": result = 6; break; case "TUE": result = 5; break; case "WED": result = 4; break; case "THU": result = 3; break; case "FRI": result = 2; break; case "SAT": result = 1; break; } Console.WriteLine(result); } }
[["-", 8, 254, 0, 239, 0, 1, 0, 11, 12, 203], ["+", 8, 254, 0, 239, 0, 1, 0, 11, 12, 203]]
8
132
4
using System; class P { static void Main() { var s = Console.ReadLine(); if (s == "MON") Console.WriteLine("1"); if (s == "TUE") Console.WriteLine("2"); if (s == "WED") Console.WriteLine("3"); if (s == "THU") Console.WriteLine("4"); if (s == "FRI") Console.WriteLine("5"); if (s == "SAT") Console.WriteLine("6"); if (s == "SUN") Console.WriteLine("7"); } }
using System; class P { static void Main() { var s = Console.ReadLine(); if (s == "MON") Console.WriteLine("6"); if (s == "TUE") Console.WriteLine("5"); if (s == "WED") Console.WriteLine("4"); if (s == "THU") Console.WriteLine("3"); if (s == "FRI") Console.WriteLine("2"); if (s == "SAT") Console.WriteLine("1"); if (s == "SUN") Console.WriteLine("7"); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
142
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0028 { class Program { static void Main(string[] args) { char N = char.Parse(Console.ReadLine()); string S = Console.ReadLine(); string result = ""; for (int i = 0; i < S.Length; i++) { char c = char.Parse(S.Substring(i, 1)); c += N; if ('Z' < c) { c = (char)('A' + (c - 'Z' - 1)); } result += c.ToString(); } Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0028 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string S = Console.ReadLine(); string result = ""; for (int i = 0; i < S.Length; i++) { char c = char.Parse(S.Substring(i, 1)); c += (char)N; if ('Z' < c) { c = (char)('A' + (c - 'Z' - 1)); } result += c.ToString(); } Console.WriteLine(result); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 0, 24], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25]]
8
160
7
//どうかACをお恵みくださいお願いしますお願いしますお願います何もしませんから using System; namespace AtCoder { class Program { static void Main() { int N = int.Parse(Console.ReadLine()); string S = Console.ReadLine(); int n = S.Length; int[] s = new int[n]; for (int x = 0; x < n; x++) { s[x] = ((int)S[x] + N - 64) % 26 + 64; if (s[x] == 0) { s[x] = 26; } Console.Write((char)s[x]); } } } }
//どうかACをお恵みくださいお願いしますお願いしますお願います何もしませんから using System; namespace AtCoder { class Program { static void Main() { int N = int.Parse(Console.ReadLine()); string S = Console.ReadLine(); int n = S.Length; int[] s = new int[n]; for (int x = 0; x < n; x++) { s[x] = ((int)S[x] + N - 64) % 26 + 64; if (s[x] == 64) { s[x] = 90; } Console.Write((char)s[x]); } } } }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
8
130
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp11 { class Program { static void Main(string[] args) { int N = Convert.ToInt32(Console.ReadLine()); string S = Console.ReadLine(); char[] A = new char[S.Length]; int num; string ans = ""; for (int i = 0; i < S.Count(); i++) { num = S[i] + N; if (num > 90) { num -= 25; } A[i] = (char)num; ans += A[i]; } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp11 { class Program { static void Main(string[] args) { int N = Convert.ToInt32(Console.ReadLine()); string S = Console.ReadLine(); char[] A = new char[S.Length]; int num; string ans = ""; for (int i = 0; i < S.Count(); i++) { num = S[i] + N; if (num > 90) { num -= 26; } A[i] = (char)num; ans += A[i]; } Console.WriteLine(ans); } } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
8
156
2
using System; using System.Linq; namespace Sample { class Sample { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string S = Console.ReadLine(); char[] Schar = S.ToCharArray(); for (int i = 0; i < Schar.Length; i++) { int Sint = (int)Schar[i]; Sint += N; if (Sint > 90) { Sint -= 25; } Console.Write((char)Sint); } Console.Write("\n"); } } }
using System; using System.Linq; namespace Sample { class Sample { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string S = Console.ReadLine(); char[] Schar = S.ToCharArray(); for (int i = 0; i < Schar.Length; i++) { int Sint = (int)Schar[i]; Sint += N; if (Sint > 90) { Sint -= 26; } Console.Write((char)Sint); } Console.Write("\n"); } } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
8
125
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp6 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string S = Console.ReadLine(); char[] X = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; int l = S.Length; string ans = ""; for (int i = 0; i < l; i++) { int index = S.IndexOf(S[i]); ans += X[(index + N) % 26]; } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp6 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string S = Console.ReadLine(); char[] X = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; int l = S.Length; string ans = ""; for (int i = 0; i < l; i++) { int index = Array.IndexOf(X, S[i]); // Console.WriteLine(index + N); ans += X[(index + N) % 26]; } Console.WriteLine(ans); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21]]
8
242
4
//曜日判定 using System; namespace tst { class Program { public static void Main() { //アルファベット配列//alphas[0]="A" string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string[] alphas = new string[26]; for (int i = 0; i < 26; i++) { alphas[i] = alpha.Substring(i, 1); } // int読み込み int n = int.Parse(Console.ReadLine()); // string読み込み string text = Console.ReadLine(); string[] words = new string[1000]; for (int i = 0; i < text.Length; i++) { //読み込んだもの配列 words[i] = text.Substring(i, 1); //比較 for (int j = 0; j < 26; j++) { if (words[i] == alphas[j]) { int next = j + n; if (next >= 26) { // Zを超えるときはAに戻す next -= 26; } words[i] = alphas[next]; break; } } Console.Write(words[i]); } } } }
//曜日判定 using System; namespace tst { class Program { public static void Main() { //アルファベット配列//alphas[0]="A" string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string[] alphas = new string[26]; for (int i = 0; i < 26; i++) { alphas[i] = alpha.Substring(i, 1); } // int読み込み int n = int.Parse(Console.ReadLine()); // string読み込み string text = Console.ReadLine(); string[] words = new string[10000]; for (int i = 0; i < text.Length; i++) { //読み込んだもの配列 words[i] = text.Substring(i, 1); //比較 for (int j = 0; j < 26; j++) { if (words[i] == alphas[j]) { int next = j + n; if (next >= 26) { // Zを超えるときはAに戻す next -= 26; } words[i] = alphas[next]; break; } } Console.Write(words[i]); } } } }
[["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203]]
8
211
2
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine(); Dictionary<string, int> dicDay = new Dictionary<string, int>(); dicDay.Add("A", 0); dicDay.Add("B", 1); dicDay.Add("C", 2); dicDay.Add("D", 3); dicDay.Add("E", 4); dicDay.Add("F", 5); dicDay.Add("G", 6); dicDay.Add("H", 7); dicDay.Add("I", 8); dicDay.Add("J", 9); dicDay.Add("K", 10); dicDay.Add("L", 11); dicDay.Add("M", 12); dicDay.Add("N", 13); dicDay.Add("O", 14); dicDay.Add("P", 15); dicDay.Add("Q", 16); dicDay.Add("R", 17); dicDay.Add("S", 18); dicDay.Add("T", 19); dicDay.Add("U", 20); dicDay.Add("V", 21); dicDay.Add("W", 22); dicDay.Add("X", 23); dicDay.Add("Y", 24); dicDay.Add("Z", 25); var ret = string.Empty; foreach (var c in s) { var a = n + dicDay[c.ToString()]; var b = dicDay.First(p => p.Value == a).Key; ret = string.Format("{0}{1}", ret, b); } Console.WriteLine(ret); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine(); Dictionary<string, int> dicDay = new Dictionary<string, int>(); dicDay.Add("A", 0); dicDay.Add("B", 1); dicDay.Add("C", 2); dicDay.Add("D", 3); dicDay.Add("E", 4); dicDay.Add("F", 5); dicDay.Add("G", 6); dicDay.Add("H", 7); dicDay.Add("I", 8); dicDay.Add("J", 9); dicDay.Add("K", 10); dicDay.Add("L", 11); dicDay.Add("M", 12); dicDay.Add("N", 13); dicDay.Add("O", 14); dicDay.Add("P", 15); dicDay.Add("Q", 16); dicDay.Add("R", 17); dicDay.Add("S", 18); dicDay.Add("T", 19); dicDay.Add("U", 20); dicDay.Add("V", 21); dicDay.Add("W", 22); dicDay.Add("X", 23); dicDay.Add("Y", 24); dicDay.Add("Z", 25); var ret = string.Empty; foreach (var c in s) { var a = (n + dicDay[c.ToString()]) % 26; var b = dicDay.First(p => p.Value == a).Key; ret = string.Format("{0}{1}", ret, b); } Console.WriteLine(ret); } }
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
8
427
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSharp_practice { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string s = Console.ReadLine(); for (int i = 0; i < s.Length; i++) { int x = s[i] - 'A'; x = (x + n) % 26; Console.Write('A' + x); } Console.WriteLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSharp_practice { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string s = Console.ReadLine(); for (int i = 0; i < s.Length; i++) { int x = s[i] - 'A'; x = (x + n) % 26; Console.Write((char)('A' + x)); } Console.WriteLine(); } } }
[["+", 0, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["+", 3, 4, 0, 28, 0, 74, 51, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 74, 51, 23, 0, 25]]
8
126
5
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; using static Atcoder.IO; 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 { static long N; static List<(long h, long s)> lis = new List<(long h, long s)>(); public static void Answer() { var x = IO.RSInt; long ans = 0; foreach (var item in x) { if (item == 1) ans += 300000; else if (item == 2) ans += 200000; else if (item == 1) ans += 100000; } if (x.Where(a => a == 1).Count() == 2) ans += 400000; WriteLine(ans); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; using static Atcoder.IO; 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 { static long N; static List<(long h, long s)> lis = new List<(long h, long s)>(); public static void Answer() { var x = IO.RSInt; long ans = 0; foreach (var item in x) { if (item == 1) ans += 300000; else if (item == 2) ans += 200000; else if (item == 3) ans += 100000; } if (x.Where(a => a == 1).Count() == 2) ans += 400000; WriteLine(ans); } } public class IO { #region Input public static int RInt => int.Parse(ReadLine()); public static long RLong => long.Parse(ReadLine()); public static double RDouble => double.Parse(ReadLine()); public static string[] RSString => ReadLine().Split(); public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray(); public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray(); public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO"); #endregion } public class Mod { #region private readonly static long M = 1000000007; public static long Add(long a, long b) => (a * b) % M; public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; public static long Multi(long a, long b) => (a * b) % M; #endregion } }
[["-", 0, 57, 75, 57, 75, 57, 15, 16, 12, 203], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 12, 203]]
8
588
2
using System; namespace ddcc2020 { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int t = 0; if (int.Parse(s[0]) == 1 && int.Parse(s[0]) == 1) { t = 400000; } Console.WriteLine(t + Func(int.Parse(s[0])) + Func(int.Parse(s[1]))); } static int Func(int s) { if (s == 1) { return 300000; } if (s == 2) { return 200000; } if (s == 3) { return 100000; } return 0; } } }
using System; namespace ddcc2020 { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int t = 0; if (int.Parse(s[0]) == 1 && int.Parse(s[1]) == 1) { t = 400000; } Console.WriteLine(t + Func(int.Parse(s[0])) + Func(int.Parse(s[1]))); } static int Func(int s) { if (s == 1) { return 300000; } if (s == 2) { return 200000; } if (s == 3) { return 100000; } return 0; } } }
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
8
155
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得 int b = int.Parse(str[0]); //数値で受け取りたい場合は変換する int c = int.Parse(str[1]); int goukei = 0; if (b <= 3) { goukei += 100000 * (4 - b); } if (c <= 3) { goukei += 100000 * (4 - b); } if (b == 1 && c == 1) { goukei += 400000; } Console.WriteLine(goukei); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得 int b = int.Parse(str[0]); //数値で受け取りたい場合は変換する int c = int.Parse(str[1]); int goukei = 0; if (b <= 3) { goukei += 100000 * (4 - b); } if (c <= 3) { goukei += 100000 * (4 - c); } if (b == 1 && c == 1) { goukei += 400000; } Console.WriteLine(goukei); } } }
[["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22]]
8
156
2
using System; using System.Collections.Generic; using System.Linq; namespace AC { class Program { static void Main(string[] args) { var input = ReadArrayInt(); var X = input[0]; var Y = input[1]; var ans = 0; if (X == 1 && Y == 1) { ans = 1000000; } else { ans += X == 3 ? 100000 : X == 2 ? 200000 : X == 1 ? 300000 : 0; ans += Y == 3 ? 100000 : X == 2 ? 200000 : X == 1 ? 300000 : 0; } Console.WriteLine(ans); Console.ReadKey(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AC { class Program { static void Main(string[] args) { var input = ReadArrayInt(); var X = input[0]; var Y = input[1]; var ans = 0; if (X == 1 && Y == 1) { ans = 1000000; } else { ans += X == 3 ? 100000 : X == 2 ? 200000 : X == 1 ? 300000 : 0; ans += Y == 3 ? 100000 : Y == 2 ? 200000 : Y == 1 ? 300000 : 0; } Console.WriteLine(ans); Console.ReadKey(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
[["-", 0, 11, 12, 41, 75, 41, 15, 16, 31, 22], ["+", 0, 11, 12, 41, 75, 41, 15, 16, 31, 22], ["-", 12, 41, 75, 41, 75, 41, 15, 16, 31, 22], ["+", 12, 41, 75, 41, 75, 41, 15, 16, 31, 22]]
8
260
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.DDCC2019_qual { class D { static void Main(string[] args) { var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false }; SetOut(sw); Method(args); Out.Flush(); } static void Method(string[] args) { long m = ReadInt(); int[] ds = new int[m]; long[] cs = new long[m]; long digits = 0; long sum = 0; for (int i = 0; i < m; i++) { long[] dc = ReadLongs(); ds[i] = (int)dc[0]; cs[i] = dc[1]; digits += cs[i]; sum = cs[i] * ds[i]; } long res = digits - 1; long ups = sum / 9; if (sum % 9 == 0) ups--; res += ups; WriteLine(res); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.DDCC2019_qual { class D { static void Main(string[] args) { var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false }; SetOut(sw); Method(args); Out.Flush(); } static void Method(string[] args) { long m = ReadInt(); int[] ds = new int[m]; long[] cs = new long[m]; long digits = 0; long sum = 0; for (int i = 0; i < m; i++) { long[] dc = ReadLongs(); ds[i] = (int)dc[0]; cs[i] = dc[1]; digits += cs[i]; sum += cs[i] * ds[i]; } long res = digits - 1; long ups = sum / 9; if (sum % 9 == 0) ups--; res += ups; WriteLine(res); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
[["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107]]
8
422
2
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace AtCoder { struct mint : IEquatable<mint> { // static uint mod = 998244353; static uint mod = 1000000007; uint _v; public mint(long v) : this((uint)(v % mod + mod)) {} private mint(uint v) { _v = v < mod ? v : (v - mod); } public static void SetMod(uint p) { mod = p; } public static mint operator +(mint lhs, mint rhs) { return new mint(lhs._v + rhs._v); } public static mint operator -(mint lhs, mint rhs) { return new mint(lhs._v + mod - rhs._v); } public static mint operator *(mint lhs, mint rhs) { return new mint((uint)((ulong)lhs._v * rhs._v % mod)); } public static mint operator /(mint lhs, mint rhs) { return lhs * rhs.Inv(); } public static mint operator ^(mint x, int n) { return Pow(x, n); } public static bool operator ==(mint l, mint r) { return l._v == r._v; } public static bool operator !=(mint l, mint r) { return !(l == r); } public static bool operator<(mint l, mint r) { return l._v < r._v; } public static bool operator>(mint l, mint r) { return l._v > r._v; } public static mint Pow(mint x, int n) { var r = new mint(1); while (n > 0) { if ((n & 1) > 0) r *= x; x *= x; n >>= 1; } return r; } public mint Pow(int n) { return Pow(this, n); } public mint Inv() { return Pow((int)mod - 2); } public bool Equals(mint o) { return this == o; } public override bool Equals(object obj) { if (obj is mint) return this == (mint)obj; else return false; } public override int GetHashCode() { return _v.GetHashCode(); } public override string ToString() { return _v.ToString(); } public static implicit operator mint(int i) { return new mint(i); } public static implicit operator mint(long i) { return new mint(i); } private static mint[] _fact; public static void SetFact(int n) { _fact = new mint[n + 1]; _fact[0] = 1; for (int i = 1; i < n + 1; i++) { _fact[i] = _fact[i - 1] * i; } } public static mint Fact(int n) { if (_fact == null || _fact.Length < n) { SetFact(n * 2); } return _fact[n]; } public static mint Combination(int n, int r) { return Fact(n) / (Fact(n - r) * Fact(r)); } } static class Extensions { public static int LowerBound<T>(this IList<T> list, T value, IComparer<T> comp = null) { if (comp == null) comp = Comparer<T>.Default; var l = 0; var r = list.Count; while (l < r) { var m = (l + r) / 2; var c = comp.Compare(value, list[m]); if (c > 0) l = m + 1; else r = m; } return l; } public static int UpperBound<T>(this IList<T> list, T value, IComparer<T> comp = null) { if (comp == null) comp = Comparer<T>.Default; var l = 0; var r = list.Count; while (l < r) { var m = (l + r) / 2; var c = comp.Compare(value, list[m]); if (c >= 0) l = m + 1; else r = m; } return r; } } class Program { static int ReadInt() { return int.Parse(Console.ReadLine()); } static long ReadLong() { return long.Parse(Console.ReadLine()); } static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static int[] ReadIntArray(int n) { var a = new int[n]; for (int i = 0; i < n; i++) { a[i] = ReadInt(); } return a; } static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } static long[] ReadLongArray(int n) { var a = new long[n]; for (int i = 0; i < n; i++) { a[i] = ReadLong(); } return a; } static List<T> ReadObjects<T>(int n, Func<int[], T> creator) { var l = new List<T>(n); for (int i = 0; i < n; i++) { var a = ReadIntArray(); l.Add(creator(a)); } return l; } static int[,] ReadMatrix(int n, int m) { var r = new int[n, m]; for (int i = 0; i < n; i++) { var a = ReadIntArray(); for (int j = 0; j < m; j++) { r[i, j] = a[j]; } } return r; } public static int[] ZAlgotithm(string s) { var len = s.Length; var a = new int[len]; a[0] = len; var i = 1; var j = 0; while (i < len) { while (i + j < len && s[j] == s[i + j]) j++; a[i] = j; if (j == 0) { i++; continue; } var k = 1; while (i + k < len && k + a[k] < j) { a[i + k] = a[k]; k++; } i += k; j -= k; } return a; } public class MaxHeap<T> : IEnumerable<T> { private List<T> _list; private Comparer<T> _comp; public int Count { get { return _list.Count; } } public MaxHeap() : this(0) {} public MaxHeap(int capacity, Comparison<T> comp = null) { _list = new List<T>(capacity); if (comp == null) { _comp = Comparer<T>.Default; } else { _comp = Comparer<T>.Create(comp); } } public void Push(T elem) { Upheap(elem); } public T Pop() { return Downheap(); } public T Peek() { return _list[0]; } private void Swap(int i, int j) { var a = _list[j]; _list[j] = _list[i]; _list[i] = a; } private void Upheap(T elem) { _list.Add(elem); var i = _list.Count - 1; while (true) { if (i == 0) return; var j = (i - 1) / 2; var e = _list[i]; var p = _list[j]; var c = _comp.Compare(e, p); if (c > 0) { Swap(i, j); i = j; continue; } else { break; } } } private T Downheap() { var result = _list[0]; var last = _list.Count - 1; Swap(0, last); _list.RemoveAt(last); if (_list.Count == 0) return result; var i = 0; while (true) { if (i == _list.Count - 1) return result; var p = _list[i]; var j = i * 2 + 1; if (j >= _list.Count) return result; if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) < 0) { j++; } if (_comp.Compare(_list[i], _list[j]) < 0) { Swap(i, j); i = j; } else { return result; } } } public MaxHeap<T> Copy(Comparison<T> comp = null) { var c = new MaxHeap<T>(0, comp); c._list = _list.ToList(); return c; } public MaxHeap(List<T> list) { _list = list; _comp = Comparer<T>.Default; } public List<T> GetList() { return _list; } public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } public class MinHeap<T> : IEnumerable<T> { private List<T> _list; private Comparer<T> _comp; public int Count { get { return _list.Count; } } public MinHeap() : this(0) {} public MinHeap(int capacity, Comparison<T> comp = null) { _list = new List<T>(capacity); if (comp == null) { _comp = Comparer<T>.Default; } else { _comp = Comparer<T>.Create(comp); } } public void Push(T elem) { Upheap(elem); } public T Pop() { return Downheap(); } public T Peek() { return _list[0]; } private void Swap(int i, int j) { var a = _list[j]; _list[j] = _list[i]; _list[i] = a; } private void Upheap(T elem) { _list.Add(elem); var i = _list.Count - 1; while (true) { if (i == 0) return; var j = (i - 1) / 2; var e = _list[i]; var p = _list[j]; var c = _comp.Compare(e, p); if (c < 0) { Swap(i, j); i = j; continue; } else { break; } } } private T Downheap() { var result = _list[0]; var last = _list.Count - 1; Swap(0, last); _list.RemoveAt(last); if (_list.Count == 0) return result; var i = 0; while (true) { if (i == _list.Count - 1) return result; var p = _list[i]; var j = i * 2 + 1; if (j >= _list.Count) return result; if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) > 0) { j++; } if (_comp.Compare(_list[i], _list[j]) > 0) { Swap(i, j); i = j; } else { return result; } } } public MinHeap<T> Copy(Comparison<T> comp = null) { var c = new MinHeap<T>(0, comp); c._list = _list.ToList(); return c; } public MinHeap(List<T> list) { _list = list; _comp = Comparer<T>.Default; } public List<T> GetList() { return _list; } public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } class InputLine { private string[] _inputs; private int _index = 0; InputLine(string input) { _inputs = input.Split(); _index = 0; } public static InputLine Read() { return new InputLine(Console.ReadLine()); } public int NextInt() { return int.Parse(_inputs[_index++]); } public long NextLong() { return long.Parse(_inputs[_index++]); } public double NextDouble() { return double.Parse(_inputs[_index++]); } } public static int GCD(int x, int y) { var a = Math.Max(x, y); var b = x + y - a; while (b != 0) { var c = b; b = a % b; a = c; } return a; } public static long GCD(long x, long y) { var a = Math.Max(x, y); var b = x + y - a; while (b != 0) { var c = b; b = a % b; a = c; } return a; } static long ModPower(long x, long y, long mod) { var bytes = BitConverter.GetBytes(y); var bits = new System.Collections.BitArray(bytes); var max2 = 0; for (int i = bits.Length - 1; i >= 0; i--) { if (bits[i]) { max2 = i; break; } } long result = 1; for (int i = max2; i >= 0; i--) { result = (result * result) % mod; if (bits[i]) { result = (result * x) % mod; } } return result; } static long ModFact(long n, long mod) { long result = 1; for (int i = 1; i <= n; i++) { result = result * i % mod; } return result; } static long ModAdd(long x, long y, long mod) { return ((x % mod) + (y % mod)) % mod; } static long ModMul(long x, long y, long mod) { return ((x % mod) * (y % mod)) % mod; } static long ModDiv(long x, long y, long mod) { //フェルマーの小定理より、a^(-1) = a^(p-2) return ModMul(x, ModPower(y, mod - 2, mod), mod); } static long ModComb(long n, long r, long mod) { long numerator = 1; for (int i = 0; i < r; i++) { numerator = ModMul(numerator, n - i, mod); } long denominator = ModFact(r, mod); return ModDiv(numerator, denominator, mod); } class Graph { private int _size; private List<int>[] _map; public IEnumerable<int> this[int i] { get { if (_map[i] == null) return Enumerable.Empty<int>(); return _map[i]; } } public Graph(int size) { _size = size; _map = new List<int>[size]; } public void Add(int from, int to) { if (_map[from] == null) { _map[from] = new List<int>(); } _map[from].Add(to); } } class Graph<T> { private int _size; private List<T>[] _edges; public Graph(int size) { _size = size; _edges = new List<T>[size]; } public List<T> this[int i] { get { if (_edges[i] == null) _edges[i] = new List<T>(); return _edges[i]; } } } static Graph<T> NewGraph<T>(int size, T template) { return new Graph<T>(size); } static List<T> NewList<T>(T template) { return new List<T>(); } static T[] NewArray<T>(int size, T template) { return new T[size]; } static long p1097 = 1000000007; static void Main(string[] args) { //↓ var m = ReadInt(); long cc = 0; long sum = 0; for (int i = 0; i < m; i++) { var dc = ReadLongArray(); var d = dc[0]; var c = dc[1]; cc += c; sum += d * c; } Console.WriteLine((cc - 1) + sum / 9); //↑ } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace AtCoder { struct mint : IEquatable<mint> { // static uint mod = 998244353; static uint mod = 1000000007; uint _v; public mint(long v) : this((uint)(v % mod + mod)) {} private mint(uint v) { _v = v < mod ? v : (v - mod); } public static void SetMod(uint p) { mod = p; } public static mint operator +(mint lhs, mint rhs) { return new mint(lhs._v + rhs._v); } public static mint operator -(mint lhs, mint rhs) { return new mint(lhs._v + mod - rhs._v); } public static mint operator *(mint lhs, mint rhs) { return new mint((uint)((ulong)lhs._v * rhs._v % mod)); } public static mint operator /(mint lhs, mint rhs) { return lhs * rhs.Inv(); } public static mint operator ^(mint x, int n) { return Pow(x, n); } public static bool operator ==(mint l, mint r) { return l._v == r._v; } public static bool operator !=(mint l, mint r) { return !(l == r); } public static bool operator<(mint l, mint r) { return l._v < r._v; } public static bool operator>(mint l, mint r) { return l._v > r._v; } public static mint Pow(mint x, int n) { var r = new mint(1); while (n > 0) { if ((n & 1) > 0) r *= x; x *= x; n >>= 1; } return r; } public mint Pow(int n) { return Pow(this, n); } public mint Inv() { return Pow((int)mod - 2); } public bool Equals(mint o) { return this == o; } public override bool Equals(object obj) { if (obj is mint) return this == (mint)obj; else return false; } public override int GetHashCode() { return _v.GetHashCode(); } public override string ToString() { return _v.ToString(); } public static implicit operator mint(int i) { return new mint(i); } public static implicit operator mint(long i) { return new mint(i); } private static mint[] _fact; public static void SetFact(int n) { _fact = new mint[n + 1]; _fact[0] = 1; for (int i = 1; i < n + 1; i++) { _fact[i] = _fact[i - 1] * i; } } public static mint Fact(int n) { if (_fact == null || _fact.Length < n) { SetFact(n * 2); } return _fact[n]; } public static mint Combination(int n, int r) { return Fact(n) / (Fact(n - r) * Fact(r)); } } static class Extensions { public static int LowerBound<T>(this IList<T> list, T value, IComparer<T> comp = null) { if (comp == null) comp = Comparer<T>.Default; var l = 0; var r = list.Count; while (l < r) { var m = (l + r) / 2; var c = comp.Compare(value, list[m]); if (c > 0) l = m + 1; else r = m; } return l; } public static int UpperBound<T>(this IList<T> list, T value, IComparer<T> comp = null) { if (comp == null) comp = Comparer<T>.Default; var l = 0; var r = list.Count; while (l < r) { var m = (l + r) / 2; var c = comp.Compare(value, list[m]); if (c >= 0) l = m + 1; else r = m; } return r; } } class Program { static int ReadInt() { return int.Parse(Console.ReadLine()); } static long ReadLong() { return long.Parse(Console.ReadLine()); } static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static int[] ReadIntArray(int n) { var a = new int[n]; for (int i = 0; i < n; i++) { a[i] = ReadInt(); } return a; } static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } static long[] ReadLongArray(int n) { var a = new long[n]; for (int i = 0; i < n; i++) { a[i] = ReadLong(); } return a; } static List<T> ReadObjects<T>(int n, Func<int[], T> creator) { var l = new List<T>(n); for (int i = 0; i < n; i++) { var a = ReadIntArray(); l.Add(creator(a)); } return l; } static int[,] ReadMatrix(int n, int m) { var r = new int[n, m]; for (int i = 0; i < n; i++) { var a = ReadIntArray(); for (int j = 0; j < m; j++) { r[i, j] = a[j]; } } return r; } public static int[] ZAlgotithm(string s) { var len = s.Length; var a = new int[len]; a[0] = len; var i = 1; var j = 0; while (i < len) { while (i + j < len && s[j] == s[i + j]) j++; a[i] = j; if (j == 0) { i++; continue; } var k = 1; while (i + k < len && k + a[k] < j) { a[i + k] = a[k]; k++; } i += k; j -= k; } return a; } public class MaxHeap<T> : IEnumerable<T> { private List<T> _list; private Comparer<T> _comp; public int Count { get { return _list.Count; } } public MaxHeap() : this(0) {} public MaxHeap(int capacity, Comparison<T> comp = null) { _list = new List<T>(capacity); if (comp == null) { _comp = Comparer<T>.Default; } else { _comp = Comparer<T>.Create(comp); } } public void Push(T elem) { Upheap(elem); } public T Pop() { return Downheap(); } public T Peek() { return _list[0]; } private void Swap(int i, int j) { var a = _list[j]; _list[j] = _list[i]; _list[i] = a; } private void Upheap(T elem) { _list.Add(elem); var i = _list.Count - 1; while (true) { if (i == 0) return; var j = (i - 1) / 2; var e = _list[i]; var p = _list[j]; var c = _comp.Compare(e, p); if (c > 0) { Swap(i, j); i = j; continue; } else { break; } } } private T Downheap() { var result = _list[0]; var last = _list.Count - 1; Swap(0, last); _list.RemoveAt(last); if (_list.Count == 0) return result; var i = 0; while (true) { if (i == _list.Count - 1) return result; var p = _list[i]; var j = i * 2 + 1; if (j >= _list.Count) return result; if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) < 0) { j++; } if (_comp.Compare(_list[i], _list[j]) < 0) { Swap(i, j); i = j; } else { return result; } } } public MaxHeap<T> Copy(Comparison<T> comp = null) { var c = new MaxHeap<T>(0, comp); c._list = _list.ToList(); return c; } public MaxHeap(List<T> list) { _list = list; _comp = Comparer<T>.Default; } public List<T> GetList() { return _list; } public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } public class MinHeap<T> : IEnumerable<T> { private List<T> _list; private Comparer<T> _comp; public int Count { get { return _list.Count; } } public MinHeap() : this(0) {} public MinHeap(int capacity, Comparison<T> comp = null) { _list = new List<T>(capacity); if (comp == null) { _comp = Comparer<T>.Default; } else { _comp = Comparer<T>.Create(comp); } } public void Push(T elem) { Upheap(elem); } public T Pop() { return Downheap(); } public T Peek() { return _list[0]; } private void Swap(int i, int j) { var a = _list[j]; _list[j] = _list[i]; _list[i] = a; } private void Upheap(T elem) { _list.Add(elem); var i = _list.Count - 1; while (true) { if (i == 0) return; var j = (i - 1) / 2; var e = _list[i]; var p = _list[j]; var c = _comp.Compare(e, p); if (c < 0) { Swap(i, j); i = j; continue; } else { break; } } } private T Downheap() { var result = _list[0]; var last = _list.Count - 1; Swap(0, last); _list.RemoveAt(last); if (_list.Count == 0) return result; var i = 0; while (true) { if (i == _list.Count - 1) return result; var p = _list[i]; var j = i * 2 + 1; if (j >= _list.Count) return result; if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) > 0) { j++; } if (_comp.Compare(_list[i], _list[j]) > 0) { Swap(i, j); i = j; } else { return result; } } } public MinHeap<T> Copy(Comparison<T> comp = null) { var c = new MinHeap<T>(0, comp); c._list = _list.ToList(); return c; } public MinHeap(List<T> list) { _list = list; _comp = Comparer<T>.Default; } public List<T> GetList() { return _list; } public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } class InputLine { private string[] _inputs; private int _index = 0; InputLine(string input) { _inputs = input.Split(); _index = 0; } public static InputLine Read() { return new InputLine(Console.ReadLine()); } public int NextInt() { return int.Parse(_inputs[_index++]); } public long NextLong() { return long.Parse(_inputs[_index++]); } public double NextDouble() { return double.Parse(_inputs[_index++]); } } public static int GCD(int x, int y) { var a = Math.Max(x, y); var b = x + y - a; while (b != 0) { var c = b; b = a % b; a = c; } return a; } public static long GCD(long x, long y) { var a = Math.Max(x, y); var b = x + y - a; while (b != 0) { var c = b; b = a % b; a = c; } return a; } static long ModPower(long x, long y, long mod) { var bytes = BitConverter.GetBytes(y); var bits = new System.Collections.BitArray(bytes); var max2 = 0; for (int i = bits.Length - 1; i >= 0; i--) { if (bits[i]) { max2 = i; break; } } long result = 1; for (int i = max2; i >= 0; i--) { result = (result * result) % mod; if (bits[i]) { result = (result * x) % mod; } } return result; } static long ModFact(long n, long mod) { long result = 1; for (int i = 1; i <= n; i++) { result = result * i % mod; } return result; } static long ModAdd(long x, long y, long mod) { return ((x % mod) + (y % mod)) % mod; } static long ModMul(long x, long y, long mod) { return ((x % mod) * (y % mod)) % mod; } static long ModDiv(long x, long y, long mod) { //フェルマーの小定理より、a^(-1) = a^(p-2) return ModMul(x, ModPower(y, mod - 2, mod), mod); } static long ModComb(long n, long r, long mod) { long numerator = 1; for (int i = 0; i < r; i++) { numerator = ModMul(numerator, n - i, mod); } long denominator = ModFact(r, mod); return ModDiv(numerator, denominator, mod); } class Graph { private int _size; private List<int>[] _map; public IEnumerable<int> this[int i] { get { if (_map[i] == null) return Enumerable.Empty<int>(); return _map[i]; } } public Graph(int size) { _size = size; _map = new List<int>[size]; } public void Add(int from, int to) { if (_map[from] == null) { _map[from] = new List<int>(); } _map[from].Add(to); } } class Graph<T> { private int _size; private List<T>[] _edges; public Graph(int size) { _size = size; _edges = new List<T>[size]; } public List<T> this[int i] { get { if (_edges[i] == null) _edges[i] = new List<T>(); return _edges[i]; } } } static Graph<T> NewGraph<T>(int size, T template) { return new Graph<T>(size); } static List<T> NewList<T>(T template) { return new List<T>(); } static T[] NewArray<T>(int size, T template) { return new T[size]; } static long p1097 = 1000000007; static void Main(string[] args) { //↓ var m = ReadInt(); long cc = 0; long sum = 0; for (int i = 0; i < m; i++) { var dc = ReadLongArray(); var d = dc[0]; var c = dc[1]; cc += c; sum += d * c; } Console.WriteLine((cc - 1) + (sum - 1) / 9); //↑ } } }
[["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 25]]
8
3,502
4
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class DDCC2020_QUALD { static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var M = NN; var dc = Repeat(0, M).Select(_ => Tuple.Create(NN, NN)).ToList(); var ans = 0L; var idx = 0; var odd = new List<long>(); while (true) { if (dc.Count <= idx) break; var item = dc[idx]; ans += item.Item2 - 1; var tmp = item.Item1 * item.Item2; odd.Add(tmp % 10); if (tmp >= 10) dc.Add(Tuple.Create(1L, tmp / 10)); ++idx; } idx = 0; while (true) { if (idx == odd.Count - 1) break; ++ans; var sum = odd[idx] + odd[idx + 1]; if (sum >= 10) { odd[idx] = 1; odd[idx + 1] = sum - 10; } else { odd[idx + 1] += sum; ++idx; } } Console.WriteLine(ans); } static class Console_ { static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); } static long NN => long.Parse(Console_.NextString()); static double ND => double.Parse(Console_.NextString()); static string NS => Console_.NextString(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library {}
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class DDCC2020_QUALD { static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var M = NN; var dc = Repeat(0, M).Select(_ => Tuple.Create(NN, NN)).ToList(); var ans = 0L; var idx = 0; var odd = new List<long>(); while (true) { if (dc.Count <= idx) break; var item = dc[idx]; ans += item.Item2 - 1; var tmp = item.Item1 * item.Item2; odd.Add(tmp % 10); if (tmp >= 10) dc.Add(Tuple.Create(1L, tmp / 10)); ++idx; } idx = 0; while (true) { if (idx == odd.Count - 1) break; ++ans; var sum = odd[idx] + odd[idx + 1]; if (sum >= 10) { odd[idx] = 1; odd[idx + 1] = sum - 10; } else { odd[idx + 1] = sum; ++idx; } } Console.WriteLine(ans); } static class Console_ { static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); } static long NN => long.Parse(Console_.NextString()); static double ND => double.Parse(Console_.NextString()); static string NS => Console_.NextString(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library {}
[["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32]]
8
903
2
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; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { int m = int.Parse(Console.ReadLine()); var dc = Enumerable.Repeat(0, m) .Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()) .ToArray(); var a = dc.Sum(x => x[0] * x[1]); var res = dc.Sum(x => x[1]) /*桁数*/; res += a / 10; Console.WriteLine(res - 1); } }
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; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { int m = int.Parse(Console.ReadLine()); var dc = Enumerable.Repeat(0, m) .Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()) .ToArray(); var a = dc.Sum(x => x[0] * x[1]); var res = dc.Sum(x => x[1]) /*桁数*/; res += (a - 1) / 9; Console.WriteLine(res - 1); } }
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
8
198
6
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; public class Hello { public static void Main() { int read = rint(); WriteLine(read * 2); } //各種読取 static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static int[,] inta2(int num_array, int in_array) { int[,] int_array2 = new int[num_array, in_array]; for (int i = 0; i < num_array; i++) { int[] temp_array = inta(); for (int j = 0; j < in_array; j++) { int_array2[i, j] = temp_array[j]; } } return int_array2; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; } // A/B小数点以下切上 static long divideup(long divided, long divid) { long temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } } //知見 // (string) hogestr -> (char[]) hoge // char hoge = hogestr.ToCharArray(); // (char[]) hoge -> (string) hogestr // string hoge = new string(hoge); // Hashtable × Dictionary ○ // Dictionary hoge<string,int> // hoge.ContainsKey(string) -> return boolean // hoge[string] -> return int // hoge[int] -> CE // Dictionary hoge<int1,int2> // hoge<int1,int2>: hoge[int1] -> return int2 // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2 // SortedDictionary() > SortedList() ??? // キュー -> 幅優先 ??? // スタック -> 深さ優先 ???
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; public class Hello { public static void Main() { int read = rint(); WriteLine(read * read); } //各種読取 static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static int[,] inta2(int num_array, int in_array) { int[,] int_array2 = new int[num_array, in_array]; for (int i = 0; i < num_array; i++) { int[] temp_array = inta(); for (int j = 0; j < in_array; j++) { int_array2[i, j] = temp_array[j]; } } return int_array2; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; } // A/B小数点以下切上 static long divideup(long divided, long divid) { long temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } } //知見 // (string) hogestr -> (char[]) hoge // char hoge = hogestr.ToCharArray(); // (char[]) hoge -> (string) hogestr // string hoge = new string(hoge); // Hashtable × Dictionary ○ // Dictionary hoge<string,int> // hoge.ContainsKey(string) -> return boolean // hoge[string] -> return int // hoge[int] -> CE // Dictionary hoge<int1,int2> // hoge<int1,int2>: hoge[int1] -> return int2 // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2 // SortedDictionary() > SortedList() ??? // キュー -> 幅優先 ??? // スタック -> 深さ優先 ???
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
8
582
2
using System; class Program { static void Main(string[] args) { string str = Console.ReadLine(); // string[] str = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 string str = "<>>><<><<<<<>>><"; long N = Int64.Parse(str); // string[] strA = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 string[] strB = // Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得 // long[] A = new long[N]; // long[] B = new long[N]; long time = N ^ 2; Console.WriteLine(time.ToString()); } }
using System; class Program { static void Main(string[] args) { string str = Console.ReadLine(); // string[] str = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 string str = "<>>><<><<<<<>>><"; long N = Int64.Parse(str); // string[] strA = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 string[] strB = // Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得 // long[] A = new long[N]; // long[] B = new long[N]; long time = N * N; Console.WriteLine(time.ToString()); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 140], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
8
62
4
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Numerics; namespace abc145 { class Program { static void Main(string[] args) { // Console.SetIn(new StreamReader("input.txt")); solve_abc145A(); } public static void solve_abc145B() {} public static void solve_abc145A() { int r = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(r == 1 ? 0 : r * r); } } }
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Numerics; namespace abc145 { class Program { static void Main(string[] args) { // Console.SetIn(new StreamReader("input.txt")); solve_abc145A(); } public static void solve_abc145B() {} public static void solve_abc145A() { int r = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(r * r); } } }
[["-", 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], ["-", 3, 4, 0, 28, 0, 41, 75, 16, 31, 22]]
8
94
6
#define Local using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; namespace MyProject { class Program { static void Main(string[] args) { #if Local var sw = new Stopwatch(); sw.Start(); Console.SetIn(new StreamReader("input.in")); #endif var solver = new Solver(); solver.Solve(); #if Local Console.WriteLine($"{sw.ElapsedMilliseconds}ms"); #endif } } class Solver { public void Solve() { var r = int.Parse(Console.ReadLine()); var answer = Math.Pow(r, 2); Console.WriteLine(answer); } } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; namespace MyProject { class Program { static void Main(string[] args) { #if Local var sw = new Stopwatch(); sw.Start(); Console.SetIn(new StreamReader("input.in")); #endif var solver = new Solver(); solver.Solve(); #if Local Console.WriteLine($"{sw.ElapsedMilliseconds}ms"); #endif } } class Solver { public void Solve() { var r = int.Parse(Console.ReadLine()); var answer = Math.Pow(r, 2); Console.WriteLine(answer); } } }
[["-", 36, 36, 36, 36, 36, 36, 36, 36, 0, 208], ["-", 36, 36, 36, 36, 36, 36, 0, 208, 0, 323], ["-", 36, 36, 36, 36, 0, 208, 0, 323, 0, 22], ["-", 36, 36, 0, 208, 0, 323, 0, 22, 0, 231], ["-", 0, 208, 0, 323, 0, 22, 0, 231, 141, 22], ["-", 0, 323, 0, 22, 0, 231, 141, 22, 0, 231], ["-", 0, 22, 0, 231, 141, 22, 0, 231, 141, 232], ["-", 0, 231, 141, 22, 0, 231, 141, 232, 234, 232], ["-", 141, 22, 0, 231, 141, 232, 234, 232, 141, 22], ["-", 0, 231, 141, 232, 234, 232, 141, 22, 0, 231], ["-", 141, 232, 234, 232, 141, 22, 0, 231, 141, 232], ["-", 234, 232, 141, 22, 0, 231, 141, 232, 234, 22], ["-", 141, 22, 0, 231, 141, 232, 234, 22, 141, 22], ["-", 0, 231, 141, 232, 234, 22, 141, 22, 0, 231], ["-", 141, 232, 234, 22, 141, 22, 0, 231, 141, 232], ["-", 234, 22, 141, 22, 0, 231, 141, 232, 234, 22], ["-", 0, 231, 141, 232, 234, 22, 141, 22, 0, 209], ["-", 141, 232, 234, 22, 141, 22, 0, 209, 141, 22], ["-", 234, 22, 141, 22, 0, 209, 141, 22, 8, 201], ["-", 141, 22, 0, 209, 141, 22, 8, 201, 0, 235], ["-", 0, 209, 141, 22, 8, 201, 0, 235, 0, 235], ["-", 36, 36, 36, 36, 0, 208, 0, 323, 0, 324]]
8
156
3
using System; using System.Linq; using System.Collections.Generic; using System.Diagnostics; using Debug = System.Diagnostics.Trace; using SB = System.Text.StringBuilder; using System.Numerics; using static System.Math; using Number = System.Int32; namespace Program { public class Solver { Random rnd = new Random(); public void Solve() { var n = ri; var a = Enumerate(n, x => rl); var cnt = new long[60]; foreach (var x in a) for (int i = 0; i < 60; i++) if ((x >> i & 1) == 1) cnt[i]++; Debug.WriteLine(cnt.AsJoinedString()); var ans = 0L; const long M = (long)1e9 + 7; for (int i = 0; i < 60; i++) { var v = 1L << i; v = v * cnt[i] % M; v = v * (n - cnt[i]) % M; Debug.WriteLine(v); ans = (ans + v) % M; } Console.WriteLine(ans); } const long INF = 1L << 60; static int[] dx = { -1, 0, 1, 0 }; static int[] dy = { 0, 1, 0, -1 }; int ri { get { return sc.Integer(); } } long rl { get { return sc.Long(); } } double rd { get { return sc.Double(); } } string rs { get { return sc.Scan(); } } public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput()); static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < a.Length; ++i) a[i] = f(i); return a; } static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; } } } #region main static class Ex { static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); } static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); } static public void Main() { Console.SetOut(new Program.IO.Printer( Console.OpenStandardOutput()) { AutoFlush = true }); var solver = new Program.Solver(); /* var t = new System.Threading.Thread(solver.Solve, 50000000); t.Start(); t.Join(); //*/ solver.Solve(); Console.Out.Flush(); } } #endregion #region Ex namespace Program.IO { using System.IO; using System.Text; using System.Globalization; public class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {} } public class StreamScanner { public StreamScanner(Stream stream) { str = stream; } public readonly Stream str; private readonly byte[] buf = new byte[1024]; private int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } private byte read() { if (isEof) return 0; if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public string ScanLine() { var sb = new StringBuilder(); for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b); return sb.ToString(); } public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); } public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); } public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); } } } #endregion #region Set /// <summary> /// 要素の追加、削除、検索、取得が可能な集合を表します. /// </summary> /// <typeparam name="T">優先度付きキュー内の要素の型を指定します.</typeparam> /// <remarks>内部的にはAVL木によって実装されています.</remarks> public class Set<T> { Node root; readonly IComparer<T> comparer; readonly Node nil; /// <summary> /// 多重集合かどうかを表します. /// </summary> public bool IsMultiSet { get; set; } public Set(IComparer<T> comparer) { nil = new Node(default(T)); root = nil; this.comparer = comparer; } public Set(Comparison<T> comaprison) : this(Comparer<T>.Create(comaprison)) {} public Set() : this(Comparer<T>.Default) {} /// <summary> /// 要素をコレクションに追加します. /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public bool Add(T v) { return insert(ref root, v); } /// <summary> /// v が存在するならコレクションから削除します. /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public bool Remove(T v) { return remove(ref root, v); } /// <summary> /// 0-indexed で index 番目の要素をコレクションから取得します.. /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public T this[int index] { get { return find(root, index); } } public int Count { get { return root.Count; } } public void RemoveAt(int k) { if (k < 0 || k >= root.Count) throw new ArgumentOutOfRangeException(); removeAt(ref root, k); } /// <summary> /// このコレクションに含まれる要素を昇順に並べて返します. /// </summary> /// <remarks>この操作は計算量 O(N) で実行されます.</remarks> public T[] Items { get { var ret = new T[root.Count]; var k = 0; walk(root, ret, ref k); return ret; } } void walk(Node t, T[] a, ref int k) { if (t.Count == 0) return; walk(t.lst, a, ref k); a[k++] = t.Key; walk(t.rst, a, ref k); } bool insert(ref Node t, T key) { if (t.Count == 0) { t = new Node(key); t.lst = t.rst = nil; t.Update(); return true; } var cmp = comparer.Compare(t.Key, key); bool res; if (cmp > 0) res = insert(ref t.lst, key); else if (cmp == 0) { if (IsMultiSet) res = insert(ref t.lst, key); else return false; } else res = insert(ref t.rst, key); balance(ref t); return res; } bool remove(ref Node t, T key) { if (t.Count == 0) return false; var cmp = comparer.Compare(key, t.Key); bool ret; if (cmp < 0) ret = remove(ref t.lst, key); else if (cmp > 0) ret = remove(ref t.rst, key); else { ret = true; var k = t.lst.Count; if (k == 0) { t = t.rst; return true; } if (t.rst.Count == 0) { t = t.lst; return true; } t.Key = find(t.lst, k - 1); removeAt(ref t.lst, k - 1); } balance(ref t); return ret; } void removeAt(ref Node t, int k) { var cnt = t.lst.Count; if (cnt < k) removeAt(ref t.rst, k - cnt - 1); else if (cnt > k) removeAt(ref t.lst, k); else { if (cnt == 0) { t = t.rst; return; } if (t.rst.Count == 0) { t = t.lst; return; } t.Key = find(t.lst, k - 1); removeAt(ref t.lst, k - 1); } balance(ref t); } void balance(ref Node t) { var balance = t.lst.Height - t.rst.Height; if (balance == -2) { if (t.rst.lst.Height - t.rst.rst.Height > 0) { rotR(ref t.rst); } rotL(ref t); } else if (balance == 2) { if (t.lst.lst.Height - t.lst.rst.Height < 0) rotL(ref t.lst); rotR(ref t); } else t.Update(); } T find(Node t, int k) { if (k < 0 || k > root.Count) throw new ArgumentOutOfRangeException(); for (;;) { if (k == t.lst.Count) return t.Key; else if (k < t.lst.Count) t = t.lst; else { k -= t.lst.Count + 1; t = t.rst; } } } /// <summary> /// コレクションに含まれる要素であって、 v 以上の最小の要素の番号を返します。 /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public int LowerBound(T v) { var k = 0; var t = root; for (;;) { if (t.Count == 0) return k; if (comparer.Compare(v, t.Key) <= 0) t = t.lst; else { k += t.lst.Count + 1; t = t.rst; } } } /// <summary> /// コレクションに含まれる要素であって、 v /// より真に大きい、最小の要素の番号を返します。 /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public int UpperBound(T v) { var k = 0; var t = root; for (;;) { if (t.Count == 0) return k; if (comparer.Compare(t.Key, v) <= 0) { k += t.lst.Count + 1; t = t.rst; } else t = t.lst; } } void rotR(ref Node t) { var l = t.lst; t.lst = l.rst; l.rst = t; t.Update(); l.Update(); t = l; } void rotL(ref Node t) { var r = t.rst; t.rst = r.lst; r.lst = t; t.Update(); r.Update(); t = r; } class Node { public Node(T key) { Key = key; } public int Count { get; private set; } public sbyte Height { get; private set; } public T Key { get; set; } public Node lst, rst; public void Update() { Count = 1 + lst.Count + rst.Count; Height = (sbyte)(1 + Math.Max(lst.Height, rst.Height)); } public override string ToString() { return string.Format("Count = {0}, Key = {1}", Count, Key); } } } #endregion
using System; using System.Linq; using System.Collections.Generic; using System.Diagnostics; using Debug = System.Diagnostics.Trace; using SB = System.Text.StringBuilder; using System.Numerics; using static System.Math; using Number = System.Int32; namespace Program { public class Solver { Random rnd = new Random(); public void Solve() { var n = ri; var a = Enumerate(n, x => rl); var cnt = new long[60]; foreach (var x in a) for (int i = 0; i < 60; i++) if ((x >> i & 1) == 1) cnt[i]++; Debug.WriteLine(cnt.AsJoinedString()); var ans = 0L; const long M = (long)1e9 + 7; for (int i = 0; i < 60; i++) { var v = (1L << i) % M; v = v * cnt[i] % M; v = v * (n - cnt[i]) % M; Debug.WriteLine(v); ans = (ans + v) % M; } Console.WriteLine(ans); } const long INF = 1L << 60; static int[] dx = { -1, 0, 1, 0 }; static int[] dy = { 0, 1, 0, -1 }; int ri { get { return sc.Integer(); } } long rl { get { return sc.Long(); } } double rd { get { return sc.Double(); } } string rs { get { return sc.Scan(); } } public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput()); static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < a.Length; ++i) a[i] = f(i); return a; } static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; } } } #region main static class Ex { static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); } static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); } static public void Main() { Console.SetOut(new Program.IO.Printer( Console.OpenStandardOutput()) { AutoFlush = true }); var solver = new Program.Solver(); /* var t = new System.Threading.Thread(solver.Solve, 50000000); t.Start(); t.Join(); //*/ solver.Solve(); Console.Out.Flush(); } } #endregion #region Ex namespace Program.IO { using System.IO; using System.Text; using System.Globalization; public class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {} } public class StreamScanner { public StreamScanner(Stream stream) { str = stream; } public readonly Stream str; private readonly byte[] buf = new byte[1024]; private int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } private byte read() { if (isEof) return 0; if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; } public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } public string ScanLine() { var sb = new StringBuilder(); for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b); return sb.ToString(); } public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); } public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); } public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); } } } #endregion #region Set /// <summary> /// 要素の追加、削除、検索、取得が可能な集合を表します. /// </summary> /// <typeparam name="T">優先度付きキュー内の要素の型を指定します.</typeparam> /// <remarks>内部的にはAVL木によって実装されています.</remarks> public class Set<T> { Node root; readonly IComparer<T> comparer; readonly Node nil; /// <summary> /// 多重集合かどうかを表します. /// </summary> public bool IsMultiSet { get; set; } public Set(IComparer<T> comparer) { nil = new Node(default(T)); root = nil; this.comparer = comparer; } public Set(Comparison<T> comaprison) : this(Comparer<T>.Create(comaprison)) {} public Set() : this(Comparer<T>.Default) {} /// <summary> /// 要素をコレクションに追加します. /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public bool Add(T v) { return insert(ref root, v); } /// <summary> /// v が存在するならコレクションから削除します. /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public bool Remove(T v) { return remove(ref root, v); } /// <summary> /// 0-indexed で index 番目の要素をコレクションから取得します.. /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public T this[int index] { get { return find(root, index); } } public int Count { get { return root.Count; } } public void RemoveAt(int k) { if (k < 0 || k >= root.Count) throw new ArgumentOutOfRangeException(); removeAt(ref root, k); } /// <summary> /// このコレクションに含まれる要素を昇順に並べて返します. /// </summary> /// <remarks>この操作は計算量 O(N) で実行されます.</remarks> public T[] Items { get { var ret = new T[root.Count]; var k = 0; walk(root, ret, ref k); return ret; } } void walk(Node t, T[] a, ref int k) { if (t.Count == 0) return; walk(t.lst, a, ref k); a[k++] = t.Key; walk(t.rst, a, ref k); } bool insert(ref Node t, T key) { if (t.Count == 0) { t = new Node(key); t.lst = t.rst = nil; t.Update(); return true; } var cmp = comparer.Compare(t.Key, key); bool res; if (cmp > 0) res = insert(ref t.lst, key); else if (cmp == 0) { if (IsMultiSet) res = insert(ref t.lst, key); else return false; } else res = insert(ref t.rst, key); balance(ref t); return res; } bool remove(ref Node t, T key) { if (t.Count == 0) return false; var cmp = comparer.Compare(key, t.Key); bool ret; if (cmp < 0) ret = remove(ref t.lst, key); else if (cmp > 0) ret = remove(ref t.rst, key); else { ret = true; var k = t.lst.Count; if (k == 0) { t = t.rst; return true; } if (t.rst.Count == 0) { t = t.lst; return true; } t.Key = find(t.lst, k - 1); removeAt(ref t.lst, k - 1); } balance(ref t); return ret; } void removeAt(ref Node t, int k) { var cnt = t.lst.Count; if (cnt < k) removeAt(ref t.rst, k - cnt - 1); else if (cnt > k) removeAt(ref t.lst, k); else { if (cnt == 0) { t = t.rst; return; } if (t.rst.Count == 0) { t = t.lst; return; } t.Key = find(t.lst, k - 1); removeAt(ref t.lst, k - 1); } balance(ref t); } void balance(ref Node t) { var balance = t.lst.Height - t.rst.Height; if (balance == -2) { if (t.rst.lst.Height - t.rst.rst.Height > 0) { rotR(ref t.rst); } rotL(ref t); } else if (balance == 2) { if (t.lst.lst.Height - t.lst.rst.Height < 0) rotL(ref t.lst); rotR(ref t); } else t.Update(); } T find(Node t, int k) { if (k < 0 || k > root.Count) throw new ArgumentOutOfRangeException(); for (;;) { if (k == t.lst.Count) return t.Key; else if (k < t.lst.Count) t = t.lst; else { k -= t.lst.Count + 1; t = t.rst; } } } /// <summary> /// コレクションに含まれる要素であって、 v 以上の最小の要素の番号を返します。 /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public int LowerBound(T v) { var k = 0; var t = root; for (;;) { if (t.Count == 0) return k; if (comparer.Compare(v, t.Key) <= 0) t = t.lst; else { k += t.lst.Count + 1; t = t.rst; } } } /// <summary> /// コレクションに含まれる要素であって、 v /// より真に大きい、最小の要素の番号を返します。 /// </summary> /// <remarks>この操作は計算量 O(log N) で実行されます.</remarks> public int UpperBound(T v) { var k = 0; var t = root; for (;;) { if (t.Count == 0) return k; if (comparer.Compare(t.Key, v) <= 0) { k += t.lst.Count + 1; t = t.rst; } else t = t.lst; } } void rotR(ref Node t) { var l = t.lst; t.lst = l.rst; l.rst = t; t.Update(); l.Update(); t = l; } void rotL(ref Node t) { var r = t.rst; t.rst = r.lst; r.lst = t; t.Update(); r.Update(); t = r; } class Node { public Node(T key) { Key = key; } public int Count { get; private set; } public sbyte Height { get; private set; } public T Key { get; set; } public Node lst, rst; public void Update() { Count = 1 + lst.Count + rst.Count; Height = (sbyte)(1 + Math.Max(lst.Height, rst.Height)); } public override string ToString() { return string.Format("Count = {0}, Key = {1}", Count, Key); } } } #endregion
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
8
2,342
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using static System.Console; using static System.Math; using static MyIO; using static MyUtil; public class D { public static void Main() => (new Solver()).Solve(); } public class Solver { public void Solve() { long N = GetLong(); long[] A = GetLongs((int)N); long[] cnt = new long[63]; for (int i = 0; i < N; i++) { long rest = A[i]; for (int j = 0; j <= 62; j++) { if (rest % 2 == 1) cnt[j]++; rest >>= 1; } } var P = new ModInt(0); for (int i = 0; i <= 62; i++) { if (cnt[i] == 0) continue; P += new ModInt((cnt[i] * (cnt[i] - 1)) / 2) * new ModInt(1 << (i + 1)); } var Q = new ModInt(0); for (int i = 0; i < N; i++) Q += new ModInt(A[i]) * (N - 1); WriteLine((Q - P).Val); } } public struct ModInt { public long Mod { get; private set; } public long Val { get; private set; } public ModInt(long v) { // must initialize (default: Mod = 0) Mod = 1000000007; Val = v % Mod; } public static ModInt operator +(ModInt x, ModInt y) { long mod = x.Mod; long tmp = x.Val + y.Val; if (tmp >= mod) tmp -= mod; return new ModInt(tmp); } public static ModInt operator -(ModInt x, ModInt y) { long mod = x.Mod; long tmp = x.Val; if (tmp < y.Val) tmp += mod; tmp -= y.Val; return new ModInt(tmp); } public static ModInt operator *(ModInt x, ModInt y) { long mod = x.Mod; return new ModInt((x.Val * y.Val) % mod); } public static ModInt operator /(ModInt x, ModInt y) { long mod = x.Mod; long pow = mod - 2; long yy = y.Val; long inv = 1; while (pow > 0) { if ((pow & 1) == 1) inv = (inv * yy) % mod; yy = (yy * yy) % mod; pow >>= 1; } return new ModInt((x.Val * inv) % mod); } public static ModInt operator +(ModInt x, long y) => x + new ModInt(y); public static ModInt operator -(ModInt x, long y) => x - new ModInt(y); public static ModInt operator *(ModInt x, long y) => x * new ModInt(y); public static ModInt operator /(ModInt x, long y) => x / new ModInt(y); public static ModInt operator ++(ModInt x) => x + new ModInt(1); public static ModInt operator --(ModInt x) => x - new ModInt(1); } public static class MyIO { private static string[] args = null; private static int num = -1; private static int used = -1; private static string getArg() { if (used == num) { args = Console.ReadLine().Split(' '); num = args.Length; used = 0; } return args[used++]; } public static int GetInt() => int.Parse(getArg()); public static long GetLong() => long.Parse(getArg()); public static double GetDouble() => double.Parse(getArg()); public static string GetString() => getArg(); public static char GetChar() => getArg()[0]; public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray(); public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray(); public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray(); public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray(); } public static class MyUtil { public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if (x.CompareTo(y) < 0) x = y; } public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if (x.CompareTo(y) > 0) x = y; } public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using static System.Console; using static System.Math; using static MyIO; using static MyUtil; public class D { public static void Main() => (new Solver()).Solve(); } public class Solver { public void Solve() { long N = GetLong(); long[] A = GetLongs((int)N); long[] cnt = new long[63]; for (int i = 0; i < N; i++) { long rest = A[i]; for (int j = 0; j <= 62; j++) { if (rest % 2 == 1) cnt[j]++; rest >>= 1; } } var P = new ModInt(0); for (int i = 0; i <= 62; i++) { if (cnt[i] == 0) continue; P += new ModInt((cnt[i] * (cnt[i] - 1)) / 2) * new ModInt(1L << (i + 1)); } var Q = new ModInt(0); for (int i = 0; i < N; i++) Q += new ModInt(A[i]) * (N - 1); WriteLine((Q - P).Val); } } public struct ModInt { public long Mod { get; private set; } public long Val { get; private set; } public ModInt(long v) { // must initialize (default: Mod = 0) Mod = 1000000007; Val = v % Mod; } public static ModInt operator +(ModInt x, ModInt y) { long mod = x.Mod; long tmp = x.Val + y.Val; if (tmp >= mod) tmp -= mod; return new ModInt(tmp); } public static ModInt operator -(ModInt x, ModInt y) { long mod = x.Mod; long tmp = x.Val; if (tmp < y.Val) tmp += mod; tmp -= y.Val; return new ModInt(tmp); } public static ModInt operator *(ModInt x, ModInt y) { long mod = x.Mod; return new ModInt((x.Val * y.Val) % mod); } public static ModInt operator /(ModInt x, ModInt y) { long mod = x.Mod; long pow = mod - 2; long yy = y.Val; long inv = 1; while (pow > 0) { if ((pow & 1) == 1) inv = (inv * yy) % mod; yy = (yy * yy) % mod; pow >>= 1; } return new ModInt((x.Val * inv) % mod); } public static ModInt operator +(ModInt x, long y) => x + new ModInt(y); public static ModInt operator -(ModInt x, long y) => x - new ModInt(y); public static ModInt operator *(ModInt x, long y) => x * new ModInt(y); public static ModInt operator /(ModInt x, long y) => x / new ModInt(y); public static ModInt operator ++(ModInt x) => x + new ModInt(1); public static ModInt operator --(ModInt x) => x - new ModInt(1); } public static class MyIO { private static string[] args = null; private static int num = -1; private static int used = -1; private static string getArg() { if (used == num) { args = Console.ReadLine().Split(' '); num = args.Length; used = 0; } return args[used++]; } public static int GetInt() => int.Parse(getArg()); public static long GetLong() => long.Parse(getArg()); public static double GetDouble() => double.Parse(getArg()); public static string GetString() => getArg(); public static char GetChar() => getArg()[0]; public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray(); public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray(); public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray(); public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray(); } public static class MyUtil { public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if (x.CompareTo(y) < 0) x = y; } public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if (x.CompareTo(y) > 0) x = y; } public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; } }
[["-", 12, 230, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 12, 230, 3, 4, 0, 28, 0, 16, 31, 203]]
8
1,094
2
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] A = new long[N]; string[] str = Console.ReadLine().Split(); for (var i = 0; i < N; i++) { A[i] = long.Parse(str[i]); } long[] D1 = new long[61]; long[] D2 = new long[61]; long mod = 1000000007; for (var i = 0; i < N; i++) { long a = 1; for (var j = 0; j <= 60; j++) { if (A[i] / a % 2 == 1) { D1[j]++; } else { D2[j]++; } a *= 2; } } long a1 = 1; long ans = 0; for (var i = 0; i <= 60; i++) { long b1 = D1[i] * D2[i] % mod; b1 = b1 * a1 % mod; ans = (ans + b1) % mod; a1 *= 2; } Console.WriteLine(ans); } }
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] A = new long[N]; string[] str = Console.ReadLine().Split(); for (var i = 0; i < N; i++) { A[i] = long.Parse(str[i]); } long[] D1 = new long[61]; long[] D2 = new long[61]; long mod = 1000000007; for (var i = 0; i < N; i++) { long a = 1; for (var j = 0; j <= 60; j++) { if (A[i] / a % 2 == 1) { D1[j]++; } else { D2[j]++; } a *= 2; } } long a1 = 1; long ans = 0; for (var i = 0; i <= 60; i++) { long b1 = D1[i] * D2[i] % mod; b1 = a1 % mod * b1 % mod; ans = (ans + b1) % mod; a1 *= 2; } Console.WriteLine(ans); } }
[["-", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22]]
8
264
6
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; var h1 = new int[s[0]][]; var h2 = new int[s[0]][]; var bs = new Bitset[s[0]][]; for (int i = 0; i < s[0]; i++) { h1[i] = sc.Ia; bs[i] = new Bitset[s[1]]; } for (int i = 0; i < s[0]; i++) { h2[i] = sc.Ia; } int o = 100 * 100 * 2; o = 12; for (int i = 0; i < s[0]; i++) { for (int j = 0; j < s[1]; j++) { bs[i][j] = new Bitset(o * 2); if (i == 0 && j == 0) { bs[i][j][o] = 1; bs[i][j] >>= Abs(h1[i][j] - h2[i][j]); continue; } if (i != 0) { bs[i][j] |= bs[i - 1][j] << Abs(h1[i][j] - h2[i][j]); bs[i][j] |= bs[i - 1][j] >> Abs(h1[i][j] - h2[i][j]); } if (j != 0) { bs[i][j] |= bs[i][j - 1] << Abs(h1[i][j] - h2[i][j]); bs[i][j] |= bs[i][j - 1] >> Abs(h1[i][j] - h2[i][j]); } } } int ans = int.MaxValue; for (int i = 0; i < o * 2; i++) { if (bs[s[0] - 1][s[1] - 1][i] == 1) { ans = Min(ans, Abs(o - i)); } } Console.WriteLine("{0}", ans); } } public class Bitset { public int n, l; public ulong[] he; public Bitset(int n) { this.n = n; l = (n >> 6) + 1; he = new ulong[l]; } public Bitset(int n, long a) { this.n = n; l = (n >> 6) + 1; he = new ulong[l]; he[0] = (ulong)a; } public Bitset(int n, bool b) { this.n = n; l = (n >> 6) + 1; he = new ulong[l]; int y = n % 64; if (y == 0) { for (int i = 0; i < l; i++) { he[i] = ulong.MaxValue; } } else { for (int i = 0; i < l - 1; i++) { he[i] = ulong.MaxValue; } he[l - 1] = (1UL << y) - 1; } } public int this[int i] { set { he[i >> 6] = (he[i >> 6] & (ulong.MaxValue ^ (1UL << i))) | ((ulong)value << i); } get { return (int)((he[i >> 6] >> i) & 1); } } public static Bitset operator &(Bitset a, Bitset b) { Bitset c = new Bitset(a.n); int d = Math.Min(a.l, b.l); for (int i = 0; i < d; i++) { c.he[i] = a.he[i] & b.he[i]; } return c; } public static Bitset operator |(Bitset a, Bitset b) { Bitset c; if (a.l < b.l) { c = a; a = b; b = c; } c = new Bitset(a.n); int i = 0; for (; i < b.l; i++) { c.he[i] = a.he[i] | b.he[i]; } for (; i < a.l; i++) { c.he[i] = a.he[i]; } return c; } public static Bitset operator ^(Bitset a, Bitset b) { Bitset c; if (a.l < b.l) { c = a; a = b; b = c; } c = new Bitset(a.n); int i = 0; for (; i < b.l; i++) { c.he[i] = a.he[i] ^ b.he[i]; } for (; i < a.l; i++) { c.he[i] = a.he[i]; } return c; } public static Bitset operator <<(Bitset a, int b) { Bitset c = new Bitset(a.n); if (b > a.l << 6) { return c; } int d = (b + 63) >> 6; if (b % 64 == 0) { for (int i = a.l - 1; i >= d; i--) { c.he[i] = a.he[i - d]; } } else { for (int i = a.l - 1; i >= d; i--) { c.he[i] = (a.he[i - d + 1] << b) | (a.he[i - d] >> (64 - b)); } c.he[d - 1] = a.he[0] << b; } return c; } public static Bitset operator>>(Bitset a, int b) { Bitset c = new Bitset(a.n); if (b > a.l << 6) { return c; } int d = (b + 63) >> 6; if (b % 64 == 0) { for (int i = 0; i + d < c.l; i++) { c.he[i] = a.he[i + d]; } } else { for (int i = 0; i + d < c.l; i++) { c.he[i] = (a.he[i + d - 1] >> b) | (a.he[i + d] << (64 - b)); } c.he[c.l - d] = a.he[c.l - 1] >> b; } return c; } public static bool operator ==(Bitset a, Bitset b) { int mx = Max(a.l, b.l), mn = Min(a.l, b.l); for (int i = 0; i < mn; i++) { if (a.he[i] != b.he[i]) { return false; } } if (a.l > b.l) { for (int i = mn; i < mx; i++) { if (a.he[i] != 0) { return false; } } } else { for (int i = mn; i < mx; i++) { if (b.he[i] != 0) { return false; } } } return true; } public static bool operator !=(Bitset a, Bitset b) { int mx = Max(a.l, b.l), mn = Min(a.l, b.l); for (int i = 0; i < mn; i++) { if (a.he[i] != b.he[i]) { return true; } } if (a.l > b.l) { for (int i = mn; i < mx; i++) { if (a.he[i] != 0) { return true; } } } else { for (int i = mn; i < mx; i++) { if (b.he[i] != 0) { return true; } } } return false; } public override bool Equals(object obj) { return false; } public override int GetHashCode() { return 0; } public string St() { string t = "", s; for (int i = 0; i < l - 1; i++) { s = Convert.ToString((long)he[i], 2); s = (64 > s.Length ? new string('0', 64 - s.Length) : "") + s; t = s + t; } s = Convert.ToString((long)he[l - 1], 2); s = ((n % 64) > s.Length ? new string('0', (n % 64) - s.Length) : "") + s; return s + t; } } 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; var h1 = new int[s[0]][]; var h2 = new int[s[0]][]; var bs = new Bitset[s[0]][]; for (int i = 0; i < s[0]; i++) { h1[i] = sc.Ia; bs[i] = new Bitset[s[1]]; } for (int i = 0; i < s[0]; i++) { h2[i] = sc.Ia; } int o = 80 * 80 * 2; for (int i = 0; i < s[0]; i++) { for (int j = 0; j < s[1]; j++) { bs[i][j] = new Bitset(o * 2); if (i == 0 && j == 0) { bs[i][j][o] = 1; bs[i][j] >>= Abs(h1[i][j] - h2[i][j]); continue; } if (i != 0) { bs[i][j] |= bs[i - 1][j] << Abs(h1[i][j] - h2[i][j]); bs[i][j] |= bs[i - 1][j] >> Abs(h1[i][j] - h2[i][j]); } if (j != 0) { bs[i][j] |= bs[i][j - 1] << Abs(h1[i][j] - h2[i][j]); bs[i][j] |= bs[i][j - 1] >> Abs(h1[i][j] - h2[i][j]); } } } int ans = int.MaxValue; for (int i = 0; i < o * 2; i++) { if (bs[s[0] - 1][s[1] - 1][i] == 1) { ans = Min(ans, Abs(o - i)); } } Console.WriteLine("{0}", ans); } } public class Bitset { public int n, l; public ulong[] he; public Bitset(int n) { this.n = n; l = (n >> 6) + 1; he = new ulong[l]; } public Bitset(int n, long a) { this.n = n; l = (n >> 6) + 1; he = new ulong[l]; he[0] = (ulong)a; } public Bitset(int n, bool b) { this.n = n; l = (n >> 6) + 1; he = new ulong[l]; int y = n % 64; if (y == 0) { for (int i = 0; i < l; i++) { he[i] = ulong.MaxValue; } } else { for (int i = 0; i < l - 1; i++) { he[i] = ulong.MaxValue; } he[l - 1] = (1UL << y) - 1; } } public int this[int i] { set { he[i >> 6] = (he[i >> 6] & (ulong.MaxValue ^ (1UL << i))) | ((ulong)value << i); } get { return (int)((he[i >> 6] >> i) & 1); } } public static Bitset operator &(Bitset a, Bitset b) { Bitset c = new Bitset(a.n); int d = Math.Min(a.l, b.l); for (int i = 0; i < d; i++) { c.he[i] = a.he[i] & b.he[i]; } return c; } public static Bitset operator |(Bitset a, Bitset b) { Bitset c; if (a.l < b.l) { c = a; a = b; b = c; } c = new Bitset(a.n); int i = 0; for (; i < b.l; i++) { c.he[i] = a.he[i] | b.he[i]; } for (; i < a.l; i++) { c.he[i] = a.he[i]; } return c; } public static Bitset operator ^(Bitset a, Bitset b) { Bitset c; if (a.l < b.l) { c = a; a = b; b = c; } c = new Bitset(a.n); int i = 0; for (; i < b.l; i++) { c.he[i] = a.he[i] ^ b.he[i]; } for (; i < a.l; i++) { c.he[i] = a.he[i]; } return c; } public static Bitset operator <<(Bitset a, int b) { Bitset c = new Bitset(a.n); if (b > a.l << 6) { return c; } int d = (b + 63) >> 6; if (b % 64 == 0) { for (int i = a.l - 1; i >= d; i--) { c.he[i] = a.he[i - d]; } } else { for (int i = a.l - 1; i >= d; i--) { c.he[i] = (a.he[i - d + 1] << b) | (a.he[i - d] >> (64 - b)); } c.he[d - 1] = a.he[0] << b; } return c; } public static Bitset operator>>(Bitset a, int b) { Bitset c = new Bitset(a.n); if (b > a.l << 6) { return c; } int d = (b + 63) >> 6; if (b % 64 == 0) { for (int i = 0; i + d < c.l; i++) { c.he[i] = a.he[i + d]; } } else { for (int i = 0; i + d < c.l; i++) { c.he[i] = (a.he[i + d - 1] >> b) | (a.he[i + d] << (64 - b)); } c.he[c.l - d] = a.he[c.l - 1] >> b; } return c; } public static bool operator ==(Bitset a, Bitset b) { int mx = Max(a.l, b.l), mn = Min(a.l, b.l); for (int i = 0; i < mn; i++) { if (a.he[i] != b.he[i]) { return false; } } if (a.l > b.l) { for (int i = mn; i < mx; i++) { if (a.he[i] != 0) { return false; } } } else { for (int i = mn; i < mx; i++) { if (b.he[i] != 0) { return false; } } } return true; } public static bool operator !=(Bitset a, Bitset b) { int mx = Max(a.l, b.l), mn = Min(a.l, b.l); for (int i = 0; i < mn; i++) { if (a.he[i] != b.he[i]) { return true; } } if (a.l > b.l) { for (int i = mn; i < mx; i++) { if (a.he[i] != 0) { return true; } } } else { for (int i = mn; i < mx; i++) { if (b.he[i] != 0) { return true; } } } return false; } public override bool Equals(object obj) { return false; } public override int GetHashCode() { return 0; } public string St() { string t = "", s; for (int i = 0; i < l - 1; i++) { s = Convert.ToString((long)he[i], 2); s = (64 > s.Length ? new string('0', 64 - s.Length) : "") + s; t = s + t; } s = Convert.ToString((long)he[l - 1], 2); s = ((n % 64) > s.Length ? new string('0', (n % 64) - s.Length) : "") + s; return s + t; } } 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, 200, 0, 212, 0, 16, 31, 16, 31, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 31, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203]]
8
2,822
8
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Numerics; using static System.Math; using static System.Array; using static AtCoder.Tool; namespace AtCoder { class AC { // const int MOD = 1000000007; const int MOD = 998244353; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dI = { 0, 1, 0, -1, 1, -1, -1, 1 }; static readonly int[] dJ = { 1, 0, -1, 0, 1, 1, -1, -1 }; // 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 IO_ShortCut(); long N, X, D; cin.Input(out N, out X, out D); if (D == 0) { cin.OutL(N + 1); return; } if (D < 0) { X = -X; D = -D; } long ans = 0; Func<long, long, long> s = (a, b) => -a * (a - 1) / 2 + b * (b + 1) / 2; var rec = new Dictionary<int, List<long>>(); for (long i = 0; i <= N; i++) { long rem = ((i * Abs(X)) % D); var r = (int)rem; if (!rec.ContainsKey(r)) rec[r] = new List<long>(); rec[r].Add(i); } foreach (var rs in rec) { long r = rs.Key; var lis = rs.Value; lis.Sort((x, y) => { long dif = (x * X - r) + x * (x - 1) / 2 * D - (y * X - r) - y * (y - 1) / 2 * D; return dif == 0 ? 0 : (dif > 0 ? 1 : -1); }); long mx = -(long)1e15; foreach (var p in lis) { var k = p; long st = (k * X - r) / D + s(0, k - 1); long ed = (k * X - r) / D + s(N - k, N - 1); long num = ed - st + 1; long no = Max(0, mx - st + 1); // cin.Out_Sep(st, ed, mx); ans += Max(0, num - no); mx = Max(mx, ed); // cin.OutL(ans); } } cin.OutL(ans); // 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; } } } class IO_ShortCut { public IO_ShortCut() {} public string[] ReadSplit => Console.ReadLine().Split(); public int[] ReadSplitInt => ConvertAll(Console.ReadLine().Split(), int.Parse); public long[] ReadSplitLong => ConvertAll(Console.ReadLine().Split(), long.Parse); public double[] ReadSplit_Double => ConvertAll(Console.ReadLine().Split(), double.Parse); public string Str => Console.ReadLine(); public int Int => int.Parse(Console.ReadLine()); public long Long => long.Parse(Console.ReadLine()); public double Double => double.Parse(Console.ReadLine()); public T Conv<T>(string input) => (T)Convert.ChangeType(input, typeof(T)); public void Input<T>(out T a) => a = Conv<T>(Console.ReadLine()); public void Input<T, U>(out T a, out U b) { var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); } public void Input<T, U, V>(out T a, out U b, out V c) { var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); } public void Input<T, U, V, W>(out T a, out U b, out V c, out W d) { var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); d = Conv<W>(q[3]); } public void OutL(object s) => Console.WriteLine(s); public void Out_Sep<T>(IEnumerable<T> s) => Console.WriteLine(string.Join(" ", s)); public void Out_Sep<T>(IEnumerable<T> s, string sep) => Console.WriteLine(string.Join($"{sep}", s)); public void Out_Sep(params object[] s) => Console.WriteLine(string.Join(" ", s)); public void Out_One(object s) => Console.Write($"{s} "); public void Out_One(object s, string sep) => Console.Write($"{s}{sep}"); } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { array = ConvertAll(array, x => initialvalue); } static public void Swap<T>(ref T a, ref T b) { T keep = a; a = b; b = keep; } static public void Display<T>(T[,] array2d, int n, int m) { for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { Console.Write($"{array2d[i, j]} "); } Console.WriteLine(); } } static public long LPow(int a, int b) => (long)Pow(a, b); } class Modulo { private int M; private readonly long[] m_facs; public long Mul(long a, long b) { return ((a * b) % M); } public Modulo(long n, int m) { M = m; m_facs = new long[n + 1]; m_facs[0] = 1; for (long i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public long Fac(long n) { return m_facs[n]; } public long Pow(long a, long m) { switch (m) { case 0: return 1L; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public long Div(long a, long b) { return Mul(a, Pow(b, M - 2)); } public long Ncr(long n, long r) { if (n < r) { return 0; } if (n == r) { return 1; } long res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Numerics; using static System.Math; using static System.Array; using static AtCoder.Tool; namespace AtCoder { class AC { // const int MOD = 1000000007; const int MOD = 998244353; const int INF = int.MaxValue / 2; const long SINF = long.MaxValue / 2; const double EPS = 1e-8; static readonly int[] dI = { 0, 1, 0, -1, 1, -1, -1, 1 }; static readonly int[] dJ = { 1, 0, -1, 0, 1, 1, -1, -1 }; // 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 IO_ShortCut(); long N, X, D; cin.Input(out N, out X, out D); if (D == 0) { cin.OutL(X == 0 ? 1 : N + 1); return; } if (D < 0) { X = -X; D = -D; } long ans = 0; Func<long, long, long> s = (a, b) => -a * (a - 1) / 2 + b * (b + 1) / 2; var rec = new Dictionary<int, List<long>>(); for (long i = 0; i <= N; i++) { long rem = ((i * Abs(X)) % D); var r = (int)rem; if (!rec.ContainsKey(r)) rec[r] = new List<long>(); rec[r].Add(i); } foreach (var rs in rec) { long r = rs.Key; var lis = rs.Value; lis.Sort((x, y) => { long dif = (x * X - r) + x * (x - 1) / 2 * D - (y * X - r) - y * (y - 1) / 2 * D; return dif == 0 ? 0 : (dif > 0 ? 1 : -1); }); long mx = -(long)1e15; foreach (var p in lis) { var k = p; long st = (k * X - r) / D + s(0, k - 1); long ed = (k * X - r) / D + s(N - k, N - 1); long num = ed - st + 1; long no = Max(0, mx - st + 1); // cin.Out_Sep(st, ed, mx); ans += Max(0, num - no); mx = Max(mx, ed); // cin.OutL(ans); } } cin.OutL(ans); // 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; } } } class IO_ShortCut { public IO_ShortCut() {} public string[] ReadSplit => Console.ReadLine().Split(); public int[] ReadSplitInt => ConvertAll(Console.ReadLine().Split(), int.Parse); public long[] ReadSplitLong => ConvertAll(Console.ReadLine().Split(), long.Parse); public double[] ReadSplit_Double => ConvertAll(Console.ReadLine().Split(), double.Parse); public string Str => Console.ReadLine(); public int Int => int.Parse(Console.ReadLine()); public long Long => long.Parse(Console.ReadLine()); public double Double => double.Parse(Console.ReadLine()); public T Conv<T>(string input) => (T)Convert.ChangeType(input, typeof(T)); public void Input<T>(out T a) => a = Conv<T>(Console.ReadLine()); public void Input<T, U>(out T a, out U b) { var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); } public void Input<T, U, V>(out T a, out U b, out V c) { var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); } public void Input<T, U, V, W>(out T a, out U b, out V c, out W d) { var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]); d = Conv<W>(q[3]); } public void OutL(object s) => Console.WriteLine(s); public void Out_Sep<T>(IEnumerable<T> s) => Console.WriteLine(string.Join(" ", s)); public void Out_Sep<T>(IEnumerable<T> s, string sep) => Console.WriteLine(string.Join($"{sep}", s)); public void Out_Sep(params object[] s) => Console.WriteLine(string.Join(" ", s)); public void Out_One(object s) => Console.Write($"{s} "); public void Out_One(object s, string sep) => Console.Write($"{s}{sep}"); } public static class Tool { static public void Initialize<T>(ref T[] array, T initialvalue) { array = ConvertAll(array, x => initialvalue); } static public void Swap<T>(ref T a, ref T b) { T keep = a; a = b; b = keep; } static public void Display<T>(T[,] array2d, int n, int m) { for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { Console.Write($"{array2d[i, j]} "); } Console.WriteLine(); } } static public long LPow(int a, int b) => (long)Pow(a, b); } class Modulo { private int M; private readonly long[] m_facs; public long Mul(long a, long b) { return ((a * b) % M); } public Modulo(long n, int m) { M = m; m_facs = new long[n + 1]; m_facs[0] = 1; for (long i = 1; i <= n; ++i) { m_facs[i] = Mul(m_facs[i - 1], i); } } public long Fac(long n) { return m_facs[n]; } public long Pow(long a, long m) { switch (m) { case 0: return 1L; case 1: return a; default: long p1 = Pow(a, m / 2); long p2 = Mul(p1, p1); return ((m % 2) == 0) ? p2 : Mul(p2, a); } } public long Div(long a, long b) { return Mul(a, Pow(b, M - 2)); } public long Ncr(long n, long r) { if (n < r) { return 0; } if (n == r) { return 1; } long res = Fac(n); res = Div(res, Fac(r)); res = Div(res, Fac(n - r)); return res; } } }
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102]]
8
1,661
6
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design; using System.IO.Compression; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using Console = System.Console; namespace Atcoder { class Program { private const long COMDIV = 1000000007; static void Main(string[] args) { var r1 = Console.ReadLine().Split().Select(int.Parse).ToArray(); var r2 = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(r1[0] == r2[1] ? 0 : 1); } } }
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design; using System.IO.Compression; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using Console = System.Console; namespace Atcoder { class Program { private const long COMDIV = 1000000007; static void Main(string[] args) { var r1 = Console.ReadLine().Split().Select(int.Parse).ToArray(); var r2 = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(r1[0] == r2[0] ? 0 : 1); } } }
[["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
8
163
2
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; using static program.Const; namespace program { class Program { static void Main() { var n1 = ScanIntArray(); var n2 = ScanIntArray(); WriteLine(n1[0] == n2[0] ? 0 : -1); } } static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public static long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } 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 int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } 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; using static program.Const; namespace program { class Program { static void Main() { var n1 = ScanIntArray(); var n2 = ScanIntArray(); WriteLine(n1[0] == n2[0] ? 0 : 1); } } static class Const { public static string alp = "abcdefghijklmnopqrstuvwxyz"; public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public static long MOD = 1000000007; public static int INF = int.MaxValue; public static long INFL = long.MaxValue; } 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 int Floor2(this int a) { int N = 1; while (N < a) N *= 2; return N / 2; } static public long Floor2(this long a) { long N = 1; while (N < a) N *= 2; return N / 2; } static public int Ceiling2(this int a) { int N = 1; while (N < a) N *= 2; return N; } static public long Ceiling2(this long a) { long N = 1; while (N < a) N *= 2; return N; } 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; } } }
[["-", 3, 4, 0, 28, 0, 41, 75, 241, 0, 33]]
8
1,427
1
#define A using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using static System.Console; using static System.Math; class Program { static void Main() { #if A FastIO.Int(); var D = FastIO.Int(); FastIO.Int(); var K = FastIO.Int(); WriteLine(D < K ? 1 : 0); #endif #if B var N = int.Parse(ReadLine()); for (int i = 1; i <= N; i++) { if ((i * 108) / 100 == N) { WriteLine(i); return; } } WriteLine(":("); #endif #if C var X = int.Parse(ReadLine()); var q = X / 100; var r = X % 100; WriteLine(5 * q < r ? 0 : 1); #endif #if D var N = int.Parse(ReadLine()); var S = ReadLine(); var b = new int[10]; for (int i = 0; i < b.Length; i++) { b[i] = -1; for (int j = 0; j < S.Length; j++) { if (S[j] == '0' + i) { b[i] = j; break; } } } var c = new int[10, 10]; for (int i = 0; i < 10; i++) { if (b[i] == -1) continue; for (int j = 0; j < 10; j++) { c[i, j] = -1; for (int k = b[i] + 1; k < S.Length; k++) { if (S[k] == '0' + j) { c[i, j] = k; break; } } } } var d = new int[10, 10, 10]; for (int i = 0; i < 10; i++) { if (b[i] == -1) continue; for (int j = 0; j < 10; j++) { if (c[i, j] == -1) continue; for (int k = 0; k < 10; k++) { d[i, j, k] = -1; for (int l = c[i, j] + 1; l < S.Length; l++) { if (S[l] == '0' + k) { d[i, j, k] = l; break; } } } } } var ans = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { for (int k = 0; k < 10; k++) { if (d[i, j, k] > 0) { ans++; } } } } WriteLine(ans); #endif } } public static class FastIO { static System.IO.Stream str = System.Console.OpenStandardInput(); const int size = 1024; static byte[] buffer = new byte[size]; static int ptr; static int len; static byte Read() { if (ptr == len) { len = str.Read(buffer, 0, size); if (len == 0) return 0; ptr = 0; } return buffer[ptr++]; } public static int Int() { var c = Read(); while (c < 0x21) { c = Read(); } var n = false; if (c == '-') { n = true; c = Read(); } var ret = 0; while (c > 0x20) { ret = ret * 10 + c - '0'; c = Read(); } return n ? -ret : ret; } public static long Long() { var c = Read(); while (c < 0x21) { c = Read(); } var n = false; if (c == '-') { n = true; c = Read(); } var ret = 0L; while (c > 0x20) { ret = ret * 10 + c - '0'; c = Read(); } return n ? -ret : ret; } }
#define A using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using static System.Console; using static System.Math; class Program { static void Main() { #if A FastIO.Int(); var D = FastIO.Int(); FastIO.Int(); var K = FastIO.Int(); WriteLine(D > K ? 1 : 0); #endif #if B var N = int.Parse(ReadLine()); for (int i = 1; i <= N; i++) { if ((i * 108) / 100 == N) { WriteLine(i); return; } } WriteLine(":("); #endif #if C var X = int.Parse(ReadLine()); var q = X / 100; var r = X % 100; WriteLine(5 * q < r ? 0 : 1); #endif #if D var N = int.Parse(ReadLine()); var S = ReadLine(); var b = new int[10]; for (int i = 0; i < b.Length; i++) { b[i] = -1; for (int j = 0; j < S.Length; j++) { if (S[j] == '0' + i) { b[i] = j; break; } } } var c = new int[10, 10]; for (int i = 0; i < 10; i++) { if (b[i] == -1) continue; for (int j = 0; j < 10; j++) { c[i, j] = -1; for (int k = b[i] + 1; k < S.Length; k++) { if (S[k] == '0' + j) { c[i, j] = k; break; } } } } var d = new int[10, 10, 10]; for (int i = 0; i < 10; i++) { if (b[i] == -1) continue; for (int j = 0; j < 10; j++) { if (c[i, j] == -1) continue; for (int k = 0; k < 10; k++) { d[i, j, k] = -1; for (int l = c[i, j] + 1; l < S.Length; l++) { if (S[l] == '0' + k) { d[i, j, k] = l; break; } } } } } var ans = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { for (int k = 0; k < 10; k++) { if (d[i, j, k] > 0) { ans++; } } } } WriteLine(ans); #endif } } public static class FastIO { static System.IO.Stream str = System.Console.OpenStandardInput(); const int size = 1024; static byte[] buffer = new byte[size]; static int ptr; static int len; static byte Read() { if (ptr == len) { len = str.Read(buffer, 0, size); if (len == 0) return 0; ptr = 0; } return buffer[ptr++]; } public static int Int() { var c = Read(); while (c < 0x21) { c = Read(); } var n = false; if (c == '-') { n = true; c = Read(); } var ret = 0; while (c > 0x20) { ret = ret * 10 + c - '0'; c = Read(); } return n ? -ret : ret; } public static long Long() { var c = Read(); while (c < 0x21) { c = Read(); } var n = false; if (c == '-') { n = true; c = Read(); } var ret = 0L; while (c > 0x20) { ret = ret * 10 + c - '0'; c = Read(); } return n ? -ret : ret; } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 18], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47]]
8
922
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp5 { class Program { static void Main(string[] args) { String S = Console.ReadLine(); String[] L = S.Split(' '); int M1 = int.Parse(L[0]); int D1 = int.Parse(L[1]); S = Console.ReadLine(); L = S.Split(' '); int M2 = int.Parse(L[0]); int D2 = int.Parse(L[1]); if (D2 == 1) { Console.WriteLine("1"); } if (D2 == 1) { Console.WriteLine("0"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp5 { class Program { static void Main(string[] args) { String S = Console.ReadLine(); String[] L = S.Split(' '); int M1 = int.Parse(L[0]); int D1 = int.Parse(L[1]); S = Console.ReadLine(); L = S.Split(' '); int M2 = int.Parse(L[0]); int D2 = int.Parse(L[1]); if (D2 == 1) { Console.WriteLine("1"); } else { Console.WriteLine("0"); } } } }
[["-", 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, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
8
174
7
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; 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); } static void Main(string[] args) { var V1 = ReadInts(); var V2 = ReadInts(); Console.WriteLine(V1[0] == V1[0] ? 0 : 1); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; 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); } static void Main(string[] args) { var V1 = ReadInts(); var V2 = ReadInts(); Console.WriteLine(V1[0] == V2[0] ? 0 : 1); } } }
[["-", 0, 28, 0, 41, 15, 16, 12, 204, 205, 22], ["+", 0, 28, 0, 41, 15, 16, 12, 204, 205, 22]]
8
230
2
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; namespace FertiLib.Contest.G { static class Program { public static void Solve(Scanner cin) { int n = cin.ReadInt(); for (int i = 0; i < 50000; i++) { if (n == (int)Math.Floor(i * 1.08)) Console.WriteLine(i); } Console.WriteLine(":("); } 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 Extention { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); public static int UpperBound<T>(this IList<T> list, T value) => list.BinarySearch(value, true, 0, list.Count, Comparer<T>.Default); public static int LowerBound<T>(this IList<T> list, T value) => list.BinarySearch(value, false, 0, list.Count, Comparer<T>.Default); public static int BinarySearch<T>(this IList<T> list, T value, bool isUpperBound, int index, int length, Comparer<T> comparer) { var ng = index - 1; var ok = index + length; while (ok - ng > 1) { var mid = ng + (ok - ng) / 2; var res = comparer.Compare(list[mid], value); if (res < 0 || (isUpperBound && res == 0)) ng = mid; else ok = mid; } return ok; } } 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; using System.Runtime.CompilerServices; namespace FertiLib.Contest.G { static class Program { public static void Solve(Scanner cin) { int n = cin.ReadInt(); for (int i = 0; i < 50000; i++) { if (n == (int)Math.Floor(i * 1.08)) { Console.WriteLine(i); return; } } Console.WriteLine(":("); } 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 Extention { public static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); public static int UpperBound<T>(this IList<T> list, T value) => list.BinarySearch(value, true, 0, list.Count, Comparer<T>.Default); public static int LowerBound<T>(this IList<T> list, T value) => list.BinarySearch(value, false, 0, list.Count, Comparer<T>.Default); public static int BinarySearch<T>(this IList<T> list, T value, bool isUpperBound, int index, int length, Comparer<T> comparer) { var ng = index - 1; var ok = index + length; while (ok - ng > 1) { var mid = ng + (ok - ng) / 2; var res = comparer.Compare(list[mid], value); if (res < 0 || (isUpperBound && res == 0)) ng = mid; else ok = mid; } return ok; } } 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, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
2,877
4
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 N = IO.RInt; for (int i = 0; i < 100000; i++) { decimal a = i * (decimal)1.08; if (a == N) { WriteLine(i); return; } } WriteLine(":("); } } 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 N = IO.RInt; for (int i = 0; i < 100000; i++) { int a = (int)(i * (decimal)1.08); if (a == N) { WriteLine(i); return; } } WriteLine(":("); } } 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, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 74, 51, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 74, 51, 23, 0, 25]]
8
525
7
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static Libraries.Input; namespace Libraries { static class Input { private static Func<string, T[]> Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray(); private static Func<string, T> Convert<T>() { Type t = typeof(T); if (t == typeof(string)) return _ => (T)(object)_; if (t == typeof(int)) return _ => (T)(object) int.Parse(_); if (t == typeof(long)) return _ => (T)(object) long.Parse(_); if (t == typeof(double)) return _ => (T)(object) double.Parse(_); if (t == typeof(string[])) return _ => (T)(object)_.Split(' '); if (t == typeof(int[])) return _ => (T)(object)Cast<int>()(_); if (t == typeof(long[])) return _ => (T)(object)Cast<long>()(_); if (t == typeof(double[])) return _ => (T)(object)Cast<double>()(_); throw new NotSupportedException(t + "is not supported."); } private static T Convert<T>(string s) => Convert<T>()(s); private static string String() => Console.ReadLine(); private static string[] String(long rowNumber) => new bool [rowNumber].Select(_ => String()).ToArray(); public static void Cin<T>(out T a) => a = Convert<T>(String()); public static void Cin<T1, T2>(out T1 a1, out T2 a2) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); } public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); } public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3, out T4 a4) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); } public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); } public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5, out T6 a6) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); set(v[5], out a6); } private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s); public static void Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray(); public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) { l1 = new T1[n]; l2 = new T2[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i]); } public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2, out T3[] l3) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i]); } public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2, out T3[] l3, out T4[] l4) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; l4 = new T4[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i], out l4[i]); } public static void Cin<T>(out T[] a) => a = Convert<T[]>(String()); public static void Cin<T>(long h, out T[][] map) => map = String(h).Select(Convert<T[]>()).ToArray(); } class Program { public static void Main(string[] args) { StreamWriter streamWriter = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(streamWriter); new Solver().Solve(); Console.Out.Flush(); } public static void Debug() { new Solver().Solve(); } } class Solver { public void Solve() { int n; Cin(out n); for (int i = 0; i < n; i++) { if (i * 108 / 100 == n) { Console.WriteLine(i); return; } } Console.WriteLine(":("); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static Libraries.Input; namespace Libraries { static class Input { private static Func<string, T[]> Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray(); private static Func<string, T> Convert<T>() { Type t = typeof(T); if (t == typeof(string)) return _ => (T)(object)_; if (t == typeof(int)) return _ => (T)(object) int.Parse(_); if (t == typeof(long)) return _ => (T)(object) long.Parse(_); if (t == typeof(double)) return _ => (T)(object) double.Parse(_); if (t == typeof(string[])) return _ => (T)(object)_.Split(' '); if (t == typeof(int[])) return _ => (T)(object)Cast<int>()(_); if (t == typeof(long[])) return _ => (T)(object)Cast<long>()(_); if (t == typeof(double[])) return _ => (T)(object)Cast<double>()(_); throw new NotSupportedException(t + "is not supported."); } private static T Convert<T>(string s) => Convert<T>()(s); private static string String() => Console.ReadLine(); private static string[] String(long rowNumber) => new bool [rowNumber].Select(_ => String()).ToArray(); public static void Cin<T>(out T a) => a = Convert<T>(String()); public static void Cin<T1, T2>(out T1 a1, out T2 a2) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); } public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); } public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3, out T4 a4) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); } public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); } public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5, out T6 a6) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); set(v[5], out a6); } private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s); public static void Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray(); public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) { l1 = new T1[n]; l2 = new T2[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i]); } public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2, out T3[] l3) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i]); } public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2, out T3[] l3, out T4[] l4) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; l4 = new T4[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i], out l4[i]); } public static void Cin<T>(out T[] a) => a = Convert<T[]>(String()); public static void Cin<T>(long h, out T[][] map) => map = String(h).Select(Convert<T[]>()).ToArray(); } class Program { public static void Main(string[] args) { StreamWriter streamWriter = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(streamWriter); new Solver().Solve(); Console.Out.Flush(); } public static void Debug() { new Solver().Solve(); } } class Solver { public void Solve() { int n; Cin(out n); for (int i = 0; i <= n; i++) { if (i * 108 / 100 == n) { Console.WriteLine(i); return; } } Console.WriteLine(":("); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
1,426
2
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace B_SMTB2019 { class MainClass { static int[] s; public static void Main(string[] args) { s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse); double m = s[0] + 0.49999999; int ans = (int)(m / 1.08); int tmp = (int)(ans * 1.08); // WriteLine(ans); // WriteLine(tmp); if (tmp == s[0]) { WriteLine(ans); } else { WriteLine(":("); } /* WriteLine(ans); if (m % 108 == 0) { WriteLine(m / 108); } else { WriteLine(":("); WriteLine(m % 108); WriteLine(m / 108); } */ } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace B_SMTB2019 { class MainClass { static int[] s; public static void Main(string[] args) { s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse); double m = s[0] + 0.999999999; int ans = (int)(m / 1.08); int tmp = (int)(ans * 1.08); // WriteLine(ans); // WriteLine(tmp); if (tmp == s[0]) { WriteLine(ans); } else { WriteLine(":("); } /* WriteLine(ans); if (m % 108 == 0) { WriteLine(m / 108); } else { WriteLine(":("); WriteLine(m % 108); WriteLine(m / 108); } */ } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 250], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 250]]
8
139
2
using System; public class Program { static void Main() { string line = Console.ReadLine().Trim(); var zeikomiKingaku = long.Parse(line); var zeinukiKingaku = CalcZeinuki(zeikomiKingaku); Console.WriteLine(zeinukiKingaku == 0 ? ":(" : zeinukiKingaku.ToString()); } /// <summary> /// 税抜き金額算出 /// ※理論値が存在しない場合は、0を出力 /// ※1~9の場合は税抜 = 税込 /// </summary> /// <param name="zeikomiKingaku"></param> /// <returns></returns> private static int CalcZeinuki(double zeikomiKingaku) { var calczeinukiKingaku = Math.Ceiling(zeikomiKingaku / 1.08); var checkKingaku = Math.Floor(calczeinukiKingaku * 1.08); return calczeinukiKingaku == checkKingaku && calczeinukiKingaku > 9 ? 0 : (int)calczeinukiKingaku; } }
using System; public class Program { static void Main() { string line = Console.ReadLine().Trim(); var zeikomiKingaku = long.Parse(line); var zeinukiKingaku = CalcZeinuki(zeikomiKingaku); Console.WriteLine(zeinukiKingaku == 0 ? ":(" : zeinukiKingaku.ToString()); } /// <summary> /// 税抜き金額算出 /// ※理論値が存在しない場合は、0を出力 /// ※1~9の場合は税抜 = 税込 /// </summary> /// <param name="zeikomiKingaku"></param> /// <returns></returns> private static int CalcZeinuki(double zeikomiKingaku) { var calczeinukiKingaku = Math.Ceiling(zeikomiKingaku / 1.08); var checkKingaku = Math.Floor((int)calczeinukiKingaku * 1.08); return zeikomiKingaku != checkKingaku && calczeinukiKingaku > 9 ? 0 : (int)calczeinukiKingaku; } }
[["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["-", 0, 37, 0, 41, 15, 16, 31, 16, 31, 22], ["-", 0, 37, 0, 41, 15, 16, 31, 16, 17, 60], ["+", 0, 37, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 0, 37, 0, 41, 15, 16, 31, 16, 17, 79]]
8
122
7
using System; using System.Linq; using System.Collections.Generic; namespace B { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); Func<int, int> withoutTax = x => (int)((x / 1.08) + 0.5); var a = (int)(withoutTax(n) * 1.08); if (a == n) { Console.WriteLine(withoutTax(n)); } else { Console.WriteLine(":("); } } } }
using System; using System.Linq; using System.Collections.Generic; namespace B { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); Func<int, int> withoutTax = x => (int)(Math.Ceiling(x / 1.08)); var a = (int)(withoutTax(n) * 1.08); if (a == n) { Console.WriteLine(withoutTax(n)); } else { Console.WriteLine(":("); } } } }
[["+", 8, 74, 51, 23, 0, 213, 63, 214, 205, 22], ["+", 8, 74, 51, 23, 0, 213, 63, 214, 0, 131], ["+", 8, 74, 51, 23, 0, 213, 63, 214, 141, 22], ["-", 0, 218, 8, 74, 51, 23, 0, 16, 17, 72], ["-", 0, 218, 8, 74, 51, 23, 0, 16, 12, 250]]
8
116
5
using System; class Program { static void Main(string[] args) { string str1 = Console.ReadLine(); int N = Int32.Parse(str1); int X = (int)Math.Ceiling(N / 1.08); int NR = (int)Math.Floor(X * 1.08); if (N == NR) { Console.WriteLine("1"); } else { Console.WriteLine(":("); } } }
using System; class Program { static void Main(string[] args) { string str1 = Console.ReadLine(); int N = Int32.Parse(str1); int X = (int)Math.Ceiling(N / 1.08); int NR = (int)Math.Floor(X * 1.08); if (N == NR) { Console.WriteLine(X.ToString()); } else { Console.WriteLine(":("); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
96
8
using System; using System.Linq; namespace MSBPC2019 { class B { static void Main(string[] args) { long N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { if (N == (long)(i * 1.08)) { Console.WriteLine(i); return; } } Console.WriteLine(":("); } } }
using System; using System.Linq; namespace MSBPC2019 { class B { static void Main(string[] args) { long N = long.Parse(Console.ReadLine()); for (double i = 0; i <= N; i++) { // Console.WriteLine((long)(i * 1.08)); if (N == (long)(i * 1.08)) { Console.WriteLine(i); return; } } Console.WriteLine(":("); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
90
6
using System; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int X_cand = (int)(N / 1.08); int X = (int)(X_cand * 1.08); if (X == N) Console.WriteLine(X_cand); else { int X_cand2 = (int)((X_cand + 1) * 1.08); if (X_cand2 == N) Console.WriteLine(X_cand2); else Console.WriteLine(":("); } } }
using System; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int X_cand = (int)(N / 1.08); int X = (int)(X_cand * 1.08); if (X == N) Console.WriteLine(X_cand); else { int X_cand2 = (int)((X_cand + 1) * 1.08); if (X_cand2 == N) Console.WriteLine(X_cand + 1); else Console.WriteLine(":("); } } }
[["-", 64, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
111
4
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { int pay = int.Parse(Console.ReadLine()); decimal rate = decimal.Parse("1.08"); for (decimal i = 0; i < pay; i++) { decimal price = (int)(i * rate); // int price = (int)Math.Floor(i * 1.08); if (Math.Abs(price - pay) < 1) { Console.WriteLine(i); return; } } Console.WriteLine(":("); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { int pay = int.Parse(Console.ReadLine()); decimal rate = decimal.Parse("1.08"); for (decimal i = 0; i <= pay; i++) { decimal price = (int)(i * rate); // int price = (int)Math.Floor(i * 1.08); if (Math.Abs(price - pay) < 1) { Console.WriteLine(i); return; } } Console.WriteLine(":("); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
122
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var waaaa = new waaaa(); waaaa.Solve(); } } public class waaaa { const int MOD = 1000000007; const int INF = 1 << 30; const long INFL = 1 << 62; const int MOD2 = 998244353; myinout IO = new myinout(); Math2 mmath = new Math2(); public void Solve() { //ここから var o = IO.IntM; int N = o[0]; int f = 0; for (int i = 0; i < N; ++i) { if (Math.Floor((double)i * 1.08) == N) f = i; } if (f != 0) IO.wri(f); else IO.wri(":("); } } // b-aで降順 public class Math2 { public long[] Fact; // Nまでの階乗 public long[] invFact; //階乗の逆元 // Nまでの階乗をセットしておく public void FactoricalModSet(long N, long MOD = 1000000007) { Fact = new long[N + 1]; invFact = new long[N + 1]; Fact[0] = 1; for (long i = 1; i <= N; ++i) { Fact[i] = Fact[i - 1] * i % MOD; } invFact[N] = pow(Fact[N], MOD - 2); for (long i = N; i > 0; --i) { invFact[i - 1] = invFact[i] * i % MOD; } } // nCr 引数:n r (mod) public long nCr(long n, long r, long MOD = 1000000007) { return (Fact[n] * invFact[r] % MOD * invFact[n - r] % MOD); } //階乗(O(logN)) 引数:底x n乗 (MOD) public long pow(long x, long n, long MOD = 1000000007) { long res = 1; while (n > 0) { if ((n & 1) != 0) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } //最大公約数 引数:整数x,y public long GCD(long x, long y) { while (y != 0) { var r = x % y; x = y; y = r; } return x; } //最小公倍数 引数:整数x,y public long LCM(long x, long y) { return x * y / GCD(x, y); } //素因数分解 引数:整数N public Dictionary<long, int> PrimeFactorization(long N) { var ret = new Dictionary<long, int>(); for (long i = 2; i * i <= N; ++i) { int cnt = 0; while (N % i == 0) { cnt++; N /= i; } if (cnt != 0) ret[i] = cnt; } if (N >= 2) ret[N] = 1; return ret; } //約数列挙 public List<long> divisorenumrate(long N) { var ret = new List<long>(); for (long i = 1; i * i <= N; ++i) { if (N % i == 0) { ret.Add(i); ret.Add(N / i); } } return ret; } } class myinout { // in public string Str => Console.ReadLine(); public string[] StrM => Str.Split(' '); public long[] LongM => StrM.Select(long.Parse).ToArray(); public int[] IntM => StrM.Select(int.Parse).ToArray(); public char[] CharM => Str.ToArray(); public long Long1 => LongM[0]; public int Int1 => IntM[0]; // out public void wri<T>(T x) { Console.WriteLine(x); } public void yn(bool x) { if (x) wri("Yes"); else wri("No"); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var waaaa = new waaaa(); waaaa.Solve(); } } public class waaaa { const int MOD = 1000000007; const int INF = 1 << 30; const long INFL = 1 << 62; const int MOD2 = 998244353; myinout IO = new myinout(); Math2 mmath = new Math2(); public void Solve() { //ここから var o = IO.IntM; int N = o[0]; int f = 0; for (int i = 0; i <= N; ++i) { if (Math.Floor((double)i * 1.08) == N) f = i; } if (f != 0) IO.wri(f); else IO.wri(":("); } } // b-aで降順 public class Math2 { public long[] Fact; // Nまでの階乗 public long[] invFact; //階乗の逆元 // Nまでの階乗をセットしておく public void FactoricalModSet(long N, long MOD = 1000000007) { Fact = new long[N + 1]; invFact = new long[N + 1]; Fact[0] = 1; for (long i = 1; i <= N; ++i) { Fact[i] = Fact[i - 1] * i % MOD; } invFact[N] = pow(Fact[N], MOD - 2); for (long i = N; i > 0; --i) { invFact[i - 1] = invFact[i] * i % MOD; } } // nCr 引数:n r (mod) public long nCr(long n, long r, long MOD = 1000000007) { return (Fact[n] * invFact[r] % MOD * invFact[n - r] % MOD); } //階乗(O(logN)) 引数:底x n乗 (MOD) public long pow(long x, long n, long MOD = 1000000007) { long res = 1; while (n > 0) { if ((n & 1) != 0) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } //最大公約数 引数:整数x,y public long GCD(long x, long y) { while (y != 0) { var r = x % y; x = y; y = r; } return x; } //最小公倍数 引数:整数x,y public long LCM(long x, long y) { return x * y / GCD(x, y); } //素因数分解 引数:整数N public Dictionary<long, int> PrimeFactorization(long N) { var ret = new Dictionary<long, int>(); for (long i = 2; i * i <= N; ++i) { int cnt = 0; while (N % i == 0) { cnt++; N /= i; } if (cnt != 0) ret[i] = cnt; } if (N >= 2) ret[N] = 1; return ret; } //約数列挙 public List<long> divisorenumrate(long N) { var ret = new List<long>(); for (long i = 1; i * i <= N; ++i) { if (N % i == 0) { ret.Add(i); ret.Add(N / i); } } return ret; } } class myinout { // in public string Str => Console.ReadLine(); public string[] StrM => Str.Split(' '); public long[] LongM => StrM.Select(long.Parse).ToArray(); public int[] IntM => StrM.Select(int.Parse).ToArray(); public char[] CharM => Str.ToArray(); public long Long1 => LongM[0]; public int Int1 => IntM[0]; // out public void wri<T>(T x) { Console.WriteLine(x); } public void yn(bool x) { if (x) wri("Yes"); else wri("No"); } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
819
2
using System; class ProgramB { static void Main(string[] args) { //入力 string input = Console.ReadLine(); int n = int.Parse(input); // int x = (int)((double)n / 1.08) + 1; int xn = (int)(x * 1.08); if (xn == n) Console.WriteLine(x); else { Console.WriteLine(":("); } } }
using System; class ProgramB { static void Main(string[] args) { //入力 string input = Console.ReadLine(); int n = int.Parse(input); // int x = (int)(Math.Ceiling((double)n / 1.08)); int xn = (int)(x * 1.08); if (xn == n) Console.WriteLine(x); else { Console.WriteLine(":("); } } }
[["+", 0, 74, 51, 23, 0, 213, 63, 214, 205, 22], ["+", 0, 74, 51, 23, 0, 213, 63, 214, 0, 131], ["+", 0, 74, 51, 23, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 74, 51, 23, 0, 25]]
8
93
7
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { class Program { static void Main(string[] args) { var swr = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(swr); int n = int.Parse(Console.ReadLine()); double ans = 0; for (double i = 1; i < n; i++) { if (Math.Truncate(i * 1.08) == n) { ans = i; } } if (ans == 0) { Console.WriteLine(":("); } else { Console.WriteLine(ans); } Console.Out.Flush(); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { class Program { static void Main(string[] args) { var swr = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(swr); double n = double.Parse(Console.ReadLine()); double ans = 0; for (double i = 1; i <= n; i++) { if (Math.Truncate(i * 1.08) == n) { ans = i; break; } } if (ans == 0) { Console.WriteLine(":("); } else { Console.WriteLine(ans); } Console.Out.Flush(); } } }
[["-", 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], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
8
165
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace sumitrust2019_B { class Program { static void Main(string[] args) { var x = int.Parse(Console.ReadLine()); var ans = -1; for (int i = 0; i < x; i++) { if (Math.Floor(i * 1.08) == x) { ans = i; break; } } Console.WriteLine(ans == -1 ? ":(" : ans.ToString()); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace sumitrust2019_B { class Program { static void Main(string[] args) { var x = int.Parse(Console.ReadLine()); var ans = -1; for (int i = 0; i <= x; i++) { if (Math.Floor(i * 1.08) == x) { ans = i; break; } } Console.WriteLine(ans == -1 ? ":(" : ans.ToString()); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
123
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderA { static void Main() { var sc = new Scanner(); long x = sc.NextLong(); long up = x / 100; long down = x % 100; long count = 0; while (down > 0) { if (down > 5) { down -= 5; } else { down = 0; } count++; } long answer = up >= down ? 1 : 0; Console.WriteLine(answer); } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderA { static void Main() { var sc = new Scanner(); long x = sc.NextLong(); long up = x / 100; long down = x % 100; long count = 0; while (down > 0) { if (down > 5) { down -= 5; } else { down = 0; } count++; } long answer = (up >= count) ? 1 : 0; Console.WriteLine(answer); } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
[["+", 0, 200, 0, 212, 0, 41, 15, 23, 0, 24], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 12, 22], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 41, 15, 23, 0, 25]]
8
410
4
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace CP { class Atria { static void Main(string[] args) { int n = int.Parse(ReadLine()); bool[] dp = new bool[101000]; dp[0] = true; for (int i = 0; i < 100000; i++) { if (dp[i]) { dp[i + 100] = true; dp[i + 101] = true; dp[i + 102] = true; dp[i + 103] = true; dp[i + 104] = true; dp[i + 105] = true; } } WriteLine(dp[n - 1] ? 1 : 0); } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace CP { class Atria { static void Main(string[] args) { int n = int.Parse(ReadLine()); bool[] dp = new bool[101000]; dp[0] = true; for (int i = 0; i < 100000; i++) { if (dp[i]) { dp[i + 100] = true; dp[i + 101] = true; dp[i + 102] = true; dp[i + 103] = true; dp[i + 104] = true; dp[i + 105] = true; } } WriteLine(dp[n] ? 1 : 0); } } }
[["-", 15, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 15, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
179
2
using System; using System.Collections.Generic; using System.Linq; namespace AtCoderCs { class Program { static void Main() { var Arg = int.Parse(Console.ReadLine()); if (2000 < Arg || Arg == 100) Console.WriteLine(1); else if (Arg < 100) Console.WriteLine(0); else { var Num = Arg / 100; var Surplus = (Arg - 1) / 5; if (Surplus < Num) Console.WriteLine(1); else Console.WriteLine(0); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoderCs { class Program { static void Main() { var Arg = int.Parse(Console.ReadLine()); if (2000 < Arg || Arg == 100) Console.WriteLine(1); else if (Arg < 100) Console.WriteLine(0); else { var Num = Arg / 100; var Surplus = ((Arg % 100) - 1) / 5; if (Surplus < Num) Console.WriteLine(1); else Console.WriteLine(0); } } } }
[["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25]]
8
117
4
using System; using System.Collections; using System.Collections.Generic; using static Exter; using System.Linq; using System.Numerics; #if DEBUG #else using console = System.Console; #endif public class App { public static void Main(string[] args) { var v = readarr[0]; cout = (v / 100) * 105 > v ? 1 : 0; } public static long Gcd(long a, long b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static long GcdRecursive(long a, long b) { if (b == 0) return a; return GcdRecursive(b, a % b); } } public class RollingHash { long[] h; long m = 2147483647; int b = 524287; Power baser; public RollingHash(string s) { baser = new Power(b); h = new long[s.Length]; h[0] = 0; for (int i = 1; i < s.Length; i++) { h[i] = (h[i - 1] * b + s[i]) % m; } } public long Calc(int l, int r) { cout = h[r]; cout = h[l] * baser.GetEntry(r - l - 1); return 0; } } public class PriorityQueue<T> : IEnumerable<T> where T : IComparable { List<T> buffer = new List<T>(); static void PushHeap(List<T> array, T elem) { int n = array.Count; array.Add(elem); while (n != 0) { int i = (n - 1) / 2; if (array[n].CompareTo(array[i]) < 0) { T tmp = array[n]; array[n] = array[i]; array[i] = tmp; } n = i; } } static void PopHeap(List<T> array) { int n = array.Count - 1; array[0] = array[n]; array.RemoveAt(array.Count - 1); for (int i = 0, j; (j = 2 * i + 1) < n;) { if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) > 0)) j++; if (array[i].CompareTo(array[j]) > 0) { T tmp = array[j]; array[j] = array[i]; array[i] = tmp; } i = j; } } public int Count { get { return buffer.Count; } } public void Push(T elem) { PushHeap(this.buffer, elem); } public T Peek() { return buffer[0]; } public T Pop() { T a = buffer[0]; PopHeap(this.buffer); return a; } public IEnumerator<T> GetEnumerator() { var v = new List<T>(buffer); while (v.Count != 0) { yield return v[0]; PopHeap(v); } } IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } } public class Power { public int Base; private List<long> Value = new List<long>(); public Power(int v) { if (v == 1) new ArgumentOutOfRangeException(); long prev = -1; long g = v; Base = v; while (g > prev) { Value.Add(g); prev = g; g *= g; } } public long GetEntry(int exponent) { long s = 1; for (int i = 0; (1 << i) <= exponent; i++) { if ((exponent & (1 << i)) != 0) { s *= Value[i]; } } return s; } } public static class Exter { public static IEnumerable<long> PrimeFactors(long n) { int i = 2; long tmp = n; while (i * i <= n) { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } public class LoopArray<T> { public readonly int Length; private T[] arr; public LoopArray(int Capacity) { Length = Capacity; } public LoopArray(T[] ar) { arr = new T[ar.Length]; Array.Copy(ar, arr, ar.Length); } } public class Point { public Point(int cx, int cy) { x = cx; y = cy; } public int x; public int y; } public static IEnumerable<Result> ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b, Func<T1, T2, Result> f) { foreach (var v in a) { foreach (var w in b) yield return f(v, w); } } public static IEnumerable<Result> ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b, Func<T1, T2, Result> f, Func<T1, T2, bool> s) { foreach (var v in a) { foreach (var w in b) if (s(v, w)) yield return f(v, w); } } public static int ToInt(this long v) => (int)v; public static int ToInt(this string v) => int.Parse(v); public static int Max(params int[] p) => p.Max(); public static long Max(params long[] p) => p.Max(); public static int Min(params int[] p) => p.Min(); public static long Min(params long[] p) => p.Min(); public static int Gcd(int a, int b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static int GcdRecursive(int a, int b) => b == 0 ? a : GcdRecursive(b, a % b); public static object cout { set { console.Write(value.ToString()); console.WriteLine(); } } public static void ToCout<t>(this IEnumerable<t> v) { cout = string.Join(",", v); } public static long[] readarr { get { preadarr = console.ReadLine().Split().Select(s => long.Parse(s)).ToArray(); return preadarr; } } public static long[] preadarr; } #if DEBUG public static class console { static int cursorLine = 0; static readonly string[] cin = System.IO.File.ReadAllLines("Input.txt"); static public string ReadLine() { if (cursorLine == cin.Length) cout = "Out"; return cin[cursorLine++]; } static public void WriteLine() { Console.WriteLine(); } static public void WriteLine<T>(T input) { Console.WriteLine(input); } static public void Write<T>(T input) { Console.Write(input); } static public void WriteLine(string s, params object[] arr) { Console.WriteLine(s, arr); } } #endif
using System; using System.Collections; using System.Collections.Generic; using static Exter; using System.Linq; using System.Numerics; #if DEBUG #else using console = System.Console; #endif public class App { public static void Main(string[] args) { var v = readarr[0]; cout = (v / 100) * 105 >= v ? 1 : 0; } public static long Gcd(long a, long b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static long GcdRecursive(long a, long b) { if (b == 0) return a; return GcdRecursive(b, a % b); } } public class RollingHash { long[] h; long m = 2147483647; int b = 524287; Power baser; public RollingHash(string s) { baser = new Power(b); h = new long[s.Length]; h[0] = 0; for (int i = 1; i < s.Length; i++) { h[i] = (h[i - 1] * b + s[i]) % m; } } public long Calc(int l, int r) { cout = h[r]; cout = h[l] * baser.GetEntry(r - l - 1); return 0; } } public class PriorityQueue<T> : IEnumerable<T> where T : IComparable { List<T> buffer = new List<T>(); static void PushHeap(List<T> array, T elem) { int n = array.Count; array.Add(elem); while (n != 0) { int i = (n - 1) / 2; if (array[n].CompareTo(array[i]) < 0) { T tmp = array[n]; array[n] = array[i]; array[i] = tmp; } n = i; } } static void PopHeap(List<T> array) { int n = array.Count - 1; array[0] = array[n]; array.RemoveAt(array.Count - 1); for (int i = 0, j; (j = 2 * i + 1) < n;) { if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) > 0)) j++; if (array[i].CompareTo(array[j]) > 0) { T tmp = array[j]; array[j] = array[i]; array[i] = tmp; } i = j; } } public int Count { get { return buffer.Count; } } public void Push(T elem) { PushHeap(this.buffer, elem); } public T Peek() { return buffer[0]; } public T Pop() { T a = buffer[0]; PopHeap(this.buffer); return a; } public IEnumerator<T> GetEnumerator() { var v = new List<T>(buffer); while (v.Count != 0) { yield return v[0]; PopHeap(v); } } IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } } public class Power { public int Base; private List<long> Value = new List<long>(); public Power(int v) { if (v == 1) new ArgumentOutOfRangeException(); long prev = -1; long g = v; Base = v; while (g > prev) { Value.Add(g); prev = g; g *= g; } } public long GetEntry(int exponent) { long s = 1; for (int i = 0; (1 << i) <= exponent; i++) { if ((exponent & (1 << i)) != 0) { s *= Value[i]; } } return s; } } public static class Exter { public static IEnumerable<long> PrimeFactors(long n) { int i = 2; long tmp = n; while (i * i <= n) { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } public class LoopArray<T> { public readonly int Length; private T[] arr; public LoopArray(int Capacity) { Length = Capacity; } public LoopArray(T[] ar) { arr = new T[ar.Length]; Array.Copy(ar, arr, ar.Length); } } public class Point { public Point(int cx, int cy) { x = cx; y = cy; } public int x; public int y; } public static IEnumerable<Result> ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b, Func<T1, T2, Result> f) { foreach (var v in a) { foreach (var w in b) yield return f(v, w); } } public static IEnumerable<Result> ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b, Func<T1, T2, Result> f, Func<T1, T2, bool> s) { foreach (var v in a) { foreach (var w in b) if (s(v, w)) yield return f(v, w); } } public static int ToInt(this long v) => (int)v; public static int ToInt(this string v) => int.Parse(v); public static int Max(params int[] p) => p.Max(); public static long Max(params long[] p) => p.Max(); public static int Min(params int[] p) => p.Min(); public static long Min(params long[] p) => p.Min(); public static int Gcd(int a, int b) => a > b? GcdRecursive(a, b) : GcdRecursive(b, a); private static int GcdRecursive(int a, int b) => b == 0 ? a : GcdRecursive(b, a % b); public static object cout { set { console.Write(value.ToString()); console.WriteLine(); } } public static void ToCout<t>(this IEnumerable<t> v) { cout = string.Join(",", v); } public static long[] readarr { get { preadarr = console.ReadLine().Split().Select(s => long.Parse(s)).ToArray(); return preadarr; } } public static long[] preadarr; } #if DEBUG public static class console { static int cursorLine = 0; static readonly string[] cin = System.IO.File.ReadAllLines("Input.txt"); static public string ReadLine() { if (cursorLine == cin.Length) cout = "Out"; return cin[cursorLine++]; } static public void WriteLine() { Console.WriteLine(); } static public void WriteLine<T>(T input) { Console.WriteLine(input); } static public void Write<T>(T input) { Console.Write(input); } static public void WriteLine(string s, params object[] arr) { Console.WriteLine(s, arr); } } #endif
[["-", 0, 1, 0, 11, 12, 41, 15, 16, 17, 47], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 17, 20]]
8
1,552
2
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int X = int.Parse(Console.ReadLine()); if (X >= 2000) { Console.WriteLine("1"); } else { if (X % 100 < (X / 100) * 5) { Console.WriteLine("1"); } else { Console.WriteLine("0"); } } } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int X = int.Parse(Console.ReadLine()); if (X >= 2000) { Console.WriteLine("1"); } else { if (X % 100 <= (X / 100) * 5) { Console.WriteLine("1"); } else { Console.WriteLine("0"); } } } }
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 19]]
8
101
2
using System; using System.Collections.Generic; using System.Linq; namespace AC { class Program { static void Main(string[] args) { var X = ReadInt(); var div = X / 100; var rem = X % 100; if (rem >= div && rem <= div * 5) { Console.WriteLine(1); return; } Console.WriteLine(0); Console.ReadKey(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AC { class Program { static void Main(string[] args) { var X = ReadInt(); var div = X / 100; var rem = X % 100; if (rem >= 0 && rem <= div * 5) { Console.WriteLine(1); return; } Console.WriteLine(0); Console.ReadKey(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203]]
8
213
2
using System; using System.Linq; //リストの使用 using System.Collections.Generic; using System.Text; //テキストの高速出力に必要 class Program { static void Main() { int x = int.Parse(Console.ReadLine()); bool[] dp = new bool[x + 1]; for (int i = 0; i <= 5; i++) dp[100 + i] = true; for (int i = 200; i <= x; i++) { for (int j = 100; j <= 105; j++) { if (dp[i - j]) dp[i] = true; } } if (dp[x]) Console.WriteLine(1); else Console.WriteLine(0); } }
using System; using System.Linq; //リストの使用 using System.Collections.Generic; using System.Text; //テキストの高速出力に必要 class Program { static void Main() { int x = int.Parse(Console.ReadLine()); bool[] dp = new bool[100001]; for (int i = 0; i <= 5; i++) dp[100 + i] = true; for (int i = 200; i <= x; i++) { for (int j = 100; j <= 105; j++) { if (dp[i - j]) dp[i] = true; } } if (dp[x]) Console.WriteLine(1); else Console.WriteLine(0); } }
[["-", 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, 203]]
8
153
4
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { var cin = new Scanner2(); int x = cin.Int(); int num = x / 100; int r = x % 100; int need = r / 5; if (r % 5 == 0) { need += 1; } if (need > num) { Console.WriteLine(0); } else { Console.WriteLine(1); } } } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private string[] buf_; private int index_; Func<string> reader_; public Scanner2(string file = "") { if (string.IsNullOrWhiteSpace(file)) { reader_ = Console.ReadLine; } else { filePath_ = file; var fs = new StreamReader(file); reader_ = fs.ReadLine; } buf_ = new string[0]; index_ = 0; } public string Next() { if (index_ < buf_.Length) { return buf_[index_++]; } string st = reader_(); while (st == "") { st = reader_(); } buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries); if (buf_.Length == 0) { return Next(); } index_ = 0; return buf_[index_++]; } public int Int() => int.Parse(Next()); public long Long() => long.Parse(Next()); public double Double() => double.Parse(Next()); public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = Int() + add; } return Array; } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = Long() + add; } return Array; } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = Double() + add; } return Array; } public void Save(string text) { if (string.IsNullOrWhiteSpace(filePath_)) { return; } File.WriteAllText(filePath_ + "_output.txt", text); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { var cin = new Scanner2(); int x = cin.Int(); int num = x / 100; int r = x % 100; int need = r / 5; if (r % 5 != 0) { need += 1; } if (need > num) { Console.WriteLine(0); } else { Console.WriteLine(1); } } } public class Scanner2 { private readonly char[] delimiter_ = new char[] { ' ' }; private readonly string filePath_; private string[] buf_; private int index_; Func<string> reader_; public Scanner2(string file = "") { if (string.IsNullOrWhiteSpace(file)) { reader_ = Console.ReadLine; } else { filePath_ = file; var fs = new StreamReader(file); reader_ = fs.ReadLine; } buf_ = new string[0]; index_ = 0; } public string Next() { if (index_ < buf_.Length) { return buf_[index_++]; } string st = reader_(); while (st == "") { st = reader_(); } buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries); if (buf_.Length == 0) { return Next(); } index_ = 0; return buf_[index_++]; } public int Int() => int.Parse(Next()); public long Long() => long.Parse(Next()); public double Double() => double.Parse(Next()); public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = Int() + add; } return Array; } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = Long() + add; } return Array; } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = Double() + add; } return Array; } public void Save(string text) { if (string.IsNullOrWhiteSpace(filePath_)) { return; } File.WriteAllText(filePath_ + "_output.txt", text); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79]]
8
575
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderA { static void Main() { var sc = new Scanner(); int n = sc.NextInt(); string s = sc.Next(); int answer = 0; for (int i = 0; i <= 9; i++) { for (int j = 0; j <= 9; j++) { for (int k = 0; k <= 9; k++) { if (IsValid(s, i, j, k)) { answer++; } } } } Console.WriteLine(answer); } private static bool IsValid(string s, int a, int b, int c) { if (s.IndexOf(a.ToString()) == -1) { return false; } s = s.Substring(s.IndexOf(a.ToString())); if (s.IndexOf(b.ToString()) == -1) { return false; } s = s.Substring(s.IndexOf(b.ToString())); if (s.IndexOf(c.ToString()) == -1) { return false; } return true; } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderA { static void Main() { var sc = new Scanner(); int n = sc.NextInt(); string s = sc.Next(); int answer = 0; for (int i = 0; i <= 9; i++) { for (int j = 0; j <= 9; j++) { for (int k = 0; k <= 9; k++) { if (IsValid(s, i, j, k)) { answer++; } } } } Console.WriteLine(answer); } private static bool IsValid(string s, int a, int b, int c) { if (s.IndexOf(a.ToString()) == -1) { return false; } s = s.Substring(s.IndexOf(a.ToString()) + 1); if (s.IndexOf(b.ToString()) == -1) { return false; } s = s.Substring(s.IndexOf(b.ToString()) + 1); if (s.IndexOf(c.ToString()) == -1) { return false; } return true; } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
[["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
551
4
using System; using System.Collections.Generic; using System.Linq; class TEST { public static void Main() { int num = int.Parse(Console.ReadLine()); string str = Console.ReadLine(); string x = str.Substring(0, num / 2 - 1); string y = str.Substring(num / 2); if (x == y) Console.WriteLine("Yes"); else Console.WriteLine("No"); } }
using System; using System.Collections.Generic; using System.Linq; class TEST { public static void Main() { int num = int.Parse(Console.ReadLine()); string str = Console.ReadLine(); string x = str.Substring(0, num / 2); string y = str.Substring(num / 2); // Console.WriteLine(x); // Console.WriteLine(y); // Console.ReadKey(); if (x == y) Console.WriteLine("Yes"); else Console.WriteLine("No"); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
103
2
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var str = Console.ReadLine(); if (n % 2 == 1) Console.WriteLine("No"); var head = new string(str.Take(n / 2).ToArray()); Console.WriteLine(head + head == str ? "Yes" : "No"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var str = Console.ReadLine(); if (n % 2 == 1) { Console.WriteLine("No"); return; } var head = new string(str.Take(n / 2).ToArray()); Console.WriteLine(head + head == str ? "Yes" : "No"); } } }
[["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
118
4
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { var n = IO.ReadInt; var s = ReadLine(); bool f = false; if (s.Length % 2 != 0) { IO.WriteLineYes_or_No(f); return; } var a = s.Substring(0, n / 2 - 1); if (s == a + a) f = true; IO.WriteLineYes_or_No(f); } public class IO { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); #endregion } /// <summary> /// 正の数の四則演算のみ対応 /// </summary> public class Mod { // 割る数の定義 private readonly static long M = 1000000007; // 足し算 public static long Add(long a, long b) => (a * b) % M; // 引き算 public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; // 掛け算 public static long Multi(long a, long b) => (a * b) % M; } public class Scanner { public string Str => Console.ReadLine().Trim(); public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray(); public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray(); // public char[][] Grid(int n) => Create(n, () => Str.ToCharArray()); // public int[] ArrInt1D(int n) => Create(n, () => Int); // public long[] ArrLong1D(int n) => Create(n, () => Long); // public int[][] ArrInt2D(int n) => Create(n, () => ArrInt); // public long[][] ArrLong2D(int n) => Create(n, () => ArrLong); private Queue<string> q = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] // インライン化を推奨する public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); } public void Make<T1>(out T1 v1) => v1 = Next<T1>(); public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); } public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); } public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); } public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); } public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); } } } public class Combination { public static long Choice2(long n) { if (n <= 1) return 0; if (n == 2) return 1; else return n * (n - 1) / 2; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using static System.Console; using static System.Math; namespace Atcoder { class Program { static void Main(string[] args) { try { Solve.Answer(); } catch (Exception ex) { WriteLine(ex.ToString()); } } } public class Solve { public static void Answer() { var n = IO.ReadInt; var s = ReadLine(); bool f = false; if (s.Length % 2 != 0) { IO.WriteLineYes_or_No(f); return; } var a = s.Substring(0, n / 2); if (s == a + a) f = true; IO.WriteLineYes_or_No(f); } public class IO { #region Input public static string ReadString => ReadLine(); public static int ReadInt => int.Parse(ReadLine()); public static long ReadLong => long.Parse(ReadLine()); public static double ReadDouble => double.Parse(ReadLine()); public static List<string> ReadSplitString => ReadLine().Split().ToList(); public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList(); public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList(); public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList(); #endregion #region Output public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list)); public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No"); #endregion } /// <summary> /// 正の数の四則演算のみ対応 /// </summary> public class Mod { // 割る数の定義 private readonly static long M = 1000000007; // 足し算 public static long Add(long a, long b) => (a * b) % M; // 引き算 public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M; // 掛け算 public static long Multi(long a, long b) => (a * b) % M; } public class Scanner { public string Str => Console.ReadLine().Trim(); public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray(); public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray(); // public char[][] Grid(int n) => Create(n, () => Str.ToCharArray()); // public int[] ArrInt1D(int n) => Create(n, () => Int); // public long[] ArrLong1D(int n) => Create(n, () => Long); // public int[][] ArrInt2D(int n) => Create(n, () => ArrInt); // public long[][] ArrLong2D(int n) => Create(n, () => ArrLong); private Queue<string> q = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] // インライン化を推奨する public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); } public void Make<T1>(out T1 v1) => v1 = Next<T1>(); public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); } public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); } public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); } public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); } public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); } } } public class Combination { public static long Choice2(long n) { if (n <= 1) return 0; if (n == 2) return 1; else return n * (n - 1) / 2; } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
1,025
2
using System; class Program { static void Main(string[] args) { int a; string b; a = Int32.Parse(Console.ReadLine()); b = Console.ReadLine(); if (b.Length != a) { return; } if (a % 2 != 0) { Console.WriteLine("No"); return; } string strHarf = b.Substring(0, 2 / a); if (b == strHarf + strHarf) { Console.WriteLine("Yes"); return; } else { Console.WriteLine("No"); return; } // int a, b, c; // a = int.Parse(Console.ReadLine()); //標準入力 // string[] str = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 b = int.Parse(str[0]); // //数値で受け取りたい場合は変換する c = int.Parse(str[1]); // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力 // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, // c);//改行付き出力 } }
using System; class Program { static void Main(string[] args) { int a; string b; a = Int32.Parse(Console.ReadLine()); b = Console.ReadLine(); if (b.Length != a) { return; } if (a % 2 != 0) { Console.WriteLine("No"); return; } string strHarf = b.Substring(0, a / 2); if (b == strHarf + strHarf) { Console.WriteLine("Yes"); return; } else { Console.WriteLine("No"); return; } // int a, b, c; // a = int.Parse(Console.ReadLine()); //標準入力 // string[] str = Console.ReadLine().Split(' // ');//2つ以上のスペース区切り入力の取得 b = int.Parse(str[0]); // //数値で受け取りたい場合は変換する c = int.Parse(str[1]); // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力 // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, // c);//改行付き出力 } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
135
4
using System; using System.Diagnostics; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; 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"); // MyDebugger.Test(process, "../TextFile2.txt"); // MyDebugger.MakeTestCase("../TextFile2.txt"); #else object ret = process(new StreamReader(Console.OpenStandardInput())); Console.WriteLine(ret); #endif } static object process(TextReader input) { var n = int.Parse(input.ReadLine()); var s = input.ReadLine(); if (n % 2 != 0) return No; for (int i = 0; i < n / 2; i++) { if (s[i] != s[n / 2 + 1]) return No; } return Yes; } }
using System; using System.Diagnostics; using System.IO; using System.Text; using System.Linq; using System.Collections.Generic; 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"); // MyDebugger.Test(process, "../TextFile2.txt"); // MyDebugger.MakeTestCase("../TextFile2.txt"); #else object ret = process(new StreamReader(Console.OpenStandardInput())); Console.WriteLine(ret); #endif } static object process(TextReader input) { var n = int.Parse(input.ReadLine()); var s = input.ReadLine(); if (n % 2 != 0) return No; for (int i = 0; i < n / 2; i++) { if (s[i] != s[n / 2 + i]) return No; } return Yes; } }
[["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 22]]
8
193
2